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