You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.4 KiB
76 lines
2.4 KiB
const app = getApp();
|
|
Component({
|
|
data: {
|
|
selected: null, //当前选中的tab下标
|
|
color: "#A0A0A0",
|
|
selectedColor: "#646464", //tabbar选中字体颜色
|
|
list: [{
|
|
"pagePath": "pages/index/index",
|
|
"iconPath": "icons/home.png",
|
|
"selectedIconPath": "icons/homeActive.png",
|
|
"text": "首页"
|
|
},
|
|
{
|
|
"pagePath": "pages/insight/index",
|
|
"iconPath": "icons/insight.png",
|
|
"selectedIconPath": "icons/insightActive.png",
|
|
"text": "洞察"
|
|
},
|
|
{
|
|
"pagePath": "pages/brandCrisis/index",
|
|
"iconPath": "icons/logo.png",
|
|
"selectedIconPath": "icons/logo.png",
|
|
"text": "",
|
|
diyClass: 'diy'
|
|
},
|
|
{
|
|
"pagePath": "pages/varComm/index",
|
|
"iconPath": "icons/varComm.png",
|
|
"selectedIconPath": "icons/varCommActive.png",
|
|
"text": "对比"
|
|
},
|
|
{
|
|
"pagePath": "pages/mine/index",
|
|
"iconPath": "icons/mine.png",
|
|
"selectedIconPath": "icons/mineActive.png",
|
|
"text": "我的"
|
|
}
|
|
], //tabbar循环数据集
|
|
},
|
|
attached() {},
|
|
methods: {
|
|
switchTab(e) {
|
|
const data = e.currentTarget.dataset;
|
|
const url = data.path
|
|
// this.setData({
|
|
// selected: data.index
|
|
// })
|
|
wx.switchTab({
|
|
url: "/" + url
|
|
})
|
|
},
|
|
init() {
|
|
const page = getCurrentPages().pop();
|
|
let n = this.data.list.findIndex(item => item.pagePath === `${page.route}`);
|
|
if(n === 2) {
|
|
app.globalData.request({
|
|
action: 'logOpenid',
|
|
openid: wx.getStorageSync('openid'),
|
|
token: app.globalData.getStorage('token')
|
|
}).then(res => {
|
|
let arr = this.data.list;
|
|
arr[2].selectedIconPath = res.brandnImg;
|
|
this.setData({
|
|
list: arr,
|
|
selected: n
|
|
});
|
|
})
|
|
} else {
|
|
this.setData({
|
|
selected: n
|
|
});
|
|
}
|
|
|
|
}
|
|
},
|
|
}) |