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