niucloud-admin/niucloud/public/wap/assets/app-pages-member-address_edit.ffaba58c.js
2026-04-03 11:21:55 +08:00

2 lines
11 KiB
JavaScript

import{a8 as e,a9 as a,aa as l,ae as t,af as s,l as i,m as r,o as d,e as o,w as u,f as n,k as c,E as v,p,d as m,b as f,r as h,M as _,c8 as g,t as b,c9 as y,F as x,ca as w,z as C,g as S,C as V,D as k,B as A,c7 as z,cb as j,c as $,cc as I,K as P,L as B,q as N,A as E}from"./index-e204f8a0.js";import{_ as M}from"./u-input.32fa069b.js";import{_ as T,a as W}from"./u-form.9851509f.js";import{_ as q}from"./u-loading-icon.f633cc42.js";import{_ as U}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as D}from"./area-select.58782f96.js";import"./u-icon.0467785f.js";import"./u-line.9595b94f.js";import"./u-popup.634a8d49.js";import"./u-transition.7f6cc838.js";const F=U({name:"u-switch",mixins:[a,l,{props:{loading:{type:Boolean,default:()=>e.switch.loading},disabled:{type:Boolean,default:()=>e.switch.disabled},size:{type:[String,Number],default:()=>e.switch.size},activeColor:{type:String,default:()=>e.switch.activeColor},inactiveColor:{type:String,default:()=>e.switch.inactiveColor},modelValue:{type:[Boolean,String,Number],default:()=>e.switch.value},activeValue:{type:[String,Number,Boolean],default:()=>e.switch.activeValue},inactiveValue:{type:[String,Number,Boolean],default:()=>e.switch.inactiveValue},asyncChange:{type:Boolean,default:()=>e.switch.asyncChange},space:{type:[String,Number],default:()=>e.switch.space}}}],watch:{modelValue:{immediate:!0,handler(e){e!==this.inactiveValue&&this.activeValue}}},data:()=>({bgColor:"#ffffff"}),computed:{isActive(){return this.modelValue===this.activeValue},switchStyle(){let e={};return e.width=t(2*this.size+2),e.height=t(Number(this.size)+2),this.customInactiveColor&&(e.borderColor="rgba(0, 0, 0, 0)"),e.backgroundColor=this.isActive?this.activeColor:this.inactiveColor,e},nodeStyle(){let e={};e.width=t(this.size-this.space),e.height=t(this.size-this.space);const a=this.isActive?t(this.space):t(this.size);return e.transform=`translateX(-${a})`,e},bgStyle(){let e={};return e.width=t(2*Number(this.size)-this.size/2),e.height=t(this.size),e.backgroundColor=this.inactiveColor,e.transform=`scale(${this.isActive?0:1})`,e},customInactiveColor(){return"#fff"!==this.inactiveColor&&"#ffffff"!==this.inactiveColor}},emits:["update:modelValue","change"],methods:{addStyle:s,clickHandler(){if(!this.disabled&&!this.loading){const e=this.isActive?this.inactiveValue:this.activeValue;this.asyncChange||this.$emit("update:modelValue",e),this.$nextTick(()=>{this.$emit("change",e)})}}}},[["render",function(e,a,l,t,s,m){const f=p,h=i(r("u-loading-icon"),q);return d(),o(f,{class:v(["u-switch cursor-pointer",[e.disabled&&"u-switch--disabled"]]),style:c([m.switchStyle,m.addStyle(e.customStyle)]),onClick:m.clickHandler},{default:u(()=>[n(f,{class:"u-switch__bg",style:c([m.bgStyle])},null,8,["style"]),n(f,{class:v(["u-switch__node",[e.modelValue&&"u-switch__node--on"]]),style:c([m.nodeStyle]),ref:"u-switch__node"},{default:u(()=>[n(h,{show:e.loading,mode:"circle",timingFunction:"linear",color:e.modelValue?e.activeColor:"#AAABAD",size:.6*e.size},null,8,["show","color","size"])]),_:1},8,["class","style"])]),_:1},8,["class","style","onClick"])}],["__scopeId","data-v-09bf48b9"]]),H=U(m({__name:"address_edit",setup(e){const a=f(),l=h({id:0,name:"",mobile:"",province_id:0,city_id:0,district_id:0,lat:"",lng:"",address:"",address_name:"",full_address:"",is_default:0,area:""}),t=h(),s=h(null),m=h(""),q=h(!1),U=h(!1),H=h("address"),O=h(2);h(null),_(e=>{O.value=e.isSelectMap||"";const a=uni.getStorageSync("selectAddressCallback");if(e.id)g(e.id).then(e=>{e.data&&Object.assign(l.value,e.data),a&&(H.value="express"==a.delivery?"address":"locationAddress")});else if(e.name){uni.getStorageSync("addressInfo")&&Object.assign(l.value,uni.getStorageSync("addressInfo")),Q(e.latng);const a=Y("latng").split(",");l.value.lat=a[0],l.value.lng=a[1]}m.value=e.source||"",a&&(H.value="express"==a.delivery?"address":"locationAddress"),ee()});const R=b(()=>({name:{type:"string",required:!0,message:E("namePlaceholder"),trigger:["blur","change"]},mobile:[{type:"string",required:!0,message:E("mobilePlaceholder"),trigger:["blur","change"]},{validator(e,a,l){/^1[3-9]\d{9}$/.test(a)?l():l(new Error(E("mobileError")))}}],area:{validator(){let e=!0;return uni.$u.test.isEmpty(l.value.area)&&uni.$u.test.isEmpty(l.value.address_name)&&(e=!1),e},message:E("selectAreaPlaceholder")},address:{type:"string",required:!0,message:E("addressPlaceholder"),trigger:["blur","change"]}})),K=()=>{U.value=!0,t.value.open()},L=e=>{var a,t,s,i,r,d,o,u,n;!U.value||l.value.province_id!=(null==(a=e.province)?void 0:a.id)&&l.value.city_id==(null==(t=e.city)?void 0:t.id)&&l.value.district_id==(null==(s=e.district)?void 0:s.id)||(l.value.lat="",l.value.lng=""),l.value.province_id=(null==(i=e.province)?void 0:i.id)||0,l.value.city_id=(null==(r=e.city)?void 0:r.id)||0,l.value.district_id=(null==(d=e.district)?void 0:d.id)||0,l.value.area=`${(null==(o=e.province)?void 0:o.name)||""}${(null==(u=e.city)?void 0:u.name)||""}${(null==(n=e.district)?void 0:n.name)||""}`,U.value=!1},X=h(!1),G=()=>{const e=l.value.id?z:j;s.value.validate().then(()=>{if(!X.value){if(X.value=!0,q.value=!0,l.value.full_address=l.value.area+l.value.address,1==O.value&&!l.value.lat&&!l.value.lng)return x({title:"缺少经纬度,请在地图上重新选点",icon:"none"}),X.value=!1,q.value=!1,!1;e(l.value).then(e=>{X.value=!1,setTimeout(()=>{if(q.value=!1,"shop_order_payment"==m.value){const a=uni.getStorageSync("selectAddressCallback");a&&(a.address_id=e.data.id||l.value.id,uni.setStorage({key:"selectAddressCallback",data:a,success(){$({url:a.back,mode:"redirectTo"})}}))}else $({url:"/app/pages/member/address",mode:"redirectTo",param:{source:m.value}})},1e3)}).catch(()=>{X.value=!1,q.value=!1})}})},J=()=>{let e=a.diyAddressInfo?a.diyAddressInfo.latitude:"",t=a.diyAddressInfo?a.diyAddressInfo.longitude:"";l.value;let s=location.origin+location.pathname+"?source="+m.value;O.value&&(s=s+"&isSelectMap="+O.value);let i="";e&&t&&(i=`latng=${e},${t}`),I(s,i)},Q=e=>{y({latlng:e}).then(e=>{e.data?(l.value.address=e.data.formatted_addresses.recommend,l.value.full_address="",l.value.full_address+=null!=e.data.province?e.data.province:"",l.value.full_address+=null!=e.data.city?""+e.data.city:"",l.value.full_address+=null!=e.data.district?""+e.data.district:"",l.value.address_name=l.value.full_address.replace(/-/g,""),l.value.area=e.data.province+e.data.city+e.data.district||e.data.full_address,l.value.province_id=null!=e.data.province_id?e.data.province_id:0,l.value.city_id=null!=e.data.city_id?e.data.city_id:0,l.value.district_id=null!=e.data.district_id?e.data.district_id:0):x({title:e.msg,icon:"none"})})},Y=e=>{const a=window.location.search.substring(1).split("&");for(let l=0;l<a.length;l++){const t=a[l].split("=");if(t[0]==e)return t[1]}return!1},Z=h([]),ee=()=>{w(3).then(e=>{Z.value=e.data}).catch()};return h(!1),C(()=>{}),(e,a)=>{const m=i(r("u-input"),M),f=i(r("u-form-item"),T),h=p,_=P,g=i(r("u-switch"),F),b=i(r("u-form"),W),y=B,x=i(r("area-select"),D),w=N("layout-default-uni");return d(),o(w,null,{default:u(()=>[n(h,{class:"bg-[var(--page-bg-color)] min-h-[100vh] overflow-hidden address-edit",style:c(e.themeColor())},{default:u(()=>[n(b,{labelPosition:"left",model:l.value,errorType:"toast",rules:S(R),ref_key:"formRef",ref:s},{default:u(()=>[n(h,{class:"sidebar-margin card-template mt-[var(--top-m)] py-[20rpx]"},{default:u(()=>[n(h,null,{default:u(()=>[n(f,{label:S(E)("name"),prop:"name",labelWidth:"200rpx"},{default:u(()=>[n(m,{fontSize:"28rpx",modelValue:l.value.name,"onUpdate:modelValue":a[0]||(a[0]=e=>l.value.name=e),modelModifiers:{trim:!0},border:"none",clearable:"",maxlength:"25",placeholderStyle:"color: #888",placeholder:S(E)("namePlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(h,{class:"mt-[16rpx]"},{default:u(()=>[n(f,{label:S(E)("mobile"),prop:"mobile",labelWidth:"200rpx"},{default:u(()=>[n(m,{fontSize:"28rpx",modelValue:l.value.mobile,"onUpdate:modelValue":a[1]||(a[1]=e=>l.value.mobile=e),modelModifiers:{trim:!0},maxlength:"11",border:"none",clearable:"",placeholder:S(E)("mobilePlaceholder"),placeholderStyle:"color: #888"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(h,{class:"mt-[16rpx]"},{default:u(()=>[n(f,{label:S(E)("selectArea"),prop:"area",labelWidth:"200rpx"},{default:u(()=>["address"==H.value&&1!=O.value?(d(),o(h,{key:0,class:"flex w-full items-center h-[52rpx]",onClick:K},{default:u(()=>[l.value.area?(d(),o(h,{key:1,class:"text-[28rpx] flex-1 leading-[1.4]"},{default:u(()=>[V(k(l.value.area),1)]),_:1})):(d(),o(h,{key:0,class:"text-[#888] text-[28rpx] flex-1"},{default:u(()=>[V(k(S(E)("selectAreaPlaceholder")),1)]),_:1})),n(h,{onClick:A(J,["stop"]),class:"flex items-center"},{default:u(()=>[n(_,{class:"nc-iconfont nc-icon-dizhiguanliV6xx mr-[4rpx] text-[32rpx] text-[var(--primary-color)]"}),n(_,{class:"text-[24rpx] whitespace-nowrap text-[var(--primary-color)]"},{default:u(()=>[V("定位")]),_:1})]),_:1},8,["onClick"])]),_:1})):(d(),o(h,{key:1,class:"flex justify-between items-center flex-1 h-[52rpx]",onClick:J},{default:u(()=>[l.value.area||l.value.address_name?(d(),o(h,{key:0,class:"text-[28rpx] text-[#303133] leading-[1.4]"},{default:u(()=>[V(k(l.value.area||l.value.address_name),1)]),_:1})):(d(),o(h,{key:1,class:"text-[#888] text-[28rpx]"},{default:u(()=>[V(k(S(E)("selectAddressPlaceholder")),1)]),_:1})),n(h,{class:"flex items-center"},{default:u(()=>[n(_,{class:"nc-iconfont nc-icon-dizhiguanliV6xx text-[32rpx] mr-[4rpx] text-[var(--primary-color)]"}),n(_,{class:"text-[24rpx] whitespace-nowrap text-[var(--primary-color)]"},{default:u(()=>[V("定位")]),_:1})]),_:1})]),_:1}))]),_:1},8,["label"])]),_:1}),n(h,{class:"mt-[16rpx]"},{default:u(()=>[n(f,{label:S(E)("address"),prop:"address",labelWidth:"200rpx"},{default:u(()=>[n(m,{fontSize:"28rpx",modelValue:l.value.address,"onUpdate:modelValue":a[2]||(a[2]=e=>l.value.address=e),border:"none",clearable:"",maxlength:"120",placeholder:S(E)("addressPlaceholder"),placeholderStyle:"color: #888"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})]),_:1}),n(h,{class:"sidebar-margin card-template mt-[var(--top-m)] py-[10rpx]"},{default:u(()=>[n(f,{label:S(E)("defaultAddress"),prop:"name","border-bottom":!1,labelWidth:"200rpx"},{default:u(()=>[n(g,{modelValue:l.value.is_default,"onUpdate:modelValue":a[3]||(a[3]=e=>l.value.is_default=e),size:"20",activeValue:1,inactiveValue:0,activeColor:"var(--primary-color)",inactiveColor:"var(--temp-bg)"},null,8,["modelValue"])]),_:1},8,["label"])]),_:1})]),_:1},8,["model","rules"]),n(h,{class:"w-full footer"},{default:u(()=>[n(h,{class:"py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-30 left-0 right-0 box-border"},{default:u(()=>[n(y,{"hover-class":"none",class:v(["primary-btn-bg !text-[#fff] h-[80rpx] leading-[80rpx] rounded-[100rpx] text-[26rpx] font-500",{"opacity-50":q.value}]),onClick:G,disabled:q.value,loading:X.value},{default:u(()=>[V(k(S(E)("save")),1)]),_:1},8,["disabled","loading","class"])]),_:1})]),_:1}),n(x,{ref_key:"areaRef",ref:t,onComplete:L,"area-id":l.value.district_id||l.value.city_id},null,8,["area-id"])]),_:1},8,["style"])]),_:1})}}}),[["__scopeId","data-v-a96fea0b"]]);export{H as default};