|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
* @Author: ch
|
|
|
|
|
* @Date: 2022-07-08 11:46:30
|
|
|
|
|
* @LastEditors: ch
|
|
|
|
|
* @LastEditTime: 2022-07-09 18:34:53
|
|
|
|
|
* @LastEditTime: 2022-07-12 11:37:13
|
|
|
|
|
* @Description: file content
|
|
|
|
|
-->
|
|
|
|
|
<template>
|
|
|
|
@ -66,35 +66,70 @@ const ENV = process.env;
|
|
|
|
|
},
|
|
|
|
|
pay(){
|
|
|
|
|
if(this.payType === 'wxpay'){
|
|
|
|
|
this.wxPay();
|
|
|
|
|
if(localStorage.getItem('payOpenId') && WeixinJSBridge){
|
|
|
|
|
this.wxJsapiPay()
|
|
|
|
|
}else{
|
|
|
|
|
this.wxH5Pay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
this.aliPay();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
async wxPay(){
|
|
|
|
|
// h5支付
|
|
|
|
|
const {error, result} = await ApiPostH5Pay({
|
|
|
|
|
payOrderNo : this.orderInfo.payOrderNo,
|
|
|
|
|
payCode : 'WX_H5',
|
|
|
|
|
appCode : this.orderInfo.prepayWxApp.prepayAppCode
|
|
|
|
|
});
|
|
|
|
|
if(error){
|
|
|
|
|
uni._$toast(error.message);
|
|
|
|
|
return false;
|
|
|
|
|
/**
|
|
|
|
|
* 微信APP内部点击支付
|
|
|
|
|
*/
|
|
|
|
|
async wxJsapiPay(){
|
|
|
|
|
const {result} = await this.getOrderInfo('WX_JSAPI');
|
|
|
|
|
if(result){
|
|
|
|
|
const par = result.payDataInfo;
|
|
|
|
|
WeixinJSBridge.invoke('getBrandWCPayRequest', {
|
|
|
|
|
appId : par.appId,
|
|
|
|
|
timeStamp : par.timeStamp,
|
|
|
|
|
nonceStr : par.nonceStr,
|
|
|
|
|
package: par.packageValue,
|
|
|
|
|
signType : par.signType,
|
|
|
|
|
paySign : par.paySign
|
|
|
|
|
}, res => {
|
|
|
|
|
if(res.err_msg !== 'get_brand_wcpay_request:cancel'){
|
|
|
|
|
if(this.orderInfo.returnUrl){
|
|
|
|
|
window.location.replace(this.orderInfo.returnUrl);
|
|
|
|
|
}else{
|
|
|
|
|
uni.redirectTo({
|
|
|
|
|
url : `/pages/wapResult?payOrderNo=${this.payOrderNo}`
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* h5唤起微信支付
|
|
|
|
|
*/
|
|
|
|
|
async wxH5Pay(){
|
|
|
|
|
const {error, result} = await this.getOrderInfo('WX_H5');
|
|
|
|
|
if(result){
|
|
|
|
|
// 到这必然是h5页面所以可以用window这个API
|
|
|
|
|
window.location.replace(data.payDataInfo.h5Url);
|
|
|
|
|
}
|
|
|
|
|
window.location.replace(data.payDataInfo.h5Url);
|
|
|
|
|
},
|
|
|
|
|
async aliPay(){
|
|
|
|
|
const {error, result} = await this.getOrderInfo('ALI_WAP');
|
|
|
|
|
if(result){
|
|
|
|
|
// 到这必然是h5页面所以可以用window这个API
|
|
|
|
|
window.location.replace(data.payDataInfo.payUrl);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
async getPayData(payCode){
|
|
|
|
|
const {error, result} = await ApiPostH5Pay({
|
|
|
|
|
payOrderNo : this.orderInfo.payOrderNo,
|
|
|
|
|
payCode : 'ALI_WAP',
|
|
|
|
|
payCode,
|
|
|
|
|
appCode : this.orderInfo.prepayAliApp.prepayAppCode
|
|
|
|
|
});
|
|
|
|
|
if(error){
|
|
|
|
|
uni._$toast(error.message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
window.location.replace(data.payDataInfo.payUrl);
|
|
|
|
|
return {error, result};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|