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
提交
6efa1600
提交
6efa1600
编写于
7月 28, 2020
作者:
KK
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
http 组件调整
上级
d04cdb6e
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
24 行增加
和
16 行删除
+24
-16
http.ts
src/ibiz-core/utils/http/http.ts
+24
-16
未找到文件。
src/ibiz-core/utils/http/http.ts
浏览文件 @
6efa1600
import
axios
,
{
AxiosResponse
}
from
'axios'
;
import
axios
,
{
AxiosResponse
}
from
'axios'
;
import
qs
from
'qs'
;
import
qs
from
'qs'
;
import
{
HttpResponse
}
from
'./http-response'
;
/**
/**
* Http net 对象
* Http net 对象
* 调用 getInstance() 获取实例
* 调用 getInstance() 获取实例
...
@@ -86,10 +87,10 @@ export class Http {
...
@@ -86,10 +87,10 @@ export class Http {
// }
// }
// return _data;
// return _data;
// }],
// }],
}).
then
((
response
:
any
)
=>
{
}).
then
((
response
:
AxiosResponse
)
=>
{
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
);
resolve
(
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
)
);
}).
catch
((
response
:
any
)
=>
{
}).
catch
((
response
:
AxiosResponse
)
=>
{
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
);
reject
(
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
)
);
});
});
});
});
}
}
...
@@ -131,10 +132,11 @@ export class Http {
...
@@ -131,10 +132,11 @@ export class Http {
this
.
beginLoading
();
this
.
beginLoading
();
}
}
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
axios
.
get
(
url
).
then
((
response
:
any
)
=>
{
axios
.
get
(
url
).
then
((
response
:
AxiosResponse
)
=>
{
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
);
resolve
(
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
));
}).
catch
((
response
:
any
)
=>
{
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
);
}).
catch
((
response
:
AxiosResponse
)
=>
{
reject
(
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
));
});
});
});
});
}
}
...
@@ -155,15 +157,15 @@ export class Http {
...
@@ -155,15 +157,15 @@ export class Http {
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
)
=>
{
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
);
resolve
(
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
);
}).
catch
((
response
:
any
)
=>
{
}).
catch
((
response
:
any
)
=>
{
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
)
=>
{
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
);
resolve
(
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
)
);
}).
catch
((
response
:
any
)
=>
{
}).
catch
((
response
:
any
)
=>
{
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
);
reject
(
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
)
);
});
});
}
}
});
});
...
@@ -186,9 +188,9 @@ export class Http {
...
@@ -186,9 +188,9 @@ export class Http {
data
=
this
.
handleRequestData
(
data
);
data
=
this
.
handleRequestData
(
data
);
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
axios
.
put
(
url
,
data
).
then
((
response
:
any
)
=>
{
axios
.
put
(
url
,
data
).
then
((
response
:
any
)
=>
{
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
);
resolve
(
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
)
);
}).
catch
((
response
:
any
)
=>
{
}).
catch
((
response
:
any
)
=>
{
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
);
reject
(
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
)
);
});
});
});
});
}
}
...
@@ -203,14 +205,20 @@ export class Http {
...
@@ -203,14 +205,20 @@ export class Http {
* @param {number} [serialnumber]
* @param {number} [serialnumber]
* @memberof Http
* @memberof Http
*/
*/
private
doResponseRresult
(
response
:
any
,
funt
:
Function
,
isloading
?:
boolean
,
serialnumber
?:
number
):
void
{
private
doResponseRresult
(
response
:
any
,
funt
:
Function
,
isloading
?:
boolean
,
serialnumber
?:
number
):
HttpResponse
{
if
(
isloading
)
{
if
(
isloading
)
{
this
.
endLoading
();
this
.
endLoading
();
}
}
if
(
serialnumber
)
{
if
(
serialnumber
)
{
Object
.
assign
(
response
,
{
serialnumber
:
serialnumber
});
Object
.
assign
(
response
,
{
serialnumber
:
serialnumber
});
}
}
funt
(
response
);
if
(
response
)
{
if
(
response
.
status
===
200
)
{
return
new
HttpResponse
(
200
,
response
.
data
,
undefined
,
response
.
headers
);
}
return
new
HttpResponse
(
response
.
status
,
response
.
data
,
{
code
:
101
,
message
:
HttpResponse
.
getStatusMessage
(
response
.
status
)
},
response
.
headers
)
}
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'请求发生异常,无返回结果!'
},
response
.
headers
);
}
}
/**
/**
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录