You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
8.6 KiB
1 lines
8.6 KiB
import{d as ee,v as le,r as y,l as B,aq as te,S as ae,k as r,aj as g,al as ie,h as _,c as L,e as o,w as c,u as n,J as k,m as x,a as h,ac as z,bn as de,F as U,W as D,i as H,t as J,ax as re,K as oe,am as se,G as ne,D as ce,a4 as ue,af as pe,H as _e,E as me,L as fe}from"./index-f5d841af.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import"./el-form-item-4ed993c7.js";/* empty css *//* empty css *//* empty css */import{g as ve,e as be,a as ye}from"./shop_address-3db321e7.js";import{B as w,Y as ge,al as he}from"./sys-4eb1a831.js";import{c as Ve,l as we,a as Le}from"./qqmap-011f3cfb.js";const ke={class:"main-container"},xe={class:"flex flex-col"},Ee={id:"container",class:"w-[800px] h-[520px] relative"},Pe={class:"fixed-footer-wrap"},Ae={class:"fixed-footer !z-[9999]"},Je=ee({__name:"edit",setup(Ce){const N=le(),E=parseInt(N.query.id),m=y(!1),W=N.meta.title,p=B({province:[],city:[],district:[]}),P=y(),A=y(),C=y();w(0).then(a=>{p.province=a.data});let R="";te(()=>{const a=document.createElement("script");ge().then(l=>{R=l.data.key,a.type="text/javascript",a.src="https://map.qq.com/api/gljs?libraries=tools,service&v=1.exp&key="+l.data.key,document.body.appendChild(a)}),a.onload=()=>{setTimeout(()=>{Y()},500)}});let v,M;const j=y(!0),Y=()=>{const a=window.TMap,l=a.LatLng,t=new l(e.lat,e.lng);v=new a.Map("container",{center:t,zoom:14}),v.on("tilesloaded",()=>{j.value=!1}),M=Ve(v),v.on("click",d=>{v.setCenter(d.latLng),M.updateGeometries({id:"center",position:d.latLng}),F(d.latLng.lat,d.latLng.lng)}),F(t.lat,t.lng)},u=B({province_id:0,city_id:0,district_id:0}),F=(a,l)=>{we({mapKey:R,lat:a,lng:l}).then(({message:t,result:d})=>{t=="query ok"||t=="Success"?(e.lat=d.location.lat,e.lng=d.location.lng,e.address=d.formatted_addresses.recommend,he(d.ad_info.adcode).then(({data:s})=>{u.province_id=s.province?s.province.id:0,u.city_id=s.city?s.city.id:0,u.district_id=s.district?s.district.id:0})):console.error(t,d)}).catch(t=>{console.log(t)})},I={id:0,contact_name:"",mobile:"",province_id:0,city_id:0,district_id:0,address:"",full_address:"",lat:39.908626,lng:116.39719,is_delivery_address:0,is_refund_address:0,is_default_delivery:0,is_default_refund:0},e=B({...I});E&&(async(a=0)=>{m.value=!0,Object.assign(e,I);const l=await(await ve(a)).data;Object.keys(e).forEach(t=>{l[t]!=null&&(e[t]=l[t])}),m.value=!1})(E);const G=y(),Q=ae(()=>({address_type:[{validator:(a,l,t)=>{!e.is_delivery_address&&!e.is_refund_address&&t(new Error(r("addressTypeRequire"))),t()}}],contact_name:[{required:!0,message:r("contactNamePlaceholder"),trigger:"blur"}],mobile:[{required:!0,message:r("mobilePlaceholder"),trigger:"blur"},{trigger:"blur",validator:(a,l,t)=>{l&&!/^1[3-9]\d{9}$/.test(l)&&t(new Error(r("mobileTips"))),t()}}],address_area:[{validator:(a,l,t)=>{e.province_id||t(new Error(r("provincePlaceholder"))),e.city_id||t(new Error(r("cityPlaceholder"))),p.district.length&&!e.district_id&&t(new Error(r("districtPlaceholder"))),t()}}],address:[{required:!0,message:r("addressPlaceholder"),trigger:"blur"}]}));g(()=>e.province_id,a=>{a?w(e.province_id).then(l=>{p.city=l.data;const t=e.city_id;if(t){let d=!1;for(let s=0;s<l.data.length;s++)if(t==l.data[s].id){d=!0;break}if(d){e.city_id=t;return}}e.city_id=0,S()}):e.city_id=0}),g(()=>e.city_id,a=>{a?w(e.city_id).then(l=>{p.district=l.data;const t=e.district_id;if(t){let d=!1;for(let s=0;s<l.data.length;s++)if(t==l.data[s].id){d=!0;break}if(d){e.district_id=t;return}}S(),e.district_id=0}):e.district_id=0}),g(()=>e.district_id,a=>{a&&S()});const S=ie(()=>{setTimeout(()=>{const a=[e.province_id?P.value.selectedLabel:"",e.city_id?A.value.selectedLabel:"",e.district_id?C.value.selectedLabel:""];Le({mapKey:R,address:a.join("")}).then(({message:l,result:t})=>{if(l=="Success"||l=="query ok"){const d=new window.TMap.LatLng(t.location.lat,t.location.lng);v.setCenter(d),M.updateGeometries({id:"center",position:d}),e.lat=t.location.lat,e.lng=t.location.lng}else console.error(l,t)})},500)},500);g(()=>u.province_id,a=>{a&&w(u.province_id).then(l=>{p.city=l.data,e.province_id=u.province_id,e.city_id=u.city_id})}),g(()=>u.city_id,a=>{a&&w(u.city_id).then(l=>{p.district=l.data,e.city_id=u.city_id,e.district_id=u.district_id})}),g(()=>u.district_id,a=>{a&&(e.district_id=u.district_id)});const X=async a=>{m.value||!a||await a.validate(async l=>{if(l){m.value=!0;const t=e,d=[t.province_id?P.value.selectedLabel:"",t.city_id?A.value.selectedLabel:"",t.district_id?C.value.selectedLabel:"",t.address];t.full_address=d.join(""),(E?be:ye)(t).then(f=>{m.value=!1,history.back()}).catch(()=>{m.value=!1})}})},K=()=>{history.back()};return(a,l)=>{const t=re,d=oe,s=se,f=ne,T=ce,b=ue,q=pe,Z=_e,O=me,$=fe;return _(),L("div",ke,[o(d,{class:"card !border-none mb-[15px]",shadow:"never"},{default:c(()=>[o(t,{content:n(W),icon:a.ArrowLeft,onBack:K},null,8,["content","icon"])]),_:1}),k((_(),x(d,{class:"box-card !border-none",shadow:"never"},{default:c(()=>[o(Z,{model:e,"label-width":"90px",ref_key:"formRef",ref:G,rules:n(Q),class:"page-form"},{default:c(()=>[o(f,{label:n(r)("addressType"),prop:"address_type"},{default:c(()=>[h("div",xe,[h("div",null,[o(s,{modelValue:e.is_delivery_address,"onUpdate:modelValue":l[0]||(l[0]=i=>e.is_delivery_address=i),label:n(r)("deliveryAddress"),"true-label":1,"false-label":0},null,8,["modelValue","label"]),k(o(s,{modelValue:e.is_default_delivery,"onUpdate:modelValue":l[1]||(l[1]=i=>e.is_default_delivery=i),label:n(r)("defaultDeliveryAddress"),"true-label":1,"false-label":0},null,8,["modelValue","label"]),[[z,e.is_delivery_address]])]),h("div",null,[o(s,{modelValue:e.is_refund_address,"onUpdate:modelValue":l[2]||(l[2]=i=>e.is_refund_address=i),label:n(r)("refundAddress"),"true-label":1,"false-label":0},null,8,["modelValue","label"]),k(o(s,{modelValue:e.is_default_refund,"onUpdate:modelValue":l[3]||(l[3]=i=>e.is_default_refund=i),label:n(r)("defaultRefundAddress"),"true-label":1,"false-label":0},null,8,["modelValue","label"]),[[z,e.is_refund_address]])])])]),_:1},8,["label"]),o(f,{label:n(r)("contactName"),prop:"contact_name"},{default:c(()=>[o(T,{modelValue:e.contact_name,"onUpdate:modelValue":l[4]||(l[4]=i=>e.contact_name=i),modelModifiers:{trim:!0},clearable:"",placeholder:n(r)("contactNamePlaceholder"),class:"input-width",maxlength:"10"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),o(f,{label:n(r)("mobile"),prop:"mobile"},{default:c(()=>[o(T,{modelValue:e.mobile,"onUpdate:modelValue":l[5]||(l[5]=i=>e.mobile=i),modelModifiers:{trim:!0},clearable:"",placeholder:n(r)("mobilePlaceholder"),class:"input-width",onKeyup:l[6]||(l[6]=i=>n(de)(i)),onBlur:l[7]||(l[7]=i=>e.mobile=i.target.value)},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),o(f,{label:n(r)("fullAddress"),prop:"address_area"},{default:c(()=>[o(q,{modelValue:e.province_id,"onUpdate:modelValue":l[8]||(l[8]=i=>e.province_id=i),"value-key":"id",clearable:"",class:"w-[200px]",ref_key:"provinceRef",ref:P},{default:c(()=>[o(b,{label:n(r)("provincePlaceholder"),value:0},null,8,["label"]),(_(!0),L(U,null,D(p.province,(i,V)=>(_(),x(b,{key:V,label:i.name,value:i.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),o(q,{modelValue:e.city_id,"onUpdate:modelValue":l[9]||(l[9]=i=>e.city_id=i),"value-key":"id",clearable:"",class:"w-[200px] ml-3",ref_key:"cityRef",ref:A},{default:c(()=>[o(b,{label:n(r)("cityPlaceholder"),value:0},null,8,["label"]),(_(!0),L(U,null,D(p.city,(i,V)=>(_(),x(b,{key:V,label:i.name,value:i.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),o(q,{modelValue:e.district_id,"onUpdate:modelValue":l[10]||(l[10]=i=>e.district_id=i),"value-key":"id",clearable:"",class:"w-[200px] ml-3",ref_key:"districtRef",ref:C},{default:c(()=>[o(b,{label:n(r)("districtPlaceholder"),value:0},null,8,["label"]),(_(!0),L(U,null,D(p.district,(i,V)=>(_(),x(b,{key:V,label:i.name,value:i.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"]),o(f,{prop:"address"},{default:c(()=>[o(T,{modelValue:e.address,"onUpdate:modelValue":l[11]||(l[11]=i=>e.address=i),modelModifiers:{trim:!0},clearable:"",placeholder:n(r)("addressPlaceholder"),class:"input-width"},null,8,["modelValue","placeholder"])]),_:1}),o(f,null,{default:c(()=>[k(h("div",Ee,null,512),[[$,j.value]])]),_:1})]),_:1},8,["model","rules"])]),_:1})),[[$,m.value]]),h("div",Pe,[h("div",Ae,[o(O,{type:"primary",onClick:l[12]||(l[12]=i=>X(G.value))},{default:c(()=>[H(J(n(r)("save")),1)]),_:1}),o(O,{onClick:l[13]||(l[13]=i=>K())},{default:c(()=>[H(J(n(r)("cancel")),1)]),_:1})])])])}}});export{Je as default};
|
|
|