|
|
@@ -109,7 +109,8 @@ export default {
|
|
|
enable_wx_pub: false,
|
|
|
launchName: '',
|
|
|
launchPath: '',
|
|
|
- iosPrice: 0
|
|
|
+ iosPrice: 0,
|
|
|
+ createOrderTimer: null
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -132,6 +133,9 @@ export default {
|
|
|
},
|
|
|
beforeRouteLeave(to, from, next) {
|
|
|
console.log(to);
|
|
|
+ if (this.createOrderTimer) {
|
|
|
+ clearInterval(this.createOrderTimer);
|
|
|
+ }
|
|
|
if (to.path !== '/couponList') {
|
|
|
this.$store.commit('setCouponInfo', null);
|
|
|
}
|
|
|
@@ -250,6 +254,46 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
+ createOrder() {
|
|
|
+ if (!this.payType) {
|
|
|
+ this.$toast('请选择支付方式');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$toast.loading('请不要离开当前页面');
|
|
|
+
|
|
|
+ let params = {
|
|
|
+ collectionId: this.$route.query.id,
|
|
|
+ qty: 1,
|
|
|
+ couponId: (this.couponInfo || {}).id || '',
|
|
|
+ invitor: sessionStorage.getItem('invitor')
|
|
|
+ };
|
|
|
+ return this.$http.post('/order/mqCreate', params).then(res => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ let checkOrder = () => {
|
|
|
+ this.$http
|
|
|
+ .get('/order/createResult', { id: res.id })
|
|
|
+ .then(res => {
|
|
|
+ if (res) {
|
|
|
+ clearInterval(this.createOrderTimer);
|
|
|
+ this.createOrderTimer = null;
|
|
|
+ if (res.success) {
|
|
|
+ resolve(res.data);
|
|
|
+ } else {
|
|
|
+ reject({ error: res.data });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ clearInterval(this.createOrderTimer);
|
|
|
+ this.createOrderTimer = null;
|
|
|
+ reject(e);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ setTimeout(checkOrder, 500);
|
|
|
+ this.createOrderTimer = setInterval(checkOrder, 2000);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
submit() {
|
|
|
if (!this.payType) {
|
|
|
this.$toast('请选择支付方式');
|