index.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 nick_name = common_vendor.ref("");
  36. const user = common_vendor.computed(() => {
  37. return common_vendor.index.getStorageSync("user");
  38. });
  39. common_vendor.onShow(async () => {
  40. await searchConfig();
  41. await searchOther();
  42. await clearPage();
  43. await search();
  44. if (!user.value)
  45. show.value = true;
  46. });
  47. common_vendor.onPullDownRefresh(async () => {
  48. await clearPage();
  49. await search();
  50. common_vendor.index.stopPullDownRefresh();
  51. });
  52. const searchConfig = async () => {
  53. config.value = common_vendor.index.getStorageSync("config");
  54. };
  55. const searchOther = async () => {
  56. let res;
  57. res = await $api(`dictData`, "GET", { code: "subject", is_use: "0" });
  58. if (res.errcode === 0)
  59. subjectList.value = res.data;
  60. subjectList.value.unshift({ label: "全部", value: "-1", is_show: true });
  61. };
  62. const searchInfo = async () => {
  63. if (nick_name.value) {
  64. await clearPage();
  65. await search();
  66. }
  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. if (nick_name.value)
  76. info.nick_name = nick_name.value;
  77. const res = await $api("teacher", "GET", info);
  78. if (res.errcode === 0) {
  79. list.value = list.value.concat(res.data);
  80. total.value = res.total;
  81. } else {
  82. common_vendor.index.showToast({
  83. title: res.errmsg || "",
  84. icon: "error"
  85. });
  86. }
  87. };
  88. const toTab = async (data) => {
  89. console.log(data);
  90. };
  91. const showChange = () => {
  92. show.value = false;
  93. };
  94. const scrolltolower = () => {
  95. if (total.value > list.value.length) {
  96. common_vendor.index.showLoading({
  97. title: "加载中",
  98. mask: true
  99. });
  100. page.value = page.value + 1;
  101. skip.value = page.value * limit.value;
  102. search();
  103. common_vendor.index.hideLoading();
  104. } else
  105. is_bottom.value = true;
  106. };
  107. const clearPage = () => {
  108. list.value = [];
  109. skip.value = 0;
  110. limit.value = 6;
  111. page.value = 0;
  112. };
  113. return (_ctx, _cache) => {
  114. return common_vendor.e({
  115. a: common_vendor.o(searchInfo),
  116. b: common_vendor.o(($event) => nick_name.value = $event),
  117. c: common_vendor.p({
  118. modelValue: nick_name.value
  119. }),
  120. d: common_vendor.o(toTab),
  121. e: common_vendor.p({
  122. list: subjectList.value,
  123. keyName: "label"
  124. }),
  125. f: total.value > 0
  126. }, total.value > 0 ? {
  127. g: common_vendor.f(list.value, (item, index, i0) => {
  128. return {
  129. a: common_vendor.t(item.nick_name),
  130. b: index,
  131. c: "f3506c63-3-" + i0 + ",f3506c63-2"
  132. };
  133. }),
  134. h: common_vendor.o(scrolltolower)
  135. } : {
  136. i: common_vendor.p({
  137. mode: "list",
  138. icon: "/static/list.png"
  139. })
  140. }, {
  141. j: is_bottom.value
  142. }, is_bottom.value ? {
  143. k: common_vendor.t(config.value.bottom_title || "没有更多了!")
  144. } : {}, {
  145. l: common_vendor.o(showChange),
  146. m: common_vendor.p({
  147. show: show.value
  148. })
  149. });
  150. };
  151. }
  152. });
  153. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-f3506c63"], ["__file", "D:/project/学吧/learn_applet/pages/teacher/index.vue"]]);
  154. wx.createPage(MiniProgramPage);