"use strict";
const common_libraries_apiLoading = require("../../common/libraries/apiLoading.js");
const common_libraries_day = require("../../common/libraries/day.js");
const common_libraries_naviHelper = require("../../common/libraries/naviHelper.js");
const gen_Apis = require("../../gen/Apis.js");
const INDEX_pass_model = require("./model.js");
const getFitmentShow = (data) => {
  common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Visitor.VisitorApplies.Show, data).then((res) => {
    var _a, _b, _c, _d, _e, _f;
    INDEX_pass_model.useModel.showData.value = res == null ? void 0 : res.data;
    if ((_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.renovation_workers) == null ? void 0 : _b.length) {
      INDEX_pass_model.useModel.userInfo.value = (_d = (_c = res == null ? void 0 : res.data) == null ? void 0 : _c.renovation_workers) == null ? void 0 : _d[0];
    }
    if ((_e = res == null ? void 0 : res.data) == null ? void 0 : _e.code_expired_at) {
      INDEX_pass_model.useModel.isExpired.value = common_libraries_day.isDatePassed((_f = res == null ? void 0 : res.data) == null ? void 0 : _f.code_expired_at);
    }
    console.log(res);
  });
};
const method = {
  init(e) {
    INDEX_pass_model.useModel.formData.value = e;
    console.log(e, INDEX_pass_model.useModel.formData.value, "sncd");
    getFitmentShow(e);
  },
  handleSubmit(val) {
    var _a, _b, _c, _d, _e;
    common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Visitor.VisitorApplies.Scan, {
      code: (_c = (_b = (_a = INDEX_pass_model.useModel) == null ? void 0 : _a.showData) == null ? void 0 : _b.value) == null ? void 0 : _c.visitor_code,
      scan_type: val,
      ...(_e = (_d = INDEX_pass_model.useModel) == null ? void 0 : _d.formData) == null ? void 0 : _e.value
    }).then((res) => {
      common_libraries_naviHelper.showToast("操作成功！", () => {
        getFitmentShow(INDEX_pass_model.useModel.formData.value);
      });
      console.log(res);
    });
  }
};
exports.method = method;
