"use strict";
const common_vendor = require("../../../common/vendor.js");
const api_request = require("../../../api/request.js");
const _sfc_main = {
  __name: "addressList",
  setup(__props) {
    common_vendor.ref([null, null, null, null, null, null, null, null, null]);
    const addressArr = common_vendor.ref([]);
    common_vendor.onShow(() => {
      getAddress();
    });
    const getAddress = async () => {
      const res = await common_vendor.index.request({
        url: api_request.baseUrl + "/address/list",
        method: "POST",
        header: {
          cookie: common_vendor.wx$1.getStorageSync("cookie")
        }
      });
      if (res.data.code === 1) {
        addressArr.value = res.data.data;
        console.log("获取的地址信息--->", res.data.data);
      }
    };
    const editAddress = (value) => {
      console.log("地址信息", value);
      common_vendor.index.navigateTo({
        url: "/pages/Shopping-cart/newaddress_Info/newaddress_Info?editInfo=" + JSON.stringify(value)
      });
    };
    const confirmPop = (id) => {
      common_vendor.index.showModal({
        title: "提示",
        content: "是否删除地址?",
        success: (e) => {
          if (e.confirm) {
            deleteAddress(id);
          } else {
            return;
          }
        }
      });
    };
    const deleteAddress = async (id) => {
      const res = await common_vendor.index.request({
        url: api_request.baseUrl + "/address/delete",
        method: "POST",
        header: {
          "cookie": common_vendor.wx$1.getStorageSync("cookie")
        },
        data: { id }
      });
      if (res.data.code === 1) {
        getAddress();
      }
    };
    const jump_newAddress = () => {
      common_vendor.index.navigateTo({
        url: "/pages/Shopping-cart/newaddress_Info/newaddress_Info"
      });
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.f(addressArr.value, (item, index, i0) => {
          return common_vendor.e({
            a: common_vendor.t(item.name),
            b: common_vendor.t(item.phone),
            c: item.isDefault === 1
          }, item.isDefault === 1 ? {} : {}, {
            d: common_vendor.o(($event) => editAddress(item), index),
            e: common_vendor.o(($event) => confirmPop(item.id), index),
            f: common_vendor.t(item.region),
            g: common_vendor.t(item.detailAddress),
            h: index
          });
        }),
        b: common_vendor.o(($event) => jump_newAddress())
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-3ed0d3c0"], ["__file", "D:/微信小程序/课设整合/匠承非遗小程序端/jiangchengfeiyi-xiaochengxu/pages/mine/addressList/addressList.vue"]]);
wx.createPage(MiniProgramPage);
