diff --git a/pages/order/pay/index.js b/pages/order/pay/index.js index af07a1f..ab3e25d 100644 --- a/pages/order/pay/index.js +++ b/pages/order/pay/index.js @@ -50,6 +50,24 @@ Page({ isPaying: false, + sku_model_type: "", + templateIds: { + "ticket": [ + // 订单状态变化通知 + "cgeAlh1IzNlCua-q0UInEHzWaZdqvpfiVq1eBo-Oj4o", + //出票结果通知 + "zdh2DYFLJ8M-jwiW6EXfhJ4qPpreWp1rHIMd0jrLWII", + // 订单支付成功通知 + "KFtX7CPbFkYTbxowaLC0-bEdeGdzfWpaOXCTOOWS_NM", + ], + "post": [ + // 订单支付成功通知 + "KFtX7CPbFkYTbxowaLC0-bEdeGdzfWpaOXCTOOWS_NM", + // 订单发货通知 + "zyoVCQnrhXYojldRffIgz8O4uEeuJvbhWBxqNbhrPMU" + ], + } + }, /** @@ -141,9 +159,6 @@ Page({ commonApi.user_post("order/query",{ order_id:this.data.id }).then(res=>{ - - - // 书券产品 if(res.data.order_product_list[0].product_id == 75012 || res.data.order_product_list[0].product_id == 75013 || @@ -156,7 +171,7 @@ Page({ isBook:true, payIndex:1 }) - } + } if(res.data.create_time && res.data.auto_close_time && res.data.state=='UNPAID'){ let time = (new Date(res.data.create_time.replace(/-/g,'/')).getTime() + Number(res.data.auto_close_time) * 1000); this.daojishi(time); @@ -199,6 +214,7 @@ Page({ carCouponTip:carCouponTip, info: res.data, MTTip: MTTip, + sku_model_type: res.data.order_product_list[0].product_model }) console.log(this.data.ERMB); @@ -230,6 +246,7 @@ Page({ }) }, pay:function(){ + let _this = this; let arr = [] this.data.info.order_product_list.forEach(item => { arr.push(item.product_id) @@ -260,7 +277,6 @@ Page({ } } - let _this = this; if(this.data.payIndex==1) { this.setData({ showNumMask:true @@ -289,11 +305,25 @@ Page({ title: '支付成功', icon:'success' }) + + let templateIds = _this.data.templateIds[_this.data.sku_model_type]; + if (templateIds && Array.isArray(templateIds) && templateIds.length>0) { + wx.requestSubscribeMessage({ + tmplIds: templateIds, + complete (res) { + wx.redirectTo({ + url: '../payresult/index?tid='+_this.data.id+'&ids='+_this.data.ids.join(',') + }) + } + }) + return + } + setTimeout(()=>{ // 支付成功不还原isPaying redirectTo 会删掉当前页面触发unload // _this.data.isPaying = false wx.redirectTo({ - url: '../payresult/index?tid='+_this.data.id+'&ids='+_this.data.ids.join(',') + url: '../payresult/index?tid='+_this.data.id+'&ids='+_this.data.ids.join(',') }) },1000) },