初始化
parent
00fd0d3379
commit
e4e4048392
|
@ -59,7 +59,7 @@
|
||||||
<el-col :span="8" v-for="customer in apitypeList" v-if="apitypeList.length != 0&&activeNameL=='全部类型'||customer.sysLeixingpick==activeNameL">
|
<el-col :span="8" v-for="customer in apitypeList" v-if="apitypeList.length != 0&&activeNameL=='全部类型'||customer.sysLeixingpick==activeNameL">
|
||||||
<el-card class="box-card">
|
<el-card class="box-card">
|
||||||
<div slot="header" class="clearfix">
|
<div slot="header" class="clearfix">
|
||||||
<el-image :src="customer.sysTypes" @click="initiatePayment(customer)">
|
<el-image :src="customer.sysTypes" @click="goToPaySuccess(customer)">
|
||||||
<div slot="placeholder" class="image-slot">
|
<div slot="placeholder" class="image-slot">
|
||||||
加载中<span class="dot">...</span>
|
加载中<span class="dot">...</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -145,34 +145,16 @@ export default {
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
},
|
},
|
||||||
paymentStatus: null, // 初始支付状态
|
|
||||||
alipayUrl: null, // 支付宝支付页面的URL
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async initiatePayment(customer){
|
|
||||||
try {
|
|
||||||
this.paymentStatus = 'loading';
|
|
||||||
const response = await axios.get('/alipay/pay', {
|
|
||||||
params: {
|
|
||||||
subject: customer.sysIntro,
|
|
||||||
traceNo: Math.floor(Math.random() * 900000) + 100000, // 商户订单号
|
|
||||||
totalAmount: customer.sysNumber, // 金额,单位为元
|
|
||||||
},
|
|
||||||
});
|
|
||||||
this.alipayUrl = URL.createObjectURL(new Blob([response.data], { type: 'text/html' }));
|
|
||||||
|
|
||||||
window.location.href = this.alipayUrl; // 或者使用iframe显示
|
async goToPaySuccess(customer){
|
||||||
|
//在这里我选择了window.open(url,'_self')形式,也就是不跳转新的页面,在本页面直接跳转
|
||||||
this.paymentStatus = 'success';
|
window.open("http://127.0.0.1:8080/alipay/pay?subject="+customer.sysIntro+"&traceNo="+Math.floor(Math.random() * 900000) + 100000+"&totalAmount="+customer.sysNumber,'_self')
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error('支付请求失败:', error);
|
|
||||||
this.paymentStatus = 'error';
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getType(activeNameL){
|
getType(activeNameL){
|
||||||
|
|
Loading…
Reference in New Issue