1 |
- import{N as e,z as a,Q as l,o as s,aJ as t,R as d,f as o,g as r,w as i,x as n,_ as m,aK as u,q as c,m as f,k as _,u as p,v as b,i as h,s as g,P as y,n as w,j as x,J as B}from"./index-dbd18a2c.js";import{m as V,a as v,b as A,d as S}from"./phone-international-input.18d32780.js";import{_ as k,a as j}from"./su-region-picker.58ab2ddf.js";import{a as R,_ as I}from"./s-layout.cc30b4d6.js";import{_ as N}from"./_plugin-vue_export-helper.1b428a4d.js";import"./useGoods.12bde50a.js";const U=N({__name:"edit",setup(N){const U=e(null),$=a({showRegion:!1,model:{name:"",mobile:"",detailAddress:"",defaultStatus:!1,areaName:"",addressType:2},rules:{}}),z={name:{rules:[{required:!0,errorMessage:l("address.enter_recipient_name")}]},mobile:V,detailAddress:{rules:[{required:!0,errorMessage:l("address.enter_detailed_address")}]}},C=e=>{$.model.areaName=`${e.province_name} ${e.city_name} ${e.district_name}`,$.model.areaId=e.district_id,$.showRegion=!1},q=async()=>{console.log($);if(!(await n(U).validate().catch((e=>{console.log("error: ",e)}))))return;const e={...$.model},{code:a}=$.model.id>0?await t.updateAddress(e):await t.createAddress(e);0===a&&g.$router.back()},D=()=>{y({title:l("setting.prompt"),content:l("address.confirm_delete_address"),success:async function(e){if(!e.confirm)return;const{code:a}=await t.deleteAddress($.model.id,2);0===a&&g.$router.back()}})};return s((async e=>{if(m.isEmpty(d("areaData"))&&u.getAreaTree().then((e=>{0===e.code&&c("areaData",e.data)})),e.id){let{code:a,data:l}=await t.getAddress(e.id,2);if(0!==a)return;$.model=l}if(e.data){let a=JSON.parse(e.data);let l=d("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 t=s[0].children.filter((e=>e.name==a.district_name));a.district_id=t[0].id,$.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 s=f(w("uni-easyinput"),v),t=f(w("uni-forms-item"),A),d=x,m=f(w("su-switch"),k),u=f(w("uni-forms"),S),c=B,g=f(w("su-fixed"),R),y=f(w("su-region-picker"),j),V=f(w("s-layout"),I);return o(),r(V,{title:$.model.id?n(l)("address.edit_virtual_address"):n(l)("address.add_virtual_address")},{default:i((()=>[_(u,{ref_key:"addressFormRef",ref:U,modelValue:$.model,"onUpdate:modelValue":a[4]||(a[4]=e=>$.model=e),rules:z,validateTrigger:"bind",labelWidth:"160",labelAlign:"left",border:"",labelStyle:{fontWeight:"bold"}},{default:i((()=>[_(d,{class:"bg-white form-box ss-p-x-30"},{default:i((()=>[_(t,{name:"name",label:n(l)("address.recipient"),class:"form-item"},{default:i((()=>[_(s,{modelValue:$.model.name,"onUpdate:modelValue":a[0]||(a[0]=e=>$.model.name=e),placeholder:n(l)("address.enter_recipient_name"),inputBorder:!1,placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",maxlength:10},null,8,["modelValue","placeholder"])])),_:1},8,["label"]),_(t,{name:"mobile",label:n(l)("account.phone_number"),class:"form-item"},{default:i((()=>[_(s,{modelValue:$.model.mobile,"onUpdate:modelValue":a[1]||(a[1]=e=>$.model.mobile=e),type:"number",placeholder:n(l)("account.enter_phone_number"),inputBorder:!1,placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"},null,8,["modelValue","placeholder"])])),_:1},8,["label"]),_(t,{name:"detailAddress",label:n(l)("address.detailed_address"),formItemStyle:{alignItems:"flex-start"},labelStyle:{lineHeight:"5em"},class:"textarea-item"},{default:i((()=>[_(s,{inputBorder:!1,type:"textarea",modelValue:$.model.detailAddress,"onUpdate:modelValue":a[2]||(a[2]=e=>$.model.detailAddress=e),placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",placeholder:n(l)("address.enter_detailed_address"),clearable:""},null,8,["modelValue","placeholder"])])),_:1},8,["label"])])),_:1}),_(d,{class:"ss-m-y-20 bg-white ss-p-x-30 ss-flex ss-row-between ss-col-center default-box"},{default:i((()=>[_(d,{class:"default-box-title"},{default:i((()=>[p(b(n(l)("address.set_as_default_virtual_address")),1)])),_:1}),_(m,{style:{transform:"scale(0.8)"},modelValue:$.model.defaultStatus,"onUpdate:modelValue":a[3]||(a[3]=e=>$.model.defaultStatus=e)},null,8,["modelValue"])])),_:1})])),_:1},8,["modelValue"]),_(g,{bottom:"",opacity:!1,bg:"",placeholder:"",noFixed:!1,index:10},{default:i((()=>[_(d,{class:"footer-box ss-flex-col ss-row-between ss-p-20"},{default:i((()=>[_(d,{class:"ss-m-b-20"},{default:i((()=>[_(c,{class:"ss-reset-button save-btn ui-Shadow-Main",onClick:q},{default:i((()=>[p(b(n(l)("common.save")),1)])),_:1})])),_:1}),$.model.id?(o(),r(c,{key:0,class:"ss-reset-button cancel-btn",onClick:D},{default:i((()=>[p(b(n(l)("common.delete")),1)])),_:1})):h("",!0)])),_:1})])),_:1}),_(y,{show:$.showRegion,onCancel:a[5]||(a[5]=e=>$.showRegion=!1),onConfirm:C},null,8,["show"])])),_:1},8,["title"])}}},[["__scopeId","data-v-c9d31157"]]);export{U as default};
|