index.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_up_list_item2 = common_vendor.resolveComponent("up-list-item");
  5. const _easycom_up_list2 = common_vendor.resolveComponent("up-list");
  6. const _easycom_up_empty2 = common_vendor.resolveComponent("up-empty");
  7. const _easycom_up_overlay2 = common_vendor.resolveComponent("up-overlay");
  8. (_easycom_up_list_item2 + _easycom_up_list2 + _easycom_up_empty2 + _easycom_up_overlay2)();
  9. }
  10. const _easycom_up_list_item = () => "../../node-modules/uview-plus/components/u-list-item/u-list-item.js";
  11. const _easycom_up_list = () => "../../node-modules/uview-plus/components/u-list/u-list.js";
  12. const _easycom_up_empty = () => "../../node-modules/uview-plus/components/u-empty/u-empty.js";
  13. const _easycom_up_overlay = () => "../../node-modules/uview-plus/components/u-overlay/u-overlay.js";
  14. if (!Math) {
  15. (_easycom_up_list_item + _easycom_up_list + _easycom_up_empty + login + _easycom_up_overlay)();
  16. }
  17. const login = () => "../../components/login.js";
  18. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  19. __name: "index",
  20. setup(__props) {
  21. const $api = common_vendor.inject("$api");
  22. const config = common_vendor.ref({ logo: [], file: [] });
  23. const list = common_vendor.ref([]);
  24. const total = common_vendor.ref(0);
  25. const skip = common_vendor.ref(0);
  26. const limit = common_vendor.ref(5);
  27. const page = common_vendor.ref(0);
  28. const is_bottom = common_vendor.ref(false);
  29. const show = common_vendor.ref(false);
  30. const educationList = common_vendor.ref([]);
  31. const nick_name = common_vendor.ref("");
  32. const user = common_vendor.computed(() => {
  33. return common_vendor.index.getStorageSync("user");
  34. });
  35. common_vendor.onShow(async () => {
  36. await searchConfig();
  37. await searchOther();
  38. await clearPage();
  39. await search();
  40. if (!user.value)
  41. show.value = true;
  42. });
  43. common_vendor.onPullDownRefresh(async () => {
  44. await clearPage();
  45. await search();
  46. common_vendor.index.stopPullDownRefresh();
  47. });
  48. const searchConfig = async () => {
  49. config.value = common_vendor.index.getStorageSync("config");
  50. };
  51. const searchOther = async () => {
  52. let res;
  53. res = await $api(`dictData`, "GET", { code: "education", is_use: "0" });
  54. if (res.errcode === 0)
  55. educationList.value = res.data;
  56. };
  57. const searchInfo = async () => {
  58. await clearPage();
  59. await search();
  60. };
  61. const search = async () => {
  62. const info = {
  63. skip: skip.value,
  64. limit: limit.value,
  65. status: "1",
  66. is_show: "0"
  67. };
  68. if (nick_name.value)
  69. info.nick_name = nick_name.value;
  70. const res = await $api("teacher", "GET", info);
  71. if (res.errcode === 0) {
  72. list.value = list.value.concat(res.data);
  73. total.value = res.total;
  74. } else {
  75. common_vendor.index.showToast({
  76. title: res.errmsg || "",
  77. icon: "error"
  78. });
  79. }
  80. };
  81. const showChange = () => {
  82. show.value = false;
  83. };
  84. const getDict = (data, model) => {
  85. let res;
  86. if (model == "education")
  87. res = educationList.value.find((f) => f.value == data);
  88. return res.label || "暂无";
  89. };
  90. const toBuy = (item) => {
  91. common_vendor.index.navigateTo({
  92. url: `/pagesHome/teacher/index?id=${item._id}`
  93. });
  94. };
  95. const scrolltolower = () => {
  96. if (total.value > list.value.length) {
  97. common_vendor.index.showLoading({
  98. title: "加载中",
  99. mask: true
  100. });
  101. page.value = page.value + 1;
  102. skip.value = page.value * limit.value;
  103. search();
  104. common_vendor.index.hideLoading();
  105. } else
  106. is_bottom.value = true;
  107. };
  108. const clearPage = () => {
  109. list.value = [];
  110. skip.value = 0;
  111. limit.value = 6;
  112. page.value = 0;
  113. };
  114. return (_ctx, _cache) => {
  115. return common_vendor.e({
  116. a: nick_name.value,
  117. b: common_vendor.o(($event) => nick_name.value = $event.detail.value),
  118. c: common_vendor.o(searchInfo),
  119. d: total.value > 0
  120. }, total.value > 0 ? {
  121. e: common_vendor.f(list.value, (item, index, i0) => {
  122. return common_vendor.e({
  123. a: item.icon && item.icon.length > 0 && item.icon
  124. }, item.icon && item.icon.length > 0 && item.icon ? {
  125. b: item.icon[0].url
  126. } : {
  127. c: config.value.icon[0].url
  128. }, {
  129. d: common_vendor.t(item.nick_name || "暂无昵称"),
  130. e: common_vendor.t(item.time || "休息中"),
  131. f: common_vendor.t(item.college || "暂无"),
  132. g: common_vendor.t(getDict(item.education, "education")),
  133. h: common_vendor.t(item.money || "免费"),
  134. i: common_vendor.o(($event) => toBuy(item), index),
  135. j: index,
  136. k: "f3506c63-1-" + i0 + ",f3506c63-0"
  137. });
  138. }),
  139. f: common_vendor.o(scrolltolower)
  140. } : {
  141. g: common_vendor.p({
  142. mode: "list",
  143. icon: "/static/list.png"
  144. })
  145. }, {
  146. h: is_bottom.value
  147. }, is_bottom.value ? {
  148. i: common_vendor.t(config.value.bottom_title || "没有更多了!")
  149. } : {}, {
  150. j: common_vendor.o(showChange),
  151. k: common_vendor.p({
  152. show: show.value
  153. })
  154. });
  155. };
  156. }
  157. });
  158. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-f3506c63"], ["__file", "D:/project/学吧/learn_applet/pages/teacher/index.vue"]]);
  159. wx.createPage(MiniProgramPage);