"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_api = require("../../utils/api.js");
const utils_des = require("../../utils/des.js");
if (!Array) {
  const _easycom_uni_segmented_control2 = common_vendor.resolveComponent("uni-segmented-control");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  (_easycom_uni_segmented_control2 + _easycom_uni_popup2)();
}
const _easycom_uni_segmented_control = () => "../../uni_modules/uni-segmented-control/components/uni-segmented-control/uni-segmented-control.js";
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  (_easycom_uni_segmented_control + NoData + _easycom_uni_popup + Tabber)();
}
const Tabber = () => "../../components/tabber.js";
const NoData = () => "../../components/noData.js";
const _sfc_main = {
  __name: "record",
  setup(__props) {
    const activeCurrent = common_vendor.ref(0);
    const currentPage = common_vendor.ref(1);
    const total = common_vendor.ref(0);
    const controlList = ["全部", "待审核", "已拒绝", "已推送"];
    const list = common_vendor.ref([]);
    const popup = common_vendor.ref(null);
    const popObj = common_vendor.ref({});
    common_vendor.onLoad(() => {
      getData();
    });
    common_vendor.onReachBottom(() => {
      if (total.value > list.value.length) {
        currentPage.value++;
        getData();
      } else {
        common_vendor.index.showToast({
          title: "没有更多数据了",
          icon: "none"
        });
      }
    });
    const getData = async () => {
      const res = await utils_api.myRequest({
        url: "/wanzai/api/smartVisitor/appointmentPageRecord",
        data: {
          currentPage: currentPage.value,
          pageCount: 6,
          userId: common_vendor.index.getStorageSync("userInfo").id,
          type: activeCurrent.value
        }
      });
      const result = JSON.parse(utils_des.decryptDes(res.data));
      total.value = result.totalCount;
      list.value = [...list.value, ...result.list];
    };
    const handleClick = (item) => {
      popObj.value = item;
      popup.value.open();
    };
    const onClickItem = (e) => {
      if (activeCurrent.value != e.currentIndex) {
        activeCurrent.value = e.currentIndex;
        currentPage.value = 1;
        list.value = [];
        getData();
      }
    };
    const handleCancel = (id) => {
      common_vendor.index.showModal({
        title: "提示",
        content: "确定取消预约吗？",
        success: (res) => {
          if (res.confirm) {
            handleCancelReq(id);
          }
        }
      });
    };
    const handleCancelReq = async (id) => {
      await utils_api.myRequest({
        url: "/wanzai/api/smartVisitor/deleteSmartVisitorById",
        data: {
          id
        }
      });
      common_vendor.index.showToast({
        title: "取消预约成功",
        icon: "none",
        duration: 2e3
      });
      setTimeout(() => {
        currentPage.value = 1;
        list.value = [];
        getData();
      }, 2e3);
    };
    const closePop = () => {
      popup.value.close();
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(onClickItem),
        b: common_vendor.p({
          current: activeCurrent.value,
          values: controlList,
          styleType: "text",
          activeColor: "#0061FF"
        }),
        c: common_vendor.f(list.value, (item, k0, i0) => {
          return common_vendor.e({
            a: common_vendor.t(item.userName),
            b: common_vendor.t(item.createTime),
            c: item.statuStr == "待审核"
          }, item.statuStr == "待审核" ? {
            d: common_vendor.t(item.statuStr)
          } : {}, {
            e: item.statuStr == "已拒绝"
          }, item.statuStr == "已拒绝" ? {
            f: common_vendor.t(item.statuStr)
          } : {}, {
            g: item.statuStr == "已推送"
          }, item.statuStr == "已推送" ? {
            h: common_vendor.t(item.statuStr)
          } : {}, {
            i: common_vendor.t(item.visitorTime),
            j: common_vendor.t(item.visitReason),
            k: item.statuStr == "待审核"
          }, item.statuStr == "待审核" ? {
            l: common_vendor.o(($event) => handleCancel(item.id), item.id)
          } : {}, {
            m: item.id,
            n: common_vendor.o(($event) => handleClick(item), item.id)
          });
        }),
        d: !list.value.length
      }, !list.value.length ? {} : {}, {
        e: common_vendor.o(closePop),
        f: popObj.value.statuStr == "待审核"
      }, popObj.value.statuStr == "待审核" ? {
        g: common_vendor.t(popObj.value.statuStr)
      } : {}, {
        h: popObj.value.statuStr == "已拒绝"
      }, popObj.value.statuStr == "已拒绝" ? {
        i: common_vendor.t(popObj.value.statuStr)
      } : {}, {
        j: popObj.value.statuStr == "已推送"
      }, popObj.value.statuStr == "已推送" ? {
        k: common_vendor.t(popObj.value.statuStr)
      } : {}, {
        l: common_vendor.t(popObj.value.userName),
        m: common_vendor.t(popObj.value.userPhone),
        n: common_vendor.t(popObj.value.visitorTime),
        o: common_vendor.t(popObj.value.userNumber),
        p: common_vendor.t(popObj.value.visitReason),
        q: common_vendor.t(popObj.value.carNum ? popObj.value.carNum : "无"),
        r: common_vendor.t(popObj.value.peerNum ? popObj.value.peerNum : "无"),
        s: common_vendor.t(popObj.value.visitorType == 1 ? "受访学生" : "受访人"),
        t: common_vendor.t(popObj.value.respondentName),
        v: common_vendor.t(popObj.value.responcode || popObj.value.respondentPhone),
        w: common_vendor.sr(popup, "00bd71c9-2", {
          "k": "popup"
        }),
        x: common_vendor.p({
          type: "center",
          ["is-mask-click"]: false
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-00bd71c9"], ["__file", "E:/workSpace/WanZai_School_app/pagesReservation/record/record.vue"]]);
wx.createPage(MiniProgramPage);
