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.

82 lines
2.7 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/appSearch.png",
"selectedIconPath": "",
"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: 'getUserMainBrand',
token: wx.getStorageSync('token') || 't%2BrswgjvzGM='
}).then(res => {
app.globalData.request({
action: "getUserBrandHome",
brandname: res
}).then(data => {
let brandObj = data[0];
let arr = this.data.list;
arr[2].selectedIconPath = brandObj.img;
this.setData({
list: arr,
selected: n
});
})
})
} else {
this.setData({
selected: n
});
}
}
},
})