"use strict";
const common_vendor = require("../../common/vendor.js");
const common_libraries_getPageConfig = require("../../common/libraries/getPageConfig.js");
const common_libraries_userUserLogin = require("../../common/libraries/userUserLogin.js");
const common_libraries_naviHelper = require("../../common/libraries/naviHelper.js");
const common_libraries_apiLoading = require("../../common/libraries/apiLoading.js");
const gen_Apis = require("../../gen/Apis.js");
const gen_Enums = require("../../gen/Enums.js");
require("../../common/libraries/request.js");
const common_store_useWeAppAuthStore = require("../../common/store/useWeAppAuthStore.js");
require("../../common/store/useWorkStore.js");
require("../../common/libraries/setTabBar.js");
if (!Array) {
  const _easycom_hs_enum_tag2 = common_vendor.resolveComponent("hs-enum-tag");
  const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
  const _easycom_hs_popup2 = common_vendor.resolveComponent("hs-popup");
  (_easycom_hs_enum_tag2 + _easycom_uni_icons2 + _easycom_up_icon2 + _easycom_hs_popup2)();
}
const _easycom_hs_enum_tag = () => "../hs-enum-tag/hs-enum-tag.js";
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
const _easycom_up_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_hs_popup = () => "../hs-popup/hs-popup.js";
if (!Math) {
  (_easycom_hs_enum_tag + _easycom_uni_icons + _easycom_up_icon + _easycom_hs_popup)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "hs-popup-switch-house",
  props: ["show", "dataList", "pageSource", "defaultHouseId"],
  emits: ["close", "change"],
  setup(__props, { emit }) {
    const props = __props;
    const dataList = common_vendor.ref([]);
    const formData = common_vendor.ref({ page: 1 });
    const metaData = common_vendor.ref({});
    const auth = common_store_useWeAppAuthStore.useWeAppAuthStore();
    common_vendor.watch(
      () => props == null ? void 0 : props.show,
      () => {
        if (props == null ? void 0 : props.show) {
          formData.value.page = 1;
          dataList.value = [];
          getHouseList();
        }
      }
    );
    const handleClose = () => {
      emit("close");
    };
    const hadnleNewBindingHouse = () => {
      var _a;
      common_vendor.index.navigateTo({
        url: ((_a = auth == null ? void 0 : auth.data) == null ? void 0 : _a.user) ? "/INDEX/binding/index" : "/pages/login"
      });
    };
    const getHouseList = () => {
      var _a;
      if (!((_a = common_libraries_userUserLogin.getUserLogin) == null ? void 0 : _a.getLoginStatus()))
        return;
      common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Archive.HouseOccupants.List, formData == null ? void 0 : formData.value).then((res) => {
        dataList.value = [...dataList.value, ...res == null ? void 0 : res.data];
        metaData.value = res == null ? void 0 : res.meta;
        console.log(res);
      });
    };
    const handleSelectedHouse = (e) => {
      var _a, _b;
      if ((e == null ? void 0 : e.asset_houses_id) === ((_b = (_a = auth == null ? void 0 : auth.data) == null ? void 0 : _a.selected_house) == null ? void 0 : _b.id)) {
        common_libraries_naviHelper.showToast("已是该房屋！");
        return;
      }
      common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Archive.HouseOccupants.UpdateSelectedHouse, {
        asset_houses_id: e == null ? void 0 : e.asset_houses_id
      }).then((res) => {
        auth == null ? void 0 : auth.me(() => {
          emit("change", e);
        });
        console.log(res);
      });
    };
    return (_ctx, _cache) => {
      var _a, _b;
      return common_vendor.e({
        a: (_a = dataList.value) == null ? void 0 : _a.length
      }, ((_b = dataList.value) == null ? void 0 : _b.length) ? {
        b: common_vendor.f(dataList.value, (i, index, i0) => {
          var _a2, _b2, _c, _d, _e, _f, _g;
          return common_vendor.e({
            a: common_vendor.t((_a2 = i == null ? void 0 : i.asset_house) == null ? void 0 : _a2.full_name),
            b: "22fbb487-1-" + i0 + ",22fbb487-0",
            c: common_vendor.p({
              value: i == null ? void 0 : i.house_relation,
              Enums: common_vendor.unref(gen_Enums.HouseOccupantsHouseRelationEnum)
            }),
            d: (i == null ? void 0 : i.asset_houses_id) === ((_d = (_c = (_b2 = common_vendor.unref(auth)) == null ? void 0 : _b2.data) == null ? void 0 : _c.selected_house) == null ? void 0 : _d.id)
          }, (i == null ? void 0 : i.asset_houses_id) === ((_g = (_f = (_e = common_vendor.unref(auth)) == null ? void 0 : _e.data) == null ? void 0 : _f.selected_house) == null ? void 0 : _g.id) ? {
            e: "22fbb487-2-" + i0 + ",22fbb487-0",
            f: common_vendor.p({
              type: "checkbox-filled",
              size: "20",
              color: common_vendor.unref(common_libraries_getPageConfig.getStyleColorValueInfo)()
            })
          } : {
            g: "22fbb487-3-" + i0 + ",22fbb487-0",
            h: common_vendor.p({
              type: "circle",
              size: "20",
              color: "#999"
            })
          }, {
            i: index,
            j: common_vendor.o(($event) => handleSelectedHouse(i), index)
          });
        })
      } : {}, {
        c: common_vendor.p({
          name: "plus-circle",
          size: "25",
          color: "#3D3D3D"
        }),
        d: common_vendor.o(hadnleNewBindingHouse),
        e: common_vendor.n((props == null ? void 0 : props.pageSource) === "archive_houses" ? "popup_content archive_houses_content" : "popup_content"),
        f: common_vendor.o(handleClose),
        g: common_vendor.p({
          show: props == null ? void 0 : props.show,
          mode: "bottom",
          closeable: true,
          round: 20
        })
      });
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-22fbb487"], ["__file", "/Users/zsq/Sources/github/2025property-pay/pay-customer/src/components/hs-popup-switch-house/hs-popup-switch-house.vue"]]);
wx.createComponent(Component);
