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.3 KiB

//app.js
App({
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;
}
});
},
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
});
},
globalData: {
systemInfo: null,//客户端设备信息
tabBar: {
"color": "#727272",
"selectedColor": "#F46368",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "/pages/index/index",
"text": "首页",
"iconPath": "/components/tabbarComponent/icon/home.png",
"selectedIconPath": "/component/tabbarComponent/icon/homeSel.png"
},
{
"pagePath": "pages/insight/index",
"text": "服务",
"iconPath": "/components/tabbarComponent/icon/service.png",
"selectedIconPath": "/component/tabbarComponent/icon/serviceSel.png"
},
{
"pagePath": "pages/brandSearch/index",
"text": "导航",
"iconPath": "/components/tabbarComponent/icon/navagati.png",
"isSpecial": true,
},
{
"pagePath": "pages/varComm/index",
"text": "订单",
"iconPath": "/components/tabbarComponent/icon/order.png",
"selectedIconPath": "/component/tabbarComponent/icon/orderSel.png"
},
{
"pagePath": "pages/mine/index",
"text": "我的",
"iconPath": "/components/tabbarComponent/icon/my.png",
"selectedIconPath": "/component/tabbarComponent/icon/mySel.png"
}
]
}
}
})