index.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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_overlay2 = common_vendor.resolveComponent("up-overlay");
  10. (_easycom_u_swiper2 + _easycom_up_notice_bar2 + _easycom_up_tabs2 + _easycom_up_list_item2 + _easycom_up_list2 + _easycom_up_overlay2)();
  11. }
  12. const _easycom_u_swiper = () => "../../node-modules/uview-plus/components/u-swiper/u-swiper.js";
  13. const _easycom_up_notice_bar = () => "../../node-modules/uview-plus/components/u-notice-bar/u-notice-bar.js";
  14. const _easycom_up_tabs = () => "../../node-modules/uview-plus/components/u-tabs/u-tabs.js";
  15. const _easycom_up_list_item = () => "../../node-modules/uview-plus/components/u-list-item/u-list-item.js";
  16. const _easycom_up_list = () => "../../node-modules/uview-plus/components/u-list/u-list.js";
  17. const _easycom_up_overlay = () => "../../node-modules/uview-plus/components/u-overlay/u-overlay.js";
  18. if (!Math) {
  19. (_easycom_u_swiper + _easycom_up_notice_bar + _easycom_up_tabs + _easycom_up_list_item + _easycom_up_list + login + _easycom_up_overlay)();
  20. }
  21. const login = () => "../../components/login.js";
  22. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  23. __name: "index",
  24. setup(__props) {
  25. const $api = common_vendor.inject("$api");
  26. common_vendor.inject("$apifile");
  27. const typeList = common_vendor.ref([
  28. { name: "兴趣", icon: "t-icon-xingqu", type: "0" },
  29. { name: "小学", icon: "t-icon-xiaoxue", type: "1" },
  30. { name: "中学", icon: "t-icon-zhongxue", type: "2" },
  31. { name: "高中", icon: "t-icon-gaozhong", type: "3" }
  32. ]);
  33. const config = common_vendor.ref({ icon: [], logo: [], file: [] });
  34. const list = common_vendor.ref([]);
  35. const total = common_vendor.ref(0);
  36. const skip = common_vendor.ref(0);
  37. const limit = common_vendor.ref(5);
  38. const page = common_vendor.ref(0);
  39. const is_bottom = common_vendor.ref(false);
  40. const subjectList = common_vendor.ref([]);
  41. const educationList = common_vendor.ref([]);
  42. const show = common_vendor.ref(false);
  43. const user = common_vendor.computed(() => {
  44. return common_vendor.index.getStorageSync("user");
  45. });
  46. common_vendor.onShow(async () => {
  47. await searchConfig();
  48. await searchOther();
  49. await clearPage();
  50. await search();
  51. if (!user.value)
  52. show.value = true;
  53. });
  54. common_vendor.onPullDownRefresh(async () => {
  55. await clearPage();
  56. await search();
  57. common_vendor.index.stopPullDownRefresh();
  58. });
  59. const searchConfig = async () => {
  60. config.value = common_vendor.index.getStorageSync("config");
  61. };
  62. const searchOther = async () => {
  63. let res;
  64. res = await $api(`dictData`, "GET", { code: "subject", is_use: "0" });
  65. if (res.errcode === 0)
  66. subjectList.value = res.data;
  67. subjectList.value.unshift({ label: "全部", value: "-1", is_show: true });
  68. res = await $api(`dictData`, "GET", { code: "education", is_use: "0" });
  69. if (res.errcode === 0)
  70. educationList.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.icon),
  138. b: common_vendor.t(item.name),
  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: common_vendor.f(list.value, (item, index, i0) => {
  148. return common_vendor.e({
  149. a: item.icon && item.icon.length > 0 && item.icon
  150. }, item.icon && item.icon.length > 0 && item.icon ? {
  151. b: item.icon[0].url
  152. } : {
  153. c: config.value.icon[0].url
  154. }, {
  155. d: common_vendor.t(item.course || "暂无"),
  156. e: common_vendor.t(item.time || "休息中"),
  157. f: common_vendor.t(item.nick_name || "暂无"),
  158. g: common_vendor.t(item.content || "暂无"),
  159. h: common_vendor.t(item.money || "免费"),
  160. i: common_vendor.o(($event) => toBuy(item), index),
  161. j: index,
  162. k: "4978fed5-4-" + i0 + ",4978fed5-3"
  163. });
  164. }),
  165. h: common_vendor.o(scrolltolower),
  166. i: common_vendor.o(showChange),
  167. j: common_vendor.p({
  168. show: show.value
  169. })
  170. });
  171. };
  172. }
  173. });
  174. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4978fed5"], ["__file", "D:/project/学吧/learn_applet/pages/home/index.vue"]]);
  175. wx.createPage(MiniProgramPage);