const app = getApp(); Component({ data: { isShow: false, toTop: false, selected: 0, color: "#444", selectedColor: "#1890ff", list: [ { iconPath: "../assets/images/home.png", selectedIconPath: "../assets/images/home1.png", pagePath: "/pages/firstBill/index", text: "首页", index: 0, }, { iconPath: "../assets/images/ksbm.svg", selectedIconPath: "../assets/images/ksbm.svg", pagePath: "/pages/newEnroll/enroll/index", // text: "消息", index: 1, }, { iconPath: "../assets/images/wd.png", selectedIconPath: "../assets/images/wd1.png", pagePath: "/pages/mine/index", text: "我的", index: 2, }, ], }, lifetimes: { show: function () { // 页面被展示 console.log("tabbar show"); }, attached: function () { // 在组件实例进入页面节点树时执行 console.log("tabbar attached"); }, detached: function () { // 在组件实例被从页面节点树移除时执行 }, }, methods: { switchTab(e) { const data = e.currentTarget.dataset; const url = data.path; wx.vibrateShort({ type: "heavy", success: function (e) { console.log(e); }, }); if (data.index == 0 && this.data.selected == 0) { if(this.data.toTop){ app.globalData.toTop = 1; } else { app.globalData.refresh = 1 } } if (!app.globalData.isLogin) { if (data.index == 1) { wx.navigateTo({ url: "/pages/login/index", }); return; } } else { if (data.index == 1) { if (app.globalData.loginUserInfo.agencyStatus != 1) { wx.navigateTo({ url: "/pages/tobeAgency/index", }); } else { wx.navigateTo({ url, }); // wx.redirectTo({}); } return; } } // this.setData({ // selected: data.index, // }); wx.switchTab({ url }); }, touchMove(){ return false } }, });