index.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
  5. _easycom_up_icon2();
  6. }
  7. const _easycom_up_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
  8. if (!Math) {
  9. _easycom_up_icon();
  10. }
  11. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  12. __name: "index",
  13. setup(__props) {
  14. const $api = common_vendor.inject("$api");
  15. const id = common_vendor.ref("");
  16. const config = common_vendor.ref({ logo: [], file: [] });
  17. const courseInfo = common_vendor.ref({});
  18. const teacherInfo = common_vendor.ref({});
  19. const subjectList = common_vendor.ref([]);
  20. const educationList = common_vendor.ref([]);
  21. const typeList = common_vendor.ref([]);
  22. const gradeList = common_vendor.ref([]);
  23. const genderList = common_vendor.ref([]);
  24. const learnStatusList = common_vendor.ref([]);
  25. common_vendor.computed(() => {
  26. return common_vendor.index.getStorageSync("user");
  27. });
  28. common_vendor.onLoad(async (options) => {
  29. id.value = options && options.id;
  30. await searchConfig();
  31. await searchOther();
  32. await search();
  33. });
  34. const searchConfig = async () => {
  35. config.value = common_vendor.index.getStorageSync("config");
  36. };
  37. const searchOther = async () => {
  38. let res;
  39. res = await $api(`dictData`, "GET", { code: "subject", is_use: "0" });
  40. if (res.errcode === 0)
  41. subjectList.value = res.data;
  42. res = await $api(`dictData`, "GET", { code: "grade", is_use: "0" });
  43. if (res.errcode === 0)
  44. gradeList.value = res.data;
  45. res = await $api(`dictData`, "GET", { code: "education", is_use: "0" });
  46. if (res.errcode === 0)
  47. educationList.value = res.data;
  48. res = await $api(`dictData`, "GET", { code: "courseType", is_use: "0" });
  49. if (res.errcode === 0)
  50. typeList.value = res.data;
  51. res = await $api(`dictData`, "GET", { code: "gender", is_use: "0" });
  52. if (res.errcode === 0)
  53. genderList.value = res.data;
  54. res = await $api(`dictData`, "GET", { code: "learnStatus", is_use: "0" });
  55. if (res.errcode === 0)
  56. learnStatusList.value = res.data;
  57. };
  58. const search = async () => {
  59. if (id.value) {
  60. const res = await $api(`course/appHomeDetail/${id.value}`, "GET", {});
  61. if (res.errcode == "0") {
  62. courseInfo.value = res.data.courseInfo;
  63. teacherInfo.value = res.data.teacherInfo;
  64. }
  65. }
  66. };
  67. const getDict = (data, model) => {
  68. if (data) {
  69. let res;
  70. if (model == "education")
  71. res = educationList.value.find((f) => f.value == data);
  72. else if (model == "subject")
  73. res = subjectList.value.find((f) => f.value == data);
  74. else if (model == "grade")
  75. res = gradeList.value.find((f) => f.value == data);
  76. else if (model == "type")
  77. res = typeList.value.find((f) => f.value == data);
  78. else if (model == "gender")
  79. res = genderList.value.find((f) => f.value == data);
  80. else if (model == "learnStatus")
  81. res = learnStatusList.value.find((f) => f.value == data);
  82. return res.label || "暂无";
  83. }
  84. };
  85. return (_ctx, _cache) => {
  86. return common_vendor.e({
  87. a: common_vendor.t(courseInfo.value.name || "暂无"),
  88. b: common_vendor.t(getDict(courseInfo.value.type, "type")),
  89. c: common_vendor.t(getDict(courseInfo.value.grade, "grade")),
  90. d: common_vendor.t(getDict(courseInfo.value.subject, "subject")),
  91. e: courseInfo.value.is_follow
  92. }, courseInfo.value.is_follow ? {
  93. f: common_vendor.p({
  94. name: "star-fill",
  95. color: "#FFA500",
  96. size: "30"
  97. })
  98. } : {
  99. g: common_vendor.p({
  100. name: "star",
  101. color: "#FFA500",
  102. size: "30"
  103. })
  104. }, {
  105. h: common_vendor.n(courseInfo.value.type === "0" ? "one0" : courseInfo.value.type === "1" ? "one1" : courseInfo.value.type === "2" ? "one2" : courseInfo.value.type === "3" ? "one3" : ""),
  106. i: common_vendor.t(courseInfo.value.start_time || "暂无"),
  107. j: common_vendor.t(courseInfo.value.end_time || "暂无"),
  108. k: common_vendor.t(courseInfo.value.money || "免费")
  109. });
  110. };
  111. }
  112. });
  113. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-115e567b"], ["__file", "D:/project/学吧/learn_applet/pagesHome/course/index.vue"]]);
  114. wx.createPage(MiniProgramPage);