md
This commit is contained in:
parent
007c61b606
commit
f62caaabe1
@ -1,15 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="wechat-payment-container" style="background: #fff;padding: 1rem;">
|
<div class="wechat-payment-container" style="background: #fff;padding: 1rem;">
|
||||||
<div v-if="!isWx">请在微信浏览器中打开此页面进行支付</div>
|
<div v-if="!isWx">请在微信浏览器中打开此页面进行支付</div>
|
||||||
<div v-if="resultVisible&&isWx" >
|
<div v-if="payStatus!=0&&isWx" >
|
||||||
|
<div v-if="payStatus&&payStatus==1" class="text-center" >
|
||||||
|
<h1 style="font-size: 24px; color: #303133; margin-bottom: 10px;">支付中</h1>
|
||||||
|
<p style="color: #606266; margin-bottom: 30px;">{{ errorMessage }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 失败状态提示 -->
|
<!-- 失败状态提示 -->
|
||||||
<div v-if="resultVisible&&!paymentSuccess" class="text-center" >
|
<div v-if="payStatus&&payStatus==3" class="text-center" >
|
||||||
<i class="el-icon-circle-check"></i>
|
|
||||||
<h1 style="font-size: 24px; color: #303133; margin-bottom: 10px;">支付失败</h1>
|
<h1 style="font-size: 24px; color: #303133; margin-bottom: 10px;">支付失败</h1>
|
||||||
<p style="color: #606266; margin-bottom: 30px;">{{ errorMessage }}</p>
|
<p style="color: #606266; margin-bottom: 30px;">{{ errorMessage }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="paymentSuccess" class="text-center">
|
<div v-if="payStatus&&payStatus==2" class="text-center">
|
||||||
<i class="el-icon-circle-check success-icon"></i>
|
<i class="el-icon-circle-check success-icon"></i>
|
||||||
<h1 style="font-size: 24px; color: #303133; margin-bottom: 10px;">支付成功</h1>
|
<h1 style="font-size: 24px; color: #303133; margin-bottom: 10px;">支付成功</h1>
|
||||||
<p style="color: #606266; margin-bottom: 30px;">感谢您的支持,我们将竭诚为您服务</p>
|
<p style="color: #606266; margin-bottom: 30px;">感谢您的支持,我们将竭诚为您服务</p>
|
||||||
@ -160,7 +164,6 @@ export default {
|
|||||||
payStatus:0,
|
payStatus:0,
|
||||||
|
|
||||||
loadingVisible: false,
|
loadingVisible: false,
|
||||||
resultVisible: false,
|
|
||||||
paymentSuccess: false,
|
paymentSuccess: false,
|
||||||
errorMessage: '',
|
errorMessage: '',
|
||||||
wechatPaymentParams: null,
|
wechatPaymentParams: null,
|
||||||
@ -202,7 +205,7 @@ export default {
|
|||||||
recType: null,
|
recType: null,
|
||||||
payMan: null,
|
payMan: null,
|
||||||
payManCode: null,
|
payManCode: null,
|
||||||
settleBillNo: this.settleBillNo,
|
settleBillNo: null,
|
||||||
blAudit: null,
|
blAudit: null,
|
||||||
auditDate: null,
|
auditDate: null,
|
||||||
auditManCode: null,
|
auditManCode: null,
|
||||||
@ -216,7 +219,7 @@ export default {
|
|||||||
breakReason: null,
|
breakReason: null,
|
||||||
breakEmpCode: null,
|
breakEmpCode: null,
|
||||||
recManCode: null,
|
recManCode: null,
|
||||||
settleType: this.settleType,
|
settleType: null,
|
||||||
refundDate: null,
|
refundDate: null,
|
||||||
refundManCode: null,
|
refundManCode: null,
|
||||||
refundSeq: null,
|
refundSeq: null,
|
||||||
@ -256,6 +259,7 @@ export default {
|
|||||||
this.settleBillItem = response.data.data;
|
this.settleBillItem = response.data.data;
|
||||||
// console.log("===>this.settleBillItem==>",this.settleBillItem);
|
// console.log("===>this.settleBillItem==>",this.settleBillItem);
|
||||||
} else {
|
} else {
|
||||||
|
this.payStatus==3;
|
||||||
this.showPaymentResult(false, response.data.msg || '获取账单失败');
|
this.showPaymentResult(false, response.data.msg || '获取账单失败');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -278,6 +282,7 @@ export default {
|
|||||||
requestPayment(code,state) {
|
requestPayment(code,state) {
|
||||||
this.loadingVisible = true;
|
this.loadingVisible = true;
|
||||||
|
|
||||||
|
this.payStatus==1;
|
||||||
// 调用后端API获取微信支付参数
|
// 调用后端API获取微信支付参数
|
||||||
axios.post(process.env.VUE_APP_BASE_API+'/oms2c/common/sumbitWxPayByCode', {
|
axios.post(process.env.VUE_APP_BASE_API+'/oms2c/common/sumbitWxPayByCode', {
|
||||||
code: code,
|
code: code,
|
||||||
@ -289,6 +294,7 @@ export default {
|
|||||||
this.wechatPaymentParams = response.data.data;
|
this.wechatPaymentParams = response.data.data;
|
||||||
this.invokeWechatPayment();
|
this.invokeWechatPayment();
|
||||||
} else {
|
} else {
|
||||||
|
this.payStatus==3;
|
||||||
this.showPaymentResult(false, response.message || '获取支付参数失败');
|
this.showPaymentResult(false, response.message || '获取支付参数失败');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -341,7 +347,7 @@ export default {
|
|||||||
// 这里使用模拟数据
|
// 这里使用模拟数据
|
||||||
|
|
||||||
// 调用接口查询是否成功
|
// 调用接口查询是否成功
|
||||||
|
this.payStatus==2;
|
||||||
this.loadingVisible = false;
|
this.loadingVisible = false;
|
||||||
this.showPaymentResult(true);
|
this.showPaymentResult(true);
|
||||||
}, 1500);
|
}, 1500);
|
||||||
@ -349,10 +355,8 @@ export default {
|
|||||||
showPaymentResult(success, message = '') {
|
showPaymentResult(success, message = '') {
|
||||||
this.paymentSuccess = success;
|
this.paymentSuccess = success;
|
||||||
this.errorMessage = message;
|
this.errorMessage = message;
|
||||||
this.resultVisible = true;
|
|
||||||
},
|
},
|
||||||
handleResultAction() {
|
handleResultAction() {
|
||||||
this.resultVisible = false;
|
|
||||||
if (this.paymentSuccess) {
|
if (this.paymentSuccess) {
|
||||||
// this.$router.push({ name: 'OrderSuccess', params: { orderId: this.orderInfo.orderId } });
|
// this.$router.push({ name: 'OrderSuccess', params: { orderId: this.orderInfo.orderId } });
|
||||||
}
|
}
|
||||||
@ -368,21 +372,6 @@ export default {
|
|||||||
const encodedRedirectUri = encodeURIComponent(redirectUri);
|
const encodedRedirectUri = encodeURIComponent(redirectUri);
|
||||||
return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${encodedRedirectUri}&response_type=code&scope=${scope}&state=${state}#wechat_redirect`;
|
return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${encodedRedirectUri}&response_type=code&scope=${scope}&state=${state}#wechat_redirect`;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 将code发送到后端换取openid
|
|
||||||
// * @param {string} code - 微信授权码
|
|
||||||
// */
|
|
||||||
// async exchangeCodeForOpenid(code) {
|
|
||||||
// try {
|
|
||||||
// const response = await this.$axios.post('/api/wechat/auth/openid', { code });
|
|
||||||
// return response.data;
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error('换取OpenID失败:', error);
|
|
||||||
// throw error;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user