1 |
- import{t as E,z as N,O as b,d as A,b8 as D,U as P,c as s,L as T,D as L,r as k,bu as q,bv as z,bw as x,bj as R,o as i,f as U,e as O,ah as I,ag as M,$ as j,B as G,q as _,P as $}from"./index.5f7ffb46.js";import{O as H}from"./index.7790de2a.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 as y}from"./index.052b3caa.js";import{F as c}from"./index.6438a25f.js";import{C as Q}from"./index.abd668f7.js";import{P as W}from"./index.de1f78a6.js";import"./Picker.148c9d83.js";import"./index.6bbd7daa.js";import"./use-tab-status.69b57a37.js";import"./index.99e0cf1f.js";import"./index.61ab9823.js";const[X,C]=E("switch"),Y={size:N,loading:Boolean,disabled:Boolean,modelValue:b,activeColor:String,inactiveColor:String,activeValue:{type:b,default:!0},inactiveValue:{type:b,default:!1}};var Z=A({name:X,props:Y,emits:["change","update:modelValue"],setup(a,{emit:o,slots:e}){const u=()=>a.modelValue===a.activeValue,f=()=>{if(!a.disabled&&!a.loading){const t=u()?a.inactiveValue:a.activeValue;o("update:modelValue",t),o("change",t)}},h=()=>{if(a.loading){const t=u()?a.activeColor:a.inactiveColor;return s(T,{class:C("loading"),color:t},null)}if(e.node)return e.node()};return D(()=>a.modelValue),()=>{var t;const{size:n,loading:r,disabled:l,activeColor:F,inactiveColor:S}=a,g=u(),V={fontSize:P(n),backgroundColor:g?F:S};return s("div",{role:"switch",class:C({on:g,loading:r,disabled:l}),style:V,tabindex:l?void 0:0,"aria-checked":g,onClick:f},[s("div",{class:C("node")},[h()]),(t=e.background)==null?void 0:t.call(e)])}}});const ee=L(Z),p=k({user:{status:"init",data:{}}}),w=()=>{p.user.status="logout",p.user.data=null},te=()=>{p.user.status="error",p.user.data=null},d=q({timeout:2e4,timeoutMessage:"\u8BF7\u6C42\u8D85\u65F6"});let B=!1,m;d.interceptors.request.use((a,o)=>{o.hideLoading||(clearTimeout(m),z({message:"\u52A0\u8F7D\u4E2D...",forbidClick:!0,loadingType:"spinner",duration:0})),B=o.initRequest||!1;const e=sessionStorage.getItem("Authorization")||"",u={};return e&&!["/api-oauth/userlogin","/api-oauth/open/sendSms"].includes(a)&&(u.Authorization=e),{url:a,options:{...o,params:x(o.params),headers:{...o.headers,...u}}}},{global:!1});d.interceptors.response.use(async a=>{if(m=setTimeout(()=>{R()},100),a.status>299||a.status<200){clearTimeout(m);const e="\u670D\u52A1\u5668\u9519\u8BEF\uFF0C\u72B6\u6001\u7801"+a.status;throw i(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";B&&(o.code===403||o.code===5e3?w():te()),console.log(o.code,"5104"),o.code===403||o.code===5e3||(clearTimeout(m),i(e));const u=U();throw o.code===5e3&&(e+="5000",u.isApp?O({api:"login"}):w()),new Error(e)}return a},{global:!1});var ge=A({name:"address-operation",setup(){const a=I(),o=M(),e=k({isClick:!1,showPicker:!1,defaultStatus:!1,phoneNumber:null,province:null,city:null,region:null,pcrStr:"",name:null,detailAddress:null}),u=t=>t&&t>=1?K(t):"",f=async()=>{try{if(!e.name){i("\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)){i("\u624B\u673A\u53F7\u8F93\u5165\u6709\u8BEF");return}if(!e.pcrStr){i("\u8BF7\u9009\u62E9\u6240\u5728\u5730\u533A");return}if(!e.detailAddress){i("\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 j(()=>{a.query.id&&h()}),()=>s("div",{class:v.operation},[s(y,{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:u},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(y,{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(H,{position:"bottom"},{default:()=>[s("div",{class:"btnGroup"},[s(G,{type:"primary",block:!0,round:!0,onClick:f,disabled:e.isClick},{default:()=>[_("\u786E\u8BA4")]})])]}),s($,{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 n=t.selectedOptions||[];e.pcrStr="",n.length===2?n.forEach((r,l)=>{e.pcrStr+=r.name,l===0?e.province=r.code:l===1&&(e.city=r.code)}):n.forEach((r,l)=>{e.pcrStr+=r.name,l===0?e.province=r.code:l===1?e.city=r.code:l===2&&(e.region=r.code)}),e.showPicker=!1}},null)]})])}});export{ge as default};
|