|
|
@@ -6,12 +6,15 @@
|
|
|
<span>{{ orderInfo.totalPrice }}</span>
|
|
|
</div>
|
|
|
|
|
|
- <van-cell title="支付银行卡" isLink>
|
|
|
- <div class="code not">请选择</div>
|
|
|
+ <van-cell title="支付银行卡" isLink @click="chooseBanK">
|
|
|
+ <div class="code" v-if="bankInfo.bindCardId">{{ bankName }}</div>
|
|
|
+ <div class="code not" v-else>请选择</div>
|
|
|
</van-cell>
|
|
|
|
|
|
<div class="btn">
|
|
|
- <van-button type="primary" block round @click="onSubmit">确认支付</van-button>
|
|
|
+ <van-button type="primary" block round :disabled="!this.bankInfo.bindCardId" @click="submit"
|
|
|
+ >确认支付</van-button
|
|
|
+ >
|
|
|
</div>
|
|
|
|
|
|
<phone-code ref="code" @onSubmit="onSubmit" @bind="bind"></phone-code>
|
|
|
@@ -25,23 +28,63 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
orderId: 0,
|
|
|
- orderInfo: {}
|
|
|
+ orderInfo: {},
|
|
|
+ bankInfo: {},
|
|
|
+ payOrder: {}
|
|
|
};
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ bankName() {
|
|
|
+ if (this.bankInfo.bindCardId) {
|
|
|
+ return this.bankInfo.bankName + '(' + this.bankInfo.bankNo.slice(-4) + ')';
|
|
|
+ }
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ },
|
|
|
mounted() {
|
|
|
if (this.$route.query.id) {
|
|
|
this.orderId = this.$route.query.id;
|
|
|
this.$http.get('/order/get/' + this.orderId).then(res => {
|
|
|
this.orderInfo = res;
|
|
|
});
|
|
|
+
|
|
|
+ this.$http.get('/user/myBankCard').then(res => {
|
|
|
+ if (res.length !== 0) {
|
|
|
+ this.bankInfo = res[0];
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ submit(e) {
|
|
|
+ if (!this.checkWebDriver(e)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.bankInfo.bindCardId) {
|
|
|
+ this.$toast('请选择银行卡');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$toast.loading({
|
|
|
+ message: '加载中...',
|
|
|
+ forbidClick: true
|
|
|
+ });
|
|
|
+ this.$http
|
|
|
+ .post('/payOrder/v2/agreement?id=' + this.orderId, {
|
|
|
+ bindCardId: this.bankInfo.bindCardId
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ this.payOrder = res;
|
|
|
+ if (res.needCaptcha) {
|
|
|
+ this.onSubmit(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
onSubmit(e) {
|
|
|
if (!this.checkWebDriver(e)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ this.$toast.success('发送成功');
|
|
|
this.$refs.code.init();
|
|
|
},
|
|
|
bind(code) {
|
|
|
@@ -49,7 +92,27 @@ export default {
|
|
|
message: '加载中...',
|
|
|
forbidClick: true
|
|
|
});
|
|
|
- console.log(code);
|
|
|
+ this.$http
|
|
|
+ .post(
|
|
|
+ `/payOrder/v2/confirmAgreement?requestId=${this.payOrder.requestId}&paymentOrderId=${this.payOrder.paymentOrderId}&code=${code}`
|
|
|
+ )
|
|
|
+ .then(() => {
|
|
|
+ this.$toast.success('支付成功');
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$router.replace('/orderDetail?id=' + this.orderId);
|
|
|
+ }, 1000);
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ this.$toast(e.error);
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$router.go(-1);
|
|
|
+ }, 1000);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ chooseBanK() {
|
|
|
+ if (!this.bankInfo.bindCardId) {
|
|
|
+ this.$router.push('/mineBanksAdd');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -96,7 +159,11 @@ export default {
|
|
|
|
|
|
.code {
|
|
|
font-size: 14px;
|
|
|
- color: #c8c9cc;
|
|
|
+ color: #000;
|
|
|
line-height: 24px;
|
|
|
+
|
|
|
+ &.not {
|
|
|
+ color: #c8c9cc;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|