| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const common_assets = require("../../common/assets.js");
- const api_assessment = require("../../api/assessment.js");
- const _sfc_main = {
- __name: "report",
- setup(__props) {
- const loading = common_vendor.ref(true);
- const evaluationId = common_vendor.ref("");
- const displayTotalScore = common_vendor.ref(0);
- const evaluationName = common_vendor.ref("测评报告");
- const submitTime = common_vendor.ref("");
- const radarData = common_vendor.ref({ categories: [], series: [] });
- const abilityResults = common_vendor.ref([]);
- common_vendor.onLoad(async (options) => {
- evaluationId.value = options.id || options.assessmentId || "";
- if (!evaluationId.value) {
- common_vendor.index.showToast({ title: "参数错误", icon: "none" });
- loading.value = false;
- return;
- }
- await loadData();
- });
- const loadData = async () => {
- if (!evaluationId.value || evaluationId.value === "undefined") {
- loading.value = false;
- return;
- }
- try {
- const userInfo = common_vendor.index.getStorageSync("userInfo") || {};
- const studentId = userInfo.studentId || userInfo.id;
- if (!studentId) {
- common_vendor.index.showToast({ title: "请先登录", icon: "none" });
- return;
- }
- const res = await api_assessment.getEvaluationResult(evaluationId.value, studentId);
- if (res.code === 200 && res.data) {
- const data = res.data;
- abilityResults.value = data.abilityResults || [];
- radarData.value = data.radarChart || { categories: [], series: [] };
- if (data.totalScore) {
- displayTotalScore.value = Math.round(Number(data.totalScore));
- } else if (radarData.value.series.length > 0) {
- const sum = radarData.value.series.reduce((s, val) => s + (Number(val) || 0), 0);
- displayTotalScore.value = Math.round(sum / radarData.value.series.length);
- }
- evaluationName.value = data.evaluationName || "测评报告";
- submitTime.value = (/* @__PURE__ */ new Date()).toLocaleString();
- }
- } catch (e) {
- common_vendor.index.__f__("error", "at pages/assessment/report.vue:141", "加载报告失败:", e);
- } finally {
- loading.value = false;
- }
- };
- const viewAbilityDetail = (item) => {
- if (item.inquireLink) {
- common_vendor.index.setStorageSync("temp_report_url", item.inquireLink);
- common_vendor.index.navigateTo({
- url: "/pages/assessment/quiz?from=report"
- });
- } else {
- common_vendor.index.showToast({ title: "暂无详情", icon: "none" });
- }
- };
- const getPoint = (angle, radius) => {
- const x = 50 + radius * Math.cos((angle - 90) * Math.PI / 180);
- const y = 50 + radius * Math.sin((angle - 90) * Math.PI / 180);
- return { x, y };
- };
- const getPentagonPath = (radius) => {
- const count = Math.max(radarData.value.categories.length, 3);
- const points = [];
- for (let i = 0; i < count; i++) {
- const { x, y } = getPoint(i * (360 / count), radius);
- points.push(`${x}% ${y}%`);
- }
- return `polygon(${points.join(", ")})`;
- };
- const axesStyles = common_vendor.computed(() => {
- const count = Math.max(radarData.value.categories.length, 3);
- return Array.from({ length: count }).map((_, i) => ({
- transform: `rotate(${i * (360 / count) - 90}deg)`
- }));
- });
- const polygonClipPath = common_vendor.computed(() => {
- const series = radarData.value.series;
- const count = series.length;
- if (count < 3)
- return "none";
- const points = series.map((score, i) => {
- const minRadius = 20;
- const rawRadius = Math.min(Number(score) || 0, 100) / 100 * 50;
- const radius = Math.max(rawRadius, minRadius);
- const { x, y } = getPoint(i * (360 / count), radius);
- return `${x}% ${y}%`;
- });
- return `polygon(${points.join(", ")})`;
- });
- const nodePositions = common_vendor.computed(() => {
- const { categories, series } = radarData.value;
- const count = categories.length;
- return categories.map((name, i) => {
- const score = series[i];
- const minRadius = 20;
- const rawRadius = Math.min(Number(score) || 0, 100) / 100 * 50;
- const radius = Math.max(rawRadius, minRadius);
- const pos = getPoint(i * (360 / count), radius);
- const angle = i * (360 / count);
- let labelStyle = { position: "absolute" };
- if (angle === 0)
- labelStyle.bottom = "40rpx";
- else if (angle < 180)
- labelStyle.left = "40rpx";
- else
- labelStyle.right = "40rpx";
- return {
- x: pos.x,
- y: pos.y,
- name,
- score,
- labelStyle
- };
- });
- });
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: loading.value
- }, loading.value ? {} : {
- b: "rotate(" + (-135 + displayTotalScore.value * 2.7) + "deg)",
- c: common_vendor.f(41, (i, k0, i0) => {
- return {
- a: i,
- b: "rotate(" + (-120 + (i - 1) * 6) + "deg)"
- };
- }),
- d: "rotate(" + (-135 + displayTotalScore.value * 2.7) + "deg)",
- e: common_vendor.t(displayTotalScore.value),
- f: common_vendor.t(evaluationName.value),
- g: common_vendor.t(submitTime.value),
- h: common_vendor.f([1, 2, 3, 4, 5], (i, k0, i0) => {
- return {
- a: i,
- b: common_vendor.n("pg-" + i),
- c: getPentagonPath(i * 20)
- };
- }),
- i: common_vendor.f(axesStyles.value, (axis, index, i0) => {
- return {
- a: index,
- b: common_vendor.s(axis)
- };
- }),
- j: polygonClipPath.value,
- k: common_vendor.f(nodePositions.value, (node, index, i0) => {
- return {
- a: common_vendor.t(node.name),
- b: common_vendor.s(node.labelStyle),
- c: common_vendor.t(node.score),
- d: common_vendor.s(node.scoreStyle),
- e: index,
- f: node.x + "%",
- g: node.y + "%"
- };
- }),
- l: common_vendor.f(abilityResults.value, (item, index, i0) => {
- return {
- a: common_vendor.t(item.name),
- b: common_vendor.t(item.isPass ? "已达标" : "未达标"),
- c: common_vendor.n(item.isPass ? "pass" : "fail"),
- d: common_vendor.t(item.score),
- e: index,
- f: common_vendor.o(($event) => viewAbilityDetail(item), index)
- };
- }),
- m: common_assets._imports_0$6
- });
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d9ddd4c0"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/assessment/report.js.map
|