45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
const auth = require('../../utils/auth')
|
|
|
|
/**
|
|
* index page logic.
|
|
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
|
*/
|
|
Page({
|
|
data: {
|
|
navTitle: '游客模式'
|
|
},
|
|
|
|
/**
|
|
* `onLoad` page method. Use this from WXML event bindings or lifecycle hooks.
|
|
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
|
*/
|
|
onLoad() {
|
|
this.syncNavTitle()
|
|
wx.switchTab({
|
|
url: '/pages/home/index'
|
|
})
|
|
},
|
|
|
|
/**
|
|
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
|
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
|
*/
|
|
onShow() {
|
|
this.syncNavTitle()
|
|
},
|
|
|
|
/**
|
|
* `syncNavTitle` page method. Use this from WXML event bindings or lifecycle hooks.
|
|
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
|
*/
|
|
syncNavTitle() {
|
|
const userInfo = auth.getStoredUserInfo()
|
|
const navTitle = userInfo && String(userInfo.shopName || '').trim()
|
|
? String(userInfo.shopName).trim()
|
|
: '游客模式'
|
|
this.setData({
|
|
navTitle
|
|
})
|
|
}
|
|
})
|