address-operation.9452a5a8.js 5.9 KB

1
  1. import{t as P,z as B,O as b,d as k,b4 as T,U as q,c as s,L,D,r as S,bp as z,bq as E,br as x,bf as R,o as n,f as U,e as O,ah as I,ag as M,$ as G,B as _,q as $,P as j}from"./index.332c7f08.js";import{O as H}from"./index.d7c1b6ac.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.324108a5.js";import{F as c}from"./index.1ed6273e.js";import{C as Q}from"./index.91135ff9.js";import{P as W}from"./index.656e257f.js";import"./Picker.e56f94bd.js";import"./index.7c580591.js";import"./use-tab-status.9d769af8.js";import"./index.1e2dfe6e.js";import"./index.4aa8e076.js";const[X,y]=P("switch"),Y={size:B,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(L,{class:y("loading"),color:t},null)}if(e.node)return e.node()};return T(()=>a.modelValue),()=>{var t;const{size:u,loading:l,disabled:i,activeColor:A,inactiveColor:N}=a,g=r(),F={fontSize:q(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=D(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=z({timeout:2e4,timeoutMessage:"\u8BF7\u6C42\u8D85\u65F6"});let V=!1,m;d.interceptors.request.use((a,o)=>{o.hideLoading||(clearTimeout(m),E({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:x(o.params),headers:{...o.headers,...r}}}},{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 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=U();throw o.code===5e3&&(e+="5000",r.isApp?O({api:"login"}):w()),new Error(e)}return a},{global:!1});var ge=k({name:"address-operation",setup(){const a=I(),o=M(),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 G(()=>{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(H,{position:"bottom"},{default:()=>[s("div",{class:"btnGroup"},[s(_,{type:"primary",block:!0,round:!0,onClick:f,disabled:e.isClick},{default:()=>[$("\u786E\u8BA4")]})])]}),s(j,{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};