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