util.wxs 2.5 KB

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