|
|
@ -51,7 +51,7 @@ |
|
|
|
computed: { |
|
|
|
payTotal() {//子组件中支付金额 |
|
|
|
let _payTotal = this.dataQuery.amount||0 |
|
|
|
return _payTotal.toFixed(2)||"0.00" |
|
|
|
return _payTotal||"0.00" |
|
|
|
} |
|
|
|
}, |
|
|
|
watch:{ |
|
|
@ -66,7 +66,9 @@ |
|
|
|
paySuccessStatus:0, |
|
|
|
decryptList: [], |
|
|
|
strResult: "", |
|
|
|
dataQuery:"" |
|
|
|
dataQuery:"", |
|
|
|
reCheckOrderCount:0,//重新查询支付结果次数 |
|
|
|
reCheckOrderCountMax:30,//重新查询支付结果最大次数 |
|
|
|
} |
|
|
|
}, |
|
|
|
async onLoad(res) { |
|
|
@ -78,8 +80,24 @@ |
|
|
|
}, |
|
|
|
async onReady() { |
|
|
|
await this.setPageHeight() |
|
|
|
// this.testAcceptScanCode() |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
//测试扫码,弹窗提醒,点确定时执行acceptScanCode |
|
|
|
testAcceptScanCode(){ |
|
|
|
uni.showModal({ |
|
|
|
title: '模拟扫码', |
|
|
|
content: '模拟扫码,点确定时执行acceptScanCode', |
|
|
|
showCancel: true, |
|
|
|
confirmText: '确定', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
console.log('用户点击确定'); |
|
|
|
this.acceptScanCode("282659672061313993") |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
setPayData(res){ |
|
|
|
console.log("setPayData:",res) |
|
|
|
res = JSON.parse(res.query) |
|
|
@ -128,7 +146,7 @@ |
|
|
|
}).then((payInfo)=>{ |
|
|
|
console.log("payInfo-result:",payInfo) |
|
|
|
return this.checkOrder(payInfo) |
|
|
|
}).then((checkInfo)=>{ |
|
|
|
}).then(async (checkInfo)=>{ |
|
|
|
console.log("最终checkInfo:",checkInfo) |
|
|
|
let {payRes,checkRes} = checkInfo |
|
|
|
// util.showNone(payRes.res.respMsg+"-"+payRes.res.respCode) |
|
|
@ -138,21 +156,192 @@ |
|
|
|
this.printOrder(checkInfo) |
|
|
|
}else{ |
|
|
|
// util.showNone(checkRes.res.respMsg+"-"+checkRes.res.respCode) |
|
|
|
let msg = checkRes.res.respMsg||"未知原因"+"-"+checkRes.res.respCode+'\n'; |
|
|
|
|
|
|
|
let {orderStatus,requestDate,respCode,respMsg,tradeNo,transNo} = checkRes.res |
|
|
|
|
|
|
|
if(orderStatus=="PROCESSING"){ |
|
|
|
//支付失败 |
|
|
|
console.log("等待支付中,需要继续查询支付结果") |
|
|
|
uni.showModal({ |
|
|
|
title: '等待支付中...', |
|
|
|
content: "如您已确认付款成功,请点击确认,继续查询支付结果!", |
|
|
|
showCancel: false, |
|
|
|
confirmText: '确认已支付成功', |
|
|
|
success: async (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
console.log('用户点击确定'); |
|
|
|
if(util.getPageRoute()=='pages/pay/index'){ |
|
|
|
this.doLoopCheck(checkInfo) |
|
|
|
}else{ |
|
|
|
util.showNone('请重新扫码使用') |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}else{ |
|
|
|
await this.checkInfoReactive(checkInfo) |
|
|
|
} |
|
|
|
} |
|
|
|
}).finally(()=>{ |
|
|
|
util.hideLoad() |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
async doLoopCheck(checkInfo){ |
|
|
|
let max = this.reCheckOrderCountMax |
|
|
|
|
|
|
|
for(let i=0;i<=max;i++){ |
|
|
|
// let res = null |
|
|
|
uni.showLoading({ |
|
|
|
title: '支付结果查询中...'+i+"/"+this.reCheckOrderCountMax, |
|
|
|
mask: true |
|
|
|
}); |
|
|
|
let recheckInfo = await this.checkOrder(checkInfo.payRes).then((_recheckInfo)=>{ |
|
|
|
return _recheckInfo |
|
|
|
}).catch(err=>{ |
|
|
|
console.warn("reCheckOrder err:",err) |
|
|
|
rj(false) |
|
|
|
}) |
|
|
|
console.log("recheckInfo--1:",recheckInfo) |
|
|
|
|
|
|
|
let {orderStatus,requestDate,respCode,respMsg,tradeNo,transNo} = recheckInfo.checkRes.res |
|
|
|
console.log("doLoopCheck recheckInfo:",recheckInfo) |
|
|
|
|
|
|
|
if(orderStatus=="SUCCESS"){ |
|
|
|
let {payRes,checkRes} = recheckInfo |
|
|
|
// util.showNone(payRes.res.respMsg+"-"+payRes.res.respCode) |
|
|
|
if(checkRes.pay_order.status == "1"){ |
|
|
|
util.showNone(checkRes.res.respMsg) |
|
|
|
this.paySuccessStatus = 1 |
|
|
|
this.printOrder(checkInfo) |
|
|
|
} |
|
|
|
break |
|
|
|
}else{ |
|
|
|
await util.asyncSetTimeOut(2000) |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
uni.hideLoading() |
|
|
|
}, |
|
|
|
async checkInfoReactive(checkInfo){ //废弃 |
|
|
|
return new Promise((rs,rj)=>{ |
|
|
|
console.log("checkInfoReactive",checkInfo) |
|
|
|
let {payRes,checkRes} = checkInfo |
|
|
|
let {orderStatus,requestDate,respCode,respMsg,tradeNo,transNo} = checkRes.res |
|
|
|
// 200021,200008,,200004 需要重新下单 |
|
|
|
let msg = checkRes.res.respMsg||"未知原因"+"-"+checkRes.res.respCode+'\n'; |
|
|
|
|
|
|
|
if(checkRes.pay_order.status == "1"){ |
|
|
|
util.showNone(checkRes.res.respMsg) |
|
|
|
this.paySuccessStatus = 1 |
|
|
|
this.printOrder(checkInfo) |
|
|
|
rs(true) |
|
|
|
} |
|
|
|
else if(respCode=="200021"||respCode=="200008"||respCode=="200004"){ |
|
|
|
//重新下单 |
|
|
|
console.warn("需要重新下单") |
|
|
|
|
|
|
|
uni.showModal({ |
|
|
|
title: '支付失败', |
|
|
|
content: msg, |
|
|
|
showCancel: false, |
|
|
|
confirmText: '确定', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
console.log('用户点击确定'); |
|
|
|
util.routeTo(`/pages/index/standby`, 'rL'); |
|
|
|
rs(true) |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
}else if(respCode=="200103"||orderStatus=="FAIL"){ |
|
|
|
//支付成功 |
|
|
|
msg = "支付失败code:"+checkRes.res.respCode+".请联系管理员!" |
|
|
|
uni.showModal({ |
|
|
|
title: '支付失败', |
|
|
|
content: checkRes.res.respMsg+"-"+checkRes.res.respCode, |
|
|
|
content: msg, |
|
|
|
showCancel: false, |
|
|
|
confirmText: '确定', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
console.log('用户点击确定'); |
|
|
|
util.routeTo(`/pages/index/standby`, 'rL'); |
|
|
|
rs(true) |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}else if(orderStatus=="PROCESSING"&&this.reCheckOrderCount==0){ |
|
|
|
//支付失败 |
|
|
|
console.log("等待支付中,需要继续查询支付结果") |
|
|
|
uni.showModal({ |
|
|
|
title: '等待支付中...', |
|
|
|
content: "如您已确认付款成功,请点击确认,继续查询支付结果!", |
|
|
|
showCancel: false, |
|
|
|
confirmText: '确认已支付成功', |
|
|
|
success: async (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
console.log('用户点击确定'); |
|
|
|
rs(true) |
|
|
|
// await this.reCheckOrder(checkInfo).then((recheckInfo)=>{ |
|
|
|
// console.warn("finally checkInfo:",recheckInfo) |
|
|
|
// }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}else if(orderStatus=="PROCESSING"&&this.reCheckOrderCount>0){ |
|
|
|
rj(checkInfo) |
|
|
|
} |
|
|
|
}).finally(()=>{ |
|
|
|
util.hideLoad() |
|
|
|
|
|
|
|
}) |
|
|
|
}, |
|
|
|
loopReCheckOrder(_checkInfo){ //废弃 |
|
|
|
reCheckOrder(_checkInfo).then((checkInfo)=>{ |
|
|
|
loopReCheckOrder(checkInfo) |
|
|
|
}).catch(err=>{ |
|
|
|
console.warn("loopReCheckOrder err:",err) |
|
|
|
util.showNone("支付结果查询超时,请联系管理员!"+err) |
|
|
|
}) |
|
|
|
}, |
|
|
|
async reCheckOrder(_checkInfo){ //废弃 |
|
|
|
let payRes = _checkInfo.payRes |
|
|
|
return new Promise(async (rs,rj)=>{ |
|
|
|
this.reCheckOrderCount++ |
|
|
|
// uni.showLoading({ |
|
|
|
// title: '支付结果查询中...'+this.reCheckOrderCount+"/"+this.reCheckOrderCountMax, |
|
|
|
// mask: true |
|
|
|
// }); |
|
|
|
if(this.reCheckOrderCount>=this.reCheckOrderCountMax){ |
|
|
|
uni.hideLoading() |
|
|
|
util.showNone("支付结果查询超时,请联系管理员!") |
|
|
|
rj(false) |
|
|
|
}else{ |
|
|
|
console.log("reCheckOrder:",payRes) |
|
|
|
await this.checkOrder(payRes).then((recheckInfo)=>{ |
|
|
|
console.log("checkInfo:",recheckInfo) |
|
|
|
return recheckInfo |
|
|
|
}).then((_recheckInfo)=>{ |
|
|
|
|
|
|
|
}).catch(err=>{ |
|
|
|
console.warn("reCheckOrder err:",err) |
|
|
|
rj(false) |
|
|
|
}) |
|
|
|
|
|
|
|
let _recheckInfo = await this.checkOrder(payRes) |
|
|
|
await this.checkInfoReactive(_recheckInfo).then((res)=>{ |
|
|
|
rs(res) |
|
|
|
}).catch(err=>{ |
|
|
|
console.warn("reCheckOrder err:",err) |
|
|
|
rj(false) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
printOrder(checkInfo){ |
|
|
|
|
|
|
@ -290,8 +479,11 @@ |
|
|
|
}) |
|
|
|
}, |
|
|
|
async makeOrder(){ |
|
|
|
let {store_id,brand_id,token} = getApp().globalData.accountInfo |
|
|
|
let {brand_id,token} = getApp().globalData.accountInfo |
|
|
|
let store_id = uni.getStorageSync("stadiumInfo").id||"" |
|
|
|
let {goods_data,amount} = this.dataQuery |
|
|
|
brand_id = parseInt(brand_id) |
|
|
|
amount = parseFloat(amount) |
|
|
|
let urlParams = { |
|
|
|
store_id,brand_id,token,amount, |
|
|
|
"goods_data": goods_data, |
|
|
@ -300,7 +492,7 @@ |
|
|
|
"card_no": "", |
|
|
|
"mark": "" |
|
|
|
} |
|
|
|
console.log("需要适配makeOrder urlParams:", urlParams) |
|
|
|
console.log("makeOrder urlParams:", urlParams) |
|
|
|
|
|
|
|
return ox.post({ |
|
|
|
url: API.makeOrder, |
|
|
@ -329,7 +521,7 @@ |
|
|
|
"goods_info": order_no, |
|
|
|
} |
|
|
|
|
|
|
|
console.log("需要适配payOrder urlParams:", urlParams) |
|
|
|
console.log("payOrder urlParams:", urlParams) |
|
|
|
|
|
|
|
return ox.post({ |
|
|
|
url: API.payOrder, |
|
|
@ -358,9 +550,9 @@ |
|
|
|
transNo,payCode,brand_id,token,orderAmt, |
|
|
|
"manual": "yes",//是否手动 |
|
|
|
} |
|
|
|
console.log("需要适配checkOrder urlParams:", urlParams) |
|
|
|
console.log("checkOrder urlParams:", urlParams) |
|
|
|
|
|
|
|
return ox.get({ |
|
|
|
return ox.post({ |
|
|
|
url: API.checkOrder, |
|
|
|
data: urlParams, |
|
|
|
isDefaultGet: true, |
|
|
|