import{O as P}from"./index.454c666f.js";import{t as B,z as T,O as b,d as k,b4 as q,U as L,c as s,L as D,D as z,r as S,bp as E,bq as x,br as R,bf as U,o as n,f as O,e as I,ah as M,ag as G,$ as _,B as $,q as j,P as H}from"./index.3b0304e1.js";import{s as v}from"./index.module.08b7a095.js";import{a as J}from"./area.bc7b6c10.js";import{v as K}from"./toolsValidate.4388d7ee.js";import{C}from"./index.ead63c4f.js";import{F as c}from"./index.f8e9940f.js";import{C as Q}from"./index.ff3f298b.js";import{P as W}from"./index.49feb9e9.js";import"./Picker.66dfa715.js";import"./index.c9ab1bb5.js";import"./use-tab-status.e36e4d74.js";import"./index.ce8d626c.js";import"./index.409ae793.js";const[X,y]=B("switch"),Y={size:T,loading:Boolean,disabled:Boolean,modelValue:b,activeColor:String,inactiveColor:String,activeValue:{type:b,default:!0},inactiveValue:{type:b,default:!1}};var Z=k({name:X,props:Y,emits:["change","update:modelValue"],setup(a,{emit:o,slots:e}){const r=()=>a.modelValue===a.activeValue,f=()=>{if(!a.disabled&&!a.loading){const t=r()?a.inactiveValue:a.activeValue;o("update:modelValue",t),o("change",t)}},h=()=>{if(a.loading){const t=r()?a.activeColor:a.inactiveColor;return s(D,{class:y("loading"),color:t},null)}if(e.node)return e.node()};return q(()=>a.modelValue),()=>{var t;const{size:u,loading:l,disabled:i,activeColor:A,inactiveColor:N}=a,g=r(),F={fontSize:L(u),backgroundColor:g?A:N};return s("div",{role:"switch",class:y({on:g,loading:l,disabled:i}),style:F,tabindex:i?void 0:0,"aria-checked":g,onClick:f},[s("div",{class:y("node")},[h()]),(t=e.background)==null?void 0:t.call(e)])}}});const ee=z(Z),p=S({user:{status:"init",data:{}}}),w=()=>{p.user.status="logout",p.user.data=null},te=()=>{p.user.status="error",p.user.data=null},d=E({timeout:2e4,timeoutMessage:"\u8BF7\u6C42\u8D85\u65F6"});let V=!1,m;d.interceptors.request.use((a,o)=>{o.hideLoading||(clearTimeout(m),x({message:"\u52A0\u8F7D\u4E2D...",forbidClick:!0,loadingType:"spinner",duration:0})),V=o.initRequest||!1;const e=sessionStorage.getItem("Authorization")||"",r={};return e&&!["/api-oauth/userlogin","/api-oauth/open/sendSms"].includes(a)&&(r.Authorization=e),{url:a,options:{...o,params:R(o.params),headers:{...o.headers,...r}}}},{global:!1});d.interceptors.response.use(async a=>{if(m=setTimeout(()=>{U()},100),a.status>299||a.status<200){clearTimeout(m);const e="\u670D\u52A1\u5668\u9519\u8BEF\uFF0C\u72B6\u6001\u7801"+a.status;throw n(e),new Error(e)}const o=await a.clone().json();if(o.code!==200&&o.errCode!==0){let e=o.msg||o.message||"\u5904\u7406\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";V&&(o.code===403||o.code===5e3?w():te()),console.log(o.code,"5104"),o.code===403||o.code===5e3||(clearTimeout(m),n(e));const r=O();throw o.code===5e3&&(e+="5000",r.isApp?I({api:"login"}):w()),new Error(e)}return a},{global:!1});var ge=k({name:"address-operation",setup(){const a=M(),o=G(),e=S({isClick:!1,showPicker:!1,defaultStatus:!1,phoneNumber:null,province:null,city:null,region:null,pcrStr:"",name:null,detailAddress:null}),r=t=>t&&t>=1?K(t):"",f=async()=>{try{if(!e.name){n("\u8BF7\u9009\u62E9\u6536\u8D27\u4EBA");return}if(!e.phoneNumber||!/^((13[0-9])|(14(0|[5-7]|9))|(15([0-3]|[5-9]))|(16(2|[5-7]))|(17[0-8])|(18[0-9])|(19([0-3]|[5-9])))\d{8}$/.test(e.phoneNumber)){n("\u624B\u673A\u53F7\u8F93\u5165\u6709\u8BEF");return}if(!e.pcrStr){n("\u8BF7\u9009\u62E9\u6240\u5728\u5730\u533A");return}if(!e.detailAddress){n("\u8BF7\u8F93\u5165\u8BE6\u7EC6\u5730\u5740");return}e.isClick=!0;const t={name:e.name,phoneNumber:e.phoneNumber,province:e.province,city:e.city,region:e.region,detailAddress:e.detailAddress,defaultStatus:e.defaultStatus};a.query.id?await d.post("/api-student/userReceiveAddress/update",{hideLoading:!1,data:{id:a.query.id,...t}}):await d.post("/api-student/userReceiveAddress/save",{hideLoading:!1,data:{...t}}),e.isClick=!1,o.back()}catch{e.isClick=!1}},h=async()=>{try{const{data:t}=await d.get("/api-student/userReceiveAddress/detail/"+a.query.id);e.name=t.name,e.phoneNumber=t.phoneNumber,e.province=t.province,e.city=t.city,e.region=t.region?t.region:"",e.pcrStr=(t.provinceName||"")+(t.cityName||"")+(t.regionName||""),e.detailAddress=t.detailAddress,e.defaultStatus=t.defaultStatus}catch{}};return _(()=>{a.query.id&&h()}),()=>s("div",{class:v.operation},[s(C,{inset:!0,class:v.form},{default:()=>[s(c,{label:"\u6536\u8D27\u4EBA",placeholder:"\u8BF7\u8F93\u5165\u6536\u8D27\u4EBA\u59D3\u540D",modelValue:e.name,"onUpdate:modelValue":t=>e.name=t},null),s(c,{label:"\u624B\u673A\u53F7",placeholder:"\u8BF7\u8F93\u5165\u6536\u8D27\u4EBA\u624B\u673A\u53F7",modelValue:e.phoneNumber,"onUpdate:modelValue":t=>e.phoneNumber=t,maxlength:11,type:"tel",formatter:r},null),s(c,{label:"\u6240\u5728\u5730\u533A",placeholder:"\u7701/\u5E02/\u533A",readonly:!0,isLink:!0,modelValue:e.pcrStr,onClick:()=>{e.showPicker=!0}},null),s(c,{label:"\u8BE6\u7EC6\u5730\u5740",placeholder:"\u8857\u9053/\u5C0F\u533A\u697C\u680B/\u4E61\u6751\u540D\u79F0",type:"textarea",rows:3,modelValue:e.detailAddress,"onUpdate:modelValue":t=>e.detailAddress=t,maxlength:100},null)]}),s(C,{inset:!0,style:{marginTop:"12px"}},{default:()=>[s(Q,{title:"\u8BBE\u7F6E\u4E3A\u9ED8\u8BA4\u5730\u5740",center:!0,class:v.default},{value:()=>s(ee,{modelValue:e.defaultStatus,"onUpdate:modelValue":t=>e.defaultStatus=t,size:"23px"},null)})]}),s(P,{position:"bottom"},{default:()=>[s("div",{class:"btnGroup"},[s($,{type:"primary",block:!0,round:!0,onClick:f,disabled:e.isClick},{default:()=>[j("\u786E\u8BA4")]})])]}),s(H,{show:e.showPicker,"onUpdate:show":t=>e.showPicker=t,position:"bottom",round:!0,class:"popupBottomSearch"},{default:()=>[s(W,{showToolbar:!0,columns:J,columnsFieldNames:{text:"name",value:"code",children:"areas"},onCancel:()=>e.showPicker=!1,onConfirm:t=>{console.log(t,"val");const u=t.selectedOptions||[];e.pcrStr="",u.length===2?u.forEach((l,i)=>{e.pcrStr+=l.name,i===0?e.province=l.code:i===1&&(e.city=l.code)}):u.forEach((l,i)=>{e.pcrStr+=l.name,i===0?e.province=l.code:i===1?e.city=l.code:i===2&&(e.region=l.code)}),e.showPicker=!1}},null)]})])}});export{ge as default};