acdr-ui/dist/build/mp-weixin/modules/mall/pay/result.js

2 lines
3.5 KiB
JavaScript

"use strict";var e=(e,r,s)=>new Promise(((o,t)=>{var u=e=>{try{d(s.next(e))}catch(r){t(r)}},a=e=>{try{d(s.throw(e))}catch(r){t(r)}},d=e=>e.done?o(e.value):Promise.resolve(e.value).then(u,a);d((s=s.apply(e,r)).next())}));const r=require("../../../common/vendor.js"),s=require("../../../sheep/index.js"),o=require("../../../sheep/api/pay/order.js"),t=require("../../../sheep/hooks/useGoods.js"),u=require("../../../sheep/api/trade/order.js"),a=require("../../../sheep/util/const.js");if(!Array){(r.resolveComponent("s-layout")+r.resolveComponent("layout-default-uni"))()}Math;const d="subscribe_btn_status",i={__name:"result",setup(i){const l=r.reactive({id:0,orderType:"goods",result:"unpaid",orderInfo:{},tradeOrder:{},counter:0}),n=r.computed((()=>"unpaid"===l.result?"waiting":"paid"===l.result?"success":"failed"===l.result?"failed":"closed"===l.result?"closed":void 0));function c(s){return e(this,null,(function*(){l.counter++;const{data:t,code:a}=yield o.PayOrderApi.getOrder(s);if(0===a){if(l.orderInfo=t,!l.orderInfo||30===l.orderInfo.status)return void(l.result="closed");if(0!==l.orderInfo.status){if(l.result="paid",r.index.showModal({title:"支付结果",showCancel:!1,content:"支付成功",success:()=>{!function(){e(this,null,(function*(){r.index.getStorageSync(d)?v():f.value=!0}))}()}}),"goods"===l.orderType){const{data:e,code:r}=yield u.OrderApi.getOrder(l.orderInfo.merchantOrderId);0===r&&(l.tradeOrder=e)}return}}l.counter<3&&"unpaid"===l.result&&setTimeout((()=>{c(s)}),1500),l.counter>=3&&(l.result="failed")}))}function p(){"recharge"===l.orderType?s.sheep.$router.redirect("/modules/mall/pay/recharge-log"):s.sheep.$router.redirect("/modules/mall/order/list")}const f=r.ref(!1);function v(){if("goods"!==l.orderType)return;const e=[a.WxaSubscribeTemplate.TRADE_ORDER_DELIVERY];3===l.tradeOrder.type&&e.push(a.WxaSubscribeTemplate.PROMOTION_COMBINATION_SUCCESS),s.sheep.$platform.useProvider("wechat").subscribeMessage(e,(()=>{r.index.removeStorageSync(d),r.index.setStorageSync(d,"已订阅"),f.value=!1}))}return r.onLoad((r=>e(this,null,(function*(){r.id&&(l.id=r.id),r.orderType&&(l.orderType=r.orderType),"fail"===r.payState?l.result="failed":yield c(l.id)})))),r.onShow((()=>{r.isEmpty(l.orderInfo)||c(l.id)})),r.onHide((()=>{l.result="unpaid",l.counter=0})),(e,o)=>r.e({a:"waiting"===n.value},(n.value,{}),{b:"success"===n.value},"success"===n.value?{c:r.unref(s.sheep).$url.static("/static/img/shop/order/order_pay_success.gif")}:{},{d:["failed","closed"].includes(n.value)},["failed","closed"].includes(n.value)?{e:r.unref(s.sheep).$url.static("/static/img/shop/order/order_paty_fail.gif")}:{},{f:"success"===n.value},(n.value,{}),{g:"failed"===n.value},(n.value,{}),{h:"closed"===n.value},(n.value,{}),{i:"waiting"===n.value},(n.value,{}),{j:"success"===n.value},"success"===n.value?{k:r.t(r.unref(t.fen2yuan)(l.orderInfo.price))}:{},{l:r.o((e=>r.unref(s.sheep).$router.go("/modules/mall/index/index"))),m:"failed"===n.value},"failed"===n.value?{n:r.o((e=>r.unref(s.sheep).$router.redirect("/modules/mall/pay/index",{id:l.id,orderType:l.orderType})))}:{},{o:"success"===n.value},"success"===n.value?{p:r.o(p)}:{},{q:"success"===n.value&&3===l.tradeOrder.type},"success"===n.value&&3===l.tradeOrder.type?{r:r.o((e=>r.unref(s.sheep).$router.redirect("/modules/mall/activity/groupon/order")))}:{},{s:f.value&&"goods"===l.orderType},f.value&&"goods"===l.orderType?{t:r.unref(s.sheep).$url.static("/static/img/shop/order/cargo.png"),v:r.o(v)}:{},{w:r.p({title:"支付结果",bgStyle:{color:"#FFF"}})})}},l=r._export_sfc(i,[["__scopeId","data-v-50a84b8c"]]);wx.createPage(l);