import{P as e,B as a,o as l,aH as t,T as s,f as o,g as d,w as r,_ as i,aI as n,x as m,q as u,n as c,m as f,i as p,z as b,s as _,R as h,u as g,l as y,L as w}from"./index-007bf156.js";import{m as x,a as B,b as V,d as A}from"./phone-international-input.3617e4e0.js";import{_ as S,a as k}from"./su-region-picker.fd747f4c.js";import{a as v,_ as j}from"./s-layout.19bedb43.js";import{_ as I}from"./_plugin-vue_export-helper.1b428a4d.js";import"./useGoods.ac3bf93e.js";const R=I({__name:"edit",setup(I){const R=e(null),U=a({showRegion:!1,model:{name:"",mobile:"",detailAddress:"",defaultStatus:!1,areaName:"",addressType:2},rules:{}}),$={name:{rules:[{required:!0,errorMessage:"请输入收货人姓名"}]},mobile:x,detailAddress:{rules:[{required:!0,errorMessage:"请输入详细地址"}]}},z=e=>{U.model.areaName=`${e.province_name} ${e.city_name} ${e.district_name}`,U.model.areaId=e.district_id,U.showRegion=!1},C=async()=>{console.log(U);if(!(await b(R).validate().catch((e=>{console.log("error: ",e)}))))return;const e={...U.model},{code:a}=U.model.id>0?await t.updateAddress(e):await t.createAddress(e);0===a&&_.$router.back()},N=()=>{h({title:"提示",content:"确认删除此收货地址吗？",success:async function(e){if(!e.confirm)return;const{code:a}=await t.deleteAddress(U.model.id,2);0===a&&_.$router.back()}})};return l((async e=>{if(i.isEmpty(s("areaData"))&&n.getAreaTree().then((e=>{0===e.code&&m("areaData",e.data)})),e.id){let{code:a,data:l}=await t.getAddress(e.id,2);if(0!==a)return;U.model=l}if(e.data){let a=JSON.parse(e.data);let l=s("areaData").filter((e=>e.name==a.province_name));a.province_id=l[0].id;let t=l[0].children.filter((e=>e.name==a.city_name));a.city_id=t[0].id;let o=t[0].children.filter((e=>e.name==a.district_name));a.district_id=o[0].id,U.model={name:a.consignee,mobile:a.mobile,detailAddress:a.address,defaultStatus:a.is_default,areaName:a.province_name+" "+a.city_name+" "+a.district_name,areaId:a.district_id}}})),(e,a)=>{const l=u(g("uni-easyinput"),B),t=u(g("uni-forms-item"),V),s=y,i=u(g("su-switch"),S),n=u(g("uni-forms"),A),m=w,b=u(g("su-fixed"),v),_=u(g("su-region-picker"),k),h=u(g("s-layout"),j);return o(),d(h,{title:U.model.id?"编辑虚拟地址":"新增虚拟地址"},{default:r((()=>[c(n,{ref_key:"addressFormRef",ref:R,modelValue:U.model,"onUpdate:modelValue":a[4]||(a[4]=e=>U.model=e),rules:$,validateTrigger:"bind",labelWidth:"160",labelAlign:"left",border:"",labelStyle:{fontWeight:"bold"}},{default:r((()=>[c(s,{class:"bg-white form-box ss-p-x-30"},{default:r((()=>[c(t,{name:"name",label:"收货人",class:"form-item"},{default:r((()=>[c(l,{modelValue:U.model.name,"onUpdate:modelValue":a[0]||(a[0]=e=>U.model.name=e),placeholder:"请填写收货人姓名",inputBorder:!1,placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",maxlength:10},null,8,["modelValue"])])),_:1}),c(t,{name:"mobile",label:"手机号",class:"form-item"},{default:r((()=>[c(l,{modelValue:U.model.mobile,"onUpdate:modelValue":a[1]||(a[1]=e=>U.model.mobile=e),type:"number",placeholder:"请输入手机号",inputBorder:!1,placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"},null,8,["modelValue"])])),_:1}),c(t,{name:"detailAddress",label:"详细地址",formItemStyle:{alignItems:"flex-start"},labelStyle:{lineHeight:"5em"},class:"textarea-item"},{default:r((()=>[c(l,{inputBorder:!1,type:"textarea",modelValue:U.model.detailAddress,"onUpdate:modelValue":a[2]||(a[2]=e=>U.model.detailAddress=e),placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",placeholder:"请输入详细地址",clearable:""},null,8,["modelValue"])])),_:1})])),_:1}),c(s,{class:"ss-m-y-20 bg-white ss-p-x-30 ss-flex ss-row-between ss-col-center default-box"},{default:r((()=>[c(s,{class:"default-box-title"},{default:r((()=>[f(" 设为默认虚拟地址 ")])),_:1}),c(i,{style:{transform:"scale(0.8)"},modelValue:U.model.defaultStatus,"onUpdate:modelValue":a[3]||(a[3]=e=>U.model.defaultStatus=e)},null,8,["modelValue"])])),_:1})])),_:1},8,["modelValue"]),c(b,{bottom:"",opacity:!1,bg:"",placeholder:"",noFixed:!1,index:10},{default:r((()=>[c(s,{class:"footer-box ss-flex-col ss-row-between ss-p-20"},{default:r((()=>[c(s,{class:"ss-m-b-20"},{default:r((()=>[c(m,{class:"ss-reset-button save-btn ui-Shadow-Main",onClick:C},{default:r((()=>[f("保存")])),_:1})])),_:1}),U.model.id?(o(),d(m,{key:0,class:"ss-reset-button cancel-btn",onClick:N},{default:r((()=>[f(" 删除 ")])),_:1})):p("",!0)])),_:1})])),_:1}),c(_,{show:U.showRegion,onCancel:a[5]||(a[5]=e=>U.showRegion=!1),onConfirm:z},null,8,["show"])])),_:1},8,["title"])}}},[["__scopeId","data-v-aebc0339"]]);export{R as default};
