| 1 |
- import{_ as e}from"./cwg-input.CxjZLKep.js";import{d as a,u as t,m as l,z as r,q as u,b as o,e as n,w as s,W as c,f as i,h as d,t as v,i as p,j as y,k as m,_ as f,r as b,K as g,c as h,o as N,a9 as C,L as T}from"./index-MhJ_BDJj.js";import{_,D as I}from"./DynamicForm.5jt2iwuz.js";import{a as k,u as w}from"./cwg-page-wrapper.DRov0aG9.js";import{_ as A}from"./lodash.CeXk6IkY.js";import{s as D}from"./toast.DxB6hwCE.js";import{u as M}from"./ucard.ClcgT_E0.js";import{u as S}from"./use-card-store.Dl89tBcq.js";import{u as V}from"./use-user-store.DiQ0s4y6.js";import"./cwg-date-picker.vue_vue_type_script_setup_true_lang.B41KTFBK.js";import"./crypt.CX7B3pNZ.js";import"./request.3HzWT8Rd.js";import"./config.BakzPYvd.js";const x=f(a({__name:"cwg-SuccessPrompt",props:{title:{default:"Retrive Successfully"},btnTitle:{default:"Done"},desc:{default:"You can now use your new password to make secure transactions."},btnClick:{type:Function,default:()=>{}},show:{type:Boolean}},setup(e){const{t:a}=t(),f=e;return(e,t)=>{const b=m,g=l(u("u-button"),r);return f.show?(o(),n(b,{key:0,class:"success-prompt-fullscreen"},{default:s((()=>[c("img",{class:"success-prompt-img",src:_,alt:"success"}),i(b,{class:"success-prompt-title"},{default:s((()=>[d(v(f.title),1)])),_:1}),i(b,{class:"success-prompt-desc"},{default:s((()=>[d(v(f.desc),1)])),_:1}),i(b,{class:"fixed-btn"},{default:s((()=>[i(b,{class:"cwg-button"},{default:s((()=>[i(g,{type:"primary",block:"",onClick:f.btnClick},{default:s((()=>[d(v(p(a)("Custom.Settings.Title")),1)])),_:1},8,["onClick"])])),_:1})])),_:1})])),_:1})):y("",!0)}}}),[["__scopeId","data-v-0b8da934"]]),B=f(a({__name:"global-order",setup(a){const c=S(),f=V(),_=b(!1),{t:B}=t(),$=w(),E=b();g((e=>{E.value=e.currency}));const F=b({transferAmount:null,payoutCurrency:void 0,payType:void 0,payMethod:void 0,deductionAccount:"",amount:void 0,receiver:void 0}),R=b({}),O=b(0),j=b({}),L=b(""),q=b([]),U=b([]),G=b([]),Q=b(!1),P=b([]),Y=b([]),z=b(),K=h((()=>q.value)),W=h((()=>P.value.map((e=>({text:e.payoutCurrency,value:e.payoutCurrency}))))),Z=h((()=>J.value.map((e=>({text:e.transferType,value:e.transferTypeId}))))),H=h((()=>X.value.map((e=>({text:e.payoutMethodValue,value:e.payoutMethodId}))))),J=h((()=>{var e;return(null==(e=P.value.find((e=>e.payoutCurrency===F.value.payoutCurrency)))?void 0:e.types)||[]})),X=h((()=>{var e;return(null==(e=J.value.find((e=>e.transferTypeId===F.value.payType)))?void 0:e.methods)||[]})),ee=h((()=>{if(!F.value.deductionAccount||!q.value.length)return 0;const e=q.value.find((e=>e.value===F.value.deductionAccount));return e&&Number(e.balance)||0}));h((()=>{const{payoutCurrency:e,payType:a,payMethod:t}=F.value;return!e||!a||!t}));const ae=h((()=>{const e=new Map;G.value.forEach((a=>{const t=a.receiverBankAccountNumber;if(!t)return;e.has(t)||e.set(t,{cardNumber:t,firstName:"",lastName:"",nativeFirstName:"",nativeLastName:""});const l=e.get(t);l.firstName||!a.receiverFirstName&&!a.receiverLastName||(l.firstName=a.receiverFirstName||"",l.lastName=a.receiverLastName||""),l.nativeFirstName||!a.receiverNativeFirstName&&!a.receiverNativeLastName||(l.nativeFirstName=a.receiverNativeFirstName||"",l.nativeLastName=a.receiverNativeLastName||"")}));return Array.from(e.values()).map((e=>{const a=`${e.firstName} ${e.lastName}`.trim(),t=`${e.nativeFirstName} ${e.nativeLastName}`.trim();let l="";return l=a&&t?`${a}(${t}) / ${e.cardNumber}`:a?`${a} / ${e.cardNumber}`:t?`${t} / ${e.cardNumber}`:e.cardNumber,{value:e.cardNumber,text:l}}))})),te=e=>{F.value.deductionAccount=e.value,e.value&&(Q.value=!0)},le=e=>{F.value.payoutCurrency=e.value,se(1)},re=e=>{F.value.payType=e.value,se(2)},ue=e=>{F.value.payMethod=e.value,se(3)},oe=e=>{if(F.value.amount=e.value,!e.value)return F.value.transferAmount=0;!async function(){O.value=0;const e=Number(F.value.amount);if(!e){const e=B("global.validator.v15");return void(L.value=e)}const{usedQuota:a,yearTransferAmountQuota:t,maxQuota:l,minQuota:r}=j.value;if(!/^(0|([1-9][0-9]*))(\.[\d]{1,2})?$/.test(e)){const e=B("global.validator.v15");return void(L.value=e)}if(e<r||e>l){const e=B("global.validator.v14",{minQuota:r,maxQuota:l});return void(L.value=e)}if(ee.value&&e>ee.value){const e=B("global.validator.balanceTip",{balance:ee.value});return void(L.value=e)}if(t){if(A.add(a,e)>t){const e=B("global.GlobalOrder.rateTip");return void(L.value=e)}}L.value="";const u=await M.globalExchangeRate({amount:e,uniqueId:R.value.uniqueId,country:R.value.fieldData.country,payoutCurrency:R.value.fieldData.payoutCurrency,transferTypeId:R.value.fieldData.transferTypeId,payoutMethodId:R.value.fieldData.payoutMethodId});200===u.code&&(R.value.exchangeRate=u.data,L.value="",O.value=ne(u.data.deductionFee,R.value.fieldData.exchangeRate),F.value.transferAmount=u.data.transferAmount)}()};const ne=(e,a)=>A.floor(A.divide(e,a),2),se=async(e,a)=>{var t;if(1===e||2===e){const e=J.value;1===e.length?F.value.payType=e[0].transferTypeId:F.value.payType=void 0;const a=(null==(t=e[0])?void 0:t.methods)||[];1===a.length?F.value.payMethod=a[0].payoutMethodId:F.value.payMethod=void 0}F.value.amount=void 0,O.value=void 0,ce(e,a)},ce=A.debounce((async(e,a)=>{const{payoutCurrency:t,payType:l,payMethod:r}=F.value;if(F.value.receiver&&!a&&1===e&&pe({value:F.value.receiver},!0),!t||!l||!r)return;const u=U.value.filter((e=>e.payoutCurrency===t&&e.transferTypeId===l&&e.payoutMethodId===r));if(u[0]){R.value={...R.value,fieldData:u[0]},ie(u[0]);try{const e=await M.globalExchangeRate({uniqueId:R.value.uniqueId,country:u[0].country,payoutCurrency:u[0].payoutCurrency,transferTypeId:u[0].transferTypeId,payoutMethodId:u[0].payoutMethodId});200===e.code&&(j.value=e.data)}catch(o){console.error("Error fetching exchange rate:",o)}}}),500),ie=async e=>{try{const a=await M.globalCurrenciesField(e);200===a.code&&ve(a.data||[])}catch(a){console.error("Error fetching currencies field:",a)}};function de(){_.value=!1,$.push({path:"/pages/wallet/index"})}const ve=async e=>{const a=(()=>{const{idType:e,idNumber:a}=R.value,t="PASSPORT"===e?"1":"GOVERNMENT_ISSUED_ID_CARD"===e?"2":"",l="PASSPORT"===e||"GOVERNMENT_ISSUED_ID_CARD"===e?a:"";return{senderFirstName:R.value.firstName,senderLastName:R.value.lastName,senderGender:R.value.gender,senderIdType:t,senderIdNumber:l,senderNationality:R.value.nationality,senderIdIssueCountry:R.value.senderIdIssueCountry,senderDateOfBirth:R.value.birthday,senderCountry:"CHN"==R.value.country||"CN"==R.value.country?"":R.value.country,senderState:R.value.senderState,senderRegion:R.value.senderRegion,senderCity:R.value.townEnName,senderAddress:R.value.address,senderZipCode:R.value.postCode,senderMobileAreaCode:R.value.areaCode,senderMobileNumber:R.value.mobile,senderEmail:R.value.email,senderBeneficiaryRelationship:"3",senderOccupation:R.value.occupation,transferType:R.value.fieldData.transferTypeId,PayoutMethod:R.value.fieldData.payoutMethodId}})(),t=await Promise.all(e.map((async e=>{var t,l;const{fieldName:r}=e,u=Object.keys(a).find((a=>a.toLowerCase()===e.fieldName.toLowerCase()));let o=u?a[u]:e.fixedValue;if("receiverBankCity"===e.fieldName)try{const a=await M.globalQueryBankCities({payoutCurrency:R.value.fieldData.payoutCurrency,country:R.value.fieldData.country});200===a.code&&Array.isArray(a.data)&&(e.availableDtos=a.data.map((e=>({value:e.bankCitiesValue,valueId:e.bankCitiesKey}))))}catch(n){console.error("Error loading receiverBankCity data:",n)}if("senderIdType"===e.fieldName&&R.value.fieldData&&"CNY"===R.value.fieldData.payoutCurrency&&Array.isArray(e.availableDtos)&&(e.availableDtos=e.availableDtos.filter((e=>"2"!==String(e.valueId))),"2"===String(o)&&(o=null),"2"===String(e.fixedValue)&&(e.fixedValue=null)),"senderIdNumber"===e.fieldName&&R.value.fieldData&&"CNY"===R.value.fieldData.payoutCurrency&&(o=""),"select"===e.fieldType){let a=F.value[r];const u=(null==(l=null==(t=e.availableDtos)?void 0:t.find((e=>e.valueId===a)))?void 0:l.value)??null;F.value[r+"Value"]=u??o}return{...e,fixedValue:o}})));Y.value=t},pe=(e,a=!1)=>{const t=e.value;if(!t)return;const l=G.value.filter((e=>e.receiverBankAccountNumber===t)),r=["receiverFirstName","receiverLastName","receiverNativeFirstName","receiverNativeLastName","receiverBankAccountNumber","receiverIdNumber","receiverIdType","receiverIdTypeValue","receiverMobileNumber","receiverMobileAreaCode","receiverBankId","receiverBankIdValue","receiverBankCity","receiverBankCityValue","receiverBankState","receiverBankStateValue","receiverBankAccountType","receiverBankAccountTypeValue","receiverBankBranchCode","receiverGender","receiverGenderValue","receiverDateOfBirth","receiverAddress","receiverZipCode","receiverCity","receiverRegion","receiverRegionValue","receiverState","receiverStateValue","receiverNationality","receiverNationalityValue","receiverOccupation","receiverOccupationValue"];if(!l.length)return void r.forEach((e=>{F.value[e]=void 0;const a=e+"Value";F.value[a]=void 0}));const{payoutCurrency:u,payType:o,payMethod:n}=F.value;let s=null;if(u&&o&&n&&(s=l.find((e=>e.payoutCurrency===u&&String(e.payoutMethod)===String(n)&&String(e.transferType)===String(o)))),s)a||se(3,!0);else{if(a)return void r.forEach((e=>{F.value[e]=void 0;const a=e+"Value";F.value[a]=void 0}));s=l[0],s&&(a||(F.value.payoutCurrency=s.payoutCurrency,F.value.payType=String(s.transferType),F.value.payMethod=String(s.payoutMethod),se(3,!0)))}s&&r.forEach((e=>{F.value[e]=s[e]}))},ye=async()=>{if(await z.value.validateForm())try{if(!F.value.amount)return void D(B("global.validator.v15"));if(L.value)return void D(L.value);if(!F.value.deductionAccount)return void D(B("placeholder.choose"));const[e,a]=F.value.deductionAccount.split(","),t={};Y.value.map((e=>({fieldName:e.fieldName,fieldType:e.fieldType}))).forEach((e=>{if(t[e.fieldName]=F.value[e.fieldName],"select"===e.fieldType){const a=e.fieldName+"Value";t[a]=F.value[a]}}));const l={...t,cardNumber:e,amount:F.value.amount,deductionAccountType:a,uniqueId:R.value.uniqueId,...R.value.exchangeRate},r=await M.globalOrdersCreate({...l});200===r.code?_.value=!0:D(r.msg)}catch(e){console.error("Error submitting order:",e),D(e.message||B("common.error"))}};return N((async()=>{R.value=f.userInfo,await(async()=>{try{const e=await M.cardAccountDropdown();200===e.code?q.value=e.data.map((e=>("1"===e.type?e.text=`${B("global.GlobalOrder.cardNo")} - ${e.cardNumber} ${B("global.GlobalOrder.bal")}: ${e.balance}`:e.text=`${B("global.GlobalOrder.bagBal")}: ${e.balance}`,e.value=`${e.cardNumber},${e.type}`,e.disabled=0===e.balance,e))):D(e.msg)}catch(e){console.error("Error fetching account dropdown:",e),D(B("common.error"))}})(),(()=>{const e=c.currencyList;U.value=e||[];const a=A.cloneDeep(e),t=[...new Set(a.map((e=>e.payoutCurrency)))].map((e=>{let t=a.filter((a=>e===a.payoutCurrency));const l=[...new Set(t.map((e=>e.transferTypeValue)))].map((e=>{const a=t.find((a=>a.transferTypeValue===e));let l=t.filter((a=>a.transferTypeValue===e)).map((e=>({payoutMethodId:e.payoutMethodId,payoutMethodValue:e.payoutMethodValue})));return{transferType:e,transferTypeId:a.transferTypeId,methods:l}}));return{payoutCurrency:e,types:l}}));P.value=t,F.value.payoutCurrency=E.value})(),(async({uniqueId:e})=>{try{const a=await M.globalReceiverUserList({uniqueId:e});200===a.code?G.value=a.data:D(a.msg)}catch(a){console.error("Error fetching receiver list:",a),D(B("common.error"))}})(R.value)})),(a,t)=>{const c=l(u("cwg-input"),e),f=m,b=T,g=l(u("u-button"),r),h=l(u("cwg-SuccessPrompt"),x),N=l(u("cwg-page-wrapper"),k);return o(),n(N,null,{default:s((()=>[i(f,{class:"page"},{default:s((()=>[i(I,{ref_key:"globalFormRef",ref:z,"global-form":F.value,fields:Y.value,step2:Q.value,type:"1"},C({top:s((()=>[i(c,{label:p(B)("global.t2"),value:F.value.deductionAccount,"onUpdate:value":t[0]||(t[0]=e=>F.value.deductionAccount=e),fkey:"deductionAccount",type:"select",columns:K.value,onChange:te,placeholder:p(B)("placeholder.choose")},null,8,["label","value","columns","placeholder"])])),bottom:s((()=>[i(f,{class:"form-section"},{default:s((()=>[i(f,{class:"form-item"},{default:s((()=>[i(c,{label:p(B)("global.t6"),value:F.value.receiver,"onUpdate:value":t[1]||(t[1]=e=>F.value.receiver=e),fkey:"receiver",type:"select",columns:ae.value,onChange:pe,placeholder:p(B)("global.t7")},null,8,["label","value","columns","placeholder"])])),_:1}),i(f,{class:"form-item"},{default:s((()=>[i(c,{label:p(B)("global.p1"),value:F.value.payoutCurrency,"onUpdate:value":t[2]||(t[2]=e=>F.value.payoutCurrency=e),fkey:"payoutCurrency",type:"select",columns:W.value,onChange:le,disabled:!P.value.length,placeholder:p(B)("global.p1")},null,8,["label","value","columns","disabled","placeholder"])])),_:1}),i(f,{class:"form-item"},{default:s((()=>[i(c,{label:p(B)("global.p2"),value:F.value.payType,"onUpdate:value":t[3]||(t[3]=e=>F.value.payType=e),fkey:"payType",type:"select",columns:Z.value,onChange:re,disabled:!F.value.payoutCurrency||!J.value.length,placeholder:p(B)("global.p2")},null,8,["label","value","columns","disabled","placeholder"])])),_:1}),H.value.length?(o(),n(f,{key:0,class:"form-item"},{default:s((()=>[i(c,{label:p(B)("global.p3"),value:F.value.payMethod,"onUpdate:value":t[4]||(t[4]=e=>F.value.payMethod=e),fkey:"payMethod",type:"select",columns:H.value,onChange:ue,disabled:!F.value.payType||!X.value.length,placeholder:p(B)("global.p3")},null,8,["label","value","columns","disabled","placeholder"])])),_:1})):y("",!0)])),_:1})])),tips:s((()=>[i(f,{class:"tips-section"},{default:s((()=>[i(f,{class:"tips"},{default:s((()=>[i(b,{class:"title"},{default:s((()=>[d(v(p(B)("global.Tips")),1)])),_:1}),i(b,null,{default:s((()=>[d(v(p(B)("global.Tips1")),1)])),_:1}),i(b,null,{default:s((()=>[d(v(p(B)("global.Tips2")),1)])),_:1}),i(b,null,{default:s((()=>[d(v(p(B)("global.Tips3")),1)])),_:1}),i(b,null,{default:s((()=>[d(v(p(B)("global.Tips4")),1)])),_:1})])),_:1})])),_:1})])),submit:s((()=>[i(f,{class:"submit-section cwg-button"},{default:s((()=>[i(g,{type:"primary",onClick:ye,class:"submit-btn prev-btn"},{default:s((()=>[i(b,null,{default:s((()=>[d(v(p(B)("Btn.Submit")),1)])),_:1})])),_:1})])),_:1})])),_:2},[Y.value.length?{name:"transferAmount",fn:s((()=>[i(f,{class:"form-section"},{default:s((()=>[i(f,{class:"form-item"},{default:s((()=>[i(b,{class:"form-label"},{default:s((()=>[d(v(p(B)("card.Form.f55"))+" ",1),j.value&&j.value.maxQuota?(o(),n(b,{key:0,class:"quota-tip"},{default:s((()=>[d(" ("+v(p(B)("global.GlobalOrder.quoteTip"))+" "+v(j.value.minQuota)+" - "+v(j.value.maxQuota)+" USD) ",1)])),_:1})):y("",!0)])),_:1}),i(c,{value:F.value.amount,"onUpdate:value":t[5]||(t[5]=e=>F.value.amount=e),required:!0,fkey:"amount",type:"number",placeholder:p(B)("global.placeholder.p4"),onChange:oe},null,8,["value","placeholder"]),L.value?(o(),n(b,{key:0,class:"form-error"},{default:s((()=>[d(v(L.value),1)])),_:1})):y("",!0),O.value?(o(),n(b,{key:1,class:"fee-text"},{default:s((()=>[d(v(`${p(B)("global.GlobalOrder.fee")}:${O.value}`)+" USD ",1)])),_:1})):y("",!0)])),_:1}),i(f,{class:"form-item"},{default:s((()=>[i(c,{label:p(B)("global.fieldName.transferAmount.fieldTitle")+" ("+F.value.payoutCurrency+")",required:!0,value:F.value.transferAmount,"onUpdate:value":t[6]||(t[6]=e=>F.value.transferAmount=e),fkey:"transferAmount",disabled:!0,placeholder:p(B)("global.fieldName.transferAmount.fieldDescription")},null,8,["label","value","placeholder"])])),_:1})])),_:1})])),key:"0"}:void 0]),1032,["global-form","fields","step2"])])),_:1}),i(h,{show:_.value,"onUpdate:show":t[7]||(t[7]=e=>_.value=e),title:p(B)("global.title1"),desc:p(B)("Custom.Withdraw.Des1"),"btn-click":de},null,8,["show","title","desc"])])),_:1})}}}),[["__scopeId","data-v-4665d02e"]]);export{B as default};
|