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