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

1 year 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="姓名">
1 year ago
<el-input v-model="form.name" :disabled="hasUser"></el-input>
1 year ago
</el-form-item>
<el-form-item label="手机号">
1 year ago
<el-input v-model="form.mobile" :disabled="hasUser"></el-input>
1 year ago
</el-form-item>
<el-form-item label="身份证号">
1 year ago
<el-input v-model="form.cardNo" :disabled="hasUser"></el-input>
1 year ago
</el-form-item>
<el-form-item label="银行卡号">
<el-input v-model="form.bankCardNo"></el-input>
</el-form-item>
<el-form-item label="充值金额">
1 year ago
<el-input-number v-model="form.amount" :min="1" :max="3000" label="充值金额" :disabled="amountDisabled"></el-input-number>
1 year 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>
1 year 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>
1 year ago
</el-main>
</el-container>
1 year ago
<el-dialog title="绑卡支付验证码" :visible.sync="bindConfirmVisible" width="30%">
1 year 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>
1 year ago
<el-button type="primary" @click="bindConfirmAndPay">确 定</el-button>
1 year 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 {
1 year ago
stoken: undefined,
1 year ago
bindConfirmVisible: false,
bindConfirmForm: {
1 year ago
stoken: '',
1 year ago
smsCode: '',
smsNo: '',
1 year ago
outMemberId: '',
amount: 1,
1 year ago
},
payConfirmVisible: false,
1 year ago
hasUser: false,
1 year ago
payConfirmForm: {
1 year ago
stoken: '',
1 year ago
smsCode: '',
1 year ago
outMemberId: '',
1 year ago
token: '',
protocol: ''
},
form: {
1 year ago
stoken: '',
1 year ago
name: '',
mobile: '',
cardNo: '',
bankCardNo: '',
amount: 1,
remark: ''
1 year ago
},
1 year ago
banks: [
{
bank1: '中国工商银行',
bank2: '中国邮政银行',
bank3: '浦发银行',
},
{
bank1: '广发银行',
bank2: '民生银行',
bank3: '光大银行',
},
{
bank1: '中信银行',
bank2: '华夏银行',
bank3: '平安银行',
},
{
bank1: '上海银行',
bank2: '区域性银行',
bank3: '',
}
],
1 year ago
amountDisabled: false
1 year ago
}
},
created() {
1 year ago
this.stoken = this.getQueryParam('token');
if (!this.stoken) {
1 year ago
return this.$message.error('参数异常');
}
1 year ago
this.form.stoken = this.stoken;
this.bindConfirmForm.stoken = this.stoken;
this.payConfirmForm.stoken = this.stoken;
this.getMemberInfo()
1 year 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;
1 year ago
this.bindConfirmForm.outMemberId = result.data.outMemberId;
1 year ago
this.bindConfirmForm.smsNo = result.data.bizData.smsNo;
console.log(this.bindConfirmForm)
} else if (result.data.nextStep == 'confirm-pay') {
this.payConfirmVisible = true;
1 year ago
this.payConfirmForm.outMemberId = result.data.outMemberId;
1 year 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!');
},
1 year 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!');
},
1 year 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('支付成功');
1 year ago
this.$alert('请记住您的订单号:' + result.data.bizData.outOrderNo , '支付成功', {
1 year ago
confirmButtonText: '确定',
callback: action => {
}
});
})
.catch((error) => {
this.$message.error('请求错误');
console.log(error);
});
console.log('submit!');
},
1 year ago
getQueryParam(name) {
1 year ago
var query = window.location.search.substring(1);
1 year ago
console.log(query)
1 year ago
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
1 year ago
console.log(pair[0], name)
1 year ago
if(pair[0] == name) {
return pair[1];
}
}
return undefined;
1 year 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);
}
1 year 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;
1 year ago
this.hasUser = true;
1 year ago
}
console.log(data)
if (data.amount > 0) {
this.form.amount = data.amount;
this.amountDisabled = true;
1 year ago
}
})
.catch((error) => {
this.$message.error('请求错误');
console.log(error);
});
console.log('submit!');
1 year ago
}
}
})
</script>
</html>