index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // components/custom-tab-bar/index.js
  2. Component({
  3. data: {
  4. selected: null,//null
  5. color: "#000000",
  6. roleId: '',
  7. selectedColor: "#4B70EA",
  8. allList: [{
  9. list1: [{ //driver
  10. "pagePath": "/pages/index/index",
  11. "iconPath": "gonghuiyuyue-wodeyuyuelan",
  12. "selectedIconPath": "yuyue1",
  13. "text": "扫码预约"
  14. },{
  15. "pagePath": "/pages/weighingRecord/index",
  16. "iconPath": "jiluliebiao",
  17. "selectedIconPath": "jilu1",
  18. "text": "过磅记录"
  19. },{
  20. "pagePath": "/pages/mine/index",
  21. "iconPath": "wode2",
  22. "selectedIconPath": "wode-active",
  23. "text": "我的"
  24. }],
  25. list2: [{ //bizAdmin
  26. "pagePath": "/pages/queueCar/index",
  27. "iconPath": "paiduiguanli",
  28. "selectedIconPath": "paiduiquhao",
  29. "text": "排队车辆"
  30. },{
  31. "pagePath": "/pages/salesOrderMan/index",
  32. "iconPath": "yundans",
  33. "selectedIconPath": "yundans-fill",
  34. "text": "物流订单"
  35. },{
  36. "pagePath": "/pages/reservationMan/index",
  37. "iconPath": "gonghuiyuyue-wodeyuyuelan",
  38. "selectedIconPath": "yuyue1",
  39. "text": "预约管理"
  40. },{
  41. "pagePath": "/pages/weighingRecord/index",
  42. "iconPath": "jiluliebiao",
  43. "selectedIconPath": "jilu1",
  44. "text": "过磅记录"
  45. },{
  46. "pagePath": "/pages/mine/index",
  47. "iconPath": "wode2",
  48. "selectedIconPath": "wode-active",
  49. "text": "我的"
  50. }],
  51. list3: [{ //send
  52. "pagePath": "/pages/deliveryConfirm/index",
  53. "iconPath": "truck_line",
  54. "selectedIconPath": "truck_fill",
  55. "text": "发货确认"
  56. },{
  57. "pagePath": "/pages/mine/index",
  58. "iconPath": "wode2",
  59. "selectedIconPath": "wode-active",
  60. "text": "我的"
  61. }],
  62. list4: [{ //sale
  63. "pagePath": "/pages/salesOrderMan/index",
  64. "iconPath": "yundans",
  65. "selectedIconPath": "yundans-fill",
  66. "text": "物流订单"
  67. },{
  68. "pagePath": "/pages/signReview/index",
  69. "iconPath": "qianshoushenpitongguo-xianxing",
  70. "selectedIconPath": "qianshoushenpitongguo",
  71. "text": "签收审核"
  72. },{
  73. "pagePath": "/pages/mine/index",
  74. "iconPath": "wode2",
  75. "selectedIconPath": "wode-active",
  76. "text": "我的"
  77. }],
  78. list5: [{ //customer
  79. "pagePath": "/pages/index/index",
  80. "iconPath": "gonghuiyuyue-wodeyuyuelan",
  81. "selectedIconPath": "yuyue1",
  82. "text": "扫码预约"
  83. },{
  84. "pagePath": "/pages/salesOrderMan/index",
  85. "iconPath": "yundans",
  86. "selectedIconPath": "yundans-fill",
  87. "text": "物流订单"
  88. },{
  89. "pagePath": "/pages/mine/index",
  90. "iconPath": "wode2",
  91. "selectedIconPath": "wode-active",
  92. "text": "我的"
  93. }],
  94. }],
  95. list: []
  96. },
  97. attached() {
  98. const roleCodeList = wx.getStorageSync('roleCodeList')
  99. //角色编码: 业务管理员:bizAdmin 司机:driver 客户:customer 发货:send 销售:sale roleCodeList.includes('send')
  100. if (roleCodeList=='bizAdmin') {
  101. this.setData({
  102. list: this.data.allList[0].list2
  103. })
  104. } else if (roleCodeList=='send') {
  105. this.setData({
  106. list: this.data.allList[0].list3
  107. })
  108. } else if (roleCodeList=='sale') {
  109. this.setData({
  110. list: this.data.allList[0].list4
  111. })
  112. } else if (roleCodeList=='customer') {
  113. this.setData({
  114. list: this.data.allList[0].list5
  115. })
  116. } else if (roleCodeList=='driver'||roleCodeList==''){
  117. this.setData({
  118. list: this.data.allList[0].list1
  119. })
  120. }
  121. //替代switchTab里的setData,解决闪烁问题
  122. // let pages = getCurrentPages()
  123. // let page = pages[0].route,curSelect = 0
  124. // if (page == 'pages/index/index') {
  125. // curSelect = 0
  126. // }else if (page == 'pages/weighingRecord/list') {
  127. // curSelect = 1
  128. // }else if(page == 'pages/mine/index'){
  129. // if (roleCodeList == '1') {
  130. // curSelect = 2
  131. // }else{
  132. // curSelect = 1
  133. // }
  134. // }
  135. // this.setData({
  136. // selected:curSelect
  137. // })
  138. },
  139. methods: {
  140. switchTab(e) {
  141. const data = e.currentTarget.dataset
  142. const url = data.path
  143. wx.switchTab({
  144. url
  145. })
  146. this.setData({
  147. selected: data.index
  148. })
  149. }
  150. },
  151. })