index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // custom-tab-bar/index.js
  2. const app=getApp()
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. },
  9. /**
  10. * 组件的初始数据
  11. */
  12. data: {
  13. active: 0,
  14. list: [
  15. {
  16. icon: 'todo-list-o',
  17. text: '订单处理',
  18. url: '/pages/index/index'
  19. },
  20. {
  21. icon: 'search',
  22. text: '订单查询',
  23. url: '/pages/order/index'
  24. },
  25. {
  26. icon:'shop-o',
  27. text:'店铺管理',
  28. url:'/pages/store/index'
  29. },{
  30. icon:'contact',
  31. text:'我的',
  32. url:'/pages/member/index'
  33. }
  34. ]
  35. },
  36. /**
  37. * 组件的方法列表
  38. */
  39. methods: {
  40. onChange(event) {
  41. this.setData({ active: event.detail });
  42. wx.switchTab({
  43. url: this.data.list[event.detail].url
  44. });
  45. },
  46. init() {
  47. const page = getCurrentPages().pop();
  48. if(app.globalData.orderNum>0){
  49. this.setData({
  50. ['list[0].info']:app.globalData.orderNum
  51. })
  52. }
  53. else{
  54. let {list}=this.data
  55. delete list[0].info
  56. this.setData({
  57. list:list
  58. })
  59. }
  60. this.setData({
  61. active: this.data.list.findIndex(item => item.url === `/${page.route}`)
  62. });
  63. }
  64. }
  65. })