|
@@ -184,6 +184,7 @@ export default {
|
|
|
return {
|
|
|
orderId: null,
|
|
|
openFlag: null,
|
|
|
+ polyOrderId: null,
|
|
|
// 订单信息
|
|
|
orderInfo: {},
|
|
|
// 立即支付弹框
|
|
@@ -196,27 +197,26 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
onLoad (page) {
|
|
|
- const orderId = page?.orderId
|
|
|
+ this.orderId = page?.orderId
|
|
|
// 该标识判断是否是从支付完成页面回调回来
|
|
|
- const openFlag = page?.type
|
|
|
- if (orderId) {
|
|
|
- this.orderId = orderId
|
|
|
- // 如果标识存在,证明需要执行轮询判断支付状态,否则直接查询
|
|
|
- if (openFlag && openFlag === 'open') {
|
|
|
- this.openFlag = openFlag
|
|
|
+ this.openFlag = page?.type
|
|
|
+ this.polyOrderId = page?.polyOrderId
|
|
|
+ if (this.orderId) {
|
|
|
+ // 如果type标识和支付订单id同时存在,证明需要执行轮询判断支付状态,否则直接查询
|
|
|
+ if (this.openFlag && this.polyOrderId) {
|
|
|
this.loadingMask = true
|
|
|
- this.handleGetOrderinfo(orderId, openFlag)
|
|
|
+ this.handlePayStatus(this.polyOrderId)
|
|
|
let time = 0
|
|
|
this.timer = setInterval(() => {
|
|
|
time ++
|
|
|
- this.handleGetOrderinfo(orderId, openFlag)
|
|
|
+ this.handlePayStatus(this.polyOrderId, openFlag)
|
|
|
// 超过60s直接清除轮询
|
|
|
if (time === 60) {
|
|
|
clearInterval(this.timer)
|
|
|
}
|
|
|
}, 1000)
|
|
|
} else {
|
|
|
- this.handleGetOrderinfo(orderId)
|
|
|
+ this.handleGetOrderinfo(this.orderId)
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -229,17 +229,11 @@ export default {
|
|
|
/**
|
|
|
* 通过订单id去获取订单信息
|
|
|
* */
|
|
|
- handleGetOrderinfo (orderId, openFlag) {
|
|
|
+ handleGetOrderinfo (orderId) {
|
|
|
this.$u.api.getOrderDetail({ id: orderId })
|
|
|
.then(res => {
|
|
|
if (res.code === 200) {
|
|
|
this.orderInfo = res.data
|
|
|
- if (openFlag === 'open') {
|
|
|
- if (res.data.payStatus === 1 || res.data.payStatus === 3) {
|
|
|
- this.loadingMask = false
|
|
|
- clearInterval(this.timer)
|
|
|
- }
|
|
|
- }
|
|
|
} else {
|
|
|
this.$refs.uToast.show({
|
|
|
title: res.msg,
|
|
@@ -247,13 +241,32 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
- .catch(() => {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '程序错误!',
|
|
|
- type: 'error'
|
|
|
- })
|
|
|
- })
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 查询支付状态
|
|
|
+ * @param { String } orderId
|
|
|
+ */
|
|
|
+ handlePayStatus(orderId) {
|
|
|
+ this.$u.api.getOrderInfo({ orderId }).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ if (res.data.payStatus === 1 || res.data.payStatus === 3) {
|
|
|
+ this.loadingMask = false
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.handleGetOrderinfo(this.orderId)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: res.msg,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ this.loadingMask = false
|
|
|
+ clearInterval(this.timer);
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ this.loadingMask = false
|
|
|
+ clearInterval(this.timer);
|
|
|
+ })
|
|
|
+ },
|
|
|
goPay (orderId) {
|
|
|
this.orderList = []
|
|
|
this.orderList.push(orderId)
|