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.

80 lines
2.4 KiB

3 years ago
//app.js
3 years ago
App({
3 years ago
onLaunch: function () {
this.hidetabbar();
this.getSystemInfo();
},
//自己对wx.hideTabBar的一个封装
hidetabbar() {
wx.hideTabBar({
fail: function() {
setTimeout(function() { // 做了个延时重试一次,作为保底。
wx.hideTabBar()
}, 500)
}
});
},
getSystemInfo: function() {
let t = this;
wx.getSystemInfo({
success: function(res) {
t.globalData.systemInfo = res;
3 years ago
}
3 years ago
});
},
editTabbar: function() {
let tabbar = this.globalData.tabBar;
let currentPages = getCurrentPages();
let _this = currentPages[currentPages.length - 1];
let pagePath = _this.route;
(pagePath.indexOf('/') != 0) && (pagePath = '/' + pagePath);
for (let i in tabbar.list) {
tabbar.list[i].selected = false;
(tabbar.list[i].pagePath == pagePath) && (tabbar.list[i].selected = true);
}
_this.setData({
tabbar: tabbar
});
3 years ago
},
globalData: {
3 years ago
systemInfo: null,//客户端设备信息
tabBar: {
"color": "#727272",
"selectedColor": "#F46368",
"backgroundColor": "#ffffff",
"list": [
{
3 years ago
"pagePath": "pages/index/index",
"iconPath": "/components/tabbarComponent/icons/home.png",
"selectedIconPath": "/components/tabbarComponent/icons/homeActive.png",
"text": "首页"
3 years ago
},
{
"pagePath": "pages/insight/index",
3 years ago
"iconPath": "/components/tabbarComponent/icons/insight.png",
"selectedIconPath": "/components/tabbarComponent/icons/insightActive.png",
"text": "洞察"
3 years ago
},
{
"pagePath": "pages/brandSearch/index",
3 years ago
"iconPath": "/components/tabbarComponent/icons/appSearch.png",
"selectedIconPath": "/components/tabbarComponent/icons/appSearchActive.png",
"text": "品牌搜索"
3 years ago
},
{
"pagePath": "pages/varComm/index",
3 years ago
"iconPath": "/components/tabbarComponent/icons/varComm.png",
"selectedIconPath": "/components/tabbarComponent/icons/varCommActive.png",
"text": "对比"
3 years ago
},
{
"pagePath": "pages/mine/index",
3 years ago
"iconPath": "/components/tabbarComponent/icons/mine.png",
"selectedIconPath": "/components/tabbarComponent/icons/mineActive.png",
"text": "我的"
3 years ago
}
]
}
3 years ago
}
})