Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-Mob-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-Mob-R7-Res
提交
bd9d6d19
提交
bd9d6d19
编写于
10月 13, 2020
作者:
KK
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复后台报错前端无任何提示bug & 代码格式化
上级
731ea5e4
变更
2
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
40 行增加
和
34 行删除
+40
-34
http.ts
src/ibiz-core/utils/http/http.ts
+37
-25
interceptor.ts
src/utils/interceptor/interceptor.ts
+3
-9
未找到文件。
src/ibiz-core/utils/http/http.ts
浏览文件 @
bd9d6d19
import
axios
,
{
AxiosResponse
}
from
'axios'
;
import
axios
,
{
AxiosResponse
}
from
'axios'
;
import
qs
from
'qs'
;
import
qs
from
'qs'
;
import
{
HttpResponse
}
from
'./http-response'
;
import
{
HttpResponse
}
from
'./http-response'
;
import
{
Notice
}
from
'@/utils/notice/notice'
;
import
{
Loading
}
from
'../loading/loading'
;
import
{
Loading
}
from
'../loading/loading'
;
/**
/**
* Http net 对象
* Http net 对象
...
@@ -24,6 +25,15 @@ export class Http {
...
@@ -24,6 +25,15 @@ export class Http {
return
this
.
Http
;
return
this
.
Http
;
}
}
/**
* 提示工具类
*
* @protected
* @type {Notice}
* @memberof UIActionBase
*/
private
notice
:
Notice
=
Notice
.
getInstance
();
/**
/**
* 单例变量声明
* 单例变量声明
*
*
...
@@ -106,27 +116,27 @@ export class Http {
...
@@ -106,27 +116,27 @@ export class Http {
* @returns {Promise<any>}
* @returns {Promise<any>}
* @memberof Http
* @memberof Http
*/
*/
public
get
(
url
:
string
,
params
:
any
=
{},
isloading
?:
boolean
,
serialnumber
?:
number
):
Promise
<
any
>
{
public
get
(
url
:
string
,
params
:
any
=
{},
isloading
?:
boolean
,
serialnumber
?:
number
):
Promise
<
any
>
{
params
=
this
.
handleRequestData
(
params
);
params
=
this
.
handleRequestData
(
params
);
if
(
params
.
srfparentdata
)
{
if
(
params
.
srfparentdata
)
{
Object
.
assign
(
params
,
params
.
srfparentdata
);
Object
.
assign
(
params
,
params
.
srfparentdata
);
delete
params
.
srfparentdata
;
delete
params
.
srfparentdata
;
}
}
if
((
Object
.
keys
(
params
)).
length
>
0
)
{
if
((
Object
.
keys
(
params
)).
length
>
0
)
{
let
tempParam
:
any
=
{};
let
tempParam
:
any
=
{};
let
sort
:
any
=
null
;
let
sort
:
any
=
null
;
Object
.
keys
(
params
).
forEach
((
item
:
any
)
=>
{
Object
.
keys
(
params
).
forEach
((
item
:
any
)
=>
{
if
(
params
[
item
]
||
Object
.
is
(
params
[
item
],
0
)
)
{
if
(
params
[
item
]
||
Object
.
is
(
params
[
item
],
0
))
{
if
(
Object
.
is
(
item
,
'sort'
))
{
if
(
Object
.
is
(
item
,
'sort'
))
{
sort
=
params
[
item
];
sort
=
params
[
item
];
}
else
{
}
else
{
tempParam
[
item
]
=
params
[
item
];
tempParam
[
item
]
=
params
[
item
];
}
}
}
}
})
})
url
+=
`?
${
qs
.
stringify
(
tempParam
)}
`
;
url
+=
`?
${
qs
.
stringify
(
tempParam
)}
`
;
if
(
sort
)
{
if
(
sort
)
{
url
+=
'&sort='
+
sort
;
url
+=
'&sort='
+
sort
;
}
}
}
}
if
(
isloading
)
{
if
(
isloading
)
{
...
@@ -151,19 +161,19 @@ export class Http {
...
@@ -151,19 +161,19 @@ export class Http {
* @returns {Promise<any>}
* @returns {Promise<any>}
* @memberof Http
* @memberof Http
*/
*/
public
delete
(
url
:
string
,
isloading
?:
boolean
,
data
?:
any
,
serialnumber
?:
number
):
Promise
<
any
>
{
public
delete
(
url
:
string
,
isloading
?:
boolean
,
data
?:
any
,
serialnumber
?:
number
):
Promise
<
any
>
{
if
(
isloading
)
{
if
(
isloading
)
{
this
.
beginLoading
();
this
.
beginLoading
();
}
}
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
if
(
!
data
)
{
if
(
!
data
)
{
axios
.
delete
(
url
).
then
((
response
:
any
)
=>
{
axios
.
delete
(
url
).
then
((
response
:
any
)
=>
{
resolve
(
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
));
resolve
(
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
));
}).
catch
((
response
:
any
)
=>
{
}).
catch
((
response
:
any
)
=>
{
reject
(
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
));
reject
(
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
));
});
});
}
else
{
}
else
{
axios
.
delete
(
url
,
{
data
:
data
}).
then
((
response
:
any
)
=>
{
axios
.
delete
(
url
,
{
data
:
data
}).
then
((
response
:
any
)
=>
{
resolve
(
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
));
resolve
(
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
));
}).
catch
((
response
:
any
)
=>
{
}).
catch
((
response
:
any
)
=>
{
reject
(
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
));
reject
(
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
));
...
@@ -217,8 +227,10 @@ export class Http {
...
@@ -217,8 +227,10 @@ export class Http {
if
(
response
.
status
===
200
)
{
if
(
response
.
status
===
200
)
{
return
new
HttpResponse
(
200
,
response
.
data
,
undefined
,
response
.
headers
);
return
new
HttpResponse
(
200
,
response
.
data
,
undefined
,
response
.
headers
);
}
}
this
.
notice
.
error
(
response
.
data
.
message
?
response
.
data
.
message
:
HttpResponse
.
getStatusMessage
(
response
.
status
));
return
new
HttpResponse
(
response
.
status
,
response
.
data
,
{
code
:
101
,
message
:
HttpResponse
.
getStatusMessage
(
response
.
status
)
},
response
.
headers
)
return
new
HttpResponse
(
response
.
status
,
response
.
data
,
{
code
:
101
,
message
:
HttpResponse
.
getStatusMessage
(
response
.
status
)
},
response
.
headers
)
}
}
this
.
notice
.
error
(
HttpResponse
.
getStatusMessage
(
response
.
status
));
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'请求发生异常,无返回结果!'
},
response
.
headers
);
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'请求发生异常,无返回结果!'
},
response
.
headers
);
}
}
...
@@ -258,11 +270,11 @@ export class Http {
...
@@ -258,11 +270,11 @@ export class Http {
* @param data
* @param data
* @memberof Http
* @memberof Http
*/
*/
private
handleRequestData
(
data
:
any
)
{
private
handleRequestData
(
data
:
any
)
{
if
(
data
.
srfsessionkey
)
{
if
(
data
.
srfsessionkey
)
{
delete
data
.
srfsessionkey
;
delete
data
.
srfsessionkey
;
}
}
if
(
data
.
srfsessionid
)
{
if
(
data
.
srfsessionid
)
{
delete
data
.
srfsessionid
;
delete
data
.
srfsessionid
;
}
}
return
data
;
return
data
;
...
...
src/utils/interceptor/interceptor.ts
浏览文件 @
bd9d6d19
...
@@ -3,7 +3,6 @@ import axios from 'axios';
...
@@ -3,7 +3,6 @@ import axios from 'axios';
import
Router
from
'vue-router'
;
import
Router
from
'vue-router'
;
import
i18n
from
'@/locale'
;
import
i18n
from
'@/locale'
;
import
ignoreProxyMap
from
'./ignore-proxy'
;
import
ignoreProxyMap
from
'./ignore-proxy'
;
import
{
Loading
}
from
'@/ibiz-core/utils'
;
/**
/**
* 拦截器
* 拦截器
*
*
...
@@ -104,22 +103,17 @@ export class Interceptors {
...
@@ -104,22 +103,17 @@ export class Interceptors {
return
response
;
return
response
;
},
(
error
:
any
)
=>
{
},
(
error
:
any
)
=>
{
error
=
error
?
error
:
{
response
:
{}
};
error
=
error
?
error
:
{
response
:
{}
};
// tslint:disable-next-line:prefer-const
let
{
response
:
res
}
=
error
;
let
{
response
:
res
}
=
error
;
let
{
data
:
_data
}
=
res
;
let
{
data
:
_data
}
=
res
;
if
(
res
.
status
===
401
)
{
if
(
res
.
status
===
401
)
{
// Loading.hidden();
this
.
doNoLogin
(
_data
.
data
);
this
.
doNoLogin
(
_data
.
data
);
}
}
if
(
res
.
status
===
404
)
{
if
(
res
.
status
===
404
)
{
// Loading.hidden();
this
.
router
.
push
({
path
:
'/404'
});
this
.
router
.
push
({
path
:
'/404'
});
}
else
if
(
res
.
status
===
500
)
{
}
else
if
(
res
.
status
===
500
)
{
// Loading.hidden();
this
.
router
.
push
({
path
:
'/500'
});
this
.
router
.
push
({
path
:
'/500'
});
}
}
return
Promise
.
reject
(
res
);
return
Promise
.
reject
(
res
);
});
});
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录