pages-user-dummyAddress-edit.84895abd.js 4.6 KB

1
  1. import{K as e,y as a,o as l,N as t,e as s,f as o,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 b,m as _,i as h,G as g}from"./index-c374f39b.js";import{m as y,a as w,b as B,d as x}from"./phone-international-input.8d9bfbe6.js";import{_ as V,a as A}from"./su-region-picker.8941cade.js";import{a as S,_ as v}from"./s-layout.9ed959df.js";import{A as j}from"./area.3155056f.js";import{A as k}from"./address.4cec94db.js";import{_ as I}from"./_plugin-vue_export-helper.1b428a4d.js";const N=I({__name:"edit",setup(I){const N=e(null),R=a({showRegion:!1,model:{name:"",mobile:"",detailAddress:"",defaultStatus:!1,areaName:"",addressType:2},rules:{}}),U={name:{rules:[{required:!0,errorMessage:"请输入收货人姓名"}]},mobile:y,detailAddress:{rules:[{required:!0,errorMessage:"请输入详细地址"}]}},$=e=>{R.model.areaName=`${e.province_name} ${e.city_name} ${e.district_name}`,R.model.areaId=e.district_id,R.showRegion=!1},C=async()=>{console.log(R);if(!(await f(N).validate().catch((e=>{console.log("error: ",e)}))))return;const e={...R.model},{code:a}=R.model.id>0?await k.updateAddress(e):await k.createAddress(e);0===a&&p.$router.back()},M=()=>{b({title:"提示",content:"确认删除此收货地址吗?",success:async function(e){if(!e.confirm)return;const{code:a}=await k.deleteAddress(R.model.id,2);0===a&&p.$router.back()}})};return l((async e=>{if(r.isEmpty(t("areaData"))&&j.getAreaTree().then((e=>{0===e.code&&i("areaData",e.data)})),e.id){let{code:a,data:l}=await k.getAddress(e.id,2);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 s=l[0].children.filter((e=>e.name==a.city_name));a.city_id=s[0].id;let o=s[0].children.filter((e=>e.name==a.district_name));a.district_id=o[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(_("uni-easyinput"),w),t=n(_("uni-forms-item"),B),r=h,i=n(_("su-switch"),V),f=n(_("uni-forms"),x),p=g,b=n(_("su-fixed"),S),y=n(_("su-region-picker"),A),j=n(_("s-layout"),v);return s(),o(j,{title:R.model.id?"编辑虚拟地址":"新增虚拟地址"},{default:d((()=>[m(f,{ref_key:"addressFormRef",ref:N,modelValue:R.model,"onUpdate:modelValue":a[4]||(a[4]=e=>R.model=e),rules:U,validateTrigger:"bind",labelWidth:"160",labelAlign:"left",border:"",labelStyle:{fontWeight:"bold"}},{default:d((()=>[m(r,{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:"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[2]||(a[2]=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(r,{class:"ss-m-y-20 bg-white ss-p-x-30 ss-flex ss-row-between ss-col-center default-box"},{default:d((()=>[m(r,{class:"default-box-title"},{default:d((()=>[u(" 设为默认虚拟地址 ")])),_:1}),m(i,{style:{transform:"scale(0.8)"},modelValue:R.model.defaultStatus,"onUpdate:modelValue":a[3]||(a[3]=e=>R.model.defaultStatus=e)},null,8,["modelValue"])])),_:1})])),_:1},8,["modelValue"]),m(b,{bottom:"",opacity:!1,bg:"",placeholder:"",noFixed:!1,index:10},{default:d((()=>[m(r,{class:"footer-box ss-flex-col ss-row-between ss-p-20"},{default:d((()=>[m(r,{class:"ss-m-b-20"},{default:d((()=>[m(p,{class:"ss-reset-button save-btn ui-Shadow-Main",onClick:C},{default:d((()=>[u("保存")])),_:1})])),_:1}),R.model.id?(s(),o(p,{key:0,class:"ss-reset-button cancel-btn",onClick:M},{default:d((()=>[u(" 删除 ")])),_:1})):c("",!0)])),_:1})])),_:1}),m(y,{show:R.showRegion,onCancel:a[5]||(a[5]=e=>R.showRegion=!1),onConfirm:$},null,8,["show"])])),_:1},8,["title"])}}},[["__scopeId","data-v-084dfbbe"]]);export{N as default};