"use strict";
const common_vendor = require("../vendor.js");
require("./request.js");
const common_store_useWeAppAuthStore = require("../store/useWeAppAuthStore.js");
const common_store_useWorkStore = require("../store/useWorkStore.js");
const auth = common_store_useWeAppAuthStore.useWeAppAuthStore();
const work = common_store_useWorkStore.useWorkStore();
const getIsHouseExist = (res) => {
  var _a, _b, _c, _d, _e, _f, _g;
  if (!((_a = auth == null ? void 0 : auth.data) == null ? void 0 : _a.user)) {
    common_vendor.index.navigateTo({
      url: "/pages/login"
    });
    return false;
  }
  if (!((_b = auth == null ? void 0 : auth.data) == null ? void 0 : _b.selected_house) && ((_c = auth == null ? void 0 : auth.data) == null ? void 0 : _c.house_occupant)) {
    work.selectedHouse += 1;
    common_vendor.index.switchTab({
      url: "/pages/index/index"
    });
    return false;
  }
  if (!(res == null ? void 0 : res.is_bind_house)) {
    return true;
  }
  if (!((_d = auth == null ? void 0 : auth.data) == null ? void 0 : _d.house_occupant) && !((_e = auth == null ? void 0 : auth.data) == null ? void 0 : _e.house_register)) {
    common_vendor.index.showModal({
      title: "提示",
      content: "未绑定房屋，请先绑定房屋！",
      confirmText: "去绑定",
      confirmColor: "#0082FA",
      success: function(res2) {
        if (res2.confirm) {
          common_vendor.index.navigateTo({
            url: "/INDEX/binding/index"
          });
          console.log("用户点击确定");
        } else if (res2.cancel) {
          console.log("用户点击取消");
        }
      }
    });
    return false;
  }
  console.log("已绑定房屋", auth == null ? void 0 : auth.data);
  if (!((_f = auth == null ? void 0 : auth.data) == null ? void 0 : _f.house_occupant) && ((_g = auth == null ? void 0 : auth.data) == null ? void 0 : _g.house_register)) {
    common_vendor.index.showModal({
      title: "提示",
      cancelText: "继续绑定",
      content: "有房屋还在审核中！",
      confirmText: "去查看",
      confirmColor: "#0082FA",
      success: function(res2) {
        if (res2.confirm) {
          common_vendor.index.navigateTo({
            url: "/INDEX/owner_audit_list/index?type=1"
          });
          console.log("用户点击确定");
        } else if (res2.cancel) {
          common_vendor.index.navigateTo({
            url: "/INDEX/binding/index"
          });
          console.log("用户点击取消");
        }
      }
    });
    return false;
  }
  return true;
};
exports.getIsHouseExist = getIsHouseExist;
