index.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_up_tabs2 = common_vendor.resolveComponent("up-tabs");
  5. const _easycom_up_empty2 = common_vendor.resolveComponent("up-empty");
  6. const _easycom_up_overlay2 = common_vendor.resolveComponent("up-overlay");
  7. (_easycom_up_tabs2 + _easycom_up_empty2 + _easycom_up_overlay2)();
  8. }
  9. const _easycom_up_tabs = () => "../../node-modules/uview-plus/components/u-tabs/u-tabs.js";
  10. const _easycom_up_empty = () => "../../node-modules/uview-plus/components/u-empty/u-empty.js";
  11. const _easycom_up_overlay = () => "../../node-modules/uview-plus/components/u-overlay/u-overlay.js";
  12. if (!Math) {
  13. (_easycom_up_tabs + _easycom_up_empty + login + _easycom_up_overlay)();
  14. }
  15. const login = () => "../../components/login.js";
  16. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  17. __name: "index",
  18. setup(__props) {
  19. const $api = common_vendor.inject("$api");
  20. const config = common_vendor.ref({ logo: [], file: [] });
  21. const type = common_vendor.ref("");
  22. const subject = common_vendor.ref("-1");
  23. common_vendor.ref("-1");
  24. const list = common_vendor.ref([]);
  25. const total = common_vendor.ref(0);
  26. const skip = common_vendor.ref(0);
  27. const limit = common_vendor.ref(5);
  28. const page = common_vendor.ref(0);
  29. const is_bottom = common_vendor.ref(false);
  30. const show = common_vendor.ref(false);
  31. const nick_name = common_vendor.ref("");
  32. const educationList = common_vendor.ref([]);
  33. const active = common_vendor.ref(0);
  34. const subjectList = common_vendor.ref([]);
  35. const gradeList = common_vendor.ref([]);
  36. const user = common_vendor.computed(() => {
  37. return common_vendor.index.getStorageSync("user");
  38. });
  39. common_vendor.onLoad(async (options) => {
  40. type.value = options && options.type;
  41. common_vendor.index.setNavigationBarTitle({
  42. title: options && options.name + "课程" || "课程"
  43. });
  44. });
  45. common_vendor.onShow(async () => {
  46. await searchConfig();
  47. await searchOther();
  48. await clearPage();
  49. await search();
  50. if (!user.value)
  51. show.value = true;
  52. });
  53. common_vendor.onPullDownRefresh(async () => {
  54. await clearPage();
  55. await search();
  56. common_vendor.index.stopPullDownRefresh();
  57. });
  58. const searchConfig = async () => {
  59. config.value = common_vendor.index.getStorageSync("config");
  60. };
  61. const searchOther = async () => {
  62. let res;
  63. res = await $api(`dictData`, "GET", { code: "education", is_use: "0" });
  64. if (res.errcode === 0)
  65. educationList.value = res.data;
  66. res = await $api(`dictData`, "GET", { code: "subject", is_use: "0" });
  67. if (res.errcode === 0)
  68. subjectList.value = res.data;
  69. subjectList.value.unshift({ label: "全部", value: "-1" });
  70. res = await $api(`dictData`, "GET", { code: "grade", is_use: "0" });
  71. if (res.errcode === 0)
  72. gradeList.value = res.data;
  73. gradeList.value.unshift({ label: "全部", value: "-1" });
  74. };
  75. const searchInfo = async () => {
  76. await clearPage();
  77. await search();
  78. };
  79. const search = async () => {
  80. const info = {
  81. skip: skip.value,
  82. limit: limit.value,
  83. status: "1",
  84. is_show: "0"
  85. };
  86. if (nick_name.value)
  87. info.nick_name = nick_name.value;
  88. const res = await $api("teacher", "GET", info);
  89. if (res.errcode === 0) {
  90. list.value = list.value.concat(res.data);
  91. total.value = res.total;
  92. } else {
  93. common_vendor.index.showToast({
  94. title: res.errmsg || "",
  95. icon: "error"
  96. });
  97. }
  98. };
  99. const showChange = () => {
  100. show.value = false;
  101. };
  102. const toChange = (index, e) => {
  103. console.log(index, e);
  104. active.value = index;
  105. subject.value = e.value;
  106. };
  107. const toTab = async (data) => {
  108. console.log(data);
  109. };
  110. const toPage = () => {
  111. if (total.value > list.value.length) {
  112. common_vendor.index.showLoading({
  113. title: "加载中",
  114. mask: true
  115. });
  116. page.value = page.value + 1;
  117. skip.value = page.value * limit.value;
  118. search();
  119. common_vendor.index.hideLoading();
  120. } else
  121. is_bottom.value = true;
  122. };
  123. const clearPage = () => {
  124. list.value = [];
  125. skip.value = 0;
  126. limit.value = 6;
  127. page.value = 0;
  128. };
  129. return (_ctx, _cache) => {
  130. return common_vendor.e({
  131. a: nick_name.value,
  132. b: common_vendor.o(($event) => nick_name.value = $event.detail.value),
  133. c: common_vendor.o(searchInfo),
  134. d: common_vendor.f(subjectList.value, (item, index, i0) => {
  135. return {
  136. a: common_vendor.t(item.label),
  137. b: common_vendor.n(active.value == index ? "listActive" : ""),
  138. c: index,
  139. d: common_vendor.o(($event) => toChange(index, item), index)
  140. };
  141. }),
  142. e: common_vendor.o(toTab),
  143. f: common_vendor.p({
  144. list: gradeList.value,
  145. keyName: "label"
  146. }),
  147. g: total.value > 0
  148. }, total.value > 0 ? common_vendor.e({
  149. h: common_vendor.f(list.value, (tag, index, i0) => {
  150. return {
  151. a: common_vendor.t(tag.nick_name),
  152. b: index,
  153. c: common_vendor.o(($event) => _ctx.toBuy(tag), index)
  154. };
  155. }),
  156. i: is_bottom.value
  157. }, is_bottom.value ? {
  158. j: common_vendor.t(config.value.bottom_title)
  159. } : {}, {
  160. k: common_vendor.o(toPage),
  161. l: common_vendor.o(
  162. //@ts-ignore
  163. (...args) => _ctx.toScroll && _ctx.toScroll(...args)
  164. )
  165. }) : {
  166. m: common_vendor.p({
  167. mode: "list",
  168. icon: "/static/list.png"
  169. })
  170. }, {
  171. n: common_vendor.o(showChange),
  172. o: common_vendor.p({
  173. show: show.value
  174. })
  175. });
  176. };
  177. }
  178. });
  179. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-db68cfa6"], ["__file", "D:/project/学吧/learn_applet/pagesHome/list/index.vue"]]);
  180. wx.createPage(MiniProgramPage);