index.js 6.6 KB

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