"use strict";
const common_vendor = require("../../common/vendor.js");
const gen_Apis = require("../../gen/Apis.js");
const INDEX_activities_show_model = require("./model.js");
require("../../common/libraries/request.js");
const common_store_useWeAppAuthStore = require("../../common/store/useWeAppAuthStore.js");
require("../../common/store/useWorkStore.js");
const common_libraries_apiLoading = require("../../common/libraries/apiLoading.js");
const common_libraries_userUserLogin = require("../../common/libraries/userUserLogin.js");
const common_libraries_naviHelper = require("../../common/libraries/naviHelper.js");
const auth = common_store_useWeAppAuthStore.useWeAppAuthStore();
const get_customer_enroll = (id) => {
  common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Activity.ActivityEnrolls.GetCustomerEnroll, {
    activities_id: id
  }).then((res) => {
    INDEX_activities_show_model.useModel.showData.value = { ...INDEX_activities_show_model.useModel.showData.value, ...res == null ? void 0 : res.data };
    console.log(res);
  });
};
const method = {
  getShow(id) {
    common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Activity.Activities.Show, {
      id
    }).then((res) => {
      INDEX_activities_show_model.useModel.showData.value = res == null ? void 0 : res.data;
      get_customer_enroll(id);
      console.log(res);
    });
  },
  handleSignUp() {
    var _a, _b, _c, _d, _e, _f, _g;
    if ((_a = common_libraries_userUserLogin.getUserLogin) == null ? void 0 : _a.onBindPhone()) {
      if (!((_b = auth == null ? void 0 : auth.data) == null ? void 0 : _b.house_occupant)) {
        common_vendor.index.showModal({
          title: "提示",
          content: "未绑定房屋，请先绑定房屋！",
          confirmText: "去绑定",
          confirmColor: "#0082FA",
          success: function(res) {
            if (res.confirm) {
              common_vendor.index.navigateTo({
                url: "/INDEX/binding/index"
              });
              console.log("用户点击确定");
            } else if (res.cancel) {
              console.log("用户点击取消");
            }
          }
        });
        return false;
      }
      common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Activity.ActivityEnrolls.Store, {
        activities_id: (_c = INDEX_activities_show_model.useModel.showData.value) == null ? void 0 : _c.id,
        customer_name: ((_e = (_d = auth == null ? void 0 : auth.data) == null ? void 0 : _d.user) == null ? void 0 : _e.name) || "",
        customer_phone: (_g = (_f = auth == null ? void 0 : auth.data) == null ? void 0 : _f.user) == null ? void 0 : _g.phone
      }).then((res) => {
        common_libraries_naviHelper.showToastBack("报名成功", 1, true);
        console.log(res);
      });
    }
  },
  handleCancelSignUp(status) {
    var _a, _b, _c, _d, _e, _f;
    common_vendor.index.showModal({
      title: "提示",
      content: status === "Cancelled" ? `您将取消 [${(_c = (_b = (_a = INDEX_activities_show_model.useModel) == null ? void 0 : _a.showData) == null ? void 0 : _b.value) == null ? void 0 : _c.title}]活动，取消后释放名额?` : `您将重新报名 [${(_f = (_e = (_d = INDEX_activities_show_model.useModel) == null ? void 0 : _d.showData) == null ? void 0 : _e.value) == null ? void 0 : _f.title}]，活动?`,
      success(res) {
        var _a2, _b2, _c2, _d2;
        if (res.confirm) {
          common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Activity.ActivityEnrolls.Cancelled, {
            id: (_d2 = (_c2 = (_b2 = (_a2 = INDEX_activities_show_model.useModel) == null ? void 0 : _a2.showData) == null ? void 0 : _b2.value) == null ? void 0 : _c2.result) == null ? void 0 : _d2.id,
            status
          }).then((res2) => {
            common_libraries_naviHelper.showToastBack(status === "Cancelled" ? "取消报名成功" : "重新报名成功", 1, true);
            console.log(res2);
          });
          console.log("用户点击确定");
        } else if (res.cancel) {
          console.log("用户点击取消");
        }
      }
    });
  }
};
exports.method = method;
