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,p as s,q as u,m as n}from"./vendor-element-CbJWrKZ5.js";import{q as r,r as v,R as i,bz as o,U as d,t as c,A as p,G as x,D as m,E as f,K as y,H as b,M as g,u as h,J as w,by as _,v as k}from"./vendor-core-DQkwEQyE.js";import{c as j}from"./wallet-on_4kG9q.js";import"./index-DITu3gCO.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"},P={class:"rounded-2xl bg-slate-50 px-4 py-3 text-sm text-slate-600 space-y-2 mb-6"},R={class:"flex justify-between gap-3"},U={class:"font-mono text-slate-700 break-all text-right"},D={key:0,class:"flex justify-between gap-3"},G={class:"text-slate-700 text-right"},H={key:1,class:"flex justify-between gap-3"},J={class:"text-slate-700"},K={class:"space-y-3"},M=r({__name:"mobile-launch",setup(r){const M=_(),T=o(),B=v(""),F=v(""),L=v(""),N=v(""),O=v("正在准备支付"),Q=v("页面将拉起支付窗口，并在此页面持续检测支付结果。"),S=v(!1),V=v(!1),W=v(!1),X=v(!1);let Y=null,Z=0;const $=e=>Array.isArray(e)?e[0]||"":"string"==typeof e?e:"",ee=()=>{Y&&(clearInterval(Y),Y=null)},ae=()=>{B.value&&M.replace({path:"/order/search",query:{keyword:B.value}})},le=()=>e(null,null,function*(){var e,a;if(B.value&&!W.value)try{Z+=1;const l=yield j(B.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(F.value){S.value=!0;try{if(!window.open(F.value,"_blank"))return void(window.location.href=F.value);V.value=!0,O.value="请在新窗口完成支付",Q.value="支付完成后无需返回首页，本页会自动检测并跳转订单页。"}finally{S.value=!1}}else l.error("缺少支付链接")};return i(()=>{if(B.value=$(T.query.order_no),F.value=decodeURIComponent($(T.query.pay_url)),L.value=$(T.query.product_name),N.value=$(T.query.amount),!B.value||!F.value)return O.value="参数错误",void(Q.value="缺少订单号或支付链接，无法继续支付。");te(),e(null,null,function*(){ee(),Z=0,yield le(),W.value||(Y=setInterval(le,2e3))})}),d(()=>{ee()}),(e,l)=>{const r=t,v=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",W.value?"bg-emerald-50 text-emerald-500":X.value?"bg-amber-50 text-amber-500":"bg-blue-50 text-blue-500"])},[W.value?(k(),m(r,{key:0,size:"28"},{default:f(()=>[g(h(s))]),_:1})):X.value?(k(),m(r,{key:1,size:"28"},{default:f(()=>[g(h(u))]),_:1})):(k(),m(r,{key:2,class:"is-loading",size:"28"},{default:f(()=>[g(h(n))]),_:1}))],2)]),p("div",C,[p("h1",I,y(O.value),1),p("p",E,y(Q.value),1)]),p("div",P,[p("div",R,[l[0]||(l[0]=p("span",{class:"text-slate-400"},"订单号",-1)),p("span",U,y(B.value),1)]),L.value?(k(),c("div",D,[l[1]||(l[1]=p("span",{class:"text-slate-400"},"商品",-1)),p("span",G,y(L.value),1)])):b("",!0),N.value?(k(),c("div",H,[l[2]||(l[2]=p("span",{class:"text-slate-400"},"金额",-1)),p("span",J,"¥"+y(N.value),1)])):b("",!0)]),p("div",K,[g(v,{type:"primary",class:"!w-full !h-11",onClick:te,loading:S.value},{default:f(()=>[w(y(V.value?"重新拉起支付":"立即支付"),1)]),_:1},8,["loading"]),X.value||W.value?(k(),m(v,{key:0,class:"!w-full !h-11",onClick:ae},{default:f(()=>[...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{M as default};
