import{_ as e}from"./u-input.46b72faa.js";import{d as a,r as l,a as t,b6 as i,aa as r,b7 as s,p as d,q as o,h as c,i as u,w as n,j as p,J as m,H as v,K as f,l as _,k as b,E as y,F as h,G as x,v as g,t as k,ao as j,o as V,b8 as C,c as P,m as $,b9 as w,ba as q,$ as A,Y as U}from"./index-849cf30e.js";import{_ as E,a as I}from"./u-form.4f9a45b5.js";import{_ as R}from"./u-switch.2489393e.js";import{_ as T}from"./u-button.9fa3f2a0.js";import{_ as Y}from"./u-popup.e01742d2.js";import"./u-icon.e3aa4770.js";import"./_plugin-vue_export-helper.1b428a4d.js";import"./u-line.19eb5c40.js";import"./u-loading-icon.d012ecbf.js";import"./u-transition.75065529.js";import"./u-safe-bottom.2f6af56c.js";const z=a({__name:"area-select",props:{areaId:{type:Number,default:0}},emits:["complete"],setup(e,{expose:a,emit:V}){const C=e,P=l(!1),$=t({province:[],city:[],district:[]}),w=l("province"),q=t({province:null,city:null,district:null});i(0).then((({data:e})=>{$.province=e})).catch(),r((()=>C.areaId),((e,a)=>{e&&!a&&s(e).then((({data:e})=>{e.province&&(q.province=e.province),e.city&&(q.city=e.city),e.district&&(q.district=e.district)})).catch()})),r((()=>q.province),(()=>{i(q.province.id).then((({data:e})=>{if($.city=e,w.value="city",q.city){let a=!1;for(let l=0;lq.city),(e=>{e?i(q.city.id).then((({data:e})=>{if($.district=e,w.value="district",q.district){let a=!1;for(let l=0;lq.district),(e=>{e&&(w.value="district",V("complete",q),P.value=!1)}),{deep:!0});return a({open:()=>{P.value=!0}}),(e,a)=>{const l=k,t=j,i=d(o("u-popup"),Y);return c(),u(i,{show:P.value,onClose:a[3]||(a[3]=e=>P.value=!1),mode:"bottom",round:10,closeable:!0},{default:n((()=>[p(l,{class:"text-center p-[30rpx]"},{default:n((()=>[m("请选择地区")])),_:1}),p(l,{class:"flex p-[30rpx] text-sm font-semibold"},{default:n((()=>[$.province.length?(c(),u(l,{key:0,class:v(["pr-[50rpx]",{"text-[red]":"province"==w.value}]),onClick:a[0]||(a[0]=e=>w.value="province")},{default:n((()=>[q.province?(c(),u(l,{key:0},{default:n((()=>[m(f(q.province.name),1)])),_:1})):(c(),u(l,{key:1},{default:n((()=>[m("请选择")])),_:1}))])),_:1},8,["class"])):_("v-if",!0),$.city.length?(c(),u(l,{key:1,class:v(["pr-[50rpx]",{"text-[red]":"city"==w.value}]),onClick:a[1]||(a[1]=e=>w.value="city")},{default:n((()=>[q.city?(c(),u(l,{key:0},{default:n((()=>[m(f(q.city.name),1)])),_:1})):(c(),u(l,{key:1},{default:n((()=>[m("请选择")])),_:1}))])),_:1},8,["class"])):_("v-if",!0),$.district.length?(c(),u(l,{key:2,class:v(["pr-[50rpx]",{"text-[red]":"district"==w.value}]),onClick:a[2]||(a[2]=e=>w.value="district")},{default:n((()=>[q.district?(c(),u(l,{key:0},{default:n((()=>[m(f(q.district.name),1)])),_:1})):(c(),u(l,{key:1},{default:n((()=>[m("请选择")])),_:1}))])),_:1},8,["class"])):_("v-if",!0)])),_:1}),p(t,{"scroll-y":"true",class:"h-[50vh]"},{default:n((()=>[p(l,{class:"flex p-[30rpx] pt-0 text-sm"},{default:n((()=>[$.province.length?b((c(),u(l,{key:0},{default:n((()=>[(c(!0),y(h,null,x($.province,(e=>(c(),u(l,{class:v(["leading-loose",{"text-[red]":q.province&&q.province.id==e.id}]),onClick:a=>q.province=e},{default:n((()=>[m(f(e.name),1)])),_:2},1032,["class","onClick"])))),256))])),_:1},512)),[[g,"province"==w.value]]):_("v-if",!0),$.city.length?b((c(),u(l,{key:1},{default:n((()=>[(c(!0),y(h,null,x($.city,(e=>(c(),u(l,{class:v(["leading-loose",{"text-[red]":q.city&&q.city.id==e.id}]),onClick:a=>q.city=e},{default:n((()=>[m(f(e.name),1)])),_:2},1032,["class","onClick"])))),256))])),_:1},512)),[[g,"city"==w.value]]):_("v-if",!0),$.district.length?b((c(),u(l,{key:2},{default:n((()=>[(c(!0),y(h,null,x($.district,(e=>(c(),u(l,{class:v(["leading-loose",{"text-[red]":q.district&&q.district.id==e.id}]),onClick:a=>q.district=e},{default:n((()=>[m(f(e.name),1)])),_:2},1032,["class","onClick"])))),256))])),_:1},512)),[[g,"district"==w.value]]):_("v-if",!0)])),_:1})])),_:1})])),_:1},8,["show"])}}}),F=a({__name:"address_edit",setup(a){const t=l({id:0,name:"",mobile:"",province_id:0,city_id:0,district_id:0,address:"",full_address:"",is_default:0,area:"",type:"address"}),i=l(),r=l(null),s=l("");V((e=>{e.id&&C(e.id).then((({data:e})=>{e&&Object.assign(t.value,e)})).catch(),s.value=e.type||""}));const v=P((()=>({name:{type:"string",required:!0,message:U("namePlaceholder"),trigger:["blur","change"]},mobile:[{type:"string",required:!0,message:U("mobilePlaceholder"),trigger:["blur","change"]},{validator:()=>uni.$u.test.mobile(t.value.mobile),message:U("mobileError")}],area:{validator:()=>!uni.$u.test.isEmpty(t.value.area),message:U("selectAreaPlaceholder")},address:{type:"string",required:!0,message:U("addressPlaceholder"),trigger:["blur","change"]}}))),_=()=>{i.value.open()},b=e=>{t.value.province_id=e.province.id||0,t.value.city_id=e.city.id||0,t.value.district_id=e.district.id||0,t.value.area=`${e.province.name||""}${e.city.name||""}${e.district.name||""}`},x=l(!1),g=()=>{const e=t.value.id?w:q;r.value.validate().then((()=>{x.value||(x.value=!0,t.value.full_address=t.value.area+t.value.address,e(t.value).then((e=>{x.value=!1,setTimeout((()=>{A({url:"/app/pages/member/address",param:{type:s.value}})}),1e3)})).catch((()=>{x.value=!1})))}))};return(a,l)=>{const s=d(o("u-input"),e),j=d(o("u-form-item"),E),V=k,C=d(o("u-switch"),R),P=d(o("u-button"),T),w=d(o("u-form"),I),q=d(o("area-select"),z);return c(),y(h,null,[p(V,{class:"px-[30rpx]"},{default:n((()=>[p(w,{labelPosition:"left",model:t.value,labelWidth:"200rpx",errorType:"toast",rules:$(v),ref_key:"formRef",ref:r},{default:n((()=>[p(V,{class:"mt-[10rpx]"},{default:n((()=>[p(j,{label:$(U)("name"),prop:"name","border-bottom":!0},{default:n((()=>[p(s,{modelValue:t.value.name,"onUpdate:modelValue":l[0]||(l[0]=e=>t.value.name=e),border:"none",clearable:"",placeholder:$(U)("namePlaceholder")},null,8,["modelValue","placeholder"])])),_:1},8,["label"])])),_:1}),p(V,{class:"mt-[10rpx]"},{default:n((()=>[p(j,{label:$(U)("mobile"),prop:"mobile","border-bottom":!0},{default:n((()=>[p(s,{modelValue:t.value.mobile,"onUpdate:modelValue":l[1]||(l[1]=e=>t.value.mobile=e),border:"none",clearable:"",placeholder:$(U)("mobilePlaceholder")},null,8,["modelValue","placeholder"])])),_:1},8,["label"])])),_:1}),p(V,{class:"mt-[10rpx]"},{default:n((()=>[p(j,{label:$(U)("selectArea"),prop:"area","border-bottom":!0,onClick:_},{default:n((()=>[t.value.area?(c(),u(V,{key:1,class:"text-[30rpx]"},{default:n((()=>[m(f(t.value.area),1)])),_:1})):(c(),u(V,{key:0,class:"text-gray-placeholder text-[30rpx]"},{default:n((()=>[m(f($(U)("selectAreaPlaceholder")),1)])),_:1}))])),_:1},8,["label"])])),_:1}),p(V,{class:"mt-[10rpx]"},{default:n((()=>[p(j,{label:$(U)("address"),prop:"address","border-bottom":!0},{default:n((()=>[p(s,{modelValue:t.value.address,"onUpdate:modelValue":l[2]||(l[2]=e=>t.value.address=e),border:"none",clearable:"",placeholder:$(U)("addressPlaceholder")},null,8,["modelValue","placeholder"])])),_:1},8,["label"])])),_:1}),p(V,{class:"mt-[10rpx]"},{default:n((()=>[p(j,{label:$(U)("defaultAddress"),prop:"name","border-bottom":!0},{default:n((()=>[p(C,{modelValue:t.value.is_default,"onUpdate:modelValue":l[3]||(l[3]=e=>t.value.is_default=e),size:"20",activeValue:1,inactiveValue:0},null,8,["modelValue"])])),_:1},8,["label"])])),_:1}),p(V,{class:"mt-[40rpx]"},{default:n((()=>[p(P,{type:"primary",shape:"circle",text:$(U)("save"),onClick:g,loading:x.value},null,8,["text","loading"])])),_:1})])),_:1},8,["model","rules"])])),_:1}),p(q,{ref_key:"areaRef",ref:i,onComplete:b,"area-id":t.value.district_id},null,8,["area-id"])],64)}}});export{F as default};