1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- // custom-tab-bar/index.js
- const app=getApp()
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- },
- /**
- * 组件的初始数据
- */
- data: {
- active: 0,
- list: [
- {
- icon: 'todo-list-o',
- text: '订单处理',
- url: '/pages/index/index'
- },
- {
- icon: 'search',
- text: '订单查询',
- url: '/pages/order/index'
- },
- {
- icon:'shop-o',
- text:'店铺管理',
- url:'/pages/store/index'
- },{
- icon:'contact',
- text:'我的',
- url:'/pages/member/index'
- }
- ]
- },
- /**
- * 组件的方法列表
- */
- methods: {
- onChange(event) {
- this.setData({ active: event.detail });
- wx.switchTab({
- url: this.data.list[event.detail].url
- });
- },
-
- init() {
- const page = getCurrentPages().pop();
- if(app.globalData.orderNum>0){
- this.setData({
- ['list[0].info']:app.globalData.orderNum
- })
- }
- else{
- let {list}=this.data
- delete list[0].info
- this.setData({
- list:list
- })
- }
- this.setData({
- active: this.data.list.findIndex(item => item.url === `/${page.route}`)
- });
- }
- }
- })
|