detailPage.js 8.17 KB
"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_train = require("../../../common/train.js");
require("../../../common/request.js");
require("../../../config.js");
require("../../../common/login.js");
require("../../../common/api.js");
if (!Array) {
  const _easycom_uni_segmented_control2 = common_vendor.resolveComponent("uni-segmented-control");
  const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  (_easycom_uni_segmented_control2 + _easycom_uni_icons2 + _easycom_uni_popup2)();
}
const _easycom_uni_segmented_control = () => "../../../uni_modules/uni-segmented-control/components/uni-segmented-control/uni-segmented-control.js";
const _easycom_uni_icons = () => "../../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
const _easycom_uni_popup = () => "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  (_easycom_uni_segmented_control + _easycom_uni_icons + trainnSchedule + _easycom_uni_popup)();
}
const trainnSchedule = () => "../../../components/train/trainSchedule/trainSchedule.js";
const _sfc_main = {
  __name: "detailPage",
  setup(__props) {
    const items = common_vendor.ref(["详情", "日程"]);
    const current = common_vendor.ref(0);
    const show = common_vendor.ref(true);
    const showMore = common_vendor.ref(false);
    const popup = common_vendor.ref();
    const state = common_vendor.ref();
    const signStatusStr = common_vendor.ref();
    const id = common_vendor.ref();
    const userList = common_vendor.ref();
    const type = common_vendor.ref("center");
    const trainList = common_vendor.ref();
    const text = common_vendor.ref();
    const scheduleList = common_vendor.ref();
    const height = common_vendor.ref();
    const flag = common_vendor.ref(true);
    const status = common_vendor.ref();
    common_vendor.ref((/* @__PURE__ */ new Date()).getTime());
    const newTime = common_vendor.ref();
    const data = common_vendor.reactive({
      addForm: {},
      form: {}
    });
    const { addForm, form } = common_vendor.toRefs(data);
    common_vendor.onLoad((option) => {
      const item = JSON.parse(decodeURIComponent(option.item));
      id.value = item.trainId;
      status.value = item.status;
      initData();
    });
    function filterTime(num) {
      if (num)
        return num.slice(0, 16);
    }
    async function initData() {
      addForm.value.id = id.value;
      let res = await common_train.trainParticulars(addForm.value);
      form.value = res.data;
      signStatusStr.value = res.data.signStatusStr;
      state.value = res.data.signStatus;
      newTime.value = new Date(res.data.enrollEndTime).getTime();
      userList.value = res.data.userList[0];
      scheduleList.value = res.data.scheduleList;
      setTimeout(() => {
        getbox();
      }, 50);
    }
    function change(e) {
      show.value = e.show;
    }
    async function trainFN(val) {
      text.value = "培训科目";
      popup.value.open(val);
      trainList.value = form.value.trainProjectsList;
    }
    function examinationFN(val) {
      text.value = "考试科目";
      popup.value.open(val);
      trainList.value = form.value.examProjectsList;
    }
    function onClickItem(e) {
      if (current.values != e.currentIndex) {
        current.value = e.currentIndex;
      }
    }
    function getbox() {
      const query = common_vendor.wx$1.createSelectorQuery();
      query.select(".text-content").boundingClientRect(function(rect) {
        height.value = rect.height;
        if (rect.height > 60) {
          showMore.value = true;
        } else {
          showMore.value = false;
        }
      }).exec();
    }
    const move = () => {
      flag.value = !flag.value;
      if (!flag.value) {
        height.value = void 0;
      } else {
        height.value = 60;
      }
    };
    function applyFN() {
      let path = "/pages/train/apply/apply?data=" + [id.value, status.value];
      common_vendor.wx$1.redirectTo({
        url: path
      });
    }
    function shut() {
      popup.value.close();
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.unref(form).cover,
        b: common_vendor.t(common_vendor.unref(form).trainName),
        c: state.value == "报名中"
      }, state.value == "报名中" ? {
        d: common_vendor.t(state.value)
      } : {}, {
        e: state.value == "进行中"
      }, state.value == "进行中" ? {
        f: common_vendor.t(state.value)
      } : {}, {
        g: state.value == "即将开始"
      }, state.value == "即将开始" ? {
        h: common_vendor.t(state.value)
      } : {}, {
        i: state.value == "已结束"
      }, state.value == "已结束" ? {
        j: common_vendor.t(state.value)
      } : {}, {
        k: state.value == "报名未开始"
      }, state.value == "报名未开始" ? {
        l: common_vendor.t(state.value)
      } : {}, {
        m: state.value == "培训未开始"
      }, state.value == "培训未开始" ? {
        n: common_vendor.t(state.value)
      } : {}, {
        o: common_vendor.t(filterTime(common_vendor.unref(form).enrollEndTime)),
        p: common_vendor.o(onClickItem),
        q: common_vendor.p({
          activeColor: "#000",
          current: current.value,
          values: items.value,
          styleType: "text"
        }),
        r: common_vendor.t(common_vendor.unref(form).enrollNotice),
        s: common_vendor.n(height.value ? "hidden" : ""),
        t: showMore.value
      }, showMore.value ? common_vendor.e({
        v: common_vendor.t(flag.value ? "查看更多" : "收起"),
        w: flag.value
      }, flag.value ? {
        x: common_vendor.p({
          type: "right",
          color: "#1ec886"
        })
      } : {
        y: common_vendor.p({
          type: "top",
          color: "#1ec886"
        })
      }, {
        z: common_vendor.o(move)
      }) : {}, {
        A: common_vendor.t(common_vendor.unref(form).organizer),
        B: common_vendor.t(common_vendor.unref(form).undertaker),
        C: common_vendor.t(common_vendor.unref(form).contactUs),
        D: common_vendor.p({
          type: "forward"
        }),
        E: common_vendor.o(($event) => trainFN("bottom")),
        F: common_vendor.p({
          type: "forward"
        }),
        G: common_vendor.o(($event) => examinationFN("bottom")),
        H: current.value === 0,
        I: common_vendor.p({
          scheduleList: scheduleList.value
        }),
        J: current.value === 1,
        K: current.value == 0
      }, current.value == 0 ? common_vendor.e({}, {
        M: state.value != 0 && state.value != 1 && state.value != 5 && signStatusStr.value != "报名结束" && signStatusStr.value != "报名未开始"
      }, state.value != 0 && state.value != 1 && state.value != 5 && signStatusStr.value != "报名结束" && signStatusStr.value != "报名未开始" ? {
        N: common_vendor.o(($event) => applyFN())
      } : {}, {
        O: signStatusStr.value == "报名结束"
      }, signStatusStr.value == "报名结束" ? {} : {}, {
        P: signStatusStr.value == "等待审核"
      }, signStatusStr.value == "等待审核" ? {} : {}, {
        Q: signStatusStr.value == "报名未开始"
      }, signStatusStr.value == "报名未开始" ? {} : {}) : {}, {
        R: common_vendor.t(text.value),
        S: common_vendor.p({
          type: "closeempty"
        }),
        T: common_vendor.o(shut),
        U: common_vendor.f(trainList.value, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.projectName),
            b: common_vendor.t(item.isNecessary == 1 ? "必选" : "非必选"),
            c: item.id
          };
        }),
        V: type.value === "left" || type.value === "right" ? 1 : "",
        W: common_vendor.sr(popup, "26574ee3-6", {
          "k": "popup"
        }),
        X: common_vendor.o(change),
        Y: common_vendor.p({
          ["background-color"]: "#fff"
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "/Users/yangyang/project/j-mini/Venue/pages/train/detailPage/detailPage.vue"]]);
_sfc_main.__runtimeHooks = 6;
wx.createPage(MiniProgramPage);