import{aj as s,ak as e}from"./index-d76b1e7a.js";import{r as t}from"./api.9246a192.js";import{u as r}from"./useRouter.2bdb47a0.js";function a(s){return t.get("/member/user/get",s,{login:!0})}function i(s){return t.post("/member/user/update-avatar",s,{login:!0})}function n(s){return t.put(`/member/user/update-nickname?nickname=${s.nickname}&birthday=${s.birthday}&sex=${s.sex}`,s,{login:!0})}const d=s=>t.put(`/member/user/update-nickname?nickname=${s.nickname}&birthday=${s.birthday}&sex=${s.sex}`);function o(s){return t.post(`/address/del/${s.id}`,void 0,{login:!0})}function u(s){return t.post("/address/addAndEdit",s,{login:!0})}const{push:l}=r(),c=s("main",{state:()=>({user:null,address:[],areaList:[],selectAddress:null,moreLoading:!0,cartId:null}),getters:{defaultAddress(s){var e,t;return null==(t=null==(e=s.address)?void 0:e.filter((s=>s.isDefault)))?void 0:t[0]}},actions:{setAccessToken:s=>(e.set("accessToken",s),a()),setSelectAddress(s){this.selectAddress=this.address.filter((e=>e.id==s))[0]},async getUserInfo(s){let e=await a();return this.user=e,e},restAddress(){this.address=[],this.moreLoading=!0},async getAddressList(s){let e=await(r={page:s},t.get("/address/list",r,{login:!0}));var r;e.length?this.address=this.address.concat(e):this.moreLoading=!1},async getAddressCityList(){let s=await t.get("/address/city_list",e,{login:!0});var e;this.areaList=s},init:()=>e.get("accessToken")?a():null,logout(){this.user=null,this.address=[],this.areaList=[],this.selectAddress=null,e.remove("accessToken"),l({url:"/pages/login/guid"},{type:"redirectTo"})}}});export{u as a,i as b,d as c,n as d,o as g,c as u};
