util.wxs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 getVehicleType(id) {
  34. var drivingModelList = [{
  35. id: 1,
  36. name: 'A1'
  37. },
  38. {
  39. id: 2,
  40. name: 'A2'
  41. },
  42. {
  43. id: 3,
  44. name: 'A3'
  45. },
  46. {
  47. id: 4,
  48. name: 'B1'
  49. },
  50. {
  51. id: 5,
  52. name: 'B2'
  53. },
  54. {
  55. id: 6,
  56. name: 'C1'
  57. },
  58. {
  59. id: 7,
  60. name: 'C2'
  61. },
  62. {
  63. id: 8,
  64. name: 'C3'
  65. },
  66. {
  67. id: 9,
  68. name: 'C4'
  69. },
  70. {
  71. id: 10,
  72. name: 'C5'
  73. },
  74. {
  75. id: 11,
  76. name: 'D'
  77. },
  78. ]
  79. var name = ''
  80. drivingModelList.forEach(function (item) {
  81. if (item.id == id) {
  82. name = item.name
  83. }
  84. })
  85. return name
  86. }
  87. function desensitization(string = "", start, end) {
  88. var star = ''
  89. function makeStar(number) {
  90. if (number > 0) {
  91. star += '*';
  92. return makeStar(--number)
  93. } else {
  94. return star
  95. }
  96. };
  97. return string.substring(0, start) + makeStar(end - start) + string.substring(end)
  98. }
  99. module.exports = {
  100. indexOf: indexOf,
  101. indexOf1: indexOf1,
  102. getVehicleType: getVehicleType,
  103. desensitization: desensitization,
  104. }