"use strict";
const common_vendor = require("../../../common/vendor.js");
const sheep_index = require("../../../sheep/index.js");
const sheep_api_system_area = require("../../../sheep/api/system/area.js");
const sheep_api_member_address = require("../../../sheep/api/member/address.js");
require("../../../sheep/helper/index.js");
require("../../../sheep/api/index.js");
require("../../../sheep/api/distri/score.js");
require("../../../sheep/request/index.js");
require("../../../sheep/config/index.js");
require("../../../sheep/store/index.js");
require("../../../sheep/store/app.js");
require("../../../sheep/api/promotion/diy.js");
require("../../../sheep/platform/index.js");
require("../../../sheep/platform/provider/wechat/index.js");
require("../../../sheep/platform/provider/wechat/miniProgram.js");
require("../../../sheep/api/member/auth.js");
require("../../../sheep/api/member/social.js");
require("../../../sheep/api/member/user.js");
require("../../../sheep/platform/provider/apple/index.js");
require("../../../sheep/platform/share.js");
require("../../../sheep/router/index.js");
require("../../../sheep/hooks/useModal.js");
require("../../../sheep/helper/test.js");
require("../../../sheep/api/member/signin.js");
require("../../../sheep/helper/throttle.js");
require("../../../sheep/url/index.js");
require("../../../sheep/platform/pay.js");
require("../../../sheep/api/pay/order.js");
require("../../../sheep/store/user.js");
require("../../../sheep/store/cart.js");
require("../../../sheep/api/trade/cart.js");
require("../../../sheep/api/pay/wallet.js");
require("../../../sheep/api/trade/order.js");
require("../../../sheep/api/promotion/coupon.js");
require("../../../sheep/store/sys.js");
require("../../../sheep/store/modal.js");
require("../../../sheep/api/distri/share.js");
require("../../../sheep/api/distri/team.js");
require("../../../sheep/api/infra/file.js");
require("../../../sheep/api/member/point.js");
require("../../../sheep/api/migration/app.js");
require("../../../sheep/api/migration/chat.js");
require("../../../sheep/api/migration/index.js");
require("../../../sheep/api/migration/third.js");
require("../../../sheep/api/pay/channel.js");
require("../../../sheep/api/product/category.js");
require("../../../sheep/api/product/comment.js");
require("../../../sheep/api/product/favorite.js");
require("../../../sheep/api/product/history.js");
require("../../../sheep/api/product/spu.js");
require("../../../sheep/api/promotion/activity.js");
require("../../../sheep/api/promotion/article.js");
require("../../../sheep/api/promotion/bargain.js");
require("../../../sheep/api/promotion/combination.js");
require("../../../sheep/api/promotion/rewardActivity.js");
require("../../../sheep/api/promotion/seckill.js");
require("../../../sheep/api/system/voice.js");
require("../../../sheep/api/trade/afterSale.js");
require("../../../sheep/api/trade/brokerage.js");
require("../../../sheep/api/trade/config.js");
require("../../../sheep/api/trade/delivery.js");
require("../../../sheep/config/zIndex.js");
require("../../../sheep/helper/digit.js");
if (!Array) {
  const _easycom_s_address_item2 = common_vendor.resolveComponent("s-address-item");
  const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed");
  const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  (_easycom_s_address_item2 + _easycom_su_fixed2 + _easycom_s_empty2 + _easycom_s_layout2)();
}
const _easycom_s_address_item = () => "../../../sheep/components/s-address-item/s-address-item.js";
const _easycom_su_fixed = () => "../../../sheep/ui/su-fixed/su-fixed.js";
const _easycom_s_empty = () => "../../../sheep/components/s-empty/s-empty.js";
const _easycom_s_layout = () => "../../../sheep/components/s-layout/s-layout.js";
if (!Math) {
  (_easycom_s_address_item + _easycom_su_fixed + _easycom_s_empty + _easycom_s_layout)();
}
const _sfc_main = {
  __name: "list",
  setup(__props) {
    const state = common_vendor.reactive({
      list: [],
      // 地址列表
      loading: true
    });
    const onSelect = (addressInfo) => {
      common_vendor.index.$emit("SELECT_ADDRESS", {
        addressInfo
      });
      sheep_index.sheep.$router.back();
    };
    function importWechatAddress() {
      let wechatAddress = {};
      common_vendor.index.chooseAddress({
        success: (res) => {
          wechatAddress = {
            consignee: res.userName,
            mobile: res.telNumber,
            province_name: res.provinceName,
            city_name: res.cityName,
            district_name: res.countyName,
            address: res.detailInfo,
            region: "",
            is_default: false
          };
          if (!common_vendor.lodashExports.isEmpty(wechatAddress)) {
            sheep_index.sheep.$router.go("/pages/user/address/edit", {
              data: JSON.stringify(wechatAddress)
            });
          }
        },
        fail: (err) => {
          console.log("uni.chooseAddress调用失败，问题是：", err);
        }
      });
    }
    common_vendor.onShow(async () => {
      state.list = (await sheep_api_member_address.AddressApi.getAddressList()).data;
      state.loading = false;
    });
    common_vendor.onBeforeMount(() => {
      if (!!common_vendor.index.getStorageSync("areaData")) {
        return;
      }
      sheep_api_system_area.AreaApi.getAreaTree().then((res) => {
        if (res.code === 0) {
          common_vendor.index.setStorageSync("areaData", res.data);
        }
      });
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: state.list.length
      }, state.list.length ? {
        b: common_vendor.f(state.list, (item, k0, i0) => {
          return {
            a: item.id,
            b: common_vendor.o(($event) => onSelect(item), item.id),
            c: "5a5957ad-1-" + i0 + ",5a5957ad-0",
            d: common_vendor.p({
              hasBorderBottom: true,
              item
            })
          };
        })
      } : {}, {
        c: ["WechatMiniProgram", "WechatOfficialAccount"].includes(common_vendor.unref(sheep_index.sheep).$platform.name)
      }, ["WechatMiniProgram", "WechatOfficialAccount"].includes(common_vendor.unref(sheep_index.sheep).$platform.name) ? {
        d: common_vendor.o(importWechatAddress)
      } : {}, {
        e: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/user/address/edit")),
        f: common_vendor.p({
          bottom: true,
          placeholder: true
        }),
        g: state.list.length === 0 && !state.loading
      }, state.list.length === 0 && !state.loading ? {
        h: common_vendor.p({
          text: "暂无收货地址",
          icon: "/static/data-empty.png"
        })
      } : {}, {
        i: common_vendor.p({
          title: "收货地址",
          bgStyle: {
            color: "#FFF"
          }
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5a5957ad"], ["__file", "D:/zx/mall-front-app/pages/user/address/list.vue"]]);
wx.createPage(MiniProgramPage);
