44 lines
949 B
JavaScript
44 lines
949 B
JavaScript
// custom-tab-bar/index.js
|
|
Component({
|
|
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
active: 0,
|
|
list: [
|
|
{ value: 0, label: '发薪', icon: 'money-circle' },
|
|
{ value: 1, label: '我的', icon: 'user' },
|
|
],
|
|
pageList: [{
|
|
url: '/pages/index/index'
|
|
},
|
|
{
|
|
url: '/pages/my/my'
|
|
}]
|
|
},
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
changePage(e) {
|
|
getApp().globalData.active = e.detail.value;
|
|
wx.switchTab({
|
|
url: this.data.pageList[e.detail.value].url,
|
|
})
|
|
},
|
|
init() {
|
|
const page = getCurrentPages().pop();
|
|
this.setData({
|
|
active: this.data.pageList.findIndex(item => item.url === '/' + `${page?.route}`)
|
|
})
|
|
}
|
|
}
|
|
}) |