import{d as a}from"./vendor-CB_mu4eO.js";import{f as t,R as e,E as r,r as o}from"./souav-BTAG2baT.js";import{c as n}from"./vendor-Dm9fpm6x.js";import{d as i,w as s,r as u}from"./vendor-BXdGExd0.js";import{j as c,i as l}from"./vendor-BJZ6tUoe.js";const d=a("withdraw",()=>{const a=t(),d=i({amount:"",name:"",account:""});s(()=>d.amount,(a,t)=>{if(!a)return;let e=a.replace(/[^0-9.]/g,"").replace(/\.+/g,".").replace(/^(\d+)\.(\d).*$/,"$1.$2");e.startsWith(".")&&(e="0"+e);const r=e.split(".");r.length>2&&(e=r[0]+"."+r.slice(1).join("")),e!==a&&(d.amount=e)});const v=u([]),m=u(e.loading),f=u(!1),h=u(!1),p=u(!1),w=u(1);async function g(a=!1){var t;const o={pageNo:w.value,pageSize:10};try{const i=await n.queryApplyRecord(o);if(i.code===r.Success){const r=(null==(t=i.data)?void 0:t.withdrawList)??[];a?(v.value.push(...r),r.length<10&&(p.value=!0)):(v.value=r,m.value=0===r.length?e.EmptyData:e.success,p.value=r.length<10)}else a||(m.value=e.NetError),p.value=!0}catch(i){a||(m.value=e.NetError),p.value=!0}finally{f.value=!1,h.value=!1}}async function y(){f.value=!0,p.value=!1,w.value=1,await g()}return{form:d,onClickWithdrawAll:function(){d.amount=a.withdrawalAmount.toString()},reqWithdraw:async function(){const t=parseFloat(d.amount);if(!d.amount||t<=0)return void c("请填写提现金额");if(t<100)return void c("累计100元才可提现");if(t>a.withdrawalAmount)return void c("当前提现金额不足");if(!d.name.trim())return void c("请填写支付宝真实姓名");if(!d.account.trim())return void c("请填写支付宝账号");const e={coinsQty:10*t,trueName:d.name.trim(),withdrawAccount:d.account.trim()},i=l({message:"提交中...",forbidClick:!0,duration:0});try{const t=await n.applyWithdraw(e);i.close(),t.code===r.Success?(c("提交成功，等待官方审核"),await a.refreshUserInfo(),o.back()):c(t.msg||"提现失败")}catch(s){i.close(),c("网络请求失败")}},records:v,refreshStatus:m,refreshing:f,loading:h,finished:p,initListData:function(){0===v.value.length&&y()},onRefresh:y,onLoadMore:async function(){h.value||p.value||(h.value=!0,w.value++,await g(!0))}}});export{d as u};
