index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_up_tabs2 = common_vendor.resolveComponent("up-tabs");
  5. const _easycom_up_empty2 = common_vendor.resolveComponent("up-empty");
  6. const _easycom_up_overlay2 = common_vendor.resolveComponent("up-overlay");
  7. (_easycom_up_tabs2 + _easycom_up_empty2 + _easycom_up_overlay2)();
  8. }
  9. const _easycom_up_tabs = () => "../../node-modules/uview-plus/components/u-tabs/u-tabs.js";
  10. const _easycom_up_empty = () => "../../node-modules/uview-plus/components/u-empty/u-empty.js";
  11. const _easycom_up_overlay = () => "../../node-modules/uview-plus/components/u-overlay/u-overlay.js";
  12. if (!Math) {
  13. (_easycom_up_tabs + _easycom_up_empty + login + _easycom_up_overlay)();
  14. }
  15. const login = () => "../../components/login.js";
  16. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  17. __name: "index",
  18. setup(__props) {
  19. const $api = common_vendor.inject("$api");
  20. const config = common_vendor.ref({ logo: [], file: [] });
  21. const type = common_vendor.ref("");
  22. const subject = common_vendor.ref("-1");
  23. common_vendor.ref("-1");
  24. const list = common_vendor.ref([]);
  25. const total = common_vendor.ref(0);
  26. const skip = common_vendor.ref(0);
  27. const limit = common_vendor.ref(5);
  28. const page = common_vendor.ref(0);
  29. const is_bottom = common_vendor.ref(false);
  30. const show = common_vendor.ref(false);
  31. const nick_name = common_vendor.ref("");
  32. const educationList = common_vendor.ref([]);
  33. const active = common_vendor.ref(0);
  34. const subjectList = common_vendor.ref([]);
  35. const gradeList = common_vendor.ref([]);
  36. const user = common_vendor.computed(() => {
  37. return common_vendor.index.getStorageSync("user");
  38. });
  39. common_vendor.onLoad(async (options) => {
  40. type.value = options && options.type;
  41. common_vendor.index.setNavigationBarTitle({
  42. title: options && options.name + "课程" || "课程"
  43. });
  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: "education", is_use: "0" });
  64. if (res.errcode === 0)
  65. educationList.value = res.data;
  66. res = await $api(`dictData`, "GET", { code: "subject", is_use: "0" });
  67. if (res.errcode === 0)
  68. subjectList.value = res.data;
  69. subjectList.value.unshift({ label: "全部", value: "-1" });
  70. res = await $api(`dictData`, "GET", { code: "grade", is_use: "0" });
  71. if (res.errcode === 0)
  72. gradeList.value = res.data;
  73. gradeList.value.unshift({ label: "全部", value: "-1" });
  74. };
  75. const searchInfo = async () => {
  76. await clearPage();
  77. await search();
  78. };
  79. const search = async () => {
  80. const info = {
  81. skip: skip.value,
  82. limit: limit.value,
  83. status: "1",
  84. is_show: "0"
  85. };
  86. if (nick_name.value)
  87. info.nick_name = nick_name.value;
  88. const res = await $api("teacher", "GET", info);
  89. if (res.errcode === 0) {
  90. list.value = list.value.concat(res.data);
  91. total.value = res.total;
  92. } else {
  93. common_vendor.index.showToast({
  94. title: res.errmsg || "",
  95. icon: "error"
  96. });
  97. }
  98. };
  99. const showChange = () => {
  100. show.value = false;
  101. };
  102. const toChange = (index, e) => {
  103. console.log(index, e);
  104. active.value = index;
  105. subject.value = e.value;
  106. };
  107. const toTab = async (data) => {
  108. console.log(data);
  109. };
  110. const clearPage = () => {
  111. list.value = [];
  112. skip.value = 0;
  113. limit.value = 6;
  114. page.value = 0;
  115. };
  116. return (_ctx, _cache) => {
  117. return common_vendor.e({
  118. a: nick_name.value,
  119. b: common_vendor.o(($event) => nick_name.value = $event.detail.value),
  120. c: common_vendor.o(searchInfo),
  121. d: total.value > 0
  122. }, total.value > 0 ? common_vendor.e({
  123. e: common_vendor.f(subjectList.value, (item, index, i0) => {
  124. return {
  125. a: common_vendor.t(item.label),
  126. b: common_vendor.n(active.value == index ? "listActive" : ""),
  127. c: index,
  128. d: common_vendor.o(($event) => toChange(index, item), index)
  129. };
  130. }),
  131. f: common_vendor.o(toTab),
  132. g: common_vendor.p({
  133. list: gradeList.value,
  134. keyName: "label"
  135. }),
  136. h: total.value > 0
  137. }, total.value > 0 ? common_vendor.e({
  138. i: common_vendor.f(list.value, (tag, index, i0) => {
  139. return {
  140. a: common_vendor.t(tag.nick_name),
  141. b: index,
  142. c: common_vendor.o(($event) => _ctx.toBuy(tag), index)
  143. };
  144. }),
  145. j: is_bottom.value
  146. }, is_bottom.value ? {
  147. k: common_vendor.t(config.value.bottom_title)
  148. } : {}, {
  149. l: common_vendor.o(
  150. //@ts-ignore
  151. (...args) => _ctx.toPage && _ctx.toPage(...args)
  152. ),
  153. m: common_vendor.o(
  154. //@ts-ignore
  155. (...args) => _ctx.toScroll && _ctx.toScroll(...args)
  156. )
  157. }) : {
  158. n: common_vendor.p({
  159. mode: "list",
  160. icon: "/static/list.png"
  161. })
  162. }) : {}, {
  163. o: common_vendor.o(showChange),
  164. p: common_vendor.p({
  165. show: show.value
  166. })
  167. });
  168. };
  169. }
  170. });
  171. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-db68cfa6"], ["__file", "D:/project/学吧/learn_applet/pagesHome/list/index.vue"]]);
  172. wx.createPage(MiniProgramPage);