gxd-uni-library-editx 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gxd-uni-library-editx",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "private": false,
5
5
  "description": "聚福宝基础插件专用库",
6
6
  "main": "index.js",
@@ -478,3 +478,5 @@ export function getParentsStyle(parent, key) {
478
478
 
479
479
 
480
480
 
481
+
482
+
@@ -9,6 +9,7 @@ import {
9
9
  getSetting,
10
10
  baseIsEmpty
11
11
  } from "@/utils/xd.base";
12
+ import store from "@/store";
12
13
 
13
14
 
14
15
  import storage from "@/common/storage";
@@ -129,10 +130,10 @@ export function handlePesponse(
129
130
  clog(`Fast Link:${request.url} ${useTime}ms`, 'green');
130
131
  }
131
132
 
133
+
132
134
  //200
133
135
  if (response['statusCode'] === 200) {
134
136
  resolve(response.data);
135
- return;
136
137
  }
137
138
 
138
139
  //400
@@ -162,14 +163,58 @@ export function handlePesponse(
162
163
 
163
164
  //401
164
165
  else if (response['statusCode'] === 401) {
165
- if (!$vm) {
166
- reject(response);
167
- throw new Error(response.data.message);
168
- }
169
- else {
166
+ //是否为刷新接口报错
167
+ if(request.url.indexOf(request.userRefreshToken) !== -1) {
168
+ console.log('request.userRefreshToken.401', request.userRefreshToken);
170
169
  reject(response);
171
170
  $vm.$xdHideLoading();
172
171
  }
172
+
173
+ //其他接口报错
174
+ else{
175
+ if (!$vm) {
176
+ reject(response);
177
+ throw new Error(response.data.message);
178
+ }
179
+ else {
180
+ //需要卡登陆页面
181
+ if(response.data.code === 'NeedCardLogin') {
182
+ //当前页面为卡登陆页面不处理
183
+ if($vm.$route.path === store.state.jfbAuthorize.cardPath) {
184
+ reject(response);
185
+ $vm.$xdHideLoading();
186
+ }
187
+ else store.state.jfbAuthorize.jumpToCardLogin($vm);
188
+ }
189
+
190
+ //用户登陆失效
191
+ else if(response.data.code === 'NeedLogin') {
192
+ if ($vm.$route.path === store.state.jfbAuthorize.LoginPath) {
193
+ reject(response);
194
+ $vm.$xdHideLoading();
195
+ }
196
+ else store.state.jfbAuthorize.jumpToUserLogin($vm);
197
+ }
198
+
199
+ //401去交换token
200
+ else if(response.data.code === 'Unauthorized') {
201
+ store.dispatch('userRefreshToken')
202
+ .then(status=>{
203
+ //交给store进行方法重新调用操作
204
+ reject('reLoadApi');
205
+ })
206
+ .catch(error=>{
207
+ store.state.jfbAuthorize.jumpToUserLogin($vm);
208
+ })
209
+ }
210
+ else {
211
+ reject(response);
212
+ $vm.$xdHideLoading();
213
+ }
214
+ }
215
+ }
216
+
217
+
173
218
  }
174
219
 
175
220
  //500
@@ -51,6 +51,25 @@ export function jfbRootExec(fnName, params) {
51
51
  }
52
52
  };
53
53
 
54
+ /**
55
+ * @description 获得父级页面中的方法引用
56
+ * @param vm {Vue} 插件对象实例
57
+ * @param fnName {String} 方法名字
58
+ * @returns {Function} 返回方法调用
59
+ */
60
+ export function jfbRootFnExec(vm, fnName) {
61
+ if(typeof vm.$root[fnName] === 'function') {
62
+ return vm.$root[fnName];
63
+ }
64
+ else {
65
+ throw new Error(JSON.stringify({
66
+ message: '访问的方法不存在',
67
+ fnName,
68
+ data: params
69
+ }))
70
+ }
71
+ }
72
+
54
73
 
55
74
 
56
75
  /**