remind.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const api_assessment = require("../../api/assessment.js");
  4. const _sfc_main = {
  5. __name: "remind",
  6. setup(__props) {
  7. const source = common_vendor.ref("");
  8. const assessmentId = common_vendor.ref("");
  9. const loading = common_vendor.ref(true);
  10. const examInfo = common_vendor.ref({
  11. position: "",
  12. // 测评岗位
  13. questionTypes: "",
  14. // 题型描述
  15. totalTime: 0,
  16. // 总时长(分钟)
  17. totalScore: 0,
  18. // 总分
  19. passMark: 0,
  20. // 合格分
  21. abilityPassDesc: ""
  22. // 各能力子合格描述
  23. });
  24. const firstExamLink = common_vendor.ref("");
  25. common_vendor.onLoad(async (options) => {
  26. if (options.source)
  27. source.value = options.source;
  28. if (options.id)
  29. assessmentId.value = options.id;
  30. await loadExamInfo();
  31. });
  32. const loadExamInfo = async () => {
  33. loading.value = true;
  34. try {
  35. let data = null;
  36. if (assessmentId.value) {
  37. const res = await api_assessment.getAssessmentDetail(assessmentId.value);
  38. if (res.code === 200 && res.data) {
  39. data = res.data;
  40. }
  41. }
  42. if (!data) {
  43. const listRes = await api_assessment.getAssessmentList({ pageNum: 1, pageSize: 1 });
  44. if (listRes.code === 200 && Array.isArray(listRes.rows) && listRes.rows.length > 0) {
  45. const detailRes = await api_assessment.getAssessmentDetail(listRes.rows[0].id);
  46. if (detailRes.code === 200 && detailRes.data) {
  47. data = detailRes.data;
  48. if (!assessmentId.value) {
  49. assessmentId.value = listRes.rows[0].id;
  50. common_vendor.index.__f__("log", "at pages/assessment/remind.vue:120", "使用兜底测评ID:", assessmentId.value);
  51. }
  52. }
  53. }
  54. }
  55. if (data) {
  56. examInfo.value.position = data.position || data.evaluationName || "—";
  57. const abilityConfigs = Array.isArray(data.abilityConfigs) ? data.abilityConfigs : [];
  58. if (abilityConfigs.length > 0) {
  59. const totalTime = abilityConfigs.reduce((sum, c) => sum + (c.thirdExamTime || 0), 0);
  60. examInfo.value.totalTime = totalTime;
  61. const totalScore = abilityConfigs.reduce((sum, c) => sum + (c.thirdExamTotalScore || 0), 0);
  62. examInfo.value.totalScore = totalScore;
  63. const passMark = abilityConfigs.reduce((sum, c) => sum + (c.thirdExamPassMark || 0), 0);
  64. examInfo.value.passMark = passMark;
  65. if (abilityConfigs.length > 1) {
  66. const descs = abilityConfigs.map((c) => `${c.abilityName || c.thirdExamName || "能力"}及格${c.thirdExamPassMark || 0}分`);
  67. examInfo.value.abilityPassDesc = descs.join(",");
  68. }
  69. examInfo.value.questionTypes = "单选/多选/问答";
  70. const firstConfig = abilityConfigs.find((c) => c && c.thirdExamLink);
  71. if (firstConfig) {
  72. firstExamLink.value = firstConfig.thirdExamLink;
  73. }
  74. }
  75. }
  76. } catch (err) {
  77. common_vendor.index.__f__("error", "at pages/assessment/remind.vue:163", "加载测评信息失败:", err);
  78. } finally {
  79. loading.value = false;
  80. }
  81. };
  82. const startQuiz = async () => {
  83. try {
  84. if (!firstExamLink.value && !assessmentId.value) {
  85. common_vendor.index.showToast({ title: "未配置考试链接", icon: "none" });
  86. return;
  87. }
  88. const userInfo = common_vendor.index.getStorageSync("userInfo") || {};
  89. const studentId = userInfo.studentId;
  90. if (!studentId) {
  91. common_vendor.index.showToast({ title: "请先登录", icon: "none" });
  92. return;
  93. }
  94. if (assessmentId.value) {
  95. try {
  96. common_vendor.index.showLoading({ title: "创建测评申请..." });
  97. common_vendor.index.__f__("log", "at pages/assessment/remind.vue:192", "准备创建测评申请,evaluationId:", assessmentId.value, "studentId:", studentId);
  98. const applyRes = await api_assessment.createExamApply(assessmentId.value, studentId);
  99. common_vendor.index.__f__("log", "at pages/assessment/remind.vue:196", "测评申请创建结果:", applyRes);
  100. common_vendor.index.hideLoading();
  101. if (applyRes.code !== 200) {
  102. common_vendor.index.showToast({ title: applyRes.msg || "创建测评申请失败", icon: "none" });
  103. return;
  104. }
  105. common_vendor.index.__f__("log", "at pages/assessment/remind.vue:205", "测评申请创建成功,申请ID:", applyRes.data.id);
  106. } catch (apiError) {
  107. common_vendor.index.hideLoading();
  108. common_vendor.index.__f__("error", "at pages/assessment/remind.vue:208", "创建测评申请失败:", apiError);
  109. common_vendor.index.__f__("warn", "at pages/assessment/remind.vue:210", "测评申请创建失败,但仍允许进入考试");
  110. }
  111. }
  112. common_vendor.index.navigateTo({
  113. url: `/pages/common/webview?mode=kaoshixing&assessmentId=${encodeURIComponent(assessmentId.value || "")}&fallbackUrl=${encodeURIComponent(firstExamLink.value || "")}`
  114. });
  115. } catch (error) {
  116. common_vendor.index.__f__("error", "at pages/assessment/remind.vue:219", "打开考试链接失败:", error);
  117. common_vendor.index.showToast({ title: "打开考试链接失败", icon: "none" });
  118. }
  119. };
  120. return (_ctx, _cache) => {
  121. return common_vendor.e({
  122. a: loading.value
  123. }, loading.value ? {} : common_vendor.e({
  124. b: common_vendor.t(examInfo.value.position || "—"),
  125. c: examInfo.value.questionTypes
  126. }, examInfo.value.questionTypes ? {
  127. d: common_vendor.t(examInfo.value.questionTypes)
  128. } : {}, {
  129. e: examInfo.value.totalTime
  130. }, examInfo.value.totalTime ? {
  131. f: common_vendor.t(examInfo.value.totalTime)
  132. } : {}, {
  133. g: examInfo.value.passMark
  134. }, examInfo.value.passMark ? common_vendor.e({
  135. h: common_vendor.t(examInfo.value.totalScore),
  136. i: common_vendor.t(examInfo.value.passMark),
  137. j: examInfo.value.abilityPassDesc
  138. }, examInfo.value.abilityPassDesc ? {
  139. k: common_vendor.t(examInfo.value.abilityPassDesc)
  140. } : {}) : {}), {
  141. l: common_vendor.o(startQuiz),
  142. m: loading.value
  143. });
  144. };
  145. }
  146. };
  147. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-9bbd684a"]]);
  148. wx.createPage(MiniProgramPage);
  149. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/assessment/remind.js.map