diff --git a/components/coupons/index.wxml b/components/coupons/index.wxml index 3c0ae5c..374e4a4 100644 --- a/components/coupons/index.wxml +++ b/components/coupons/index.wxml @@ -4,16 +4,19 @@ - {{data.name}} + {{data.title}} + {{data.subTitle}} - ¥{{data.salePrice}} - ¥{{data.price}} + ¥{{data.salePrice/100}} + ¥{{data.price/100}} {{data.salePrice}} - {{data.salePrice}} + 购买 diff --git a/pages/coupons/details/index.js b/pages/coupons/details/index.js index 671c9bd..45d4bde 100644 --- a/pages/coupons/details/index.js +++ b/pages/coupons/details/index.js @@ -27,26 +27,35 @@ Page({ couponId: e.id }) }) - } + } }, /** * 支付订单更新 */ payOrderUpdate: (orderId, payOrderId, status, reason) => { // 支付成功 - return Http.post({ - url: config.api.payOrderUpdate, - data: { - payOrderId: payOrderId, - orderId: orderId, - status: status, - reason: reason - } - }) + Http.post({ + url: config.api.payOrderUpdate, + data: { + payOrderId: payOrderId, + orderId: orderId, + status: status, + reason: reason + } + }) + .then(res => { + console.log("payOrderUpdate then", res); + wx.showToast({ + title: '购买成功', + duration: 2500 + }) + }).catch(err => { + console.log("payOrderUpdate catch", err); + }) }, payment: (res) => { var that = this; - var payOrderId = '' + res.payOrderId; + var payOrderId = '' + res.data.out_trade_no; wx.requestPayment({ timeStamp: res.timeStamp, nonceStr: res.nonceStr, @@ -123,7 +132,7 @@ Page({ if (err.code == 11005) { // 用户手机未授权 wx.redirectTo({ - url: '../../getphoneInfo/index?couponId='+that.data.couponId, + url: '../../getphoneInfo/index?couponId=' + that.data.couponId, }) } if (err.code == 11006) { @@ -134,36 +143,38 @@ Page({ } }) .then(res => { - const orderId = '' + res.data.id; - that.setData({ - orderId: orderId - }) - if (res.data.payment > 0) { - // real pay - return Http.post({ - url: config.api.payOrderCreate, - data: { - orderId: orderId - } + if (res != "undefined") { + const orderId = '' + res.data.id; + that.setData({ + orderId: orderId }) - } else { - // 免费券 - that.payOrderUpdate(orderId, "0", 1) // 支付成功 - .then(res => { - wx.showToast({ - title: "支付成功", - duration: 3000 - }) + if (res.data.payment > 0) { + // 支付金额不为0 + Http.post({ + url: config.api.payOrderCreate, + data: { + orderId: orderId + } + }).then(res => { + console.log(res) + var payOrderId = '' + res.data.out_trade_no; + wx.hideLoading(); + //payment(res); + that.payOrderUpdate(that.data.orderId, payOrderId, 1) // 支付成功 }) + } else { + // 免费券 + that.payOrderUpdate(orderId, "0", 1) // 支付成功 + .then(res => { + wx.showToast({ + title: "支付成功", + duration: 3000 + }) + }) + } } - }).then(res => { - console.log(res) - if (res) { - var payOrderId = '' + res.payOrderId; - wx.hideLoading(); - //payment(res); - that.payOrderUpdate(that.data.orderId, payOrderId, 1) // 支付成功 - } + }).catch(err => { + console.log(err) }) }, }) \ No newline at end of file diff --git a/pages/coupons/details/index.wxml b/pages/coupons/details/index.wxml index 3971689..e6a8164 100644 --- a/pages/coupons/details/index.wxml +++ b/pages/coupons/details/index.wxml @@ -5,13 +5,13 @@ - {{data.title}}限购一件 + {{data.title}}限购{{data.useLimitQuantity}}件 剩余时间:2天12小时25分钟 - 剩余件数:19件 + 剩余件数:{{data.remainInventory}}件 ¥{{data.salePriceStr}} - ¥59.00 + ¥{{data.priceStr}} diff --git a/pages/coupons/index/index.wxml b/pages/coupons/index/index.wxml index d654529..6aa57d3 100644 --- a/pages/coupons/index/index.wxml +++ b/pages/coupons/index/index.wxml @@ -9,7 +9,10 @@ - 黑椒牛排 + {{item.title}} + + + {{item.subTitle}} 有效期至:{{item.expiredTime}}