commonStore.js
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import router from '@/router'
export default {
state: {
verificationCount: null,
verificationFlag: null,
lastPath: '',
},
mutations: {
setUserInfo(state, newVal) {
Object.keys(newVal).map(key => {
if (newVal[key]) state[key] = newVal[key]
})
const ua = navigator.userAgent.toLowerCase()
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
let userInfo = sessionStorage.getItem('GL_EQUITY_USER_INFO')
if (!userInfo) {
sessionStorage.setItem('GL_EQUITY_USER_INFO', JSON.stringify(state))
if (state.lastPath) {
let route = state.lastPath.replace('.', '/')
if (route == 'common/index') {
route = ''
} else {
if (!newVal.phone && route != 'device/index') {
router.replace({ name: 'common.phoneLogin' })
return
}
}
window.location.href = `${window.location.href.split('?')[0]}#/${route}`
return
}
}
}
},
setVerificationCount(state, newVal) {
state.verificationCount = newVal
},
setVerificationFlag(state, newVal) {
state.verificationFlag = newVal
},
jumpPath(state, newVal) {
state.lastPath = newVal
},
clearSessionId(state) {
state.sessionId = ''
router.replace({ name: 'common.index' })
},
reload(state) {
router.replace({ name: 'common.nothing' })
setTimeout(() => {
router.replace({ name: state.lastPath })
}, 100)
}
},
}