1 |
- import{e,f as l,w as a,j as t,z as o,i as r,y as n,p as s,t as i,g as d,A as c,C as u,I as m,v as f,c as p,l as _,m as h,k as y,F as g,r as b,u as x,au as v,av as w,U as B,o as C,_ as S,L as k,s as V,M as I,D as T}from"./index-9880b451.js";import{d as A,m as z,g as N,i as U,c as M,h as $,a as j,_ as R}from"./s-layout.dfc5b0b5.js";import{_ as D}from"./_plugin-vue_export-helper.1b428a4d.js";import{A as P,a as q}from"./address.46f090d1.js";const E={name:"UiSwitch"},F=D(Object.assign(E,{props:{modelValue:{type:[Boolean,Number],default:!1},ui:{type:String,default:""},bg:{type:String,default:"ui-BG-Main"},text:{type:String,default:""},size:{type:String,default:"sm"},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(n,{emit:s}){const i=n,d=()=>{s("update:modelValue",!i.modelValue)};return(n,s)=>{const c=r;return e(),l(c,{class:o(["ui-switch",[{disabled:i.disabled},i.ui]])},{default:a((()=>[t(c,{class:"ui-switch-wrapper",onClick:d},{default:a((()=>[t(c,{class:o(["ui-switch-input",[{"ui-switch-input-checked":i.modelValue},i.modelValue?i.bg:"",i.text,i.size]])},null,8,["class"])])),_:1})])),_:1},8,["class"])}}}),[["__scopeId","data-v-77d22f9f"]]);const G=D({name:"SuToolbar",props:{show:{type:Boolean,default:!0},cancelText:{type:String,default:"取消"},confirmText:{type:String,default:"确认"},cancelColor:{type:String,default:"#909193"},confirmColor:{type:String,default:"#3c9cff"},title:{type:String,default:""}},methods:{cancel(){this.$emit("cancel")},confirm(){this.$emit("confirm")},preventEvent(e){e&&"function"==typeof e.stopPropagation&&e.stopPropagation()},noop(e){this.preventEvent(e)}}},[["render",function(o,m,f,p,_,h){const y=u,g=r;return f.show?(e(),l(g,{key:0,class:"u-toolbar",onTouchmove:c(h.noop,["stop","prevent"])},{default:a((()=>[t(g,{class:"u-toolbar__cancel__wrapper","hover-class":"u-hover-class"},{default:a((()=>[t(y,{class:"u-toolbar__wrapper__cancel",onClick:h.cancel,style:n({color:f.cancelColor})},{default:a((()=>[s(i(f.cancelText),1)])),_:1},8,["onClick","style"])])),_:1}),f.title?(e(),l(y,{key:0,class:"u-toolbar__title u-line-1"},{default:a((()=>[s(i(f.title),1)])),_:1})):d("",!0),t(g,{class:"u-toolbar__confirm__wrapper","hover-class":"u-hover-class"},{default:a((()=>[t(y,{class:"u-toolbar__wrapper__confirm",onClick:h.confirm,style:n({color:f.confirmColor})},{default:a((()=>[s(i(f.confirmText),1)])),_:1},8,["onClick","style"])])),_:1})])),_:1},8,["onTouchmove"])):d("",!0)}],["__scopeId","data-v-7128d250"]]),O=D({__name:"su-region-picker",props:{show:{type:Boolean,default:!1},cancelColor:{type:String,default:"#6666"},confirmColor:{type:String,default:"var(--ui-BG-Main)"},cancelText:{type:String,default:"取消"},confirmText:{type:String,default:"确认"}},emits:["confirm","cancel","change"],setup(o,{emit:d}){const c=m("areaData"),u=e=>{let l=e.length;return l<=7?"":l<9?"font-size:28rpx":"font-size: 24rpx"},B=f({currentIndex:[0,0,0],moving:!1}),C=c,S=p((()=>c[B.currentIndex[0]].children)),k=p((()=>{var e;return null==(e=S.value[B.currentIndex[1]])?void 0:e.children})),V=()=>{},I=()=>{},T=()=>{d("cancel")},z=e=>{B.currentIndex[0]!==e.detail.value[0]||B.currentIndex[1]!==e.detail.value[1]?(B.currentIndex[0]!==e.detail.value[0]&&(e.detail.value[1]=0),e.detail.value[2]=0,B.currentIndex=e.detail.value,d("change",B.currentIndex)):B.currentIndex[2]=e.detail.value[2]};return(c,m)=>{const f=_(h("su-toolbar"),G),p=r,N=v,U=w,M=_(h("su-popup"),A);return e(),l(M,{show:o.show,onClose:T,round:"20"},{default:a((()=>[t(p,{class:"ui-region-picker"},{default:a((()=>[t(f,{cancelColor:o.cancelColor,confirmColor:o.confirmColor,cancelText:o.cancelText,confirmText:o.confirmText,title:"选择区域",onCancel:T,onConfirm:m[0]||(m[0]=e=>((e=null)=>{let l=B.currentIndex,a=C[l[0]],t=S.value[l[1]],o=k.value[l[2]],r={province_name:a.name,province_id:a.id,city_name:t.name,city_id:t.id,district_name:o.name,district_id:o.id};e&&d(e,r)})("confirm"))},null,8,["cancelColor","confirmColor","cancelText","confirmText"]),t(p,{class:"ui-picker-body"},{default:a((()=>[t(U,{value:B.currentIndex,onChange:z,class:"ui-picker-view",onPickstart:V,onPickend:I},{default:a((()=>[t(N,null,{default:a((()=>[(e(!0),y(g,null,b(x(C),(o=>(e(),l(p,{class:"ui-column-item",key:o.id},{default:a((()=>[t(p,{style:n(u(o.name))},{default:a((()=>[s(i(o.name),1)])),_:2},1032,["style"])])),_:2},1024)))),128))])),_:1}),t(N,null,{default:a((()=>[(e(!0),y(g,null,b(x(S),(o=>(e(),l(p,{class:"ui-column-item",key:o.id},{default:a((()=>[t(p,{style:n(u(o.name))},{default:a((()=>[s(i(o.name),1)])),_:2},1032,["style"])])),_:2},1024)))),128))])),_:1}),t(N,null,{default:a((()=>[(e(!0),y(g,null,b(x(k),(o=>(e(),l(p,{class:"ui-column-item",key:o.id},{default:a((()=>[t(p,{style:n(u(o.name))},{default:a((()=>[s(i(o.name),1)])),_:2},1032,["style"])])),_:2},1024)))),128))])),_:1})])),_:1},8,["value"])])),_:1})])),_:1})])),_:1},8,["show"])}}},[["__scopeId","data-v-43e09180"]]),W=D({__name:"edit",setup(o){const n=B(null),i=f({showRegion:!1,model:{name:"",mobile:"",detailAddress:"",defaultStatus:!1,areaName:""},rules:{}}),c={name:{rules:[{required:!0,errorMessage:"请输入收货人姓名"}]},mobile:z,detailAddress:{rules:[{required:!0,errorMessage:"请输入详细地址"}]},areaName:{rules:[{required:!0,errorMessage:"请选择您的位置"}]}},u=e=>{i.model.areaName=`${e.province_name} ${e.city_name} ${e.district_name}`,i.model.areaId=e.district_id,i.showRegion=!1},p=async()=>{if(!(await x(n).validate().catch((e=>{console.log("error: ",e)}))))return;const e={...i.model},{code:l}=i.model.id>0?await P.updateAddress(e):await P.createAddress(e);0===l&&V.$router.back()},y=()=>{I({title:"提示",content:"确认删除此收货地址吗?",success:async function(e){if(!e.confirm)return;const{code:l}=await P.deleteAddress(i.model.id);0===l&&V.$router.back()}})};return C((async e=>{if(S.isEmpty(m("areaData"))&&q.getAreaTree().then((e=>{0===e.code&&k("areaData",e.data)})),e.id){let{code:l,data:a}=await P.getAddress(e.id);if(0!==l)return;i.model=a}if(e.data){let l=JSON.parse(e.data);let a=m("areaData").filter((e=>e.name==l.province_name));l.province_id=a[0].id;let t=a[0].children.filter((e=>e.name==l.city_name));l.city_id=t[0].id;let o=t[0].children.filter((e=>e.name==l.district_name));l.district_id=o[0].id,i.model={...i.model,...l}}})),(o,m)=>{const f=_(h("uni-easyinput"),N),g=_(h("uni-forms-item"),U),b=_(h("uni-icons"),M),x=r,v=_(h("su-switch"),F),w=_(h("uni-forms"),$),B=T,C=_(h("su-fixed"),j),S=_(h("su-region-picker"),O),k=_(h("s-layout"),R);return e(),l(k,{title:i.model.id?"编辑地址":"新增地址"},{default:a((()=>[t(w,{ref_key:"addressFormRef",ref:n,modelValue:i.model,"onUpdate:modelValue":m[6]||(m[6]=e=>i.model=e),rules:c,validateTrigger:"bind",labelWidth:"160",labelAlign:"left",border:"",labelStyle:{fontWeight:"bold"}},{default:a((()=>[t(x,{class:"bg-white form-box ss-p-x-30"},{default:a((()=>[t(g,{name:"name",label:"收货人",class:"form-item"},{default:a((()=>[t(f,{modelValue:i.model.name,"onUpdate:modelValue":m[0]||(m[0]=e=>i.model.name=e),placeholder:"请填写收货人姓名",inputBorder:!1,placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"},null,8,["modelValue"])])),_:1}),t(g,{name:"mobile",label:"手机号",class:"form-item"},{default:a((()=>[t(f,{modelValue:i.model.mobile,"onUpdate:modelValue":m[1]||(m[1]=e=>i.model.mobile=e),type:"number",placeholder:"请输入手机号",inputBorder:!1,placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"},null,8,["modelValue"])])),_:1}),t(g,{name:"areaName",label:"省市区",onClick:m[3]||(m[3]=e=>i.showRegion=!0),class:"form-item"},{default:a((()=>[t(f,{modelValue:i.model.areaName,"onUpdate:modelValue":m[2]||(m[2]=e=>i.model.areaName=e),disabled:"",inputBorder:!1,styles:{disableColor:"#fff",color:"#333"},placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",placeholder:"请选择省市区"},{right:a((()=>[t(b,{type:"right"})])),_:1},8,["modelValue"])])),_:1}),t(g,{name:"detailAddress",label:"详细地址",formItemStyle:{alignItems:"flex-start"},labelStyle:{lineHeight:"5em"},class:"textarea-item"},{default:a((()=>[t(f,{inputBorder:!1,type:"textarea",modelValue:i.model.detailAddress,"onUpdate:modelValue":m[4]||(m[4]=e=>i.model.detailAddress=e),placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",placeholder:"请输入详细地址",clearable:""},null,8,["modelValue"])])),_:1})])),_:1}),t(x,{class:"ss-m-y-20 bg-white ss-p-x-30 ss-flex ss-row-between ss-col-center default-box"},{default:a((()=>[t(x,{class:"default-box-title"},{default:a((()=>[s(" 设为默认地址 ")])),_:1}),t(v,{style:{transform:"scale(0.8)"},modelValue:i.model.defaultStatus,"onUpdate:modelValue":m[5]||(m[5]=e=>i.model.defaultStatus=e)},null,8,["modelValue"])])),_:1})])),_:1},8,["modelValue"]),t(C,{bottom:"",opacity:!1,bg:"",placeholder:"",noFixed:!1,index:10},{default:a((()=>[t(x,{class:"footer-box ss-flex-col ss-row-between ss-p-20"},{default:a((()=>[t(x,{class:"ss-m-b-20"},{default:a((()=>[t(B,{class:"ss-reset-button save-btn ui-Shadow-Main",onClick:p},{default:a((()=>[s("保存")])),_:1})])),_:1}),i.model.id?(e(),l(B,{key:0,class:"ss-reset-button cancel-btn",onClick:y},{default:a((()=>[s(" 删除 ")])),_:1})):d("",!0)])),_:1})])),_:1}),t(S,{show:i.showRegion,onCancel:m[7]||(m[7]=e=>i.showRegion=!1),onConfirm:u},null,8,["show"])])),_:1},8,["title"])}}},[["__scopeId","data-v-6ce7bcb5"]]);export{W as default};
|