You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
payment/public/payment.html

291 lines
12 KiB
HTML

2 years ago
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- import CSS -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<title>充值</title>
</head>
<body>
<div id="app">
<el-container>
<el-header style="text-align: center;">充值</el-header>
<el-main>
<el-row>
<el-col :span="24">
<el-form ref="form" :model="form" label-width="80px">
<el-form-item label="姓名">
2 years ago
<el-input v-model="form.name" :disabled="hasUser"></el-input>
2 years ago
</el-form-item>
<el-form-item label="手机号">
2 years ago
<el-input v-model="form.mobile" :disabled="hasUser"></el-input>
2 years ago
</el-form-item>
<el-form-item label="身份证号">
2 years ago
<el-input v-model="form.cardNo" :disabled="hasUser"></el-input>
2 years ago
</el-form-item>
<el-form-item label="银行卡号">
<el-input v-model="form.bankCardNo"></el-input>
</el-form-item>
<el-form-item label="充值金额">
2 years ago
<el-input-number v-model="form.amount" :min="1" :max="3000" label="充值金额" :disabled="amountDisabled"></el-input-number>
2 years ago
</el-form-item>
<el-form-item label="备注">
<el-input type="textarea" v-model="form.remark"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="recharge">立即充值</el-button>
</el-form-item>
</el-form>
</el-col>
</el-row>
2 years ago
<el-row>
<el-col :span="24">
<h3>支持的银行</h3>
<el-table
:show-header="false"
:data="banks"
style="width: 100%">
<el-table-column prop="bank1">
</el-table-column>
<el-table-column prop="bank2">
</el-table-column>
<el-table-column prop="bank3">
</el-table-column>
</el-table>
</el-col>
</el-row>
2 years ago
</el-main>
</el-container>
2 years ago
<el-dialog title="绑卡支付验证码" :visible.sync="bindConfirmVisible" width="30%">
2 years ago
<el-form :model="bindConfirmForm" label-width="80px">
<el-form-item label="验证码">
<el-input v-model="bindConfirmForm.smsCode" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="bindConfirmVisible = false">取 消</el-button>
2 years ago
<el-button type="primary" @click="bindConfirmAndPay">确 定</el-button>
2 years ago
</div>
</el-dialog>
<el-dialog title="支付验证码" :visible.sync="payConfirmVisible" width="30%">
<el-form :model="payConfirmForm" label-width="80px">
<el-form-item label="验证码">
<el-input v-model="payConfirmForm.smsCode" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="payConfirmVisible = false">取 消</el-button>
<el-button type="primary" @click="payConfirm">确 定</el-button>
</div>
</el-dialog>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/axios@1.1.2/dist/axios.min.js"></script>
<script>
new Vue({
el: '#app',
data() {
return {
2 years ago
stoken: undefined,
2 years ago
bindConfirmVisible: false,
bindConfirmForm: {
2 years ago
stoken: '',
2 years ago
smsCode: '',
smsNo: '',
2 years ago
outMemberId: '',
amount: 1,
2 years ago
},
payConfirmVisible: false,
2 years ago
hasUser: false,
2 years ago
payConfirmForm: {
2 years ago
stoken: '',
2 years ago
smsCode: '',
2 years ago
outMemberId: '',
2 years ago
token: '',
protocol: ''
},
form: {
2 years ago
stoken: '',
2 years ago
name: '',
mobile: '',
cardNo: '',
bankCardNo: '',
amount: 1,
remark: ''
2 years ago
},
2 years ago
banks: [
{
bank1: '中国工商银行',
bank2: '中国邮政银行',
bank3: '浦发银行',
},
{
bank1: '广发银行',
bank2: '民生银行',
bank3: '光大银行',
},
{
bank1: '中信银行',
bank2: '华夏银行',
bank3: '平安银行',
},
{
bank1: '上海银行',
bank2: '区域性银行',
bank3: '',
}
],
2 years ago
amountDisabled: false
2 years ago
}
},
created() {
2 years ago
this.stoken = this.getQueryParam('token');
if (!this.stoken) {
2 years ago
return this.$message.error('参数异常');
}
2 years ago
this.form.stoken = this.stoken;
this.bindConfirmForm.stoken = this.stoken;
this.payConfirmForm.stoken = this.stoken;
this.getMemberInfo()
2 years ago
},
methods: {
recharge() {
axios.post('/recharge/recharge', this.form)
.then( (response) => {
console.log(response);
let result = response.data
if (result.code != 1000) {
return this.$message.error(response.data.message);
}
if (result.data.nextStep == 'confirm-bind') {
this.bindConfirmVisible = true;
2 years ago
this.bindConfirmForm.outMemberId = result.data.outMemberId;
2 years ago
this.bindConfirmForm.smsNo = result.data.bizData.smsNo;
console.log(this.bindConfirmForm)
} else if (result.data.nextStep == 'confirm-pay') {
this.payConfirmVisible = true;
2 years ago
this.payConfirmForm.outMemberId = result.data.outMemberId;
2 years ago
this.payConfirmForm.protocol = result.data.bizData.protocol;
this.payConfirmForm.token = result.data.bizData.token;
console.log(this.payConfirmForm)
}
})
.catch((error) => {
this.$message.error('请求错误');
console.log(error);
});
console.log('submit!');
},
bindConfirm() {
axios.post('/recharge/confirm-bind-card', this.bindConfirmForm)
.then( (response) => {
console.log(response);
let result = response.data
if (result.code != 1000) {
return this.$message.error(response.data.message);
}
this.bindConfirmVisible = false;
this.recharge();
})
.catch((error) => {
this.$message.error('请求错误');
console.log(error);
});
console.log('submit!');
},
2 years ago
bindConfirmAndPay() {
this.bindConfirmForm.amount = this.form.amount;
axios.post('/recharge/confirm-bind-card-and-pay', this.bindConfirmForm)
.then( (response) => {
console.log(response);
let result = response.data
if (result.code != 1000) {
return this.$message.error(response.data.message);
}
this.bindConfirmVisible = false;
this.$message.success('支付成功');
this.$alert('请记住您的订单号:' + result.data.bizData.outOrderNo , '支付成功', {
confirmButtonText: '确定',
callback: action => {
}
});
})
.catch((error) => {
this.$message.error('请求错误');
console.log(error);
});
console.log('submit!');
},
2 years ago
payConfirm() {
axios.post('/recharge/confirm-pay', this.payConfirmForm)
.then( (response) => {
console.log(response);
let result = response.data
if (result.code != 1000) {
return this.$message.error(response.data.message);
}
this.payConfirmVisible = false;
this.$message.success('支付成功');
2 years ago
this.$alert('请记住您的订单号:' + result.data.bizData.outOrderNo , '支付成功', {
2 years ago
confirmButtonText: '确定',
callback: action => {
}
});
})
.catch((error) => {
this.$message.error('请求错误');
console.log(error);
});
console.log('submit!');
},
2 years ago
getQueryParam(name) {
2 years ago
var query = window.location.search.substring(1);
2 years ago
console.log(query)
2 years ago
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
2 years ago
console.log(pair[0], name)
2 years ago
if(pair[0] == name) {
return pair[1];
}
}
return undefined;
2 years ago
},
getMemberInfo() {
axios.post('/recharge/get-member-info', {stoken: this.stoken})
.then( (response) => {
console.log(response);
let result = response.data
if (result.code != 1000) {
return this.$message.error(response.data.message);
}
2 years ago
let data = result.data;
if (data.user != null) {
this.form.name = data.user.name;
this.form.cardNo = data.user.cardNo;
this.form.mobile = data.user.mobile;
this.form.bankCardNo = data.user.bankCardNo;
2 years ago
this.hasUser = true;
2 years ago
}
console.log(data)
if (data.amount > 0) {
this.form.amount = data.amount;
this.amountDisabled = true;
2 years ago
}
})
.catch((error) => {
this.$message.error('请求错误');
console.log(error);
});
console.log('submit!');
2 years ago
}
}
})
</script>
</html>