1import{d as U,r as c,c as k,w as V,o as Q,X,a as $,H as G,J,B as p,z as f,D as I,G as i,u as l,Z,n as j,C as d}from"./vendor-vue-CNokyTVe.js";import{_ as K}from"./AppLayout.vue_vue_type_script_setup_true_lang-DA3QqGQe.js";import{u as Y}from"./payment-DQlYKzoA.js";import{p as ee}from"./payment-Cr-0xxFS.js";import{a as te}from"./apiError-BcAuv_LF.js";import{a as ae}from"./index-DP2Z749b.js";import{i as re,a as ne}from"./providerConfig-CHSBMM6y.js";import{b as oe}from"./vendor-misc-CSmvsGIg.js";import{a as se,w as le}from"./wxpay-UHDvuORB.js";import{u as ue}from"./vendor-i18n-CJe1LeE7.js";import"./AppHeader.vue_vue_type_style_index_0_scoped_e9be4349_lang-xG_yv2rf.js";import"./useClipboard-CR8lmECi.js";import"./LocaleSwitcher-pcuQ_98X.js";/* empty css */const ie={class:"mx-auto flex max-w-md flex-col items-center space-y-6 py-8"},ce={class:"text-xl font-semibold text-gray-900 dark:text-white"},pe={key:0,class:"rounded-2xl bg-white p-6 shadow-lg dark:bg-dark-800"},me={key:1,class:"text-center text-sm text-gray-500 dark:text-gray-400"},ye={key:2,class:"text-center"},de={class:"text-lg font-medium text-red-500"},ve={key:3,class:"text-center"},fe={class:"text-sm text-gray-500 dark:text-gray-400"},ge={class:"mt-1 text-2xl font-bold tabular-nums text-gray-900 dark:text-white"},xe={class:"mt-2 text-sm text-gray-400 dark:text-gray-500"},he=["href"],_e=["disabled"],Le=U({__name:"PaymentQRCodeView",setup(we){const{t:a}=ue(),g=X(),C=Z(),M=Y(),B=ae(),q=c(null),u=c(""),T=c(""),m=c(0),v=c(0),y=c(!1),x=c(!1),z=c("");let h=null,b=null;const L=k(()=>{const e=Math.floor(v.value/60),n=v.value%60;return e.toString().padStart(2,"0")+":"+n.toString().padStart(2,"0")}),A=k(()=>re(z.value)),D=k(()=>ne(z.value)),W=k(()=>A.value?a("payment.qr.scanAlipay"):D.value?a("payment.qr.scanWxpay"):a("payment.qr.scanToPay")),P=k(()=>A.value?a("payment.qr.scanAlipayHint"):D.value?a("payment.qr.scanWxpayHint"):"");function N(){return A.value?se:D.value?le:null}async function F(){if(await j(),!q.value||!u.value)return;const e=N();if(await oe.toCanvas(q.value,u.value,{width:256,margin:2,errorCorrectionLevel:e?"M":"L"}),!e)return;const n=q.value,r=n.getContext("2d");if(!r)return;const w=new Image;w.src=e,w.onload=()=>{const o=(n.width-48)/2,s=(n.height-48)/2,t=5;r.fillStyle="#FFFFFF",r.beginPath();const S=6;r.moveTo(o-t+S,s-t),r.arcTo(o+48+t,s-t,o+48+t,s+48+t,S),r.arcTo(o+48+t,s+48+t,o-t,s+48+t,S),r.arcTo(o-t,s+48+t,o-t,s-t,S),r.arcTo(o-t,s-t,o+48+t,s-t,S),r.fill(),r.drawImage(w,o,s,48,48)}}let E=!1;async function R(){if(m.value&&!E){E=!0;try{const e=await M.pollOrderStatus(m.value);if(!e||!h)return;e.status==="COMPLETED"||e.status==="PAID"?(_(),C.push({path:"/payment/result",query:{order_id:String(m.value),status:"success"}})):(e.status==="EXPIRED"||e.status==="CANCELLED"||e.status==="FAILED")&&(_(),y.value=!0)}finally{E=!1}}}function H(e){if(v.value=Math.max(0,e),v.value<=0){y.value=!0;return}b=setInterval(()=>{v.value--,v.value<=0&&(y.value=!0,_())},1e3)}async function O(){if(!(!m.value||x.value)){x.value=!0;try{await ee.cancelOrder(m.value),_(),C.push("/purchase")}catch(e){B.showError(te(e,a,"payment.errors",a("common.error")))}finally{x.value=!1}}}function _(){h&&(clearInterval(h),h=null),b&&(clearInterval(b),b=null)}return V(u,()=>F()),Q(()=>{m.value=Number(g.query.order_id)||0,u.value=String(g.query.qr||""),T.value=String(g.query.pay_url||""),z.value=String(g.query.payment_type||"");const e=String(g.query.expires_at||"");let n=30*60;if(e){const r=new Date(e),w=new Date;n=Math.floor((r.getTime()-w.getTime())/1e3)}H(n),h=setInterval(R,3e3),F()}),$(()=>_()),(e,n)=>(d(),G(K,null,{default:J(()=>[p("div",ie,[p("h2",ce,i(u.value?W.value:l(a)("payment.qr.payInNewWindow")),1),u.value?(d(),f("div",pe,[p("canvas",{ref_key:"qrCanvas",ref:q,class:"mx-auto"},null,512)])):I("",!0),u.value&&!y.value&&P.value?(d(),f("p",me,i(P.value),1)):I("",!0),y.value?(d(),f("div",ye,[p("p",de,i(l(a)("payment.qr.expired")),1),p("button",{class:"btn btn-primary mt-4",onClick:n[0]||(n[0]=r=>l(C).push("/purchase"))},i(l(a)("payment.result.backToRecharge")),1)])):(d(),f("div",ve,[p("p",fe,i(u.value?l(a)("payment.qr.expires
1In"):l(a)("payment.qr.payInNewWindowHint")),1),p("p",ge,i(L.value),1),p("p",xe,i(l(a)("payment.qr.waitingPayment")),1)])),T.value&&!u.value&&!y.value?(d(),f("a",{key:4,href:T.value,target:"_blank",rel:"noopener noreferrer",class:"btn btn-primary w-full py-3"},i(l(a)("payment.qr.openPayWindow")),9,he)):I("",!0),!y.value&&m.value?(d(),f("button",{key:5,class:"btn btn-secondary w-full",disabled:x.value,onClick:O},i(x.value?l(a)("common.processing"):l(a)("payment.qr.cancelOrder")),9,_e)):I("",!0)])]),_:1}))}});export{Le as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.