address-operation-legacy.c28f1bfc.js 5.9 KB

1
  1. System.register(["./index-legacy.eb062188.js","./index-legacy.ad813f4d.js","./index.module-legacy.d054e180.js","./area-legacy.b541a943.js","./toolsValidate-legacy.95a8e7c1.js","./index-legacy.148f784c.js","./index-legacy.3a3e070a.js","./index-legacy.918b8c74.js","./index-legacy.38b799d5.js","./Picker-legacy.95f03705.js","./index-legacy.ac7c51db.js","./use-tab-status-legacy.91417466.js","./index-legacy.fab451f1.js","./index-legacy.10d8486a.js"],(function(e){"use strict";var t,a,o,n,i,l,s,r,d,c,u,p,m,g,f,h,b,y,v,k,w,C,S,V,x,j,A,N,P,q,z;return{setters:[function(e){t=e.t,a=e.z,o=e.O,n=e.d,i=e.b8,l=e.U,s=e.c,r=e.L,d=e.D,c=e.r,u=e.bu,p=e.bv,m=e.bw,g=e.bj,f=e.o,h=e.f,b=e.e,y=e.ah,v=e.ag,k=e.$,w=e.B,C=e.q,S=e.P},function(e){V=e.O},function(e){x=e.s},function(e){j=e.a},function(e){A=e.v},function(e){N=e.C},function(e){P=e.F},function(e){q=e.C},function(e){z=e.P},function(){},function(){},function(){},function(){},function(){}],execute:function(){const[T,U]=t("switch"),L={size:a,loading:Boolean,disabled:Boolean,modelValue:o,activeColor:String,inactiveColor:String,activeValue:{type:o,default:!0},inactiveValue:{type:o,default:!1}};var B=n({name:T,props:L,emits:["change","update:modelValue"],setup(e,{emit:t,slots:a}){const o=()=>e.modelValue===e.activeValue,n=()=>{if(!e.disabled&&!e.loading){const a=o()?e.inactiveValue:e.activeValue;t("update:modelValue",a),t("change",a)}},d=()=>{if(e.loading){const t=o()?e.activeColor:e.inactiveColor;return s(r,{class:U("loading"),color:t},null)}if(a.node)return a.node()};return i((()=>e.modelValue)),()=>{var t;const{size:i,loading:r,disabled:c,activeColor:u,inactiveColor:p}=e,m=o(),g={fontSize:l(i),backgroundColor:m?u:p};return s("div",{role:"switch",class:U({on:m,loading:r,disabled:c}),style:g,tabindex:c?void 0:0,"aria-checked":m,onClick:n},[s("div",{class:U("node")},[d()]),null==(t=a.background)?void 0:t.call(a)])}}});const E=d(B),R=c({user:{status:"init",data:{}}}),O=()=>{R.user.status="logout",R.user.data=null},F=u({timeout:2e4,timeoutMessage:"请求超时"});let $,D=!1;F.interceptors.request.use(((e,t)=>{t.hideLoading||(clearTimeout($),p({message:"加载中...",forbidClick:!0,loadingType:"spinner",duration:0})),D=t.initRequest||!1;const a=sessionStorage.getItem("Authorization")||"",o={};return a&&!["/api-oauth/userlogin","/api-oauth/open/sendSms"].includes(e)&&(o.Authorization=a),{url:e,options:{...t,params:m(t.params),headers:{...t.headers,...o}}}}),{global:!1}),F.interceptors.response.use((async e=>{if($=setTimeout((()=>{g()}),100),e.status>299||e.status<200){clearTimeout($);const t="服务器错误,状态码"+e.status;throw f(t),new Error(t)}const t=await e.clone().json();if(200!==t.code&&0!==t.errCode){let e=t.msg||t.message||"处理失败,请重试";D&&(403===t.code||5e3===t.code?O():(R.user.status="error",R.user.data=null)),console.log(t.code,"5104"),403!==t.code&&5e3!==t.code&&(clearTimeout($),f(e));const a=h();throw 5e3===t.code&&(e+="5000",a.isApp?b({api:"login"}):O()),new Error(e)}return e}),{global:!1}),e("default",n({name:"address-operation",setup(){const e=y(),t=v(),a=c({isClick:!1,showPicker:!1,defaultStatus:!1,phoneNumber:null,province:null,city:null,region:null,pcrStr:"",name:null,detailAddress:null}),o=e=>e&&e>=1?A(e):"",n=async()=>{try{if(!a.name)return void f("请选择收货人");if(!a.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(a.phoneNumber))return void f("手机号输入有误");if(!a.pcrStr)return void f("请选择所在地区");if(!a.detailAddress)return void f("请输入详细地址");a.isClick=!0;const o={name:a.name,phoneNumber:a.phoneNumber,province:a.province,city:a.city,region:a.region,detailAddress:a.detailAddress,defaultStatus:a.defaultStatus};e.query.id?await F.post("/api-student/userReceiveAddress/update",{hideLoading:!1,data:{id:e.query.id,...o}}):await F.post("/api-student/userReceiveAddress/save",{hideLoading:!1,data:{...o}}),a.isClick=!1,t.back()}catch(o){a.isClick=!1}};return k((()=>{e.query.id&&(async()=>{try{const{data:t}=await F.get("/api-student/userReceiveAddress/detail/"+e.query.id);a.name=t.name,a.phoneNumber=t.phoneNumber,a.province=t.province,a.city=t.city,a.region=t.region?t.region:"",a.pcrStr=(t.provinceName||"")+(t.cityName||"")+(t.regionName||""),a.detailAddress=t.detailAddress,a.defaultStatus=t.defaultStatus}catch{}})()})),()=>s("div",{class:x.operation},[s(N,{inset:!0,class:x.form},{default:()=>[s(P,{label:"收货人",placeholder:"请输入收货人姓名",modelValue:a.name,"onUpdate:modelValue":e=>a.name=e},null),s(P,{label:"手机号",placeholder:"请输入收货人手机号",modelValue:a.phoneNumber,"onUpdate:modelValue":e=>a.phoneNumber=e,maxlength:11,type:"tel",formatter:o},null),s(P,{label:"所在地区",placeholder:"省/市/区",readonly:!0,isLink:!0,modelValue:a.pcrStr,onClick:()=>{a.showPicker=!0}},null),s(P,{label:"详细地址",placeholder:"街道/小区楼栋/乡村名称",type:"textarea",rows:3,modelValue:a.detailAddress,"onUpdate:modelValue":e=>a.detailAddress=e,maxlength:100},null)]}),s(N,{inset:!0,style:{marginTop:"12px"}},{default:()=>[s(q,{title:"设置为默认地址",center:!0,class:x.default},{value:()=>s(E,{modelValue:a.defaultStatus,"onUpdate:modelValue":e=>a.defaultStatus=e,size:"23px"},null)})]}),s(V,{position:"bottom"},{default:()=>[s("div",{class:"btnGroup"},[s(w,{type:"primary",block:!0,round:!0,onClick:n,disabled:a.isClick},{default:()=>[C("确认")]})])]}),s(S,{show:a.showPicker,"onUpdate:show":e=>a.showPicker=e,position:"bottom",round:!0,class:"popupBottomSearch"},{default:()=>[s(z,{showToolbar:!0,columns:j,columnsFieldNames:{text:"name",value:"code",children:"areas"},onCancel:()=>a.showPicker=!1,onConfirm:e=>{console.log(e,"val");const t=e.selectedOptions||[];a.pcrStr="",2===t.length?t.forEach(((e,t)=>{a.pcrStr+=e.name,0===t?a.province=e.code:1===t&&(a.city=e.code)})):t.forEach(((e,t)=>{a.pcrStr+=e.name,0===t?a.province=e.code:1===t?a.city=e.code:2===t&&(a.region=e.code)})),a.showPicker=!1}},null)]})])}}))}}}));