wzj-boot/mini-app/src/appManager.js

61 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-01-12 18:04:14 +08:00
import store from '@/store'
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')
}
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)
if (!store.state.user.token) {
eventHub.$emit('onShowDialogUserInfo')
return
}
console.log('path:', path)
if (!path) {
this.showToast('建设中')
return
}
console.log('path:', path)
2021-01-12 18:04:14 +08:00
wx.navigateTo({
url: path
2021-01-12 18:04:14 +08:00
})
}
showToast(msg) {
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()