From d368dfa1f10d42b4d8d669299fdad14e8bf08d3e Mon Sep 17 00:00:00 2001 From: wangkesi Date: Thu, 18 Oct 2018 10:43:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=BB=98=E6=AC=BE?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/view/order-check.vue | 5 +- src/view/order-detail.vue | 115 +++++++++++++++++++------------------- 2 files changed, 58 insertions(+), 62 deletions(-) diff --git a/src/view/order-check.vue b/src/view/order-check.vue index dd0c049..aab0d94 100644 --- a/src/view/order-check.vue +++ b/src/view/order-check.vue @@ -189,8 +189,7 @@ export default { } } else { setTimeout(function() { - window.location.href = - "/mall/web/order_index"; + window.location.href = "/v2/order-list"; }, 2000); } } else if (data.code === 666) { @@ -213,7 +212,7 @@ export default { this.$vux.toast.text(data.msg, "middle"); setTimeout(function() { window.location.href = - "/mall/web/order_index"; + "/v2/order-list"; }, 2000); } }); diff --git a/src/view/order-detail.vue b/src/view/order-detail.vue index 130a1a4..ba1f7f6 100644 --- a/src/view/order-detail.vue +++ b/src/view/order-detail.vue @@ -104,7 +104,8 @@ export default { state: "", stateText: "", orderNo: "", - info: {} + info: {}, + authUrl: "" }; }, watch: { @@ -146,6 +147,7 @@ export default { }) .then(res => { if (res.code === 0 && res.response.data) { + this.authUrl = res.response.authUrl || ""; let info = res.response.data; this.wechat(info.merchantNo); info.create = info.createdAt @@ -232,71 +234,66 @@ export default { }); }, pay() { - this.addOrder().then(res => { - this.$vux.loading.show({ - text: "正在调起支付" - }); - if (isWeixin() && res.data.payPrice > 0) { - //微信内打开,直接调起微信公众号支付 - this.$vux.loading.hide(); - location.href = res.authUrl.replace( - "state=2", - "state=2" + "," + res.data.orderNo - ); - } else { - var paymentType = res.data.payPrice > 0 ? 7 : 10; - orderApi - .pay({ - orderNo: res.data.orderNo, - paymentType: paymentType - }) - .then(data => { - this.$vux.loading.hide(); - if (data.code === 0) { - if (paymentType === 7) { - var transMessageOutput = data.response; - var transInfo = - transMessageOutput.weixinTransParameters; - if ( - transInfo.prepayid !== "" && - transInfo.prepayid !== undefined && - transInfo.prepayid != null - ) { - window.location.href = - transInfo.mwebUrl; - } - } else { - setTimeout(function() { - window.location.href = - "/mall/web/order_index"; - }, 2000); - } - } else if (data.code === 666) { - this.$vux.toast.text( - "您还没登录,请先登录!", - "middle" - ); - setTimeout(function() { - window.location.href = - "/mall/web/user/login"; - }, 2000); - } else { + this.$vux.loading.show({ + text: "正在调起支付" + }); + if (isWeixin() && this.info.payPrice > 0) { + //微信内打开,直接调起微信公众号支付 + this.$vux.loading.hide(); + location.href = this.authUrl.replace( + "state=2", + "state=2" + "," + this.info.orderNo + ); + } else { + let paymentType = this.info.payPrice > 0 ? 7 : 10; + orderApi + .pay({ + orderNo: this.info.orderNo, + paymentType: paymentType + }) + .then(data => { + this.$vux.loading.hide(); + if (data.code === 0) { + if (paymentType === 7) { + var transMessageOutput = data.response; + var transInfo = + transMessageOutput.weixinTransParameters; if ( - data.msg === "" || - data.msg === undefined || - data.msg == null + transInfo.prepayid !== "" && + transInfo.prepayid !== undefined && + transInfo.prepayid != null ) { - data.msg = "操作失败,请刷新重试"; + window.location.href = transInfo.mwebUrl; } - this.$vux.toast.text(data.msg, "middle"); + } else { setTimeout(function() { window.location.href = - "/mall/web/order_index"; + "/v2/order-list"; }, 2000); } - }); - } - }); + } else if (data.code === 666) { + this.$vux.toast.text( + "您还没登录,请先登录!", + "middle" + ); + setTimeout(function() { + window.location.href = "/mall/web/user/login"; + }, 2000); + } else { + if ( + data.msg === "" || + data.msg === undefined || + data.msg == null + ) { + data.msg = "操作失败,请刷新重试"; + } + this.$vux.toast.text(data.msg, "middle"); + setTimeout(function() { + window.location.href = "/v2/order-list"; + }, 2000); + } + }); + } }, addOrder() { let goodsNo = this.info.goodsNo;