// Pages/index/index.js const app = getApp() Page({ data: { loading: true }, onLoad(option){ let from = option.from; let usertype = wx.getStorageSync('usertype'); console.log("index onload: ", from, usertype) if(from === "navbar"){ //切换身份 }else{ if(usertype == 2 || usertype == 3){ this.guideTo(usertype) } } }, /** * 生命周期函数--监听页面显示 */ onShow() { if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ tabBarShow:false, //true/false }) } this.setData({ loading: false }); }, goCheck(e){ console.log(e); let usertype = e.currentTarget.dataset.usertype; let url = e.currentTarget.dataset.url; wx.setStorageSync('usertype', usertype); wx.setStorageSync('next_url', url); this.guideTo(usertype); }, guideTo(usertype){ let url; if(usertype == 2){ if(!wx.$TUIKit){ app.imInit(); } url = "/Pages/yishi/index/index"; }else{ app.imLogout(); url = "/Pages/yaoshi/home/home"; } let token = wx.getStorageSync('AUTH_TOKEN_'+usertype); console.log(token); if(token){ wx.switchTab({ url: url }) }else{ app.go(app.globalData.login_url); } } })