Pārlūkot izejas kodu

仅显示有权限的应用

庄逸洲 6 gadus atpakaļ
vecāks
revīzija
19ec788c5f
1 mainītis faili ar 50 papildinājumiem un 18 dzēšanām
  1. 50 18
      src/store/modules/xt_user.js

+ 50 - 18
src/store/modules/xt_user.js Parādīt failu

1
-import { verifyToken, modifyAdminInfo } from '@/api/login/login'
1
+import {
2
+  verifyToken,
3
+  modifyAdminInfo
4
+} from '@/api/login/login'
2
 // import { mapGetters } from 'vuex'
5
 // import { mapGetters } from 'vuex'
3
 // import { getToken, setToken, removeToken } from '@/utils/auth'
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
 const xt_user = {
13
 const xt_user = {
7
   state: {
14
   state: {
33
       period_start: 0,
40
       period_start: 0,
34
       period_end: 0,
41
       period_end: 0,
35
       state: 2, // 1正版(标准) 2试用(免费) 3过期(或其他无效状态) 8 专业 9 永久,
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
     urlfors: []
49
     urlfors: []
41
   },
50
   },
68
       state.subscibe.period_start = cur_info.subscibe.period_start
77
       state.subscibe.period_start = cur_info.subscibe.period_start
69
       state.subscibe.period_end = cur_info.subscibe.period_end
78
       state.subscibe.period_end = cur_info.subscibe.period_end
70
       state.subscibe.state = cur_info.subscibe.state
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
     SET_URLFORS: (state, payload) => {
84
     SET_URLFORS: (state, payload) => {
79
       state.user.avatar = payload.avatar
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
     CLEAR_USER_INFO: (state) => {
96
     CLEAR_USER_INFO: (state) => {
86
       state.org_id = 0
97
       state.org_id = 0
110
       state.subscibe.state = 3
121
       state.subscibe.state = 3
111
       state.subscibe.patients = 0
122
       state.subscibe.patients = 0
112
 
123
 
124
+      state.org_app_types = []
113
       state.urlfors = []
125
       state.urlfors = []
114
     }
126
     }
115
   },
127
   },
121
   },
133
   },
122
 
134
 
123
   actions: {
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
       // console.log('验证 token 之前:token = ' + token)
147
       // console.log('验证 token 之前:token = ' + token)
130
       return new Promise((resolve, reject) => {
148
       return new Promise((resolve, reject) => {
131
         var cacheInfo = getAdminUserInfoCache()
149
         var cacheInfo = getAdminUserInfoCache()
139
             cur_app_id: infoJSON.current_app_id,
157
             cur_app_id: infoJSON.current_app_id,
140
             org: infoJSON.org,
158
             org: infoJSON.org,
141
             subscibe: infoJSON.subscibe,
159
             subscibe: infoJSON.subscibe,
160
+            app_types: infoJSON.app_types
142
           })
161
           })
143
 
162
 
144
           commit('SET_URLFORS', {
163
           commit('SET_URLFORS', {
156
                 cur_org_id: data.current_org_id,
175
                 cur_org_id: data.current_org_id,
157
                 cur_app_id: data.current_app_id,
176
                 cur_app_id: data.current_app_id,
158
                 org: data.org,
177
                 org: data.org,
159
-                subscibe: data.subscibe
178
+                subscibe: data.subscibe,
179
+                app_types: data.app_types
160
               })
180
               })
161
 
181
 
162
               this.commit('SET_URLFORS', {
182
               this.commit('SET_URLFORS', {
168
               resolve(data.user.id)
188
               resolve(data.user.id)
169
             } else {
189
             } else {
170
               alert('请求失败:' + response.data.msg)
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
       cacheAdminUserInfo(
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
           urlfors: state.urlfors,
214
           urlfors: state.urlfors,
186
           subscibe: state.subscibe,
215
           subscibe: state.subscibe,
216
+          app_types: state.org_app_types
187
         })
217
         })
188
       )
218
       )
189
     },
219
     },
207
     //   }
237
     //   }
208
     // }
238
     // }
209
     // 登出
239
     // 登出
210
-    FrontendLogout({ commit }) {
240
+    FrontendLogout({
241
+      commit
242
+    }) {
211
       commit('CLEAR_USER_INFO')
243
       commit('CLEAR_USER_INFO')
212
       removeAdminUserInfoCache()
244
       removeAdminUserInfoCache()
213
     }
245
     }