import{d as e,r as a,o as l,b8 as r,c as s,h as t,i as d,w as o,l as u,j as i,m,J as n,K as c,a9 as p,Y as b,b9 as v,ba as f,$ as _,bb as h,t as g,p as x,q as y,ao as V}from"./index-849cf30e.js";import{_ as j}from"./u-input.46b72faa.js";import{_ as w,a as P}from"./u-form.4f9a45b5.js";import{_ as k}from"./u-icon.e3aa4770.js";import{_ as $}from"./u-switch.2489393e.js";import{_ as q}from"./u-button.9fa3f2a0.js";import"./_plugin-vue_export-helper.1b428a4d.js";import"./u-line.19eb5c40.js";import"./u-loading-icon.d012ecbf.js";const A=e({__name:"location_address_edit",setup(e){const A=a(""),C=a({id:0,name:"",mobile:"",lat:"",lng:"",address:"",address_name:"学府街",full_address:"",is_default:0,area:"",type:"location_address"});l((e=>{e.id&&r(e.id).then((({data:e})=>{e&&(Object.assign(C.value,e),C.value.area=C.value.full_address.replace(C.value.address,"").replace(C.value.address_name,""))})).catch(),A.value=e.type||""}));const U=a(null),E=s((()=>({address:{type:"string",required:!0,message:b("addressError"),trigger:["blur","change"]},name:{type:"string",required:!0,message:b("namePlaceholder"),trigger:["blur","change"]},mobile:[{type:"string",required:!0,message:b("mobilePlaceholder"),trigger:["blur","change"]},{validator:()=>uni.$u.test.mobile(C.value.mobile),message:b("mobileError")}]}))),T=a(!1),Y=()=>{if(uni.$u.test.isEmpty(C.value.area))return void p({title:b("selectAddressPlaceholder"),icon:"none"});const e=C.value.id?v:f;U.value.validate().then((()=>{T.value||(T.value=!0,C.value.full_address=`${C.value.area}${C.value.address_name}${C.value.address}`,e(C.value).then((e=>{T.value=!1,setTimeout((()=>{_({url:"/app/pages/member/address",param:{type:A.value}})}),1e3)})).catch((()=>{T.value=!1})))}))},z=()=>{h({success:e=>{e.latitude&&(C.value.lat=e.latitude),e.longitude&&(C.value.lng=e.longitude),e.address&&(C.value.area=e.address),e.name&&(C.value.address_name=e.name)}})};return(e,a)=>{const l=g,r=x(y("u-input"),j),s=x(y("u-form-item"),w),p=x(y("u-icon"),k),v=x(y("u-switch"),$),f=x(y("u-button"),q),_=x(y("u-form"),P),h=V;return t(),d(h,{"scroll-y":"true",class:"bg-page h-screen"},{default:o((()=>[u(' \r\n\t\t \r\n\t\t '),i(l,{class:"h-[30rpx]"}),i(l,{class:"m-[30rpx] mt-0 p-[30rpx] pt-[10rpx] rounded-md bg-white"},{default:o((()=>[i(_,{labelPosition:"left",model:C.value,labelWidth:"200rpx",errorType:"toast",rules:m(E),ref_key:"formRef",ref:U},{default:o((()=>[i(l,{class:"mt-[10rpx]"},{default:o((()=>[i(s,{label:m(b)("name"),prop:"name","border-bottom":!0},{default:o((()=>[i(r,{modelValue:C.value.name,"onUpdate:modelValue":a[0]||(a[0]=e=>C.value.name=e),border:"none",clearable:"",placeholder:m(b)("namePlaceholder")},null,8,["modelValue","placeholder"])])),_:1},8,["label"])])),_:1}),i(l,{class:"mt-[10rpx]"},{default:o((()=>[i(s,{label:m(b)("mobile"),prop:"mobile","border-bottom":!0},{default:o((()=>[i(r,{modelValue:C.value.mobile,"onUpdate:modelValue":a[1]||(a[1]=e=>C.value.mobile=e),border:"none",clearable:"",placeholder:m(b)("mobilePlaceholder")},null,8,["modelValue","placeholder"])])),_:1},8,["label"])])),_:1}),i(l,{class:"mt-[10rpx]"},{default:o((()=>[i(s,{label:m(b)("deliveryAddress"),prop:"address_name","border-bottom":!0},{default:o((()=>[i(l,{class:"flex justify-between flex-1",onClick:z},{default:o((()=>[i(l,{class:"text-[#c3c4d5] text-[15px]"},{default:o((()=>[n(c(C.value.area?C.value.address_name:m(b)("selectAddressPlaceholder")),1)])),_:1}),i(p,{name:"arrow-right",color:"#c3c4d5"})])),_:1})])),_:1},8,["label"])])),_:1}),i(l,{class:"mt-[10rpx]"},{default:o((()=>[i(s,{label:m(b)("address"),prop:"address","border-bottom":!0},{default:o((()=>[i(r,{modelValue:C.value.address,"onUpdate:modelValue":a[2]||(a[2]=e=>C.value.address=e),border:"none",clearable:"",placeholder:m(b)("addressPlaceholder")},null,8,["modelValue","placeholder"])])),_:1},8,["label"])])),_:1}),i(l,{class:"mt-[10rpx]"},{default:o((()=>[i(s,{label:m(b)("defaultAddress"),prop:"name","border-bottom":!0},{default:o((()=>[i(v,{modelValue:C.value.is_default,"onUpdate:modelValue":a[3]||(a[3]=e=>C.value.is_default=e),size:"20",activeValue:1,inactiveValue:0},null,8,["modelValue"])])),_:1},8,["label"])])),_:1}),i(l,{class:"mt-[40rpx]"},{default:o((()=>[i(f,{type:"primary",shape:"circle",text:m(b)("save"),onClick:Y,loading:T.value},null,8,["text","loading"])])),_:1})])),_:1},8,["model","rules"])])),_:1})])),_:1})}}});export{A as default};