util.wxs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. function indexOf(array, appointmentAuth, checkAuth,serivceAuth) {
  2. // var userMsg= wx.getStorageSync('userMsg')
  3. // 1预约权限;2审核权限;3会议服务权限
  4. if (array) {
  5. if (array.length == 2 && (appointmentAuth || checkAuth)) {
  6. return true
  7. }
  8. if (array.indexOf(1) > -1) {
  9. if (appointmentAuth) {
  10. return true
  11. } else {
  12. return false
  13. }
  14. }
  15. if (array.indexOf(2) > -1) {
  16. if (checkAuth) {
  17. return true
  18. } else {
  19. return false
  20. }
  21. }
  22. if (array.indexOf(3) > -1) {
  23. if (serivceAuth) {
  24. return true
  25. } else {
  26. return false
  27. }
  28. }
  29. }
  30. }
  31. function indexOf1(array, value) {
  32. if (array) {
  33. if (array.indexOf(value) < 0) {
  34. return false;
  35. } else {
  36. return true;
  37. }
  38. }
  39. }
  40. function indexOf2(array, name,status, continueMeeting) {
  41. if (array) {
  42. if (array.indexOf(status) < 0) {
  43. return false;
  44. } else {
  45. var isTrue = true
  46. if (name == '会议续约') {
  47. continueMeeting ? isTrue = true : isTrue = false
  48. }
  49. return isTrue
  50. }
  51. }
  52. }
  53. function getVehicleType(id) {
  54. var drivingModelList = [{
  55. id: 1,
  56. name: 'A1'
  57. },
  58. {
  59. id: 2,
  60. name: 'A2'
  61. },
  62. {
  63. id: 3,
  64. name: 'A3'
  65. },
  66. {
  67. id: 4,
  68. name: 'B1'
  69. },
  70. {
  71. id: 5,
  72. name: 'B2'
  73. },
  74. {
  75. id: 6,
  76. name: 'C1'
  77. },
  78. {
  79. id: 7,
  80. name: 'C2'
  81. },
  82. {
  83. id: 8,
  84. name: 'C3'
  85. },
  86. {
  87. id: 9,
  88. name: 'C4'
  89. },
  90. {
  91. id: 10,
  92. name: 'C5'
  93. },
  94. {
  95. id: 11,
  96. name: 'D'
  97. },
  98. ]
  99. var name = ''
  100. drivingModelList.forEach(function (item) {
  101. if (item.id == id) {
  102. name = item.name
  103. }
  104. })
  105. return name
  106. }
  107. function desensitization(string = "", start, end) {
  108. var star = ''
  109. function makeStar(number) {
  110. if (number > 0) {
  111. star += '*';
  112. return makeStar(--number)
  113. } else {
  114. return star
  115. }
  116. };
  117. return string.substring(0, start) + makeStar(end - start) + string.substring(end)
  118. }
  119. module.exports = {
  120. indexOf: indexOf,
  121. indexOf1: indexOf1,
  122. getVehicleType: getVehicleType,
  123. desensitization: desensitization,
  124. indexOf2:indexOf2,
  125. }