Commit 8500fa15 authored by Facius's avatar Facius

Merge branch 'dev-v1.0.0' of https://git.banshouhui.com/wuzhenzhe/study into dev-v1.0.0

parents 5e291583 8fa5c924
let commonApiFun = function(vm) {
const globalUrl = process.uniEnv || {}
let ucenterApiUrl = globalUrl.uUrl
let loginWechatAuth = async (params = {}) =>
await vm.$u.post('/wxapp/unify/authorization', params)
let loginWechatAuth = async (params = {}) => await vm.$u.post('/wxapp/unify/authorization', params)
let payOrder = async (params = {}) => await vm.$u.post('/pay/order', params)
let getQiNiuToken = async (params = {}) =>
await vm.$u.post(ucenterApiUrl + 'v1/tokens', params)
let payQuery = async (params = {}) => await vm.$u.get('/pay/query', params)
let getQiNiuToken = async (params = {}) => await vm.$u.post(ucenterApiUrl + 'v1/tokens', params)
const commonApi = {
loginWechatAuth,
payOrder,
payQuery,
getQiNiuToken,
}
return commonApi
......
......@@ -55,7 +55,13 @@ const install = (Vue, vm) => {
vm.$u.toast(data.msg);
return false;
}
} else {
} else if (res.statusCode === 401) {
// 登录过期
vm.$u.toast(data.msg)
setTimeout(() => {
vm.$u.route('/pages/login/index')
}, 1500);
}else {
// HTTP状态非200
vm.$u.toast(data.msg || '服务器错误');
}
......
......@@ -19,7 +19,6 @@ export default {
],
}
},
created() {},
methods: {
payOrder() {
const data = {
......@@ -48,13 +47,33 @@ export default {
paySign: paySign,
success: (res) => {
console.log('success:' + JSON.stringify(res))
this.$u.toast('支付成功')
this.checkPayStatus(data.out_trade_no)
},
fail: (err) => {
console.log('fail:' + JSON.stringify(err))
this.$u.toast('支付失败')
if (err.errMsg === 'requestPayment:fail cancel') {
this.$u.toast('取消支付')
} else {
this.checkPayStatus(data.out_trade_no)
}
},
})
},
checkPayStatus(no) {
const params = {
outTradeNo: no
}
this.$u.api.payQuery(params).then(res => {
if (res.trade_state === 'SUCCESS') {
this.$u.toast('支付成功')
} else if (res.trade_state === 'NOTPAY') {
this.$u.toast('请稍后核实订单状态,不要重复发起支付')
} else if (res.trade_state === 'PAYERROR') {
this.$u.toast('支付失败')
} else {
this.$u.toast(res.trade_state_desc)
}
})
}
},
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment