pages-user-dummyAddress-edit.6a8c4f92.js 5.1 KB

1
  1. import{r as e,v as a,t as l,o as t,bK as s,T as d,a as o,b as r,w as i,u as n,_ as m,bL as u,E as c,j as _,d as p,e as f,f as b,x as h,s as g,R as y,k as x,i as w,M as B}from"./index-39e65128.js";import{_ as v,a as V,b as A}from"./phone-international-input.20ca2464.js";import{_ as S,a as j}from"./su-region-picker.7bd6b2cf.js";import{a as k,_ as R}from"./s-layout.69eddd84.js";import{m as I}from"./phone-international-input.vue_vue_type_style_index_0_scoped_a2d557af_lang.dec8d7d1.js";import{_ as U}from"./_plugin-vue_export-helper.1b428a4d.js";import"./s-layout.vue_vue_type_style_index_0_scoped_0789db2f_lang.a57fff0d.js";import"./s-tabbar.6c197486.js";import"./useGoods.133fe7ed.js";const $=U({__name:"edit",setup(U){const $=e(null),z=a({showRegion:!1,model:{name:"",mobile:"",detailAddress:"",defaultStatus:!1,areaName:"",addressType:2},rules:{}}),C={name:{rules:[{required:!0,errorMessage:l("address.enter_recipient_name")}]},mobile:I,detailAddress:{rules:[{required:!0,errorMessage:l("address.enter_detailed_address")}]}},M=e=>{z.model.areaName=`${e.province_name} ${e.city_name} ${e.district_name}`,z.model.areaId=e.district_id,z.showRegion=!1},N=async()=>{console.log(z);if(!(await n($).validate().catch((e=>{console.log("error: ",e)}))))return;const e={...z.model},{code:a}=z.model.id>0?await s.updateAddress(e):await s.createAddress(e);0===a&&g.$router.back()},T=()=>{y({title:l("setting.prompt"),content:l("address.confirm_delete_address"),success:async function(e){if(!e.confirm)return;const{code:a}=await s.deleteAddress(z.model.id,2);0===a&&g.$router.back()}})};return t((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 s.getAddress(e.id,2);if(0!==a)return;z.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,z.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=_(x("uni-easyinput"),v),s=_(x("uni-forms-item"),V),d=w,m=_(x("su-switch"),S),u=_(x("uni-forms"),A),c=B,g=_(x("su-fixed"),k),y=_(x("su-region-picker"),j),I=_(x("s-layout"),R);return o(),r(I,{title:z.model.id?n(l)("address.edit_virtual_address"):n(l)("address.add_virtual_address")},{default:i((()=>[p(u,{ref_key:"addressFormRef",ref:$,modelValue:z.model,"onUpdate:modelValue":a[4]||(a[4]=e=>z.model=e),rules:C,validateTrigger:"bind",labelWidth:"160",labelAlign:"left",border:"",labelStyle:{fontWeight:"bold"}},{default:i((()=>[p(d,{class:"bg-white form-box ss-p-x-30"},{default:i((()=>[p(s,{name:"name",label:n(l)("address.recipient"),class:"form-item"},{default:i((()=>[p(t,{modelValue:z.model.name,"onUpdate:modelValue":a[0]||(a[0]=e=>z.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(s,{name:"mobile",label:n(l)("account.phone_number"),class:"form-item"},{default:i((()=>[p(t,{modelValue:z.model.mobile,"onUpdate:modelValue":a[1]||(a[1]=e=>z.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(s,{name:"detailAddress",label:n(l)("address.detailed_address"),formItemStyle:{alignItems:"flex-start"},labelStyle:{lineHeight:"5em"},class:"textarea-item"},{default:i((()=>[p(t,{inputBorder:!1,type:"textarea",modelValue:z.model.detailAddress,"onUpdate:modelValue":a[2]||(a[2]=e=>z.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(d,{class:"ss-m-y-20 bg-white ss-p-x-30 ss-flex ss-row-between ss-col-center default-box"},{default:i((()=>[p(d,{class:"default-box-title"},{default:i((()=>[f(b(n(l)("address.set_as_default_virtual_address")),1)])),_:1}),p(m,{style:{transform:"scale(0.8)"},modelValue:z.model.defaultStatus,"onUpdate:modelValue":a[3]||(a[3]=e=>z.model.defaultStatus=e)},null,8,["modelValue"])])),_:1})])),_:1},8,["modelValue"]),p(g,{bottom:"",opacity:!1,bg:"",placeholder:"",noFixed:!1,index:10},{default:i((()=>[p(d,{class:"footer-box ss-flex-col ss-row-between ss-p-20"},{default:i((()=>[p(d,{class:"ss-m-b-20"},{default:i((()=>[p(c,{class:"ss-reset-button save-btn ui-Shadow-Main",onClick:N},{default:i((()=>[f(b(n(l)("common.save")),1)])),_:1})])),_:1}),z.model.id?(o(),r(c,{key:0,class:"ss-reset-button cancel-btn",onClick:T},{default:i((()=>[f(b(n(l)("common.delete")),1)])),_:1})):h("",!0)])),_:1})])),_:1}),p(y,{show:z.showRegion,onCancel:a[5]||(a[5]=e=>z.showRegion=!1),onConfirm:M},null,8,["show"])])),_:1},8,["title"])}}},[["__scopeId","data-v-c9d31157"]]);export{$ as default};