index.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 show = common_vendor.ref(false);
  42. const user = common_vendor.computed(() => {
  43. return common_vendor.index.getStorageSync("user");
  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: "subject", is_use: "0" });
  64. if (res.errcode === 0)
  65. subjectList.value = res.data;
  66. subjectList.value.unshift({ label: "全部", value: "-1", is_show: true });
  67. };
  68. const search = async () => {
  69. const info = {
  70. skip: skip.value,
  71. limit: limit.value,
  72. status: "1",
  73. is_show: "0"
  74. };
  75. const res = await $api("teacher", "GET", info);
  76. if (res.errcode === 0) {
  77. list.value = list.value.concat(res.data);
  78. total.value = res.total;
  79. } else {
  80. common_vendor.index.showToast({
  81. title: res.errmsg || "",
  82. icon: "error"
  83. });
  84. }
  85. };
  86. const toTab = async (data) => {
  87. console.log(data);
  88. };
  89. const showChange = () => {
  90. show.value = false;
  91. };
  92. const scrolltolower = () => {
  93. if (total.value > list.value.length) {
  94. common_vendor.index.showLoading({
  95. title: "加载中",
  96. mask: true
  97. });
  98. page.value = page.value + 1;
  99. skip.value = page.value * limit.value;
  100. search();
  101. common_vendor.index.hideLoading();
  102. } else
  103. is_bottom.value = true;
  104. };
  105. const clearPage = () => {
  106. list.value = [];
  107. skip.value = 0;
  108. limit.value = 6;
  109. page.value = 0;
  110. };
  111. return (_ctx, _cache) => {
  112. return common_vendor.e({
  113. a: common_vendor.p({
  114. radius: 0,
  115. list: config.value.file,
  116. height: "240px",
  117. indicator: true,
  118. indicatorMode: "dot",
  119. circular: true
  120. }),
  121. b: config.value.notice
  122. }, config.value.notice ? {
  123. c: common_vendor.p({
  124. text: config.value.notice,
  125. duration: "3000"
  126. })
  127. } : {}, {
  128. d: common_vendor.f(typeList.value, (item, index, i0) => {
  129. return {
  130. a: common_vendor.n(item.icon),
  131. b: common_vendor.t(item.name),
  132. c: index
  133. };
  134. }),
  135. e: common_vendor.o(toTab),
  136. f: common_vendor.p({
  137. list: subjectList.value,
  138. keyName: "label"
  139. }),
  140. g: common_vendor.f(list.value, (item, index, i0) => {
  141. return {
  142. a: common_vendor.t(item.nick_name),
  143. b: index,
  144. c: "4978fed5-4-" + i0 + ",4978fed5-3"
  145. };
  146. }),
  147. h: common_vendor.o(scrolltolower),
  148. i: common_vendor.o(showChange),
  149. j: common_vendor.p({
  150. show: show.value
  151. })
  152. });
  153. };
  154. }
  155. });
  156. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4978fed5"], ["__file", "D:/project/学吧/learn_applet/pages/home/index.vue"]]);
  157. wx.createPage(MiniProgramPage);