import{j as e,H as t,q as a,C as o,A as n}from"./index-CJxdOECQ.js";function i(i,s={}){const d=e("token");let p="https://api.makesong.cn/yu"+i;if("GET"===(s.method||"GET")&&s.data){const e=[];Object.keys(s.data).forEach((t=>{const a=s.data[t];null!=a&&e.push(`${encodeURIComponent(t)}=${encodeURIComponent(String(a))}`)}));const t=e.join("&");t&&(p+="?"+t)}return new Promise(((e,i)=>{t({url:p,method:s.method||"GET",data:"GET"===(s.method||"GET")?void 0:s.data,header:{"Content-Type":"application/json",...d&&{Authorization:`Bearer ${d}`},...s.header},success:t=>{const s=t.data;200===s.code?e(s.data):401==s.code?(a("token"),o({url:"/pages/login/login"})):(n({title:s.message||"请求失败",icon:"none"}),i(new Error(s.message)))},fail:e=>{n({title:"网络请求失败",icon:"none"}),i(e)}})}))}const s={auth:{register:(e,t)=>i("/api/auth/register",{method:"POST",data:{phone:e,nickname:t}}),sendCode:e=>i("/api/auth/send-code",{method:"POST",data:{phone:e}}),verificationLogin:(e,t)=>i("/api/auth/verification-login",{method:"POST",data:{phone:e,code:t}}),oneClickLogin:e=>i("/api/auth/one-click-login",{method:"POST",data:{phone:e}})},user:{getProfile:()=>i("/api/users/profile"),updateProfile:e=>i("/api/users/profile",{method:"PUT",data:e})},timeslots:{getList:e=>i("/api/timeslots",{data:e}),getById:e=>i(`/api/timeslots/${e}`)},appointments:{getList:e=>i("/api/appointments",{data:e}),getById:e=>i(`/api/appointments/${e}`),create:(e,t=1,a)=>i("/api/appointments",{method:"POST",data:{time_slot_id:e,people_count:t,notes:a}}),cancel:e=>i(`/api/appointments/${e}`,{method:"DELETE"})},health:()=>i("/health")};export{s as a};
