index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_up_list_item2 = common_vendor.resolveComponent("up-list-item");
  5. const _easycom_up_list2 = common_vendor.resolveComponent("up-list");
  6. const _easycom_up_empty2 = common_vendor.resolveComponent("up-empty");
  7. (_easycom_up_list_item2 + _easycom_up_list2 + _easycom_up_empty2)();
  8. }
  9. const _easycom_up_list_item = () => "../../node-modules/uview-plus/components/u-list-item/u-list-item.js";
  10. const _easycom_up_list = () => "../../node-modules/uview-plus/components/u-list/u-list.js";
  11. const _easycom_up_empty = () => "../../node-modules/uview-plus/components/u-empty/u-empty.js";
  12. if (!Math) {
  13. (_easycom_up_list_item + _easycom_up_list + _easycom_up_empty)();
  14. }
  15. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  16. __name: "index",
  17. setup(__props) {
  18. const $api = common_vendor.inject("$api");
  19. const config = common_vendor.ref({ logo: [], file: [] });
  20. const list = common_vendor.ref([]);
  21. const total = common_vendor.ref(0);
  22. const skip = common_vendor.ref(0);
  23. const limit = common_vendor.ref(5);
  24. const page = common_vendor.ref(0);
  25. const is_bottom = common_vendor.ref(false);
  26. const name = common_vendor.ref("");
  27. const user = common_vendor.computed(() => {
  28. return common_vendor.index.getStorageSync("user");
  29. });
  30. common_vendor.onShow(async () => {
  31. await searchConfig();
  32. await searchOther();
  33. await clearPage();
  34. await search();
  35. });
  36. common_vendor.onPullDownRefresh(async () => {
  37. await clearPage();
  38. await search();
  39. common_vendor.index.stopPullDownRefresh();
  40. });
  41. const searchConfig = async () => {
  42. config.value = common_vendor.index.getStorageSync("config");
  43. };
  44. const searchOther = async () => {
  45. };
  46. const search = async () => {
  47. const info = {
  48. skip: skip.value,
  49. limit: limit.value,
  50. teacher: user.value._id,
  51. is_show: "0"
  52. };
  53. if (name.value)
  54. info.name = name.value;
  55. const res = await $api("course", "GET", info);
  56. if (res.errcode === 0) {
  57. list.value = list.value.concat(res.data);
  58. total.value = res.total;
  59. } else {
  60. common_vendor.index.showToast({
  61. title: res.errmsg || "",
  62. icon: "error"
  63. });
  64. }
  65. };
  66. const toInput = async (e) => {
  67. await clearPage();
  68. await search();
  69. };
  70. const toAdd = async () => {
  71. common_vendor.index.navigateTo({
  72. url: `/pagesMy/course/add`
  73. });
  74. };
  75. const scrolltolower = () => {
  76. if (total.value > list.value.length) {
  77. common_vendor.index.showLoading({
  78. title: "加载中",
  79. mask: true
  80. });
  81. page.value = page.value + 1;
  82. skip.value = page.value * limit.value;
  83. search();
  84. common_vendor.index.hideLoading();
  85. } else
  86. is_bottom.value = true;
  87. };
  88. const clearPage = () => {
  89. list.value = [];
  90. skip.value = 0;
  91. limit.value = 6;
  92. page.value = 0;
  93. };
  94. return (_ctx, _cache) => {
  95. return common_vendor.e({
  96. a: common_vendor.o([($event) => name.value = $event.detail.value, toInput]),
  97. b: name.value,
  98. c: common_vendor.o(toAdd),
  99. d: total.value > 0
  100. }, total.value > 0 ? {
  101. e: common_vendor.f(list.value, (item, index, i0) => {
  102. return {
  103. a: index,
  104. b: "5cb065a7-1-" + i0 + ",5cb065a7-0"
  105. };
  106. }),
  107. f: common_vendor.o(scrolltolower)
  108. } : {
  109. g: common_vendor.p({
  110. mode: "list",
  111. icon: "/static/list.png"
  112. })
  113. }, {
  114. h: is_bottom.value
  115. }, is_bottom.value ? {
  116. i: common_vendor.t(config.value.bottom_title || "没有更多了!")
  117. } : {});
  118. };
  119. }
  120. });
  121. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5cb065a7"], ["__file", "D:/project/学吧/learn_applet/pagesMy/course/index.vue"]]);
  122. wx.createPage(MiniProgramPage);