2021-01-12 18:04:14 +08:00
|
|
|
import store from '@/store'
|
2021-01-16 10:36:53 +08:00
|
|
|
import eventHub from './common/eventHub'
|
2021-01-12 18:04:14 +08:00
|
|
|
|
2021-01-15 12:00:20 +08:00
|
|
|
class AppManager {
|
2021-01-12 18:04:14 +08:00
|
|
|
saveOpenid(openid) {
|
|
|
|
store.dispatch('setOpenidAction', openid)
|
|
|
|
}
|
|
|
|
|
|
|
|
getOpenid() {
|
|
|
|
return wx.getStorageSync('openid')
|
|
|
|
}
|
|
|
|
|
2021-01-17 01:45:15 +08:00
|
|
|
setCacheInfo() {
|
|
|
|
const mobile = wx.getStorageSync('mobile')
|
|
|
|
const openid = wx.getStorageSync('openid')
|
|
|
|
const userInfo = wx.getStorageSync('userInfo')
|
|
|
|
|
|
|
|
console.log('setCacheInfo:', mobile)
|
|
|
|
console.log('setCacheInfo:', openid)
|
|
|
|
console.log('setCacheInfo:', userInfo)
|
|
|
|
|
|
|
|
if (mobile) {
|
|
|
|
store.dispatch('setMobileAction', mobile)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (openid) {
|
|
|
|
store.dispatch('setOpenidAction', openid)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (userInfo) {
|
|
|
|
store.dispatch('setUserInfoAction', userInfo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
navigateTo(path) {
|
|
|
|
console.log('path:', path)
|
2021-01-16 10:36:53 +08:00
|
|
|
if (!store.state.user.token) {
|
|
|
|
eventHub.$emit('onShowDialogUserInfo')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-01-17 01:45:15 +08:00
|
|
|
console.log('path:', path)
|
|
|
|
|
|
|
|
if (!path) {
|
2021-01-16 10:36:53 +08:00
|
|
|
this.showToast('建设中')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-01-17 01:45:15 +08:00
|
|
|
console.log('path:', path)
|
2021-01-12 18:04:14 +08:00
|
|
|
wx.navigateTo({
|
2021-01-17 01:45:15 +08:00
|
|
|
url: path
|
2021-01-12 18:04:14 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
showToast(msg) {
|
2021-01-17 01:45:15 +08:00
|
|
|
wx.showToast({ title: msg, icon: 'none' })
|
2021-01-12 18:04:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-15 12:00:20 +08:00
|
|
|
export default new AppManager()
|