|
|
@@ -76,7 +76,11 @@
|
|
|
<div class="qrcode">
|
|
|
<vue-qrcode :value="payUrl" :options="{ width: 140, margin: 1 }" class="code"></vue-qrcode>
|
|
|
</div>
|
|
|
- <div class="qrcode-text">二维码有效时常为5分钟,请尽快支付</div>
|
|
|
+ <div class="qrcode-text">
|
|
|
+ 二维码有效时常为5分钟,<span v-if="minters < 10">0</span>{{ minters }}分<span v-if="seconds < 10"
|
|
|
+ >0</span
|
|
|
+ >{{ seconds }} 请尽快支付
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<!-- <div class="tips">
|
|
|
@@ -137,6 +141,10 @@ export default {
|
|
|
],
|
|
|
loading: false,
|
|
|
orderInfo: {},
|
|
|
+ minters: 0,
|
|
|
+ seconds: 0,
|
|
|
+ allTime: 5 * 60 - 1,
|
|
|
+ closeTime: '',
|
|
|
phone: ''
|
|
|
};
|
|
|
},
|
|
|
@@ -162,6 +170,61 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ init() {
|
|
|
+ this.status = 'Unpaid';
|
|
|
+ },
|
|
|
+ initTime(dingdanId, initTime) {
|
|
|
+ let oldTime = new Date(initTime).valueOf();
|
|
|
+ let newTime = new Date().valueOf();
|
|
|
+ let matchedTime = undefined;
|
|
|
+ let matchedTime1 = undefined;
|
|
|
+ if (oldTime) {
|
|
|
+ matchedTime = newTime - oldTime;
|
|
|
+ matchedTime1 = this.allTime - parseInt(matchedTime / 1000);
|
|
|
+ if (matchedTime1 > 0) {
|
|
|
+ this.timeout(matchedTime1);
|
|
|
+ } else {
|
|
|
+ this.show = false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (dingdanId) {
|
|
|
+ this.timeout(this.allTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ timeout(time) {
|
|
|
+ let _this = this;
|
|
|
+ _this.minters = parseInt(time / 60) > 0 ? parseInt(time / 60) : 0;
|
|
|
+ _this.seconds = parseInt(time - _this.minters * 60);
|
|
|
+ try {
|
|
|
+ if (_this.minters > 0) {
|
|
|
+ _this.closeTime = setInterval(() => {
|
|
|
+ _this.seconds--;
|
|
|
+ if (_this.seconds <= 0) {
|
|
|
+ _this.minters--;
|
|
|
+ if (_this.minters == -1) {
|
|
|
+ _this.minters = 0;
|
|
|
+ _this.seconds = 0;
|
|
|
+ clearInterval(_this.closeTime);
|
|
|
+ } else {
|
|
|
+ _this.seconds = 60;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ _this.closeTime = setInterval(() => {
|
|
|
+ _this.seconds--;
|
|
|
+ if (_this.seconds <= 0) {
|
|
|
+ this.show = false;
|
|
|
+ _this.seconds = 0;
|
|
|
+ clearInterval(_this.closeTime);
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+ },
|
|
|
submit() {
|
|
|
// if (this.payMethods === 'DCEP') {
|
|
|
// this.wait();
|
|
|
@@ -177,6 +240,7 @@ export default {
|
|
|
toUserId: this.id
|
|
|
})
|
|
|
.then(res => {
|
|
|
+ this.initTime(res.id, res.createdAt);
|
|
|
this.status = res.status;
|
|
|
this.idOrder = res.id;
|
|
|
// console.log(res);
|