2 lines
5.2 KiB
JavaScript
2 lines
5.2 KiB
JavaScript
|
"use strict";var e=Object.defineProperty,o=Object.defineProperties,r=Object.getOwnPropertyDescriptors,t=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,l=(o,r,t)=>r in o?e(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,n=(e,o)=>{for(var r in o||(o={}))i.call(o,r)&&l(e,r,o[r]);if(t)for(var r of t(o))a.call(o,r)&&l(e,r,o[r]);return e},s=(e,o,r)=>new Promise(((t,i)=>{var a=e=>{try{n(r.next(e))}catch(o){i(o)}},l=e=>{try{n(r.throw(e))}catch(o){i(o)}},n=e=>e.done?t(e.value):Promise.resolve(e.value).then(a,l);n((r=r.apply(e,o)).next())}));const d=require("../../../../common/vendor.js"),m=require("../../../../sheep/index.js"),u=require("../../../../sheep/validate/form.js"),p=require("../../../../sheep/api/system/area.js"),c=require("../../../../sheep/api/member/address.js");if(!Array){(d.resolveComponent("uni-easyinput")+d.resolveComponent("uni-forms-item")+d.resolveComponent("uni-icons")+d.resolveComponent("su-switch")+d.resolveComponent("uni-forms")+d.resolveComponent("su-fixed")+d.resolveComponent("su-region-picker")+d.resolveComponent("s-layout")+d.resolveComponent("layout-default-uni"))()}Math||((()=>"../../../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js")+(()=>"../../../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js")+(()=>"../../../../uni_modules/uni-icons/components/uni-icons/uni-icons.js")+(()=>"../../../../sheep/ui/su-switch/su-switch.js")+(()=>"../../../../uni_modules/uni-forms/components/uni-forms/uni-forms.js")+(()=>"../../../../sheep/ui/su-fixed/su-fixed.js")+(()=>"../../../../sheep/ui/su-region-picker/su-region-picker.js")+(()=>"../../../../sheep/components/s-layout/s-layout.js"))();const f={__name:"edit",setup(e){const t=d.ref(null),i=d.reactive({showRegion:!1,model:{name:"",mobile:"",detailAddress:"",defaultStatus:!1,areaName:""},rules:{}}),a={name:{rules:[{required:!0,errorMessage:"请输入收货人姓名"}]},mobile:u.mobile,detailAddress:{rules:[{required:!0,errorMessage:"请输入详细地址"}]},areaName:{rules:[{required:!0,errorMessage:"请选择您的位置"}]}},l=e=>{i.model.areaName=`${e.province_name} ${e.city_name} ${e.district_name}`,i.model.areaId=e.district_id,i.showRegion=!1},f=()=>s(this,null,(function*(){if(!(yield d.unref(t).validate().catch((e=>{}))))return;const e=n({},i.model),{code:o}=i.model.id>0?yield c.AddressApi.updateAddress(e):yield c.AddressApi.createAddress(e);0===o&&m.sheep.$router.back()})),h=()=>{d.index.showModal({title:"提示",content:"确认删除此收货地址吗?",success:function(e){return s(this,null,(function*(){if(!e.confirm)return;const{code:o}=yield c.AddressApi.deleteAddress(i.model.id);0===o&&m.sheep.$router.back()}))}})};return d.onLoad((e=>s(this,null,(function*(){if(d.lodash.isEmpty(d.index.getStorageSync("areaData"))&&p.AreaApi.getAreaTree().then((e=>{0===e.code&&d.index.setStorageSync("areaData",e.data)})),e.id){const{code:o,data:r}=yield c.AddressApi.getAddress(e.id);if(0!==o)return;i.model=r}if(e.data){const l=JSON.parse(e.data),s=(e,o)=>e.find((e=>e.name===o)),m=s(d.index.getStorageSync("areaData"),l.province_name),u=m?s(m.children,l.city_name):void 0,p=((u?s(u.children,l.district_name):void 0)||u||m).id;i.model=(t=n({},i.model),a={areaId:p,areaName:[l.province_name,l.city_name,l.district_name].filter(Boolean).join(" "),defaultStatus:!1,detailAddress:l.address,mobile:l.mobile,name:l.consignee},o(t,r(a)))}var t,a})))),(e,o)=>d.e({a:d.o((e=>i.model.name=e)),b:d.p({placeholder:"请填写收货人姓名",inputBorder:!1,placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",modelValue:i.model.name}),c:d.p({name:"name",label:"收货人"}),d:d.o((e=>i.model.mobile=e)),e:d.p({type:"number",placeholder:"请输入手机号",inputBorder:!1,placeholderStyle:"color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",modelValue:i.model.mobile}),f:d.p({name:"mobile",label:"手机号"}),g:d.p({type:"right"}),h:d.o((e=>i.model.areaName=e)),i:d.p({disabled:!0,inputBorder:!1,styles:{disableColor:"#fff",color:"#333"},p
|