|
@@ -1,7 +1,14 @@
|
1
|
|
-import { verifyToken, modifyAdminInfo } from '@/api/login/login'
|
|
1
|
+import {
|
|
2
|
+ verifyToken,
|
|
3
|
+ modifyAdminInfo
|
|
4
|
+} from '@/api/login/login'
|
2
|
5
|
// import { mapGetters } from 'vuex'
|
3
|
6
|
// import { getToken, setToken, removeToken } from '@/utils/auth'
|
4
|
|
-import { getAdminUserInfoCache, cacheAdminUserInfo, removeAdminUserInfoCache } from '@/utils/admin_info_cache'
|
|
7
|
+import {
|
|
8
|
+ getAdminUserInfoCache,
|
|
9
|
+ cacheAdminUserInfo,
|
|
10
|
+ removeAdminUserInfoCache
|
|
11
|
+} from '@/utils/admin_info_cache'
|
5
|
12
|
|
6
|
13
|
const xt_user = {
|
7
|
14
|
state: {
|
|
@@ -33,9 +40,11 @@ const xt_user = {
|
33
|
40
|
period_start: 0,
|
34
|
41
|
period_end: 0,
|
35
|
42
|
state: 2, // 1正版(标准) 2试用(免费) 3过期(或其他无效状态) 8 专业 9 永久,
|
36
|
|
- patients:20, //患者数
|
|
43
|
+ patients: 20 // 患者数
|
37
|
44
|
},
|
38
|
45
|
|
|
46
|
+ org_app_types: [], // 该用户拥有权限的应用的类型集
|
|
47
|
+
|
39
|
48
|
// 示例: ['', '',]
|
40
|
49
|
urlfors: []
|
41
|
50
|
},
|
|
@@ -68,6 +77,8 @@ const xt_user = {
|
68
|
77
|
state.subscibe.period_start = cur_info.subscibe.period_start
|
69
|
78
|
state.subscibe.period_end = cur_info.subscibe.period_end
|
70
|
79
|
state.subscibe.state = cur_info.subscibe.state
|
|
80
|
+
|
|
81
|
+ state.org_app_types = cur_info.app_types == null || cur_info.app_types == undefined ? [3] : cur_info.app_types
|
71
|
82
|
},
|
72
|
83
|
|
73
|
84
|
SET_URLFORS: (state, payload) => {
|
|
@@ -79,8 +90,8 @@ const xt_user = {
|
79
|
90
|
state.user.avatar = payload.avatar
|
80
|
91
|
},
|
81
|
92
|
|
82
|
|
- SET_SUBSCIBE_PATIENT:(state)=>{
|
83
|
|
- state.subscibe.patients += 1;
|
|
93
|
+ SET_SUBSCIBE_PATIENT: (state) => {
|
|
94
|
+ state.subscibe.patients += 1
|
84
|
95
|
},
|
85
|
96
|
CLEAR_USER_INFO: (state) => {
|
86
|
97
|
state.org_id = 0
|
|
@@ -110,6 +121,7 @@ const xt_user = {
|
110
|
121
|
state.subscibe.state = 3
|
111
|
122
|
state.subscibe.patients = 0
|
112
|
123
|
|
|
124
|
+ state.org_app_types = []
|
113
|
125
|
state.urlfors = []
|
114
|
126
|
}
|
115
|
127
|
},
|
|
@@ -121,11 +133,17 @@ const xt_user = {
|
121
|
133
|
},
|
122
|
134
|
|
123
|
135
|
actions: {
|
124
|
|
- SetSubscibePatients({ commit, state }) {
|
125
|
|
- commit('SET_SUBSCIBE_PATIENT');
|
|
136
|
+ SetSubscibePatients({
|
|
137
|
+ commit,
|
|
138
|
+ state
|
|
139
|
+ }) {
|
|
140
|
+ commit('SET_SUBSCIBE_PATIENT')
|
126
|
141
|
},
|
127
|
142
|
|
128
|
|
- VerifyToken({ commit, state }, token) {
|
|
143
|
+ VerifyToken({
|
|
144
|
+ commit,
|
|
145
|
+ state
|
|
146
|
+ }, token) {
|
129
|
147
|
// console.log('验证 token 之前:token = ' + token)
|
130
|
148
|
return new Promise((resolve, reject) => {
|
131
|
149
|
var cacheInfo = getAdminUserInfoCache()
|
|
@@ -139,6 +157,7 @@ const xt_user = {
|
139
|
157
|
cur_app_id: infoJSON.current_app_id,
|
140
|
158
|
org: infoJSON.org,
|
141
|
159
|
subscibe: infoJSON.subscibe,
|
|
160
|
+ app_types: infoJSON.app_types
|
142
|
161
|
})
|
143
|
162
|
|
144
|
163
|
commit('SET_URLFORS', {
|
|
@@ -156,7 +175,8 @@ const xt_user = {
|
156
|
175
|
cur_org_id: data.current_org_id,
|
157
|
176
|
cur_app_id: data.current_app_id,
|
158
|
177
|
org: data.org,
|
159
|
|
- subscibe: data.subscibe
|
|
178
|
+ subscibe: data.subscibe,
|
|
179
|
+ app_types: data.app_types
|
160
|
180
|
})
|
161
|
181
|
|
162
|
182
|
this.commit('SET_URLFORS', {
|
|
@@ -168,22 +188,32 @@ const xt_user = {
|
168
|
188
|
resolve(data.user.id)
|
169
|
189
|
} else {
|
170
|
190
|
alert('请求失败:' + response.data.msg)
|
171
|
|
- reject({ msg: response.data.msg, code: response.data.code })
|
|
191
|
+ reject({
|
|
192
|
+ msg: response.data.msg,
|
|
193
|
+ code: response.data.code
|
|
194
|
+ })
|
172
|
195
|
}
|
173
|
196
|
})
|
174
|
197
|
}
|
175
|
198
|
})
|
176
|
199
|
},
|
177
|
|
- ModifyAdminUserInfo({ commit, state }, params) {
|
178
|
|
- commit('MODIFY_USER_INFO', { user_name: params.user_name, avatar: params.avatar })
|
|
200
|
+ ModifyAdminUserInfo({
|
|
201
|
+ commit,
|
|
202
|
+ state
|
|
203
|
+ }, params) {
|
|
204
|
+ commit('MODIFY_USER_INFO', {
|
|
205
|
+ user_name: params.user_name,
|
|
206
|
+ avatar: params.avatar
|
|
207
|
+ })
|
179
|
208
|
cacheAdminUserInfo(
|
180
|
|
- JSON.stringify({
|
181
|
|
- user: state.user,
|
182
|
|
- org: state.org,
|
183
|
|
- current_org_id: state.org_id,
|
184
|
|
- current_app_id: state.app_id,
|
|
209
|
+ JSON.stringify({
|
|
210
|
+ user: state.user,
|
|
211
|
+ org: state.org,
|
|
212
|
+ current_org_id: state.org_id,
|
|
213
|
+ current_app_id: state.app_id,
|
185
|
214
|
urlfors: state.urlfors,
|
186
|
215
|
subscibe: state.subscibe,
|
|
216
|
+ app_types: state.org_app_types
|
187
|
217
|
})
|
188
|
218
|
)
|
189
|
219
|
},
|
|
@@ -207,7 +237,9 @@ const xt_user = {
|
207
|
237
|
// }
|
208
|
238
|
// }
|
209
|
239
|
// 登出
|
210
|
|
- FrontendLogout({ commit }) {
|
|
240
|
+ FrontendLogout({
|
|
241
|
+ commit
|
|
242
|
+ }) {
|
211
|
243
|
commit('CLEAR_USER_INFO')
|
212
|
244
|
removeAdminUserInfoCache()
|
213
|
245
|
}
|