diff --git a/api/interfaces/index.js b/api/interfaces/index.js index 1d7093e..057d676 100644 --- a/api/interfaces/index.js +++ b/api/interfaces/index.js @@ -71,7 +71,7 @@ const fridayInfo = (werlfare_id, address_id, is_deliver) => req({url: "welfare/o const fridayPay = (trade_no) => req({url: "payments/welfare/wechat",method: "POST", data: {trade_no: trade_no}}) //洗车券-获取跳转地址 -const washcarUrl = (welfare_id, right_config_id) => req({url: "washcar/infourl", data: {welfare_id: welfare_id, right_config_id: right_config_id}}) +const washcarUrl = (welfare_id, right_config_id) => req({url: "washcar/infourl", data: {welfare_id: welfare_id || '', right_config_id: right_config_id}}) //洗车券-获取跳转地址 const washcarCoupon = (coupon) => req({url: "washcar/" + coupon + "/info",method: "POST"}) diff --git a/pages/car/index.js b/pages/car/index.js index 401d12e..d204ec7 100644 --- a/pages/car/index.js +++ b/pages/car/index.js @@ -24,6 +24,7 @@ Page({ remark : '', //使用须知 score : '', //应付总积分 freight : '', //运费 + welfareType : '', //权益类型 noticeShow : false, //须知显示状态 addressShow : false, //收货地址显示 payWayIndex : 0, @@ -84,6 +85,7 @@ Page({ amount : res.data.total, moreAmount : res.data.amount, score : res.data.score, + welfareType : res.data.type, remark : res.data.detail.remark.replace(/\{ let dataUrl = '', //定义接口来源名称 - type = res.data.type //订单来源 + Newtype = res.data.type //订单来源 + // welfare为福利活动购买 - if(type == 'welfare') dataUrl = wx.$api.index.fridayInfo(welfare_id, address_id, is_deliver) + if(Newtype == 'welfare') dataUrl = wx.$api.index.fridayPay(res.data.trade_no) // right为权益购买 - if(type == 'right') dataUrl = wx.$api.index.rightStore(right_id, address_id, is_deliver, qty) + if(Newtype == 'right') dataUrl = wx.$api.index.wechat(res.data.trade_no) // 第一步接口调取 - dataUrl.then(dataRes=>{ - let payUrl = '', //定义接口来源名称 - Newtype = dataRes.data.type //订单来源 - // welfare为福利活动购买 - if(Newtype == 'welfare') payUrl = wx.$api.index.fridayPay(dataRes.data.trade_no) - - // right为权益购买 - if(Newtype == 'right') payUrl = wx.$api.index.wechat(dataRes.data.trade_no) - - // 第一步接口调取 - payUrl.then(payEes=>{ - let payInfo = JSON.parse(payEes.data) - wx.requestPayment({ - timeStamp: payInfo.timeStamp, - nonceStr : payInfo.nonceStr, - package : payInfo.package, - paySign : payInfo.paySign, - signType : payInfo.signType, - success : res=>{ - if(res.errMsg == "requestPayment:ok"){ - wx.showToast({ - title: '支付成功', - icon : 'success' - }) - if(Newtype == 'welfare'){ - setTimeout(()=>{ - if(this.data.isdeliver == 1) { - wx.reLaunch({ - url: '/pages/order/order?orderType=welfareGoods' - }) - } else { - wx.reLaunch({ - url: '/pages/order/order?orderType=welfare' - }) - } - },3000) - } - if(Newtype == 'right'){ - setTimeout(()=>{ - if(this.data.isdeliver == 1) { - wx.reLaunch({ - url: '/pages/order/order?orderType=rightsCoupons' - }) - } else { - wx.reLaunch({ - url: '/pages/order/order?orderType=rights' - }) - } - },3000) - } - } - }, - fail : res=>{ + dataUrl.then(payEes=>{ + let payInfo = JSON.parse(payEes.data) + wx.requestPayment({ + timeStamp: payInfo.timeStamp, + nonceStr : payInfo.nonceStr, + package : payInfo.package, + paySign : payInfo.paySign, + signType : payInfo.signType, + success : res=>{ + if(res.errMsg == "requestPayment:ok"){ + wx.showToast({ + title: '支付成功', + icon : 'success' + }) if(Newtype == 'welfare'){ - if(this.data.isdeliver == 1) { - wx.reLaunch({ - url: '/pages/order/order?orderType=welfareGoods&stateType=unpay' - }) - } else { - wx.reLaunch({ - url: '/pages/order/order?orderType=welfare&stateType=unpay' - }) - } + setTimeout(()=>{ + if(this.data.isdeliver == 1) { + wx.reLaunch({ + url: '/pages/order/order?orderType=welfareGoods' + }) + } else { + wx.reLaunch({ + url: '/pages/order/order?orderType=welfare' + }) + } + },3000) } if(Newtype == 'right'){ - if(this.data.isdeliver == 1) { - wx.reLaunch({ - url: '/pages/order/order?orderType=rightsCoupons&stateType=unpay' - }) - } else { - wx.reLaunch({ - url: '/pages/order/order?orderType=rights&stateType=unpay' - }) - } + setTimeout(()=>{ + if(this.data.isdeliver == 1) { + wx.reLaunch({ + url: '/pages/order/order?orderType=rightsCoupons' + }) + } else { + wx.reLaunch({ + url: '/pages/order/order?orderType=rights' + }) + } + },3000) } } - }) + }, + fail : res=>{ + console.log(this.data.isdeliver) + console.log(Newtype) + if(Newtype == 'welfare'){ + if(this.data.isdeliver == 1) { + wx.reLaunch({ + url: '/pages/order/order?orderType=welfareGoods&stateType=unpay' + }) + } else { + wx.reLaunch({ + url: '/pages/order/order?orderType=welfare&stateType=unpay' + }) + } + } + if(Newtype == 'right'){ + if(this.data.isdeliver == 1) { + wx.reLaunch({ + url: '/pages/order/order?orderType=rightsCoupons&stateType=unpay' + }) + } else { + wx.reLaunch({ + url: '/pages/order/order?orderType=rights&stateType=unpay' + }) + } + } + } }) }) + }) } }) \ No newline at end of file diff --git a/pages/car/index.wxml b/pages/car/index.wxml index 8c1e3e1..5dd57a1 100644 --- a/pages/car/index.wxml +++ b/pages/car/index.wxml @@ -1,5 +1,5 @@ - + 等待买家付款 请您尽快下单购买 @@ -9,7 +9,7 @@ - + @@ -62,7 +62,7 @@ {{detail.attribute.form_pay}} ¥{{amount}} - + 运费 diff --git a/pages/car/index.wxss b/pages/car/index.wxss index 207d27e..9c37a7d 100644 --- a/pages/car/index.wxss +++ b/pages/car/index.wxss @@ -1,7 +1,7 @@ /* 下单状态 */ .state { background: #2e71e3; - padding: 30rpx 100rpx 60rpx; + padding: 30rpx 60rpx; width: 100%; box-sizing: border-box; color: #fff; @@ -9,6 +9,10 @@ display: flex; } +.state.active { + padding: 30rpx 100rpx 60rpx; +} + .state-title { flex: 1; font-size: 32rpx; diff --git a/pages/classify/classify.js b/pages/classify/classify.js index cc9fd4e..4bf9a64 100644 --- a/pages/classify/classify.js +++ b/pages/classify/classify.js @@ -77,13 +77,26 @@ Page({ * 处理未登录时的转跳 */ userNav(e){ - let id = e.currentTarget.dataset.id + let newid = e.currentTarget.dataset.id, + canFrom = e.currentTarget.dataset.from wx.getStorage({ key : 'token', success:res=>{ - wx.navigateTo({ - url: '/pages/rights/rights?rightsId=' + id - }) + if(canFrom == 'washcar') { + wx.$api.index.washcarUrl('', newid).then(res=>{ + const newUrl = res.data + let url= encodeURIComponent(newUrl) + wx.redirectTo({ + // 跳转到webview页面 + url: `/pages/washcar/washcar?url=${url}` + }); + }) + } else { + // 跳转权益详情页 + wx.navigateTo({ + url: '/pages/rights/rights?rightsId=' + newid + }) + } }, fail: (err) => { wx.navigateTo({ diff --git a/pages/classify/classify.wxml b/pages/classify/classify.wxml index 4b41042..7740014 100644 --- a/pages/classify/classify.wxml +++ b/pages/classify/classify.wxml @@ -30,7 +30,7 @@ + data-id="{{item.right_config_id}}" data-from="{{item.from}}"> {{item.label}}