Component({ data: { selected: 0, color: "#6e6d6b", selectedColor: "#00B050", "list": [ { "pagePath": "/pages/index/index", "text": "首页", "iconPath": "/images/footer-icon-01.png", "selectedIconPath": "/images/footer-icon-01-active.png" }, { "pagePath": "/pages/news/index", "iconPath": "/images/footer-icon-05.png", "selectedIconPath": "/images/footer-icon-05-active.png", "text": "资讯" }, { "pagePath": "/pages/business/index", "iconPath": "/images/footer-icon-02.png", "selectedIconPath": "/images/footer-icon-02-active.png", "text": "门店" }, { "pagePath": "/pages/my/index", "text": "我的", "iconPath": "/images/footer-icon-04.png", "selectedIconPath": "/images/footer-icon-04-active.png" } ] }, attached() { }, methods: { switchTab(e) { var data = e.currentTarget.dataset var url = data.path if(data.index==8){ var userId = wx.getStorageSync("userId") var LoginId = wx.getStorageSync("LoginId") var userInfodata = wx.getStorageSync("userInfo") if(userId&&LoginId&&userInfodata){ wx.switchTab({ url: url, }); this.setData({ selected: data.index }) }else{ wx.navigateTo({ url: "../login/index" }) } }else{ wx.switchTab({ url: url, }); this.setData({ selected: data.index }) } } } })