myAddress.js
1.7 KB
"use strict";const e=require("../../common/vendor.js"),l=require("../../api/index.js");require("../../utils/request.js");if(!Array){const a=e.resolveComponent("u-navbar"),o=e.resolveComponent("test");(a+o)()}const f=()=>"../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";Math||f();const p={__name:"myAddress",setup(a){const o=e.ref([]);e.onShow(()=>{o.value.splice(0),d()}),e.onLoad(t=>{c.value=t.isCheck});const r=(t,n)=>{console.log(t,n,"type id是什么"),e.index.navigateTo({url:`/pages/mine/newAddress?id=${t==0?n:""}`})};let c=e.ref(0);const u=t=>{if(c.value==1){const n=getCurrentPages().pop();setTimeout(()=>{n.$vm.getOpenerEventChannel().emit("steBack",t)},1e3),e.index.navigateBack()}},g=(t,n)=>{e.index.showModal({title:"提示",content:"确认删除此地址吗",success:function(s){s.confirm&&v(t,n)}})},v=async(t,n)=>{try{const s=await l.getDelAdres(t);e.index.showToast({title:"删除成功!",icon:"none"}),d(),console.log("getDelAdres",s),n.is_default===1&&e.index.removeStorageSync("defaultAdres")}catch(s){console.log("getDelAdres",s)}},d=async()=>{try{const t=await l.getAdressList();o.value=t;let n=t.find(s=>s.is_default==1);e.index.setStorageSync("defaultAdres",n),console.log("getAdressList",t)}catch(t){e.index.showToast({title:t,icon:"none"}),console.log("getAdressList",t)}};return(t,n)=>e.e({a:e.p({placeholder:!0,title:"我的地址",bgColor:"#fff",autoBack:!0}),b:e.f(o.value,(s,h,_)=>({a:e.t(s.name),b:e.t(s.mobile),c:e.o(i=>g(s.id,s),s.id),d:e.o(i=>r(0,s.id),s.id),e:e.t(s.diqu),f:e.t(s.address),g:"03a0db18-1-"+_,h:s.id,i:e.o(i=>u(s),s.id)})),c:!o.value},o.value?{}:{},{d:e.o(s=>r(1))})}},A=e._export_sfc(p,[["__file","D:/vue/大健康商城/healthMall/pages/mine/myAddress.vue"]]);wx.createPage(A);