chatapp-h5/h5/js/payWay-BogP6dW2-1776148658686.js
2026-04-14 17:58:21 +08:00

3 lines
8.9 KiB
JavaScript

import{_ as W}from"./help-BgsLqEJs-1776148658686.js";import{_ as H}from"./coin-Dqu2_ND9-1776148658686.js";import{W as q,L as O,_ as X,r as y,aW as z,o as M,c as m,b as o,l as V,t as d,q as _,F as A,x as L,v as B,J,u as K,j as g}from"./index-CIAVq8iD-1776148658686.js";import{c as Q}from"./appConnector-B5Pbaops-1776148658686.js";import{b as Y}from"./toast-aIWCznBB-1776148658686.js";import{h as k}from"./imageHandler-DstQGL3Z-1776148658686.js";import{p as Z}from"./imagePreloader-C_QM-Nv8-1776148658686.js";import{u as ee}from"./country-DywnO8EI-1776148658686.js";import{u as te}from"./rechargeTarget-IksBf2RB-1776148658686.js";import{g as oe}from"./imagePaths-Bi1Bwe4Z-1776148658686.js";import{d as re}from"./userInfo-gLO2xl8i-1776148658686.js";import{G as ne}from"./GeneralHeader-ClI1i1Ud-1776148658686.js";function E(e,t){if(!e&&!t)return{};if(!e)return t&&isObject(t)?deepClone(t):{};if(!t)return e&&isObject(e)?deepClone(e):{};const n=deepClone(e);for(const r in t){const c=n[r],p=t[r];if(!isObject(c)||!isObject(p)){n[r]=deepClone(t[r]);continue}n[r]=E(c,p)}return n}const $={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",dev:"checkout-dev.airwallex.com",local:"localhost:3000"},ie=e=>`https://${$[e]||$.prod}`,v="/assets/elements.bundle.min.js?version=1.160.0",ae=e=>{const t=document.createElement("script");t.src=`${e}${v}`,t.crossOrigin="anonymous";const n=document.head||document.body;if(!n)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return n.appendChild(t),t},se=async e=>{if(typeof window>"u")return null;if(window.Airwallex)return window.Airwallex;let t=0;const n=async()=>{const r=document.querySelector(`script[src="${v}"], script[src="${v}/"]`)||ae(ie(e?.env||"prod"));return new Promise(((c,p)=>{r.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),c(window.Airwallex)):p(new Error("Failed to load Airwallex on load event"))})),r.addEventListener("error",(()=>{p(new Error("Failed to load Airwallex scripts")),r.remove&&r.remove()}))}))};for(;t<3;)try{return await n()}catch{t++,await new Promise((c=>window.setTimeout(c,500)))}return null},ce=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")};var le={};function de(){const e=le.ENV;return e==="staging"?"staging":e==="production"?"prod":"demo"}function pe({result:e,props:t,callback:n}){const r=de();se({env:r}).then(()=>{n({code:"INIT-LOAD",msg:"init load success."});const c=E({env:r,mode:"payment",currency:e.currency,intent_id:e.expand.id,client_secret:e.expand.client_secret,methods:[e.factoryChannelCode],recurringOptions:{card:{next_triggered_by:"customer",merchant_trigger_reason:"unscheduled",currency:e.currency}},theme:{fonts:[{src:"https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2",family:"AxLLCircular",weight:400}]}},t);ce(c)}).catch(c=>{console.error(c),n({code:"FAIL",msg:"init fail!!!"})})}const ue=async e=>{try{return await O(`/order/web/pay/application/${e}`)}catch(t){throw console.error("Failed to fetch get pay application:",t),console.error("error:"+t.response.errorMsg),t}},ye=async e=>{try{return await O(`/order/web/pay/commodity?applicationId=${e.applicationId}&payCountryId=${e.payCountryId}&regionId=${e.regionId}&type=${e.type}`)}catch(t){throw console.error("Failed to fetch get app commodity card:",t),console.error("error:"+t.response.errorMsg),t}},me=async e=>{try{return await q("/order/web/pay/recharge",e)}catch(t){throw console.error("Failed to fetch get pay application:",t),t}},ge={class:"fullPage"},fe={class:"bg"},he={style:{padding:"10px",display:"flex","flex-direction":"column",gap:"8px"}},we=["src"],_e={style:{display:"flex","flex-direction":"column",gap:"8px"}},xe={style:{display:"flex","justify-content":"space-between","align-items":"center"}},ve={style:{"font-weight":"600"}},be={style:{"min-width":"0",padding:"10px","border-radius":"8px","box-shadow":"0 0 4px 0 #00000050",display:"flex","align-items":"center",gap:"4px"}},Ce=["src"],Ie={style:{flex:"1","min-width":"0"}},Ae={style:{display:"flex","align-items":"center",gap:"4px"}},Le={style:{"font-weight":"700","min-width":"0",overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap"}},ke={style:{"font-weight":"500",color:"rgba(0, 0, 0, 0.4)"}},$e={style:{display:"flex","flex-direction":"column",gap:"8px"}},Oe={style:{width:"100%",display:"flex","justify-content":"space-between"}},Ee={style:{"font-weight":"600"}},Fe=["src"],je={style:{"font-size":"0.8em","font-weight":"500",color:"#fff"}},Re={key:0,style:{display:"flex","flex-direction":"column",gap:"12px"}},Ue={style:{display:"flex","align-items":"center",gap:"8px"}},Pe=["src"],Te={style:{"font-weight":"500"}},Ge={style:{display:"grid","grid-template-columns":"repeat(3, 1fr)",gap:"10px"}},Se=["onClick"],De={style:{"font-size":"0.9em","font-weight":"500",color:"#373232"}},Ne={style:{"font-size":"1em","font-weight":"500",color:"#131111"}},We={__name:"payWay",setup(e){const t=i=>oe("Recharge/",i),n=ee(),r=te(),c=J(),p=K(),f=y("1963531459019739137"),b=y(""),C=y(c.params.type||""),{selectedCountry:h}=z(n),l=y(r.targetUser),x=y([]),I=y([]),F=()=>{p.push({path:"/map"})},j=()=>{p.push({path:"/recharge-guide"})},R=async(i,a)=>{let s={applicationId:f.value,payCountryId:h.value.id,goodsId:a.id,userId:l.value.id,channelCode:i.channel.channelCode};const u=await me(s);if(!u.body){console.log("Payment not available, please contact administrator!!!");return}u.body.factoryCode==="AIRWALLEX"&&(r.clearTargetUser(),pe({result:u.body,props:{logoUrl:that.sysOriginLog,successUrl:`${location.origin}/#/pay-result?redirect=recharge&appType=${C.value}&appId=${f.value}&appStatus=0`,failUrl:`${location.origin}/#/pay-result?redirect=recharge&appType=${C.value}&appId=${f.value}&appStatus=1`},callback:w=>{if(w.code==="FAIL"){Y("init fail!!!");return}}})),u.body.requestUrl&&(location.href=decodeURIComponent(u.body.requestUrl))},U=async()=>(await ue(f.value)).body.appCode,P=async()=>{let i={applicationId:f.value,payCountryId:h.value.id,regionId:b.value,type:l.value.isSuperFreightAgent?"FREIGHT_GOLD_SUPER":l.value.isFreightAgent?"FREIGHT_GOLD":"GOLD"};const a=await ye(i);I.value=a.body.commodity,a.body.channels&&(x.value=a.body.channels)},T=async()=>{let i=await U();if(i){let a={sysOrigin:i,account:l.value.account,type:l.value.isSuperFreightAgent?"FREIGHT_GOLD_SUPER":l.value.isFreightAgent?"FREIGHT_GOLD":"GOLD"};const s=await re(a);s.body&&s.body.regionId&&s.body.countryList.length!=0&&(n.setCountryList(s.body.countryList),JSON.stringify(h.value)=="{}"&&n.setCountry(s.body.countryList[0]),b.value=s.body.regionId)}},G=async()=>{await T(),await P()},S=()=>{Q(async()=>{await G()})},D=()=>{const i=[t("headImg")];Z(i)};return M(async()=>{D(),S()}),(i,a)=>(g(),m("div",ge,[o("div",fe,[V(ne,{showLanguageList:!0,title:i.$t("recharge"),color:"black",style:{"box-shadow":"0 0 10px rgba(0, 0, 0, 0.1)","z-index":"999"}},null,8,["title"]),o("div",he,[o("img",{src:t("headImg"),alt:"",style:{width:"100%"}},null,8,we),o("div",_e,[o("div",xe,[o("div",ve,d(i.$t("my_information")),1),o("div",{style:{"min-width":"0",width:"1.5em"},onClick:j},[...a[1]||(a[1]=[o("img",{src:W,alt:"",style:{display:"block",width:"100%","object-fit":"cover"}},null,-1)])])]),o("div",be,[o("img",{src:l.value.userAvatar||"",alt:"",style:{width:"3em","min-width":"0","border-radius":"50%","aspect-ratio":"1/1","object-fit":"cover"},onError:a[0]||(a[0]=(...s)=>_(k)&&_(k)(...s))},null,40,Ce),o("div",Ie,[o("div",Ae,[o("div",Le,d(l.value.userNickname),1)]),o("div",ke,d(i.$t("user_id_prefix"))+" "+d(l.value.account),1)])])]),o("div",$e,[o("div",Oe,[o("div",Ee,d(i.$t("select_a_country")),1),o("div",{style:{padding:"4px","border-radius":"4px",background:"#7726ff","box-shadow":`0 1px 18px 2px #f2d9ff inset,
0 1px 4px 2px #f2d9ff inset`,display:"flex","justify-content":"center","align-items":"center",gap:"4px"},onClick:F},[o("img",{src:_(h).country?.nationalFlag,alt:"",style:{display:"block",width:"1.5em","object-fit":"contain"}},null,8,Fe),o("div",je,d(_(h).countryName),1)])]),x.value.length!=0?(g(),m("div",Re,[(g(!0),m(A,null,L(x.value,(s,u)=>(g(),m("div",{key:u,style:{padding:"10px","border-radius":"8px","box-shadow":"0 0 4px 0 #00000050",display:"flex","flex-direction":"column",gap:"8px"}},[o("div",Ue,[o("img",{src:s.channel.channelIcon,style:{display:"block",width:"2.5em"}},null,8,Pe),o("div",Te,d(s.channel.channelName),1)]),o("div",Ge,[(g(!0),m(A,null,L(I.value,(w,N)=>(g(),m("div",{style:{padding:"8px",width:"100%","border-radius":"8px","box-shadow":"0 0 4px 0 #00000050",display:"flex","flex-direction":"column","align-items":"center",gap:"4px"},key:N,onClick:He=>R(s,w)},[a[2]||(a[2]=o("img",{src:H,alt:"",style:{display:"block",width:"3em","object-fit":"cover"}},null,-1)),o("div",De,d(w.content),1),o("div",Ne," $"+d(w.amountUsd),1)],8,Se))),128))])]))),128))])):B("",!0)])])])]))}},tt=X(We,[["__scopeId","data-v-7045048d"]]);export{tt as default};