Commit 75582a53 authored by Damon's avatar Damon

feat(pay): 微信支付状态查询

parent 3fa72a1f
let commonApiFun = function(vm) {
let loginWechatAuth = async (params = {}) => await vm.$u.post('/wxapp/unify/authorization', params)
let payOrder = async (params = {}) => await vm.$u.post('/pay/order', params)
let payQuery = async (params = {}) => await vm.$u.get('/pay/query', params)
const commonApi = {
loginWechatAuth,
payOrder
payOrder,
payQuery
}
return commonApi
}
......
......@@ -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