|
|
@@ -55,7 +55,13 @@
|
|
|
<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分钟,请尽快支付</div> -->
|
|
|
+ <h3 class="qrcode-text">
|
|
|
+ 二维码有效时常为5分钟,<span v-if="minters < 10">0</span>{{ minters }}分<span
|
|
|
+ v-if="seconds < 10"
|
|
|
+ >0</span
|
|
|
+ >{{ seconds }} 请尽快支付
|
|
|
+ </h3>
|
|
|
<!-- <div class="qrcode-text">手机微信扫描二维码下单</div> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -108,6 +114,11 @@ import resolveUrl from 'resolve-url';
|
|
|
import { mapState } from 'vuex';
|
|
|
import { add } from 'mathjs';
|
|
|
export default {
|
|
|
+ props: {
|
|
|
+ statusAll: {
|
|
|
+ type: Object
|
|
|
+ }
|
|
|
+ },
|
|
|
// mixins: [pageableTable],
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -115,8 +126,13 @@ export default {
|
|
|
show2: false,
|
|
|
// url: '/userCoupon/all',
|
|
|
chooseId: '',
|
|
|
+ org: '',
|
|
|
empty: false,
|
|
|
payMethods: 'WEIXIN',
|
|
|
+ minters: 0,
|
|
|
+ seconds: 0,
|
|
|
+ allTime: 5 * 60 - 1,
|
|
|
+ closeTime: '',
|
|
|
list2: [],
|
|
|
list3: [],
|
|
|
payList: [
|
|
|
@@ -169,8 +185,63 @@ export default {
|
|
|
if (this.isLogin) {
|
|
|
this.add();
|
|
|
}
|
|
|
+ if (this.matchedTime1 == 0) {
|
|
|
+ this.show = false;
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ },
|
|
|
add() {
|
|
|
this.$http
|
|
|
.post(
|
|
|
@@ -197,7 +268,7 @@ export default {
|
|
|
this.show2 = true;
|
|
|
},
|
|
|
choose(info) {
|
|
|
- console.log(info);
|
|
|
+ // console.log(info);
|
|
|
this.chooseId = info.id;
|
|
|
this.$store.commit('setCouponInfo', info);
|
|
|
},
|
|
|
@@ -213,10 +284,11 @@ export default {
|
|
|
this.$http
|
|
|
.post(url)
|
|
|
.then(res => {
|
|
|
+ // console.log(res);
|
|
|
+ this.initTime(res.id, res.createdAt);
|
|
|
if (this.money) {
|
|
|
this.status = res.status;
|
|
|
this.id = res.id;
|
|
|
- // this.show = false;
|
|
|
} else {
|
|
|
this.$message.success('支付成功');
|
|
|
setTimeout(() => {
|
|
|
@@ -231,6 +303,7 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
init(info) {
|
|
|
+ this.status = 'Unpaid';
|
|
|
this.checkLogin()
|
|
|
.then(() => {
|
|
|
this.show = true;
|