pages-user-address-edit.3403f95d.js 5.1 KB

1
  1. import{N as e,z as a,o as l,aI as t,Q as o,f as s,g as d,w as r,_ as i,aJ as n,q as m,m as u,k as c,u as f,i as p,x as h,s as b,P as _,n as g,j as B,J as y}from"./index-a116b7fa.js";import{m as w,a as x,b as V,e as S,d as A}from"./phone-international-input.b9f6c8e6.js";import{_ as k,a as v}from"./su-region-picker.e8b91c7d.js";import{a as N,_ as j}from"./s-layout.4ae51839.js";import{_ as C}from"./_plugin-vue_export-helper.1b428a4d.js";import"./useGoods.6b315a78.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:w,detailAddress:{rules:[{required:!0,errorMessage:"请输入详细地址"}]},areaName:{rules:[{required:!0,errorMessage:"请选择您的位置"}]}},z=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 h(I).validate().catch((e=>{console.log("error: ",e)}))))return;const e={...R.model},{code:a}=R.model.id>0?await t.updateAddress(e):await t.createAddress(e);0===a&&b.$router.back()},q=()=>{_({title:"提示",content:"确认删除此收货地址吗?",success:async function(e){if(!e.confirm)return;const{code:a}=await t.deleteAddress(R.model.id);0===a&&b.$router.back()}})};return l((async e=>{if(i.isEmpty(o("areaData"))&&n.getAreaTree().then((e=>{0===e.code&&m("areaData",e.data)})),e.id){let{code:a,data:l}=await t.getAddress(e.id);if(0!==a)return;R.model=l}if(e.data){let a=JSON.parse(e.data);let l=o("areaData").filter((e=>e.name==a.province_name));a.province_id=l[0].id;let t=l[0].children.filter((e=>e.name==a.city_name));a.city_id=t[0].id;let s=t[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=u(g("uni-easyinput"),x),t=u(g("uni-forms-item"),V),o=u(g("uni-icons"),S),i=B,n=u(g("su-switch"),k),m=u(g("uni-forms"),A),h=y,b=u(g("su-fixed"),N),_=u(g("su-region-picker"),v),w=u(g("s-layout"),j);return s(),d(w,{title:R.model.id?"编辑地址":"新增地址"},{default:r((()=>[c(m,{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:r((()=>[c(i,{class:"bg-white form-box ss-p-x-30"},{default:r((()=>[c(t,{name:"name",label:"收货人",class:"form-item"},{default:r((()=>[c(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",maxlength:10},null,8,["modelValue"])])),_:1}),c(t,{name:"mobile",label:"手机号",class:"form-item"},{default:r((()=>[c(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}),c(t,{name:"areaName",label:"省市区",onClick:a[3]||(a[3]=e=>R.showRegion=!0),class:"form-item"},{default:r((()=>[c(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:r((()=>[c(o,{type:"right"})])),_:1},8,["modelValue"])])),_:1}),c(t,{name:"detailAddress",label:"详细地址",formItemStyle:{alignItems:"flex-start"},labelStyle:{lineHeight:"5em"},class:"textarea-item"},{default:r((()=>[c(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}),c(i,{class:"ss-m-y-20 bg-white ss-p-x-30 ss-flex ss-row-between ss-col-center default-box"},{default:r((()=>[c(i,{class:"default-box-title"},{default:r((()=>[f(" 设为默认地址 ")])),_:1}),c(n,{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"]),c(b,{bottom:"",opacity:!1,bg:"",placeholder:"",noFixed:!1,index:10},{default:r((()=>[c(i,{class:"footer-box ss-flex-col ss-row-between ss-p-20"},{default:r((()=>[c(i,{class:"ss-m-b-20"},{default:r((()=>[c(h,{class:"ss-reset-button save-btn ui-Shadow-Main",onClick:$},{default:r((()=>[f("保存")])),_:1})])),_:1}),R.model.id?(s(),d(h,{key:0,class:"ss-reset-button cancel-btn",onClick:q},{default:r((()=>[f(" 删除 ")])),_:1})):p("",!0)])),_:1})])),_:1}),c(_,{show:R.showRegion,onCancel:a[7]||(a[7]=e=>R.showRegion=!1),onConfirm:z},null,8,["show"])])),_:1},8,["title"])}}},[["__scopeId","data-v-8eedecb2"]]);export{I as default};