diff --git a/pages/CommodityDetails/CommodityDetails.vue b/pages/CommodityDetails/CommodityDetails.vue index 35ba87a..0e87db0 100644 --- a/pages/CommodityDetails/CommodityDetails.vue +++ b/pages/CommodityDetails/CommodityDetails.vue @@ -434,78 +434,87 @@ this.updata.totalPrice = Number((this.updata.originalTotalPrice - this.updata.discountPrice).toFixed(2)) } - addStationGoodsOrder(this.updata).then(res => { - if (res.code == 500) { - that.$refs.uToast.show({ - title: res.msg, - type: 'error' - }) - } else { - let id = res.data.id - let paydata = res.data - paydata.openid = value - paydata.payType = "WECHAT_PAY" - paydata.paymentPrice = res.data.totalPrice - appletGoodsOrderPay(paydata).then(response => { - if (response.code == 200) { - uni.requestPayment({ - timeStamp: response - .data.timeStamp, - nonceStr: response.data - .nonceStr, - package: response.data - .prepayId, - signType: response.data - .signType, - paySign: response.data - .paySign, - success: function( - res) { - that.goodsDetailsinfo( - that - .goodsInfoId, - that.updata - .patientId - ) - that.$refs - .uToast - .show({ - title: '支付成功', - type: 'success', - duration: 1000, - url: '/pages/paysuccess/paysuccess' - }) - }, - fail: function(err) { - that.goodsDetailsinfo( - that - .goodsInfoId, - that.updata - .patientId - ) - that.$refs - .uToast - .show({ - title: '取消支付', - type: 'error', - duration: 1000, - url: `/pages/payorderDetails/payorderDetails?goodsOrderId=${id}` - }) - // uni.navigateTo({ - // url: `/pages/payorderDetails/payorderDetails?goodsOrderId=${id}` - // }) - } - }); - } else { - that.$refs.uToast.show({ - title: response.msg, - type: 'error', - duration: 1000 - }) - } - }) - } - }) + if (this.updata.totalPrice > 0) { + addStationGoodsOrder(this.updata).then(res => { + if (res.code == 500) { + that.$refs.uToast.show({ + title: res.msg, + type: 'error' + }) + } else { + let id = res.data.id + let paydata = res.data + paydata.openid = value + paydata.payType = "WECHAT_PAY" + paydata.paymentPrice = res.data.totalPrice + appletGoodsOrderPay(paydata).then(response => { + if (response.code == 200) { + uni.requestPayment({ + timeStamp: response + .data.timeStamp, + nonceStr: response.data + .nonceStr, + package: response.data + .prepayId, + signType: response.data + .signType, + paySign: response.data + .paySign, + success: function( + res) { + that.goodsDetailsinfo( + that + .goodsInfoId, + that + .updata + .patientId + ) + that.$refs + .uToast + .show({ + title: '支付成功', + type: 'success', + duration: 1000, + url: '/pages/paysuccess/paysuccess' + }) + }, + fail: function(err) { + that.goodsDetailsinfo( + that + .goodsInfoId, + that + .updata + .patientId + ) + that.$refs + .uToast + .show({ + title: '取消支付', + type: 'error', + duration: 1000, + url: `/pages/payorderDetails/payorderDetails?goodsOrderId=${id}` + }) + // uni.navigateTo({ + // url: `/pages/payorderDetails/payorderDetails?goodsOrderId=${id}` + // }) + } + }); + } else { + that.$refs.uToast.show({ + title: response.msg, + type: 'error', + duration: 1000 + }) + } + }) + } + }) + } else { + that.$refs.uToast.show({ + title: '订单金额为0,无法下单', + type: 'error' + }) + } } } else { that.$refs.uToast.show({