import{v as e,c as s,o as r,n as t,ab as a,cS as o,r as l,e as d,f as c,w as u,cP as i,a0 as n,j as p,k as f,g as y,u as g,s as m,p as _,t as b,i as k,q as v,D as x}from"./index-CWyPMHxb.js";import{S as w}from"./s-layout.CUgh1tQ8.js";import{f as I}from"./useGoods.BQLkjza8.js";import{_ as h}from"./_plugin-vue_export-helper.BCo6x5W8.js";import"./index.gxKvznCa.js";const T=h({__name:"result",setup(h){const T=e({id:0,orderType:"goods",result:"unpaid",orderInfo:{},tradeOrder:{},counter:0}),$=s((()=>"unpaid"===T.result?"waiting":"paid"===T.result?"success":"failed"===T.result?"failed":"closed"===T.result?"closed":void 0));async function j(e){T.counter++;const{data:s,code:r}=await i.getOrder(e);if(0===r){if(T.orderInfo=s,!T.orderInfo||30===T.orderInfo.status)return void(T.result="closed");if(0!==T.orderInfo.status){if(T.result="paid","goods"===T.orderType){const{data:e,code:s}=await n.getOrderDetail(T.orderInfo.merchantOrderId,!0);0===s&&(T.tradeOrder=e)}return}}T.counter<3&&"unpaid"===T.result&&setTimeout((()=>{j(e)}),1500),T.counter>=3&&(T.result="failed")}function O(){"recharge"===T.orderType?m.$router.redirect("/pages/pay/recharge-log"):m.$router.redirect("/pages/order/list")}return r((async e=>{e.id&&(T.id=e.id),e.orderType&&(T.orderType=e.orderType),"fail"===e.payState?T.result="failed":await j(T.id)})),t((()=>{a(T.orderInfo)||j(T.id)})),o((()=>{T.result="unpaid",T.counter=0})),(e,s)=>{const r=k,t=v,a=x,o=l(d("s-layout"),w);return p(),c(o,{title:"支付结果",bgStyle:{color:"#FFF"}},{default:u((()=>[f(r,{class:"pay-result-box ss-flex-col ss-row-center ss-col-center"},{default:u((()=>["waiting"===$.value?(p(),c(r,{key:0,class:"pay-waiting ss-m-b-30"})):y("",!0),"success"===$.value?(p(),c(t,{key:1,class:"pay-img ss-m-b-30",src:g(m).$url.static("/static/img/shop/order/order_pay_success.gif")},null,8,["src"])):y("",!0),["failed","closed"].includes($.value)?(p(),c(t,{key:2,class:"pay-img ss-m-b-30",src:g(m).$url.static("/static/img/shop/order/order_paty_fail.gif")},null,8,["src"])):y("",!0),"success"===$.value?(p(),c(r,{key:3,class:"tip-text ss-m-b-30"},{default:u((()=>[_("支付成功")])),_:1})):y("",!0),"failed"===$.value?(p(),c(r,{key:4,class:"tip-text ss-m-b-30"},{default:u((()=>[_("支付失败")])),_:1})):y("",!0),"closed"===$.value?(p(),c(r,{key:5,class:"tip-text ss-m-b-30"},{default:u((()=>[_("该订单已关闭")])),_:1})):y("",!0),"waiting"===$.value?(p(),c(r,{key:6,class:"tip-text ss-m-b-30"},{default:u((()=>[_("检测支付结果...")])),_:1})):y("",!0),"success"===$.value?(p(),c(r,{key:7,class:"pay-total-num ss-flex"},{default:u((()=>[f(r,null,{default:u((()=>[_("￥"+b(g(I)(T.orderInfo.price)),1)])),_:1})])),_:1})):y("",!0),f(r,{class:"btn-box ss-flex ss-row-center ss-m-t-50"},{default:u((()=>[f(a,{class:"back-btn ss-reset-button",onClick:s[0]||(s[0]=e=>g(m).$router.go("/pages/index/index"))},{default:u((()=>[_(" 返回首页 ")])),_:1}),"failed"===$.value?(p(),c(a,{key:0,class:"check-btn ss-reset-button",onClick:s[1]||(s[1]=e=>g(m).$router.redirect("/pages/pay/index",{id:T.id,orderType:T.orderType}))},{default:u((()=>[_(" 重新支付 ")])),_:1})):y("",!0),"success"===$.value?(p(),c(a,{key:1,class:"check-btn ss-reset-button",onClick:O},{default:u((()=>[_(" 查看订单 ")])),_:1})):y("",!0),"success"===$.value&&3===T.tradeOrder.type?(p(),c(a,{key:2,class:"check-btn ss-reset-button",onClick:s[2]||(s[2]=e=>g(m).$router.redirect("/pages/activity/groupon/order"))},{default:u((()=>[_(" 我的拼团 ")])),_:1})):y("",!0)])),_:1})])),_:1})])),_:1})}}},[["__scopeId","data-v-c0b2ba3d"]]);export{T as default};
