提交 5574bccb authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 1aaaee91
......@@ -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))
}
}
......@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论