var e=(e,a,l)=>new Promise((t,s)=>{var u=e=>{try{r(l.next(e))}catch(a){s(a)}},n=e=>{try{r(l.throw(e))}catch(a){s(a)}},r=e=>e.done?t(e.value):Promise.resolve(e.value).then(u,n);r((l=l.apply(e,a)).next())});import{M as a,i as l,N as t,n as s,e as u,E as n}from"./vendor-element-DupX9wXy.js";import{q as r,bB as v,bC as i,r as o,R as d,U as c,t as p,v as x,A as f,G as m,D as y,E as b,M as g,u as h,K as w,H as _,J as k}from"./vendor-core-Di0OO4oJ.js";import{c as j}from"./wallet-D5bWawEZ.js";import"./index-BkDr3sJj.js";const q={class:"min-h-screen bg-slate-50 flex items-center justify-center px-4 py-8"},C={class:"w-full max-w-md rounded-3xl bg-white shadow-lg border border-slate-100 p-6"},z={class:"flex items-center justify-center mb-5"},A={class:"text-center mb-6"},I={class:"text-xl font-semibold text-slate-900 mb-2"},E={class:"text-sm leading-6 text-slate-500"},M={class:"rounded-2xl bg-slate-50 px-4 py-3 text-sm text-slate-600 space-y-2 mb-6"},P={class:"flex justify-between gap-3"},R={class:"font-mono text-slate-700 break-all text-right"},U={key:0,class:"flex justify-between gap-3"},B={class:"text-slate-700 text-right"},D={key:1,class:"flex justify-between gap-3"},G={class:"text-slate-700"},H={class:"space-y-3"},J=r({__name:"mobile-launch",setup(r){const J=v(),K=i(),N=o(""),T=o(""),F=o(""),L=o(""),O=o("正在准备支付"),Q=o("页面将拉起支付窗口，并在此页面持续检测支付结果。"),S=o(!1),V=o(!1),W=o(!1),X=o(!1);let Y=null,Z=0;const $=e=>Array.isArray(e)?e[0]||"":"string"==typeof e?e:"",ee=()=>{Y&&(clearInterval(Y),Y=null)},ae=()=>{N.value&&J.replace({path:"/order/search",query:{keyword:N.value}})},le=()=>e(null,null,function*(){var e,a;if(N.value&&!W.value)try{Z+=1;const l=yield j(N.value),t=(null==l?void 0:l.status)||(null==(e=null==l?void 0:l.data)?void 0:e.status);if(!0===l||1===(null==l?void 0:l.status)||"paid"===t||"pending_shipment"===t||1===(null==(a=null==l?void 0:l.data)?void 0:a.status))return ee(),W.value=!0,X.value=!1,O.value="支付成功",Q.value="订单已支付成功，正在跳转到订单查询页。",void setTimeout(()=>{ae()},1200);Z>=150&&(X.value=!0,O.value="支付结果确认中",Q.value="暂未检测到支付完成，如已支付可稍后点“查看订单”确认。",ee())}catch(l){}}),te=()=>{if(T.value){S.value=!0;try{if(!window.open(T.value,"_blank"))return void(window.location.href=T.value);V.value=!0,O.value="请在新窗口完成支付",Q.value="支付完成后无需返回首页，本页会自动检测并跳转订单页。"}finally{S.value=!1}}else n.error("缺少支付链接")};return d(()=>{if(N.value=$(K.query.order_no),T.value=decodeURIComponent($(K.query.pay_url)),F.value=$(K.query.product_name),L.value=$(K.query.amount),!N.value||!T.value)return O.value="参数错误",void(Q.value="缺少订单号或支付链接，无法继续支付。");te(),e(null,null,function*(){ee(),Z=0,yield le(),W.value||(Y=setInterval(le,2e3))})}),c(()=>{ee()}),(e,n)=>{const r=l,v=u;return x(),p("div",q,[f("div",C,[f("div",z,[f("div",{class:m(["h-14 w-14 rounded-full flex items-center justify-center",W.value?"bg-emerald-50 text-emerald-500":X.value?"bg-amber-50 text-amber-500":"bg-blue-50 text-blue-500"])},[W.value?(x(),y(r,{key:0,size:"28"},{default:b(()=>[g(h(a))]),_:1})):X.value?(x(),y(r,{key:1,size:"28"},{default:b(()=>[g(h(t))]),_:1})):(x(),y(r,{key:2,class:"is-loading",size:"28"},{default:b(()=>[g(h(s))]),_:1}))],2)]),f("div",A,[f("h1",I,w(O.value),1),f("p",E,w(Q.value),1)]),f("div",M,[f("div",P,[n[0]||(n[0]=f("span",{class:"text-slate-400"},"订单号",-1)),f("span",R,w(N.value),1)]),F.value?(x(),p("div",U,[n[1]||(n[1]=f("span",{class:"text-slate-400"},"商品",-1)),f("span",B,w(F.value),1)])):_("",!0),L.value?(x(),p("div",D,[n[2]||(n[2]=f("span",{class:"text-slate-400"},"金额",-1)),f("span",G,"¥"+w(L.value),1)])):_("",!0)]),f("div",H,[g(v,{type:"primary",class:"!w-full !h-11",onClick:te,loading:S.value},{default:b(()=>[k(w(V.value?"重新拉起支付":"立即支付"),1)]),_:1},8,["loading"]),X.value||W.value?(x(),y(v,{key:0,class:"!w-full !h-11",onClick:ae},{default:b(()=>[...n[3]||(n[3]=[k(" 查看订单 ",-1)])]),_:1})):_("",!0)]),n[4]||(n[4]=f("p",{class:"text-xs text-slate-400 text-center mt-5 leading-5"}," 支付页会在新窗口或新标签打开，当前页面会持续检测支付状态。 ",-1))])])}}});export{J as default};
