"use strict"; const common_vendor = require("../../common/vendor.js"); const common_assets = require("../../common/assets.js"); const api_assessment = require("../../api/assessment.js"); const api_dict = require("../../api/dict.js"); const api_message = require("../../api/message.js"); if (!Math) { CustomTabbar(); } const CustomTabbar = () => "../../components/custom-tabbar/custom-tabbar.js"; const _sfc_main = { __name: "assessment", setup(__props) { const statusBarHeight = common_vendor.ref(20); const titleBarMargin = common_vendor.ref(8); const menuButtonHeight = common_vendor.ref(32); const currentTab = common_vendor.ref(0); const searchQuery = common_vendor.ref(""); const assessments = common_vendor.ref([]); const trainings = common_vendor.ref([]); const loading = common_vendor.ref(false); const trainingLoading = common_vendor.ref(false); const passedEvaluationIds = common_vendor.ref(/* @__PURE__ */ new Set()); const hasRecordEvaluationIds = common_vendor.ref(/* @__PURE__ */ new Set()); const completedEvaluationIds = common_vendor.ref(/* @__PURE__ */ new Set()); const decodeBase64Utf8 = (value) => { if (!value || typeof value !== "string") return ""; try { const binary = atob(value); const bytes = Array.from(binary, (char) => char.charCodeAt(0)); return decodeURIComponent(bytes.map((byte) => `%${byte.toString(16).padStart(2, "0")}`).join("")); } catch (e) { return value; } }; const resolveDescription = (item, fallback = "") => { let desc = item.remark || item.description || item.desc; if (!desc && item.detail) { desc = /^[A-Za-z0-9+/=]+$/.test(item.detail) ? decodeBase64Utf8(item.detail) : item.detail; } return desc || fallback; }; const recordText = common_vendor.computed(() => { return currentTab.value === 0 ? "测评记录" : "培训记录"; }); const fetchAssessments = async () => { if (loading.value) return; loading.value = true; try { const userInfo = common_vendor.index.getStorageSync("userInfo") || {}; const userId = userInfo.studentId || null; if (userId) { const recordRes = await api_assessment.getAssessmentRecordList(userId); if (recordRes.code === 200 && recordRes.data) { const records = recordRes.data; passedEvaluationIds.value = new Set( records.filter((r) => r.finalResult === "1").map((r) => r.evaluationId) ); hasRecordEvaluationIds.value = new Set(records.map((r) => r.evaluationId)); completedEvaluationIds.value = new Set( records.filter((r) => r.finalResult === "1" || r.finalResult === "2").map((r) => r.evaluationId) ); } } const typeFilter = assessmentFilterList.value[0].selectedValue; const levelFilter = assessmentFilterList.value[1].selectedValue; const params = { pageNum: 1, pageSize: 20 }; if (searchQuery.value) params.evaluationName = searchQuery.value; if (typeFilter) params.positionType = typeFilter; if (levelFilter) params.grade = levelFilter; const res = await api_assessment.getAssessmentList(params); if (res.code === 200 && res.rows) { common_vendor.index.__f__("log", "at pages/assessment/assessment.vue:322", "测评API返回数据:", res.rows[0]); assessments.value = res.rows.filter((item) => item.status === "1").map((item) => { let title = item.evaluationName || item.name || item.title || "未知测评"; const desc = resolveDescription(item, "专业技能评估,助力职业发展"); const hasPaid = common_vendor.index.getStorageSync(`audit_paid_${item.id}`) === true; const postId = item.positionId; const isApplied = postId ? common_vendor.index.getStorageSync(`candidate_applied_${postId}`) === true : false; return { id: item.id, title, level: item.gradeLabel || item.grade || "", type: item.positionTypeLabel || item.positionType || "", category: item.positionLabel || item.position || "", desc, cover: item.mainImageUrl || item.coverImage || "/static/images/assessment_default.svg", tags: item.tags ? item.tags.split(",") : [], price: item.price || "", isCollected: false, collectionId: null, isPassed: passedEvaluationIds.value.has(item.id), hasRecord: hasRecordEvaluationIds.value.has(item.id), isCompleted: completedEvaluationIds.value.has(item.id), hasPaid, postId, isApplied }; }); } } catch (err) { common_vendor.index.__f__("error", "at pages/assessment/assessment.vue:360", "获取测评列表失败", err); common_vendor.index.showToast({ title: "加载失败,请重试", icon: "none" }); } finally { loading.value = false; } }; const fetchTrainings = async () => { if (trainingLoading.value) return; trainingLoading.value = true; try { const trainingTypeFilter = trainingFilterList.value[0].selectedValue; const jobTypeFilter = trainingFilterList.value[1].selectedValue; const jobNameFilter = trainingFilterList.value[2].selectedValue; const params = { pageNum: 1, pageSize: 20, status: 1 // 只查询已发布的 }; if (trainingTypeFilter) params.trainingType = trainingTypeFilter; if (jobTypeFilter) params.jobType = jobTypeFilter; if (jobNameFilter) params.job = jobNameFilter; if (searchQuery.value) params.name = searchQuery.value; const res = await api_assessment.getTrainingList(params); if (res.code === 200 && res.rows) { common_vendor.index.__f__("log", "at pages/assessment/assessment.vue:388", "培训API返回数据:", res.rows[0]); trainings.value = res.rows.map((item) => { common_vendor.index.__f__("log", "at pages/assessment/assessment.vue:390", "培训单项数据:", item); let title = item.name || item.trainingName || item.title; if (!title || title.trim() === "" || title.startsWith("test_")) { const job = item.job || item.position || "专业技能"; title = `${job}培训课程`; } const desc = resolveDescription(item, "提升专业技能,助力职业发展"); let location = ""; if (item.trainingType === "offline") { const city = item.city || ""; const area = item.area || ""; const addressDetail = item.addressDetail || ""; location = `${city}${area}${addressDetail}`.replace(/undefined|null/g, "").trim(); if (!location) location = "线下培训"; } else { location = "线上培训"; } const trainingTime = item.trainingStartTime ? item.trainingStartTime.split(" ")[0] + (item.trainingEndTime ? " 至 " + item.trainingEndTime.split(" ")[0] : "") : ""; const deadline = item.applyEndTime ? item.applyEndTime.split(" ")[0] : ""; return { id: item.id, title, trainingType: item.trainingType || "offline", type: item.jobType || "", category: item.job || "", tags: item.tags ? item.tags.split(",") : [], location, organizer: item.organizer || "平台推荐", trainingTime, deadline, isEnding: false, // 可以根据applyEndTime判断是否即将截止 cover: item.thumbnailUrl || "/static/images/training_default.svg", views: item.learnCount || "0", duration: item.duration || "", status: item.status === 1 ? "published" : "not-started", spectators: item.participantCount || "0", desc }; }); } } catch (err) { common_vendor.index.__f__("error", "at pages/assessment/assessment.vue:445", "获取培训列表失败", err); } finally { trainingLoading.value = false; } }; const handleTabChange = (index) => { currentTab.value = index; if (index === 0 && assessments.value.length === 0) { fetchAssessments(); } else if (index === 1 && trainings.value.length === 0) { fetchTrainings(); } }; common_vendor.watch(currentTab, (newTab) => { if (newTab === 0 && assessments.value.length === 0) { fetchAssessments(); } else if (newTab === 1 && trainings.value.length === 0) { fetchTrainings(); } }); const goToRecords = () => { common_vendor.index.showToast({ title: recordText.value, icon: "none" }); }; const goToDetail = (item) => { common_vendor.index.navigateTo({ url: `/pages/assessment/detail?id=${item.id}` }); }; const viewAssessmentReport = (item) => { if (!item.isCompleted) return; common_vendor.index.navigateTo({ url: `/pages/assessment/report?id=${item.id}` }); }; const handleApply = (item) => { if (!item.postId) { common_vendor.index.showToast({ title: "该测评未关联岗位,无法投递", icon: "none" }); return; } const userInfo = common_vendor.index.getStorageSync("userInfo") || {}; if (!userInfo.studentId) { common_vendor.index.showToast({ title: "请先登录", icon: "none" }); setTimeout(() => { common_vendor.index.navigateTo({ url: "/pages/login/login" }); }, 1e3); return; } common_vendor.index.navigateTo({ url: `/pages/my/select-resume?postId=${item.postId}` }); }; const handleConsult = async (item) => { const userInfo = common_vendor.index.getStorageSync("userInfo") || {}; const userId = userInfo.studentId || null; if (!userId) { common_vendor.index.showToast({ title: "请先登录", icon: "none" }); setTimeout(() => { common_vendor.index.navigateTo({ url: "/pages/login/login" }); }, 1e3); return; } try { common_vendor.index.showLoading({ title: "正在连接客服..." }); const userName = userInfo.name || "用户"; const userAvatar = userInfo.avatarUrl || "/static/images/user_avatar.svg"; const res = await api_message.createOrGetSession({ sessionType: 1, fromUserId: userId, fromUserName: userName, fromUserAvatar: userAvatar, sourceId: "assessment_" + ((item == null ? void 0 : item.id) || "") }); common_vendor.index.hideLoading(); if (res.data) { const session = res.data; const assessmentTitle = encodeURIComponent(item ? item.title || "" : ""); const assessmentCover = encodeURIComponent(item ? item.cover || "" : ""); const assessmentId = item ? item.id || "" : ""; const assessmentLevel = encodeURIComponent(item ? item.level || "" : ""); const assessmentPrice = item ? item.price || "" : ""; common_vendor.index.navigateTo({ url: `/pages/chat/chat?sessionId=${session.sessionId}&sessionNo=${session.sessionNo || ""}&fromUserId=${userId}&userName=${encodeURIComponent(userName)}&type=assessment&title=${assessmentTitle}&cover=${assessmentCover}&assessmentId=${assessmentId}&level=${assessmentLevel}&price=${assessmentPrice}` }); } else { common_vendor.index.showToast({ title: "创建会话失败", icon: "none" }); } } catch (err) { common_vendor.index.hideLoading(); common_vendor.index.__f__("error", "at pages/assessment/assessment.vue:550", "创建会话失败:", err); common_vendor.index.showToast({ title: "连接失败,请重试", icon: "none" }); } }; const activeFilterIndex = common_vendor.ref(-1); const assessmentFilterList = common_vendor.ref([ { label: "岗位类型", selectedLabel: "", selectedValue: "", options: [{ label: "全部", value: "" }] }, { label: "岗位等级", selectedLabel: "", selectedValue: "", options: [{ label: "全部", value: "" }] }, { label: "岗位名称", selectedLabel: "", selectedValue: "", options: [ { label: "全部", value: "" }, { label: "审计岗位", value: "audit" }, { label: "咨询岗位", value: "consult" }, { label: "税务岗位", value: "tax" } ] } ]); const loadDicts = async () => { try { const [typeRes, levelRes] = await Promise.all([ api_dict.getDicts("main_position_type"), api_dict.getDicts("main_position_level") ]); if (typeRes.code === 200) { const options = [ { label: "全部", value: "" }, ...typeRes.data.map((d) => ({ label: d.dictLabel, value: d.dictValue })) ]; assessmentFilterList.value[0].options = options; trainingFilterList.value[1].options = options; } if (levelRes.code === 200) { assessmentFilterList.value[1].options = [ { label: "全部", value: "" }, ...levelRes.data.map((d) => ({ label: d.dictLabel, value: d.dictValue })) ]; } } catch (e) { common_vendor.index.__f__("error", "at pages/assessment/assessment.vue:606", "加载字典失败", e); } }; const trainingFilterList = common_vendor.ref([ { label: "培训类型", selectedLabel: "线下培训", selectedValue: "offline", options: [ { label: "线下培训", value: "offline" }, { label: "视频培训", value: "video" }, { label: "直播培训", value: "live" } ] }, { label: "职位类型", selectedLabel: "", selectedValue: "", options: [ { label: "全部", value: "" }, { label: "全职", value: "full-time" }, { label: "兼职", value: "part-time" }, { label: "实习", value: "intern" } ] }, { label: "岗位", selectedLabel: "", selectedValue: "", options: [ { label: "全部", value: "" }, { label: "审计", value: "audit" }, { label: "咨询", value: "consult" }, { label: "税务", value: "tax" } ] } ]); const currentFilters = common_vendor.computed(() => { return currentTab.value === 0 ? assessmentFilterList.value : trainingFilterList.value; }); const currentOptions = common_vendor.computed(() => { if (activeFilterIndex.value === -1) return []; return currentFilters.value[activeFilterIndex.value].options; }); const toggleFilter = (index) => { if (activeFilterIndex.value === index) { activeFilterIndex.value = -1; } else { activeFilterIndex.value = index; } }; const closeFilter = () => { activeFilterIndex.value = -1; }; const selectOption = (opt) => { const filter = currentFilters.value[activeFilterIndex.value]; filter.selectedValue = opt.value; filter.selectedLabel = opt.value === "" ? "" : opt.label; closeFilter(); if (currentTab.value === 0) { fetchAssessments(); } else { fetchTrainings(); } }; const getTypeLabel = (type) => { const map = { "full-time": "全职", "part-time": "兼职", "intern": "实习" }; return map[type] || type; }; const getCategoryLabel = (cat) => { const map = { "audit": "审计", "consult": "咨询", "tax": "税务" }; return map[cat] || cat; }; const filteredAssessments = common_vendor.computed(() => assessments.value); const filteredTrainings = common_vendor.computed(() => trainings.value); const goToTrainingDetail = (item) => { common_vendor.index.navigateTo({ url: `/pages/assessment/training-detail?type=${item.trainingType}&title=${item.title}&status=${item.status || ""}&views=${item.views || ""}&duration=${item.duration || ""}&spectators=${item.spectators || ""}` }); }; const scrollTop = common_vendor.computed(() => { const gradientHeight = statusBarHeight.value + titleBarMargin.value + menuButtonHeight.value + common_vendor.index.upx2px(20); const whiteAreaHeight = common_vendor.index.upx2px(158); return gradientHeight + whiteAreaHeight; }); common_vendor.onMounted(() => { try { const sysInfo = common_vendor.index.getSystemInfoSync(); const menuInfo = common_vendor.index.getMenuButtonBoundingClientRect(); if (sysInfo && menuInfo) { statusBarHeight.value = sysInfo.statusBarHeight || 20; titleBarMargin.value = menuInfo.top - sysInfo.statusBarHeight; menuButtonHeight.value = menuInfo.height; } } catch (e) { } common_vendor.index.__f__("log", "at pages/assessment/assessment.vue:720", "assessment onMounted triggered"); loadDicts(); fetchAssessments(); fetchTrainings(); }); common_vendor.onLoad(() => { common_vendor.index.__f__("log", "at pages/assessment/assessment.vue:727", "assessment onLoad triggered"); }); common_vendor.onShow(() => { common_vendor.index.__f__("log", "at pages/assessment/assessment.vue:731", "assessment onShow triggered"); }); common_vendor.onPullDownRefresh(async () => { common_vendor.index.stopPullDownRefresh(); }); return (_ctx, _cache) => { return common_vendor.e({ a: common_assets._imports_0$3, b: common_vendor.o(fetchAssessments), c: searchQuery.value, d: common_vendor.o(($event) => searchQuery.value = $event.detail.value), e: menuButtonHeight.value + "px", f: statusBarHeight.value + titleBarMargin.value + "px", g: currentTab.value === 0 ? 1 : "", h: common_vendor.o(($event) => handleTabChange(0)), i: currentTab.value === 1 ? 1 : "", j: common_vendor.o(($event) => handleTabChange(1)), k: common_vendor.t(recordText.value), l: common_vendor.o(goToRecords), m: common_vendor.f(currentFilters.value, (filter, index, i0) => { return { a: common_vendor.t(filter.selectedLabel || filter.label), b: activeFilterIndex.value === index ? 1 : "", c: index, d: activeFilterIndex.value === index ? 1 : "", e: common_vendor.o(($event) => toggleFilter(index), index) }; }), n: common_assets._imports_1$2, o: activeFilterIndex.value !== -1 }, activeFilterIndex.value !== -1 ? { p: common_vendor.o(closeFilter), q: common_vendor.f(currentOptions.value, (opt, idx, i0) => { return common_vendor.e({ a: common_vendor.t(opt.label), b: currentFilters.value[activeFilterIndex.value].selectedValue === opt.value }, currentFilters.value[activeFilterIndex.value].selectedValue === opt.value ? { c: common_assets._imports_2$4 } : {}, { d: idx, e: currentFilters.value[activeFilterIndex.value].selectedValue === opt.value ? 1 : "", f: common_vendor.o(($event) => selectOption(opt), idx) }); }) } : {}, { r: loading.value && assessments.value.length === 0 && currentTab.value === 0 }, loading.value && assessments.value.length === 0 && currentTab.value === 0 ? {} : {}, { s: currentTab.value === 0 && (!loading.value || assessments.value.length > 0) }, currentTab.value === 0 && (!loading.value || assessments.value.length > 0) ? common_vendor.e({ t: common_vendor.f(filteredAssessments.value, (item, index, i0) => { return common_vendor.e({ a: item.cover, b: common_vendor.t(item.title), c: common_vendor.t(item.level), d: common_vendor.t(getTypeLabel(item.type)), e: common_vendor.t(getCategoryLabel(item.category)), f: common_vendor.f(item.tags, (tag, tIdx, i1) => { return { a: common_vendor.t(tag), b: tIdx }; }), g: common_vendor.t(item.desc), h: item.isPassed && !item.isApplied }, item.isPassed && !item.isApplied ? { i: common_vendor.o(($event) => handleApply(item), index) } : {}, { j: item.isPassed && item.isApplied }, item.isPassed && item.isApplied ? {} : {}, { k: item.hasRecord && !item.isPassed }, item.hasRecord && !item.isPassed ? { l: !item.isCompleted ? 1 : "", m: common_vendor.o(($event) => viewAssessmentReport(item), index) } : {}, { n: item.hasRecord && !item.isPassed }, item.hasRecord && !item.isPassed ? { o: common_vendor.o(($event) => goToDetail(item), index) } : {}, { p: !item.hasRecord }, !item.hasRecord ? { q: common_vendor.o(($event) => handleConsult(item), index) } : {}, { r: item.hasPaid && !item.hasRecord }, item.hasPaid && !item.hasRecord ? { s: common_vendor.o(($event) => goToDetail(item), index) } : {}, { t: index, v: common_vendor.o(($event) => goToDetail(item), index) }); }), v: filteredAssessments.value.length === 0 }, filteredAssessments.value.length === 0 ? { w: common_assets._imports_3$2 } : {}, { x: scrollTop.value + "px" }) : {}, { y: trainingLoading.value && trainings.value.length === 0 && currentTab.value === 1 }, trainingLoading.value && trainings.value.length === 0 && currentTab.value === 1 ? {} : {}, { z: currentTab.value === 1 && (!trainingLoading.value || trainings.value.length > 0) }, currentTab.value === 1 && (!trainingLoading.value || trainings.value.length > 0) ? common_vendor.e({ A: common_vendor.f(filteredTrainings.value, (item, index, i0) => { return common_vendor.e({ a: item.trainingType === "offline" }, item.trainingType === "offline" ? common_vendor.e({ b: common_vendor.t(item.title), c: common_vendor.t(getTypeLabel(item.type)), d: common_vendor.t(getCategoryLabel(item.category)), e: common_vendor.f(item.tags, (tag, tIdx, i1) => { return { a: common_vendor.t(tag), b: tIdx }; }), f: common_assets._imports_2$2, g: common_vendor.t(item.location), h: common_assets._imports_0$2, i: common_vendor.t(item.organizer), j: common_assets._imports_1$1, k: common_vendor.t(item.trainingTime), l: common_assets._imports_1$1, m: common_vendor.t(item.deadline), n: item.isEnding }, item.isEnding ? {} : {}, { o: common_vendor.o(($event) => goToTrainingDetail(item), index) }) : common_vendor.e({ p: item.cover, q: common_assets._imports_7, r: common_vendor.t(item.views), s: common_assets._imports_8$1, t: common_vendor.t(item.duration), v: item.trainingType === "live" }, item.trainingType === "live" ? { w: common_vendor.t(item.status === "streaming" ? "直播中" : item.status === "upcoming" ? "即将开始" : item.status === "not-started" ? "未开始" : item.status === "finished" ? "已结束" : "直播"), x: common_vendor.n(item.status) } : {}, { y: common_vendor.t(item.title), z: item.trainingType === "live" }, item.trainingType === "live" ? { A: common_assets._imports_9, B: common_vendor.t(item.spectators) } : {}, { C: common_vendor.o(($event) => goToTrainingDetail(item), index) }), { D: index }); }), B: filteredTrainings.value.length === 0 }, filteredTrainings.value.length === 0 ? { C: common_assets._imports_3$2 } : {}, { D: scrollTop.value + "px" }) : {}, { E: common_vendor.p({ activeIndex: 1 }) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-cc3734ea"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/assessment/assessment.js.map