Merge remote-tracking branch 'origin/master'

master
陈思豪 2024-08-25 11:41:46 +08:00
commit 20a4fdf0fa
1 changed files with 135 additions and 0 deletions

View File

@ -0,0 +1,135 @@
<template>
<el-card class="box-card">
<ul class="msg-box">
<li>
<h4>我要支付</h4>
</li>
<li>
<h4 style="margin-bottom: 15px;">支付金额</h4>
<el-radio-group v-model="amountVal" @change="amountChange">
<el-radio border :label="''+ 100">充值100</el-radio>
<el-radio border :label="''+ 500">充值500</el-radio>
<el-radio border :label="''+ 1000">充值1000</el-radio>
<el-radio border :label="''+ 2000">充值2000</el-radio>
<el-radio border :label="''+ 5000">充值5000</el-radio>
<el-radio border :label="''">自定义</el-radio>
</el-radio-group>
</li>
<li>
<h4 style="margin-bottom: 15px;">支付方式</h4>
<el-radio-group v-model="rechargeParams.paymentType" @change="paymentTypeChange">
<el-radio border :label="''+ 1">支付宝</el-radio>
<el-radio border :label="''+ 0">微信</el-radio>
</el-radio-group>
</li>
<li>
<h4 style="margin-bottom: 15px;">支付金额</h4>
<el-input :disabled="disabled" clearable v-model="rechargeParams.totalAmt" placeholder="请输入金额" style="width: 150px;"></el-input>
</li>
</ul>
<div style="text-align: center; margin-top: 30px;">
<el-button type="primary" @click="surePay"></el-button>
</div>
</el-card>
</template>
<script>
import { userRecharge } from "@/api/system/user";
export default {
data() {
return {
amountVal: '',
disabled: false,
//
returnUrl:'http://localhost:8090/#/entertainment/payment',
//
rechargeParams: {
"totalAmt": '', //
"paymentType": "0", //[0:,1:,2:,3:]
"transType": "0" //[0:,1:]
}
}
},
methods: {
//
amountChange(val) {
this.rechargeParams.totalAmt = val;
if (val === '') {
this.disabled = false
} else {
this.disabled = true
}
},
//
paymentTypeChange(val) {
this.rechargeParams.paymentType = val
},
//
async surePay() {
if (this.rechargeParams.totalAmt === '') {
this.$message.warning('请输入金额');
return;
}
if (this.rechargeParams.paymentType === '0') {
} else if (this.rechargeParams.paymentType === '1') {
let praem = {
// 便
outTradeNo:this.getProjectNum() + Math.floor(Math.random() * 10000),
//
totalAmount:this.rechargeParams.totalAmt,
//
returnUrl:this.returnUrl,
//
subject:'支付金额',
//
productCode:'FAST_INSTANT_TRADE_PAY'
}
userRecharge(praem).then(code => {
if (code.code === 200) {
//
this.$message.success('支付宝支付')
const payDiv = document.getElementById('payDiv');
if (payDiv) {
document.body.removeChild(payDiv);
}
const div = document.createElement('div');
div.id = 'payDiv';
div.innerHTML = code.data;
document.body.appendChild(div);
document.getElementById('payDiv').getElementsByTagName('form')[0].submit();
}
})
}
},
//
getProjectNum () {
const projectTime = new Date() //
const Year = projectTime.getFullYear() // IE.
const Month = projectTime.getMonth() + 1 //
const Day = projectTime.getDate() //
var CurrentDate = Year
if (Month >= 10) { // 1010
CurrentDate += Month
} else {
CurrentDate += '0' + Month
}
if (Day >= 10) {
CurrentDate += Day
} else {
CurrentDate += '0' + Day
}
return CurrentDate
}
}
}
</script>
<style scoped>
/* 信息列表样式 */
.msg-box > li {
list-style: none;
border-bottom: 1px solid #c5c5c5;
padding: 20px 10px;
}
</style>