index.js 6.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_search_bar2 = common_vendor.resolveComponent("uni-search-bar");
  const _easycom_uni_data_select2 = common_vendor.resolveComponent("uni-data-select");
  const _easycom_uni_section2 = common_vendor.resolveComponent("uni-section");
  const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  (_easycom_uni_search_bar2 + _easycom_uni_data_select2 + _easycom_uni_section2 + _easycom_uni_load_more2)();
}
const _easycom_uni_search_bar = () => "../../uni_modules/uni-search-bar/components/uni-search-bar/uni-search-bar.js";
const _easycom_uni_data_select = () => "../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select.js";
const _easycom_uni_section = () => "../../uni_modules/uni-section/components/uni-section/uni-section.js";
const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
if (!Math) {
  (_easycom_uni_search_bar + _easycom_uni_data_select + _easycom_uni_section + common_vendor.unref(uniList) + _easycom_uni_load_more)();
}
const uniList = () => "../../components/train/ulist/ulist.js";
const _sfc_main = {
  __name: "index",
  setup(__props) {
    common_vendor.ref();
    const items = common_vendor.ref(["全部", "报名中", "进行中", "即将开始", "报名未开始", "培训未开始", "已结束"]);
    const current = common_vendor.ref(0);
    const name = common_vendor.ref();
    const Nindex = common_vendor.ref(0);
    const range = common_vendor.ref([
      {
        value: 1,
        text: "全部"
      },
      {
        value: 2,
        text: "报名中"
      },
      {
        value: 3,
        text: "进行中"
      },
      {
        value: 4,
        text: "即将开始"
      },
      {
        value: 5,
        text: "报名未开始"
      },
      {
        value: 6,
        text: "培训未开始"
      },
      {
        value: 7,
        text: "已结束"
      }
    ]);
    const list = common_vendor.ref();
    const total = common_vendor.ref();
    const status = common_vendor.ref("more");
    common_vendor.ref();
    const data = common_vendor.reactive({
      addForm: {},
      contentText: {
        contentdown: "",
        contentrefresh: "加载中",
        contentnomore: "没有更多"
      }
    });
    const {
      addForm,
      contentText
    } = common_vendor.toRefs(data);
    common_vendor.onLoad((option) => {
      initData();
    });
    async function initData() {
      addForm.value.flag = current.value;
      addForm.value.pageNum = 1;
      addForm.value.pageSize = 10;
      let res = await common_train.tainList(addForm.value);
      list.value = res.rows;
      total.value = res.rows;
    }
    function detail(item) {
      let path = "/pages/train/detailPage/detailPage?item=" + encodeURIComponent(JSON.stringify(item));
      common_vendor.index.navigateTo({
        url: path
      });
    }
    function nvaText(index) {
      Nindex.value = index;
      current.value = index;
      initData();
      console.log(index);
    }
    function filterTime(num) {
      if (num)
        return num.slice(0, 16);
    }
    function change(e) {
      if (e) {
        addForm.value.flag = e - 1;
        current.value = e - 1;
        Nindex.value = e - 1;
        console.log(e);
        initData();
      }
    }
    function search(res) {
      if (res.value != "") {
        addForm.value.trainName = res.value;
        initData();
      }
    }
    function clear(res) {
      addForm.value.trainName = "";
      initData();
    }
    common_vendor.onPullDownRefresh(() => {
      addForm.value.flag = 0;
      initData();
      common_vendor.wx$1.stopPullDownRefresh();
    });
    common_vendor.onReachBottom(async () => {
      if (list.value.length == total.value) {
        status.value = "noMore";
        return false;
      } else {
        status.value = "loading";
        addForm.value.pageNum += 1;
        let res = await common_train.tainList(addForm.value);
        let arr = res.rows;
        list.value = list.value.concat(arr);
        total.value = res.total;
        status.value = "noMore";
      }
    });
    return (_ctx, _cache) => {
      return {
        a: common_vendor.o(search),
        b: common_vendor.o(_ctx.blur),
        c: common_vendor.o(clear),
        d: common_vendor.o(($event) => name.value = $event),
        e: common_vendor.p({
          radius: "30",
          placeholder: "搜索",
          clearButton: "auto",
          Button: "none",
          cancelText: "",
          bgColor: "#F4F6FA",
          modelValue: name.value
        }),
        f: common_vendor.o(change),
        g: common_vendor.o(($event) => name.value = $event),
        h: common_vendor.p({
          localdata: range.value,
          clear: false,
          placeholder: "全部",
          modelValue: name.value
        }),
        i: common_vendor.p({
          title: "",
          type: "line"
        }),
        j: common_vendor.f(items.value, (item, index, i0) => {
          return {
            a: common_vendor.t(item),
            b: common_vendor.o(($event) => nvaText(index), index),
            c: Nindex.value == index ? 1 : "",
            d: index
          };
        }),
        k: common_vendor.f(list.value, (item, k0, i0) => {
          return {
            a: "076cf674-3-" + i0,
            b: common_vendor.p({
              pic: item.cover,
              title: item.trainName,
              card: item.statusStr,
              timer: filterTime(item.enrollEndStr)
            }),
            c: item.trainId,
            d: common_vendor.o(($event) => detail(item), item.trainId)
          };
        }),
        l: common_vendor.p({
          status: status.value,
          ["content-text"]: common_vendor.unref(contentText)
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "/Users/yangyang/project/j-mini/Venue/pages/train/index.vue"]]);
_sfc_main.__runtimeHooks = 6;
wx.createPage(MiniProgramPage);