index.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_up_search2 = common_vendor.resolveComponent("up-search");
  5. const _easycom_up_tabs2 = common_vendor.resolveComponent("up-tabs");
  6. const _easycom_up_list_item2 = common_vendor.resolveComponent("up-list-item");
  7. const _easycom_up_list2 = common_vendor.resolveComponent("up-list");
  8. const _easycom_up_empty2 = common_vendor.resolveComponent("up-empty");
  9. const _easycom_up_overlay2 = common_vendor.resolveComponent("up-overlay");
  10. (_easycom_up_search2 + _easycom_up_tabs2 + _easycom_up_list_item2 + _easycom_up_list2 + _easycom_up_empty2 + _easycom_up_overlay2)();
  11. }
  12. const _easycom_up_search = () => "../../node-modules/uview-plus/components/u-search/u-search.js";
  13. const _easycom_up_tabs = () => "../../node-modules/uview-plus/components/u-tabs/u-tabs.js";
  14. const _easycom_up_list_item = () => "../../node-modules/uview-plus/components/u-list-item/u-list-item.js";
  15. const _easycom_up_list = () => "../../node-modules/uview-plus/components/u-list/u-list.js";
  16. const _easycom_up_empty = () => "../../node-modules/uview-plus/components/u-empty/u-empty.js";
  17. const _easycom_up_overlay = () => "../../node-modules/uview-plus/components/u-overlay/u-overlay.js";
  18. if (!Math) {
  19. (_easycom_up_search + _easycom_up_tabs + _easycom_up_list_item + _easycom_up_list + _easycom_up_empty + 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. const config = common_vendor.ref({ logo: [], file: [] });
  27. const list = common_vendor.ref([]);
  28. const total = common_vendor.ref(0);
  29. const skip = common_vendor.ref(0);
  30. const limit = common_vendor.ref(5);
  31. const page = common_vendor.ref(0);
  32. const is_bottom = common_vendor.ref(false);
  33. const show = common_vendor.ref(false);
  34. const subjectList = common_vendor.ref([]);
  35. const educationList = common_vendor.ref([]);
  36. const nick_name = common_vendor.ref("");
  37. const user = common_vendor.computed(() => {
  38. return common_vendor.index.getStorageSync("user");
  39. });
  40. common_vendor.onShow(async () => {
  41. await searchConfig();
  42. await searchOther();
  43. await clearPage();
  44. await search();
  45. if (!user.value)
  46. show.value = true;
  47. });
  48. common_vendor.onPullDownRefresh(async () => {
  49. await clearPage();
  50. await search();
  51. common_vendor.index.stopPullDownRefresh();
  52. });
  53. const searchConfig = async () => {
  54. config.value = common_vendor.index.getStorageSync("config");
  55. };
  56. const searchOther = async () => {
  57. let res;
  58. res = await $api(`dictData`, "GET", { code: "subject", is_use: "0" });
  59. if (res.errcode === 0)
  60. subjectList.value = res.data;
  61. subjectList.value.unshift({ label: "全部", value: "-1", is_show: true });
  62. res = await $api(`dictData`, "GET", { code: "education", is_use: "0" });
  63. if (res.errcode === 0)
  64. educationList.value = res.data;
  65. };
  66. const searchInfo = async () => {
  67. if (nick_name.value) {
  68. await clearPage();
  69. await search();
  70. }
  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. if (nick_name.value)
  80. info.nick_name = nick_name.value;
  81. const res = await $api("teacher", "GET", info);
  82. if (res.errcode === 0) {
  83. list.value = list.value.concat(res.data);
  84. total.value = res.total;
  85. } else {
  86. common_vendor.index.showToast({
  87. title: res.errmsg || "",
  88. icon: "error"
  89. });
  90. }
  91. };
  92. const toTab = async (data) => {
  93. console.log(data);
  94. };
  95. const showChange = () => {
  96. show.value = false;
  97. };
  98. const getDict = (data, model) => {
  99. let res;
  100. if (model == "education")
  101. res = educationList.value.find((f) => f.value == data);
  102. return res.label || "暂无";
  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.o(searchInfo),
  126. b: common_vendor.o(($event) => nick_name.value = $event),
  127. c: common_vendor.p({
  128. modelValue: nick_name.value
  129. }),
  130. d: common_vendor.o(toTab),
  131. e: common_vendor.p({
  132. list: subjectList.value,
  133. keyName: "label"
  134. }),
  135. f: total.value > 0
  136. }, total.value > 0 ? {
  137. g: common_vendor.f(list.value, (item, index, i0) => {
  138. return common_vendor.e({
  139. a: item.icon && item.icon.length > 0 && item.icon
  140. }, item.icon && item.icon.length > 0 && item.icon ? {
  141. b: item.icon[0].url
  142. } : {
  143. c: config.value.icon[0].url
  144. }, {
  145. d: common_vendor.t(item.nick_name || "暂无昵称"),
  146. e: common_vendor.t(item.time || "休息中"),
  147. f: common_vendor.t(item.college || "暂无"),
  148. g: common_vendor.t(getDict(item.education, "education")),
  149. h: common_vendor.t(item.money || "免费"),
  150. i: common_vendor.o(($event) => _ctx.toBuy(item), index),
  151. j: index,
  152. k: "f3506c63-3-" + i0 + ",f3506c63-2"
  153. });
  154. }),
  155. h: common_vendor.o(scrolltolower)
  156. } : {
  157. i: common_vendor.p({
  158. mode: "list",
  159. icon: "/static/list.png"
  160. })
  161. }, {
  162. j: is_bottom.value
  163. }, is_bottom.value ? {
  164. k: common_vendor.t(config.value.bottom_title || "没有更多了!")
  165. } : {}, {
  166. l: common_vendor.o(showChange),
  167. m: 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-f3506c63"], ["__file", "D:/project/学吧/learn_applet/pages/teacher/index.vue"]]);
  175. wx.createPage(MiniProgramPage);