const auth = require('../../utils/auth') Page({ data: { navTitle: '游客模式' }, onLoad() { this.syncNavTitle() wx.switchTab({ url: '/pages/home/index' }) }, onShow() { this.syncNavTitle() }, syncNavTitle() { const userInfo = auth.getStoredUserInfo() const navTitle = userInfo && String(userInfo.shopName || '').trim() ? String(userInfo.shopName).trim() : '游客模式' this.setData({ navTitle }) } })