123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- if (!Array) {
- const _easycom_up_list_item2 = common_vendor.resolveComponent("up-list-item");
- const _easycom_up_list2 = common_vendor.resolveComponent("up-list");
- const _easycom_up_empty2 = common_vendor.resolveComponent("up-empty");
- (_easycom_up_list_item2 + _easycom_up_list2 + _easycom_up_empty2)();
- }
- const _easycom_up_list_item = () => "../../node-modules/uview-plus/components/u-list-item/u-list-item.js";
- const _easycom_up_list = () => "../../node-modules/uview-plus/components/u-list/u-list.js";
- const _easycom_up_empty = () => "../../node-modules/uview-plus/components/u-empty/u-empty.js";
- if (!Math) {
- (_easycom_up_list_item + _easycom_up_list + _easycom_up_empty)();
- }
- const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
- __name: "index",
- setup(__props) {
- const $api = common_vendor.inject("$api");
- const config = common_vendor.ref({ logo: [], file: [] });
- const list = common_vendor.ref([]);
- const total = common_vendor.ref(0);
- const skip = common_vendor.ref(0);
- const limit = common_vendor.ref(5);
- const page = common_vendor.ref(0);
- const is_bottom = common_vendor.ref(false);
- const name = common_vendor.ref("");
- const subjectList = common_vendor.ref([]);
- const gradeList = common_vendor.ref([]);
- const showList = common_vendor.ref([]);
- const typeList = common_vendor.ref([]);
- const statusList = common_vendor.ref([]);
- const user = common_vendor.computed(() => {
- return common_vendor.index.getStorageSync("user");
- });
- common_vendor.onShow(async () => {
- await searchConfig();
- await searchOther();
- await clearPage();
- await search();
- });
- common_vendor.onPullDownRefresh(async () => {
- await clearPage();
- await search();
- common_vendor.index.stopPullDownRefresh();
- });
- const searchConfig = async () => {
- config.value = common_vendor.index.getStorageSync("config");
- };
- const searchOther = async () => {
- let res;
- res = await $api(`dictData`, "GET", { code: "subject", is_use: "0" });
- if (res.errcode === 0)
- subjectList.value = res.data;
- res = await $api(`dictData`, "GET", { code: "grade", is_use: "0" });
- if (res.errcode === 0)
- gradeList.value = res.data;
- res = await $api(`dictData`, "GET", { code: "courseType", is_use: "0" });
- if (res.errcode === 0)
- typeList.value = res.data;
- res = await $api(`dictData`, "GET", { code: "courseStatus", is_use: "0" });
- if (res.errcode === 0)
- statusList.value = res.data;
- res = await $api(`dictData`, "GET", { code: "show", is_use: "0" });
- if (res.errcode === 0)
- showList.value = res.data;
- };
- const search = async () => {
- const info = {
- skip: skip.value,
- limit: limit.value,
- teacher: user.value._id,
- is_show: "0"
- };
- if (name.value)
- info.name = name.value;
- const res = await $api("course", "GET", info);
- if (res.errcode === 0) {
- list.value = list.value.concat(res.data);
- total.value = res.total;
- } else {
- common_vendor.index.showToast({
- title: res.errmsg || "",
- icon: "error"
- });
- }
- };
- const getDict = (data, model) => {
- let res;
- if (model == "subject")
- res = subjectList.value.find((f) => f.value == data);
- else if (model == "grade")
- res = gradeList.value.find((f) => f.value == data);
- else if (model == "type")
- res = typeList.value.find((f) => f.value == data);
- else if (model == "status")
- res = statusList.value.find((f) => f.value == data);
- return res.label || "暂无";
- };
- const toInput = async (e2) => {
- await clearPage();
- await search();
- };
- const toAdd = async () => {
- common_vendor.index.navigateTo({
- url: `/pagesMy/course/add`
- });
- };
- const toEdit = async (item) => {
- common_vendor.index.navigateTo({
- url: `/pagesMy/course/add?id=${item.id || item._id}`
- });
- };
- const toDelete = async () => {
- common_vendor.index.showModal({
- title: "提示",
- content: "确定删除该课程吗?",
- success: async function(res) {
- if (res.confirm) {
- const arr = await $api(`course/${e._id}`, "DELETE");
- if (arr.errcode == "0") {
- common_vendor.index.showToast({
- title: "删除信息成功",
- icon: "none"
- });
- await clearPage();
- await search();
- } else {
- common_vendor.index.showToast({
- title: arr.errmsg,
- icon: "none"
- });
- }
- }
- }
- });
- };
- const scrolltolower = () => {
- if (total.value > list.value.length) {
- common_vendor.index.showLoading({
- title: "加载中",
- mask: true
- });
- page.value = page.value + 1;
- skip.value = page.value * limit.value;
- search();
- common_vendor.index.hideLoading();
- } else
- is_bottom.value = true;
- };
- const clearPage = () => {
- list.value = [];
- skip.value = 0;
- limit.value = 6;
- page.value = 0;
- };
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: common_vendor.o([($event) => name.value = $event.detail.value, toInput]),
- b: name.value,
- c: common_vendor.o(toAdd),
- d: total.value > 0
- }, total.value > 0 ? {
- e: common_vendor.f(list.value, (item, index, i0) => {
- return common_vendor.e({
- a: common_vendor.t(item.name || "暂无"),
- b: common_vendor.t(getDict(item.type, "type")),
- c: common_vendor.t(getDict(item.subject, "subject")),
- d: common_vendor.t(getDict(item.grade, "grade")),
- e: common_vendor.t(item.money || "免费"),
- f: common_vendor.t(item.start_time),
- g: common_vendor.t(item.end_time),
- h: common_vendor.t(getDict(item.status, "status")),
- i: common_vendor.n(item.status == "0" ? "red" : ""),
- j: common_vendor.o(($event) => toEdit(item), index),
- k: item.status == "0"
- }, item.status == "0" ? {
- l: common_vendor.o(($event) => toDelete(), index)
- } : {}, {
- m: index,
- n: "5cb065a7-1-" + i0 + ",5cb065a7-0"
- });
- }),
- f: common_vendor.o(scrolltolower)
- } : {
- g: common_vendor.p({
- mode: "list",
- icon: "/static/list.png"
- })
- }, {
- h: is_bottom.value
- }, is_bottom.value ? {
- i: common_vendor.t(config.value.bottom_title || "没有更多了!")
- } : {});
- };
- }
- });
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5cb065a7"], ["__file", "D:/project/学吧/learn_applet/pagesMy/course/index.vue"]]);
- wx.createPage(MiniProgramPage);
|