2 lines
5.4 KiB
JavaScript
2 lines
5.4 KiB
JavaScript
import{_ as S,k as F,I as $,o as z,c as u,l as _,q as i,b as t,t as n,m as h,aP as D,ap as I,r as f,u as N,j as p,F as R,x as M,Q as P,y as V,v as q,a9 as A,aQ as H}from"./index-CIAVq8iD-1776148658686.js";import{_ as Q}from"./arrow-Cf0JWzXk-1776148658686.js";import{_ as T}from"./dollar-B_xazKD_-1776148658686.js";import{G as O}from"./GeneralHeader-ClI1i1Ud-1776148658686.js";import{b as U,a as d,s as W}from"./toast-aIWCznBB-1776148658686.js";import{m as J}from"./MaskLayer-CMaJd7Gb-1776148658686.js";import{G as C}from"./GradientBorder-CfwSeIMB-1776148658686.js";const K={class:"exchange-gold-coins"},X={class:"content"},Y={style:{display:"flex","justify-content":"space-between","align-items":"center","margin-bottom":"10px"}},Z={style:{"font-weight":"600"}},ee={style:{color:"rgba(0, 0, 0, 0.4)"}},te={style:{padding:"16px"}},se={style:{"font-weight":"510","font-size":"1em"}},ae={key:0,class:"loading-text"},oe={key:1,style:{"font-weight":"700",color:"#333","font-size":"1.1em"}},ne={style:{"font-weight":"600","margin-bottom":"10px"}},ie={style:{padding:"16px"}},le={style:{display:"grid","grid-template-columns":"repeat(3, 1fr)",gap:"12px"}},re=["onClick"],ce={style:{"font-weight":"500",color:"#131111"}},de={style:{display:"flex","justify-content":"center","margin-top":"10px"}},ue=["disabled"],fe={style:{"font-size":"1.2em",color:"rgba(0, 0, 0, 0.8)","font-weight":"800"}},pe={style:{color:"rgba(0, 0, 0, 0.4)","font-weight":"600","font-size":"1em"}},ge={style:{width:"80%",display:"flex","justify-content":"space-between","align-items":"center"}},me={__name:"ExchangeGoldCoins",setup(_e){const{t:s,locale:x}=F(),v=N();x.value&&$(x.value);const c=f(!1),g=f("0"),l=f(null),y=f(!1),b=f(!1),m=f(""),w=A([{id:1,amount:10500,price:1},{id:2,amount:52500,price:5},{id:3,amount:105e3,price:10},{id:4,amount:525e3,price:50},{id:5,amount:105e4,price:100},{id:6,amount:21e5,price:200}]),k=async()=>{y.value=!0;try{const e=await I();e.status&&typeof e.body=="number"?g.value=e.body.toFixed(2):g.value="0.00"}catch(e){console.error("Failed to fetch bank balance:",e),g.value="0.00",d(s("failed_to_load_balance"))}finally{y.value=!1}},B=async()=>{b.value=!0;try{const e=await D();e.status&&e.body?(m.value=e.body.role||"",console.debug("用户角色:",m.value)):(m.value="",v.back())}catch(e){e.errorCode===1083?U(s("exchange_not_available")):e.message&&e.message.includes("HTTP Error: 406")?d(s("request_not_acceptable")):d(s("failed_to_load_user_info")),v.back(),m.value=""}finally{b.value=!1}},E=async()=>{if(c.value=!1,!l.value){d(s("please_select_coin_amount"));return}const e=w.find(r=>r.id===l.value),a=e.price,o=parseFloat(g.value);if(isNaN(o)||o<a){d(s("insufficient_balance",{balance:o.toFixed(2),price:a}));return}try{const r=await H({coinId:e.id,amount:e.price,price:e.price});if(r.status===!0||r.errorCode===0)W(s("exchange_success",{price:e.price})),await k(),l.value=null;else{const G=r.message||s("exchange_failed");d(G)}}catch(r){console.error("Exchange error:",r),d(s("exchange_error_occurred"))}},L=()=>{v.push("/information-details")},j=e=>{l.value===e.id?l.value=null:l.value=e.id};return z(()=>{B(),k(),console.log("document.documentElement.getAttribute('dir') === 'rtl'",document.documentElement.getAttribute("dir")==="rtl")}),(e,a)=>(p(),u("div",K,[_(O,{showLanguageList:!0,title:i(s)("exchange_gold_coins"),color:"black"},null,8,["title"]),t("div",X,[t("div",null,[t("div",Y,[t("div",Z,n(i(s)("information")),1),t("div",{style:{display:"flex","align-items":"center"},onClick:L},[t("div",ee,n(i(s)("details")),1),a[5]||(a[5]=t("img",{src:Q,alt:"",class:"flipImg"},null,-1))])]),_(C,{style:{"margin-bottom":"12px"}},{default:h(()=>[t("div",te,[t("span",se,n(i(s)("available_salaries")),1),y.value?(p(),u("span",ae,n(i(s)("loading"))+"...",1)):(p(),u("span",oe,n(g.value),1))])]),_:1})]),t("div",null,[t("div",ne,n(i(s)("exchange_gold_coins")),1),_(C,{style:{"margin-bottom":"12px"}},{default:h(()=>[t("div",ie,[t("div",le,[(p(!0),u(R,null,M(w,o=>(p(),u("div",{key:o.id,onClick:r=>j(o),class:P(["coin-item",{selected:l.value===o.id}])},[a[6]||(a[6]=t("img",{src:T,alt:"",style:{width:"40%"}},null,-1)),t("div",ce,"$"+n(o.price),1)],10,re))),128))])])]),_:1}),t("div",de,[t("button",{class:"exchange-btn",onClick:a[0]||(a[0]=o=>c.value=!0),disabled:!l.value},n(i(s)("exchange")),9,ue)])])]),_(J,{maskLayerShow:c.value,onClick:a[4]||(a[4]=o=>c.value=!1)},{default:h(()=>[c.value?(p(),u("div",{key:0,style:{width:"100vw",height:"100vh",display:"flex","justify-content":"center","align-items":"center"},onClick:a[3]||(a[3]=o=>c.value=!1)},[t("div",{style:{width:"80%","border-radius":"12px",background:"#fff",padding:"12px",display:"flex","flex-direction":"column","align-items":"center",gap:"3vw"},onClick:a[2]||(a[2]=V(()=>{},["stop"]))},[t("div",fe,n(i(s)("tips")),1),t("div",pe,n(i(s)("confirm_exchange")),1),t("div",ge,[t("div",{style:{display:"flex","justify-content":"center","align-items":"center",background:"#fff","border-radius":"70px",border:"1px solid #ffb805",color:"#ff9500","font-weight":"800",padding:"8px 12px",width:"45%"},onClick:a[1]||(a[1]=o=>c.value=!1)},n(i(s)("cancel")),1),t("div",{style:{display:"flex","justify-content":"center","align-items":"center","border-radius":"70px",background:"linear-gradient(269deg, #feb219 7.04%, #ff9326 96.78%)",color:"#fff","font-weight":"800",padding:"8px 12px",width:"45%"},onClick:E},n(i(s)("confirm")),1)])])])):q("",!0)]),_:1},8,["maskLayerShow"])]))}},Ce=S(me,[["__scopeId","data-v-3d6da2ad"]]);export{Ce as default};
|