commonStore.js
3.74 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import router from '@/router'
export default {
state: {
verificationCount: null,
verificationFlag: null,
lastPath: '',
prevPath: '',
goodsInfo: {},
merchantId: null,
order: {},
address: {},
//保存首页的数据-避免重复刷新
//门店信息
shopInfo: {},
//金刚区
menuInfo: [],
//门店服务
serverInfo: [],
//分享链接
shareInfo: {},
//是否关注公众号
concernInfo: null,
//精选数据
highInfo: [],
//直充列表
chargeList: [],
//卡券列表
cardList: []
},
mutations: {
setUserInfo(state, newVal) {
Object.keys(newVal).map(key => {
if (key == 'sessionId' && newVal[key].indexOf('-') == -1) {
return
}
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 == 'equity/index') {
route = ''
history.back() //去掉历史记录,重复页面
//router.replace({ name: 'common.marketing' })
//window.location.replace(`${window.location.href.split('?')[0]}#/${route}`)
return
} else {
if (!newVal.phone && route != 'device/index') {
if (window.__wxjs_environment == 'miniprogram') {
router.replace({ name: 'equity.index' })
} else {
router.replace({ name: 'common.phoneLogin' })
}
return
}
}
window.location.href = `${window.location.href.split('?')[0]}#/${route}`
return
} else {
let route = state.lastPath.replace('.', '/')
window.location.href = `${window.location.href.split('?')[0]}#/${route}`
}
}
}
},
setMerchantId(state, newVal) {
state.merchantId = newVal;
},
setOrder(state, newVal) {
state.order = newVal;
},
setAddress(state, newVal) {
state.address = newVal;
},
setGoodsInfo(state, newVal) {
state.goodsInfo = newVal;
sessionStorage.setItem('GL_GOODS_INFO', JSON.stringify(newVal))
},
setVerificationCount(state, newVal) {
state.verificationCount = newVal
},
setVerificationFlag(state, newVal) {
state.verificationFlag = newVal
},
jumpPath(state, newVal) {
state.lastPath = newVal
},
findPrevPath(state, newVal) {
state.prevPath = newVal
},
clearSessionId(state) {
state.sessionId = ''
router.replace({ name: 'common.marketing' })
},
reload(state) {
console.log(state, 'storeRelod方法,已译注');
// router.replace({ name: 'common.nothing' })
// setTimeout(() => {
// state.lastPath?router.replace({ name: state.lastPath }):router.replace({name: 'equity.index'})
// }, 1000)
},
setShopInfo(state, newVal) {
state.shopInfo = newVal
},
setMenuInfo(state, newVal) {
state.menuInfo = newVal
},
setServerInfo(state, newVal) {
state.serverInfo = newVal
},
setShareInfo(state, newVal) {
state.shareInfo = newVal
},
setConcernInfo(state, newVal) {
state.concernInfo = newVal
},
setHighInfo(state, newVal) {
state.highInfo = newVal
},
setchargeInfo(state, newVal) {
state.chargeList = newVal
},
setcardsInfo(state, newVal) {
state.cardList = newVal
},
},
}