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

bug fixes

上级 1aaaee91
...@@ -31,9 +31,7 @@ export default class API { ...@@ -31,9 +31,7 @@ export default class API {
/* 重新封装 请求时的执行函数 */ /* 重新封装 请求时的执行函数 */
_request(_config = {}) { _request(_config = {}) {
/* 具体执行请求成功后业务逻辑前,先执行该方法 */ /* 具体执行请求成功后业务逻辑前,先执行该方法 */
const beforeSuccess = _config.beforeSuccess const beforeSuccess = _config.beforeSuccess ? _config.beforeSuccess : this._reqSuccess
? _config.beforeSuccess
: this._reqSuccess
/* 具体执行请求失败后业务逻辑前,先执行该方法 */ /* 具体执行请求失败后业务逻辑前,先执行该方法 */
const beforeFail = _config.beforeFail ? _config.beforeFail : this._reqFail const beforeFail = _config.beforeFail ? _config.beforeFail : this._reqFail
const headers = { const headers = {
...@@ -42,9 +40,7 @@ export default class API { ...@@ -42,9 +40,7 @@ export default class API {
} }
_config.headers = _.assignIn(_config.headers, headers) _config.headers = _.assignIn(_config.headers, headers)
/* 判别 传输方式 */ /* 判别 传输方式 */
if ( if (_config.headers['Content-Type'] === 'application/x-www-form-urlencoded') {
_config.headers['Content-Type'] === 'application/x-www-form-urlencoded'
) {
let str = '' let str = ''
const _obj = _config.data || _config.params const _obj = _config.data || _config.params
for (const key in _obj) { for (const key in _obj) {
...@@ -66,10 +62,7 @@ export default class API { ...@@ -66,10 +62,7 @@ export default class API {
_config.data = fr _config.data = fr
} }
/* 创建并根据参数发起请求 */ /* 创建并根据参数发起请求 */
return this._axios(_config).then( return this._axios(_config).then(beforeSuccess.bind(this), beforeFail.bind(this))
beforeSuccess.bind(this),
beforeFail.bind(this)
)
} }
/** /**
...@@ -120,6 +113,9 @@ export default class API { ...@@ -120,6 +113,9 @@ export default class API {
router.replace({ path: '/pay' }) router.replace({ path: '/pay' })
} }
} }
if (status === 500) {
window.alert(res.response.message)
}
} }
err = new Error(JSON.stringify(res.response)) err = new Error(JSON.stringify(res.response))
} else { } else {
...@@ -132,16 +128,12 @@ export default class API { ...@@ -132,16 +128,12 @@ export default class API {
/* 重新实现 get请求 */ /* 重新实现 get请求 */
get(url, data, config) { get(url, data, config) {
return this._request( return this._request(_.assignIn({ url, method: 'GET', params: data }, config))
_.assignIn({ url, method: 'GET', params: data }, config)
)
} }
/* 重新实现 post请求 */ /* 重新实现 post请求 */
post(url, data, config) { post(url, data, config) {
return this._request( return this._request(_.assignIn({ url, method: 'POST', data: data }, config))
_.assignIn({ url, method: 'POST', data: data }, config)
)
} }
/* 重新实现 put请求 */ /* 重新实现 put请求 */
...@@ -151,8 +143,6 @@ export default class API { ...@@ -151,8 +143,6 @@ export default class API {
/* 重新实现 delete请求 */ /* 重新实现 delete请求 */
delete(url, data, config) { delete(url, data, config) {
return this._request( return this._request(_.assignIn({ url, method: 'DELETE', params: data }, config))
_.assignIn({ url, method: 'DELETE', params: data }, config)
)
} }
} }
...@@ -91,14 +91,26 @@ export default { ...@@ -91,14 +91,26 @@ export default {
type: 2, type: 2,
identity: 'transport', identity: 'transport',
unionid: this.unionid, unionid: this.unionid,
code: data.password code: data.password,
forceUpdate: '0'
}) })
api api
.bindWechat(params) .bindWechat(params)
.then(response => { .then(response => {
this.bindVisitor(() => { const { code, msg: message } = response
this.loginSuccess(response) if (code === 0) {
}) this.bindVisitor(() => {
this.loginSuccess(response)
})
} else if (code === 1007) {
this.$dialog({
confirmButtonText: '知道了',
message:
'您的手机号码已绑定其他微信号码,您可以用绑定的微信号登录后解除绑定或拨打客服电话解除绑定。解绑后再尝试绑定当前的微信号。'
})
} else {
this.$dialog({ message })
}
}) })
.catch(error => { .catch(error => {
error.response && this.$toast(error.response.data.message) error.response && this.$toast(error.response.data.message)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论