pages-user-dummyAddress-edit.cb775315.js 4.6 KB

1
  1. import{N as e,z as a,o as l,aE as t,Q as s,f as o,g as d,w as r,_ as i,aF as n,q as m,m as u,k as c,u as f,i as p,x as b,s as _,P as h,n as g,j as y,J as w}from"./index-ba48620e.js";import{m as x,a as B,b as V,d as A}from"./phone-international-input.dd3ca29e.js";import{_ as S,a as k}from"./su-region-picker.660ae4b3.js";import{a as v,_ as j}from"./s-layout.04b95866.js";import{_ as I}from"./_plugin-vue_export-helper.1b428a4d.js";import"./useGoods.edb8879f.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:x,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},z=async()=>{console.log(R);if(!(await b(N).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&&_.$router.back()},C=()=>{h({title:"提示",content:"确认删除此收货地址吗?",success:async function(e){if(!e.confirm)return;const{code:a}=await t.deleteAddress(R.model.id,2);0===a&&_.$router.back()}})};return l((async e=>{if(i.isEmpty(s("areaData"))&&n.getAreaTree().then((e=>{0===e.code&&m("areaData",e.data)})),e.id){let{code:a,data:l}=await t.getAddress(e.id,2);if(0!==a)return;R.model=l}if(e.data){let a=JSON.parse(e.data);let l=s("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 o=t[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=u(g("uni-easyinput"),B),t=u(g("uni-forms-item"),V),s=y,i=u(g("su-switch"),S),n=u(g("uni-forms"),A),m=w,b=u(g("su-fixed"),v),_=u(g("su-region-picker"),k),h=u(g("s-layout"),j);return o(),d(h,{title:R.model.id?"编辑虚拟地址":"新增虚拟地址"},{default:r((()=>[c(n,{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:r((()=>[c(s,{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:"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[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}),c(s,{class:"ss-m-y-20 bg-white ss-p-x-30 ss-flex ss-row-between ss-col-center default-box"},{default:r((()=>[c(s,{class:"default-box-title"},{default:r((()=>[f(" 设为默认虚拟地址 ")])),_:1}),c(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"]),c(b,{bottom:"",opacity:!1,bg:"",placeholder:"",noFixed:!1,index:10},{default:r((()=>[c(s,{class:"footer-box ss-flex-col ss-row-between ss-p-20"},{default:r((()=>[c(s,{class:"ss-m-b-20"},{default:r((()=>[c(m,{class:"ss-reset-button save-btn ui-Shadow-Main",onClick:z},{default:r((()=>[f("保存")])),_:1})])),_:1}),R.model.id?(o(),d(m,{key:0,class:"ss-reset-button cancel-btn",onClick:C},{default:r((()=>[f(" 删除 ")])),_:1})):p("",!0)])),_:1})])),_:1}),c(_,{show:R.showRegion,onCancel:a[5]||(a[5]=e=>R.showRegion=!1),onConfirm:$},null,8,["show"])])),_:1},8,["title"])}}},[["__scopeId","data-v-aebc0339"]]);export{N as default};