index.js 7.1 KB

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