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

267 lines
11 KiB
HTML

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