"use strict";const e=require("../common/vendor.js"),u=require("../api/order.js"),o=require("../common/assets.js"),h={data(){return{address:[]}},onLoad(){this.getUserAddr(),e.index.$on("refreshAddress",()=>{this.getUserAddr()})},methods:{getUserAddr(){this.userInfo=JSON.parse(e.index.getStorageSync("userInfo")),u.userAddr(this.userInfo.userId).then(s=>{s.code==200?(console.log("用户收货地址>>>>",s.data),this.address=s.data):e.index.showToast({title:s.msg,icon:"none"})},s=>{})},selectAddress(s){e.index.$emit("updateAddress",s),e.index.navigateBack({delta:1})},editAddress(s){e.index.navigateTo({url:"./addAddress?type=edit&addressId="+s.addressId})},delAddress(s){e.index.showModal({title:"提示",content:"确认删除此地址吗?",showCancel:!0,cancelText:"取消",confirmText:"确定",success:i=>{if(i.confirm){var c={addressId:s.addressId};u.delAddress(c).then(n=>{n.code==200?(e.index.showToast({icon:"success",title:"操作成功"}),this.getUserAddr()):e.index.showToast({icon:"none",title:"请求失败"})},n=>{})}}})},addAdress(){e.index.navigateTo({url:"./addAddress?type=add"})}}};function A(s,i,c,n,a,r){return e.e({a:e.f(a.address,(d,t,f)=>e.e({a:d.isDefault==1},d.isDefault==1?{}:{},{b:e.t(d.province),c:e.t(d.city),d:e.t(d.district),e:e.t(d.detail),f:e.t(d.realName),g:e.t(s.$parsePhone(d.phone)),h:e.o(l=>r.selectAddress(d),t),i:e.o(l=>r.delAddress(d),t),j:e.o(l=>r.editAddress(d),t),k:t})),b:o._imports_0$12,c:o._imports_1$8,d:a.address.length==0},a.address.length==0?{e:o._imports_2,f:e.o(d=>s.getAddressList())}:{},{g:e.o((...d)=>r.addAdress&&r.addAdress(...d))})}const g=e._export_sfc(h,[["render",A]]);wx.createPage(g);