2 lines
3.6 KiB
JavaScript
2 lines
3.6 KiB
JavaScript
import{d as g}from"./index-CV-mCsrN.js";import{r as s,G as d}from"./element-plus-HARoAvk-.js";import{s as a}from"./http-BM5-Wn5U.js";const y=g("user",()=>{const r=s(localStorage.getItem("token")||""),o=s(!1),t=s(localStorage.getItem("mobilePhone")||""),e=n=>{r.value=n,o.value=!0;const p=Date.now()+31536e3*1e3;localStorage.setItem("token",n),localStorage.setItem("tokenExpiry",p.toString())},i=n=>{t.value=n,localStorage.setItem("mobilePhone",n)},l=()=>{localStorage.removeItem("mobilePhone")},c=()=>{try{r.value="",o.value=!1,localStorage.removeItem("userInfo"),localStorage.removeItem("token"),localStorage.removeItem("tokenExpiry")}catch(n){console.error("Error clearing token from localStorage:",n)}},m=()=>{try{const n=localStorage.getItem("tokenExpiry");return n?Date.now()>parseInt(n,10):!0}catch(n){return console.error("Error checking token expiry:",n),!0}},u=n=>{localStorage.setItem("Identity",n)},h=()=>{localStorage.removeItem("Identity")};return d(()=>{try{const n=localStorage.getItem("token");n&&!m()?(r.value=n,o.value=!0):c()}catch(n){console.error("Error retrieving token from localStorage:",n)}}),{token:r,isLoggedIn:o,mobilePhone:t,setToken:e,clearToken:c,setMobilePhone:i,removeMobilePhone:l,setIdentity:u,removeIdentity:h}});function S(r){return r.isFilter=!0,new Promise((o,t)=>{a({url:"/api/mobile/account/login/doMerchSmsRegisterAndLogin",method:"post",data:r}).then(e=>{o(e)}).catch(e=>t(console.warn(e)))})}function v(r){return r.isFilter=!0,new Promise((o,t)=>{a({url:"/api/mobile/account/login/sendVerifyCode",method:"post",data:r}).then(e=>{o(e)}).catch(e=>t(console.warn(e)))})}function I(){return new Promise((r,o)=>{a({url:"/api/mobile/shop/shop-base-store-category/list",method:"post"}).then(t=>{r(t)}).catch(t=>o(console.warn(t)))})}function k(r){return r.map(o=>({value:o.store_category_id,label:o.store_category_name,children:o.children?[{value:o.store_category_id,label:`${o.store_category_name} 到账比例(${o.split_ratio}%)`},...o.children.map(t=>({value:t.store_category_id,label:`${t.store_category_name} 到账比例(${t.split_ratio}%)`}))]:[]}))}function P(r){return r.isFilter=!0,new Promise((o,t)=>{a({url:"/api/mobile/shop/merch/baidu/place/v2/suggestion",method:"get",params:r}).then(e=>{o(e)}).catch(e=>t(console.warn(e)))})}function _(r){return new Promise((o,t)=>{a({url:"/api/mobile/shop/lakala/tk/bank/search",method:"post",data:r}).then(e=>{o(e)}).catch(e=>t(console.warn(e)))})}function G(r){return new Promise((o,t)=>{a({url:"/api/mobile/shop/merch/apply",method:"post",data:r}).then(e=>{o(e)}).catch(e=>t(console.warn(e)))})}function x(){const r={mobile:localStorage.getItem("mobilePhone")};return new Promise((o,t)=>{a({url:"/api/mobile/shop/merch/fresh/approval/status",method:"post",data:r}).then(e=>{o(e)}).catch(e=>t(console.warn(e)))})}function E(r){return new Promise((o,t)=>{a({url:"/api/mobile/shop/merch/re-apply",method:"post",data:r}).then(e=>{o(e)}).catch(e=>t(console.warn(e)))})}function A(r){return new Promise((o,t)=>{a({url:"/api/mobile/shop/merch/detail",method:"post",data:r}).then(e=>{o(e)}).catch(e=>t(console.warn(e)))})}function T(r){return new Promise((o,t)=>{a({url:"/api/admin/account/account-user-base/doLogin",method:"post",params:r}).then(e=>{o(e)}).catch(e=>t(console.warn(e)))})}function C(r){return new Promise((o,t)=>{a({url:"/api/admin/shop/shop-base-config/image",method:"GET",params:r}).then(e=>{o(e)}).catch(e=>t(console.warn(e)))})}function L(){return new Promise((r,o)=>{a({url:"/api/mobile/shop/shop-base-district/getAppDistrict",method:"get"}).then(t=>{r(t)}).catch(t=>o(console.warn(t)))})}export{I as G,L as a,_ as b,P as c,A as d,T as e,C as f,x as g,S as h,v as i,G as m,E as r,k as t,y as u};
|