Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
transport-show-h5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
transport-show-h5
Commits
5574bccb
提交
5574bccb
authored
8月 11, 2020
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bug fixes
上级
1aaaee91
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
23 行删除
+25
-23
base_api.js
src/api/base_api.js
+9
-19
login.vue
src/pages/login/login.vue
+16
-4
没有找到文件。
src/api/base_api.js
浏览文件 @
5574bccb
...
...
@@ -31,9 +31,7 @@ export default class API {
/* 重新封装 请求时的执行函数 */
_request
(
_config
=
{})
{
/* 具体执行请求成功后业务逻辑前,先执行该方法 */
const
beforeSuccess
=
_config
.
beforeSuccess
?
_config
.
beforeSuccess
:
this
.
_reqSuccess
const
beforeSuccess
=
_config
.
beforeSuccess
?
_config
.
beforeSuccess
:
this
.
_reqSuccess
/* 具体执行请求失败后业务逻辑前,先执行该方法 */
const
beforeFail
=
_config
.
beforeFail
?
_config
.
beforeFail
:
this
.
_reqFail
const
headers
=
{
...
...
@@ -42,9 +40,7 @@ export default class API {
}
_config
.
headers
=
_
.
assignIn
(
_config
.
headers
,
headers
)
/* 判别 传输方式 */
if
(
_config
.
headers
[
'Content-Type'
]
===
'application/x-www-form-urlencoded'
)
{
if
(
_config
.
headers
[
'Content-Type'
]
===
'application/x-www-form-urlencoded'
)
{
let
str
=
''
const
_obj
=
_config
.
data
||
_config
.
params
for
(
const
key
in
_obj
)
{
...
...
@@ -66,10 +62,7 @@ export default class API {
_config
.
data
=
fr
}
/* 创建并根据参数发起请求 */
return
this
.
_axios
(
_config
).
then
(
beforeSuccess
.
bind
(
this
),
beforeFail
.
bind
(
this
)
)
return
this
.
_axios
(
_config
).
then
(
beforeSuccess
.
bind
(
this
),
beforeFail
.
bind
(
this
))
}
/**
...
...
@@ -120,6 +113,9 @@ export default class API {
router
.
replace
({
path
:
'/pay'
})
}
}
if
(
status
===
500
)
{
window
.
alert
(
res
.
response
.
message
)
}
}
err
=
new
Error
(
JSON
.
stringify
(
res
.
response
))
}
else
{
...
...
@@ -132,16 +128,12 @@ export default class API {
/* 重新实现 get请求 */
get
(
url
,
data
,
config
)
{
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'GET'
,
params
:
data
},
config
)
)
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'GET'
,
params
:
data
},
config
))
}
/* 重新实现 post请求 */
post
(
url
,
data
,
config
)
{
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'POST'
,
data
:
data
},
config
)
)
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'POST'
,
data
:
data
},
config
))
}
/* 重新实现 put请求 */
...
...
@@ -151,8 +143,6 @@ export default class API {
/* 重新实现 delete请求 */
delete
(
url
,
data
,
config
)
{
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'DELETE'
,
params
:
data
},
config
)
)
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'DELETE'
,
params
:
data
},
config
))
}
}
src/pages/login/login.vue
浏览文件 @
5574bccb
...
...
@@ -91,14 +91,26 @@ export default {
type
:
2
,
identity
:
'transport'
,
unionid
:
this
.
unionid
,
code
:
data
.
password
code
:
data
.
password
,
forceUpdate
:
'0'
})
api
.
bindWechat
(
params
)
.
then
(
response
=>
{
this
.
bindVisitor
(()
=>
{
this
.
loginSuccess
(
response
)
})
const
{
code
,
msg
:
message
}
=
response
if
(
code
===
0
)
{
this
.
bindVisitor
(()
=>
{
this
.
loginSuccess
(
response
)
})
}
else
if
(
code
===
1007
)
{
this
.
$dialog
({
confirmButtonText
:
'知道了'
,
message
:
'您的手机号码已绑定其他微信号码,您可以用绑定的微信号登录后解除绑定或拨打客服电话解除绑定。解绑后再尝试绑定当前的微信号。'
})
}
else
{
this
.
$dialog
({
message
})
}
})
.
catch
(
error
=>
{
error
.
response
&&
this
.
$toast
(
error
.
response
.
data
.
message
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论