"use strict";const e=require("../../common/vendor.js"),r=require("../../sheep/index.js"),s=require("../../sheep/api/pay/order.js"),i=require("../../sheep/hooks/useGoods.js"),o=require("../../sheep/api/trade/order.js"),a=require("../../sheep/hooks/useModal.js");if(require("../../sheep/url/index.js"),require("../../sheep/store/index.js"),require("../../sheep/store/app.js"),require("../../sheep/api/promotion/diy.js"),require("../../sheep/request/index.js"),require("../../sheep/config/index.js"),require("../../sheep/platform/index.js"),require("../../sheep/platform/provider/wechat/index.js"),require("../../sheep/platform/provider/wechat/miniProgram.js"),require("../../sheep/api/member/auth.js"),require("../../sheep/api/member/social.js"),require("../../sheep/api/member/user.js"),require("../../sheep/platform/provider/apple/index.js"),require("../../sheep/platform/share.js"),require("../../sheep/router/index.js"),require("../../sheep/helper/throttle.js"),require("../../sheep/platform/pay.js"),require("../../sheep/helper/index.js"),require("../../sheep/helper/test.js"),require("../../sheep/helper/digit.js"),require("../../sheep/store/user.js"),require("../../sheep/store/cart.js"),require("../../sheep/api/trade/cart.js"),require("../../sheep/api/pay/wallet.js"),require("../../sheep/api/promotion/coupon.js"),require("../../sheep/store/sys.js"),require("../../sheep/store/modal.js"),require("../../sheep/config/zIndex.js"),require("../../sheep/util/index.js"),require("../../sheep/api/member/signin.js"),!Array){e.resolveComponent("s-layout")()}Math;const u={__name:"result",setup(u){const t=e.reactive({id:0,orderType:"goods",result:"unpaid",orderInfo:{},tradeOrder:{},counter:0}),p=e.computed((()=>"unpaid"===t.result?"waiting":"paid"===t.result?"success":"failed"===t.result?"failed":"closed"===t.result?"closed":void 0));async function d(e){t.counter++;const{data:r,code:i}=await s.PayOrderApi.getByStatus(e);if(0===i){if(t.orderInfo=r,!t.orderInfo||30===t.orderInfo.status)return void(t.result="closed");if(0!==t.orderInfo.status){if(t.result="paid",c(),"goods"===t.orderType){const{data:e,code:r}=await o.OrderApi.getByStatus(t.orderInfo.merchantOrderId);0===r&&(t.tradeOrder=e)}return}}t.counter<3&&"unpaid"===t.result&&setTimeout((()=>{d(e)}),1500),t.counter>=3&&(t.result="failed")}function l(){"recharge"===t.orderType?r.sheep.$router.redirect("/pages/pay/recharge-log"):r.sheep.$router.redirect("/pages/order/list")}function c(){let e=["order_dispatched"];3===t.tradeOrder.type&&(e.push("groupon_finish"),e.push("groupon_fail")),r.sheep.$platform.useProvider("wechat").subscribeMessage(e)}return e.watchEffect((()=>{"success"==p.value&&a.showWalletModal({points:t.orderInfo.jf,socialStatus:t.orderInfo.sj})})),e.onLoad((async e=>{e.id&&(t.id=e.id),e.orderType&&(t.orderType=e.orderType),await d(t.id)})),e.onShow((()=>{e.lodashExports.isEmpty(t.orderInfo)||d(t.id)})),e.onHide((()=>{t.result="unpaid",t.counter=0})),(s,o)=>e.e({a:"waiting"===p.value},(p.value,{}),{b:"success"===p.value},"success"===p.value?{c:e.unref(r.sheep).$url.static("/static/images/order_pay_success.gif")}:{},{d:["failed","closed"].includes(p.value)},["failed","closed"].includes(p.value)?{e:e.unref(r.sheep).$url.static("/static/images/order_paty_fail.gif")}:{},{f:"success"===p.value},(p.value,{}),{g:"failed"===p.value},(p.value,{}),{h:"closed"===p.value},(p.value,{}),{i:"waiting"===p.value},(p.value,{}),{j:"success"===p.value},"success"===p.value?{k:e.t(e.unref(i.fen2yuan)(t.orderInfo.price))}:{},{l:e.o((s=>e.unref(r.sheep).$router.go("/pages/index/index"))),m:"failed"===p.value},"failed"===p.value?{n:e.o((s=>e.unref(r.sheep).$router.redirect("/pages/pay/index",{id:t.id,orderType:t.orderType})))}:{},{o:"success"===p.value},"success"===p.value?{p:e.o(l)}:{},{q:"success"===p.value&&3===t.tradeOrder.type},"success"===p.value&&3===t.tradeOrder.type?{r:e.o((s=>e.unref(r.sheep).$router.redirect("/pages/activity/groupon/order")))}:{},{s:e.unref(r.sheep).$url.static("/static/images/cargo.png"),t:e.o(c),v:e.p({title:"支付结果",bgStyle:{color:"#FFF"}})})}},t=e._export_sfc(u,[["__scopeId","data-v-dd2a2220"]]);wx.createPage(t);
