index.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 scrolltolower = () => {
  100. if (total.value > list.value.length) {
  101. common_vendor.index.showLoading({
  102. title: "加载中",
  103. mask: true
  104. });
  105. page.value = page.value + 1;
  106. skip.value = page.value * limit.value;
  107. search();
  108. common_vendor.index.hideLoading();
  109. } else
  110. is_bottom.value = true;
  111. };
  112. const clearPage = () => {
  113. list.value = [];
  114. skip.value = 0;
  115. limit.value = 6;
  116. page.value = 0;
  117. };
  118. return (_ctx, _cache) => {
  119. return common_vendor.e({
  120. a: common_vendor.p({
  121. radius: 0,
  122. list: config.value.file,
  123. height: "240px",
  124. indicator: true,
  125. indicatorMode: "dot",
  126. circular: true
  127. }),
  128. b: config.value.notice
  129. }, config.value.notice ? {
  130. c: common_vendor.p({
  131. text: config.value.notice,
  132. duration: "3000"
  133. })
  134. } : {}, {
  135. d: common_vendor.f(typeList.value, (item, index, i0) => {
  136. return {
  137. a: common_vendor.n(item.remark),
  138. b: common_vendor.t(item.label),
  139. c: index
  140. };
  141. }),
  142. e: common_vendor.o(toTab),
  143. f: common_vendor.p({
  144. list: subjectList.value,
  145. keyName: "label"
  146. }),
  147. g: total.value > 0
  148. }, total.value > 0 ? {
  149. h: common_vendor.f(list.value, (item, index, i0) => {
  150. return common_vendor.e({
  151. a: item.icon && item.icon.length > 0 && item.icon
  152. }, item.icon && item.icon.length > 0 && item.icon ? {
  153. b: item.icon[0].url
  154. } : {
  155. c: config.value.icon[0].url
  156. }, {
  157. d: common_vendor.t(item.course || "暂无"),
  158. e: common_vendor.t(item.time || "休息中"),
  159. f: common_vendor.t(item.nick_name || "暂无"),
  160. g: common_vendor.t(item.content || "暂无"),
  161. h: common_vendor.t(item.money || "免费"),
  162. i: common_vendor.o(($event) => toBuy(item), index),
  163. j: index,
  164. k: "4978fed5-4-" + i0 + ",4978fed5-3"
  165. });
  166. }),
  167. i: common_vendor.o(scrolltolower)
  168. } : {
  169. j: common_vendor.p({
  170. mode: "list",
  171. icon: "/static/list.png"
  172. })
  173. }, {
  174. k: common_vendor.o(showChange),
  175. l: common_vendor.p({
  176. show: show.value
  177. })
  178. });
  179. };
  180. }
  181. });
  182. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4978fed5"], ["__file", "D:/project/学吧/learn_applet/pages/home/index.vue"]]);
  183. wx.createPage(MiniProgramPage);