assessment.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. <template>
  2. <view class="container">
  3. <!-- 固定顶部区域 -->
  4. <view class="fixed-header">
  5. <!-- ① 蓝色渐变搜索区域 -->
  6. <view class="gradient-section" :style="{ paddingTop: (statusBarHeight + titleBarMargin) + 'px' }">
  7. <view class="search-wrap" :style="{ height: menuButtonHeight + 'px' }">
  8. <view class="search-bar">
  9. <image src="/static/icons/search.svg" class="search-icon" mode="aspectFit"></image>
  10. <input
  11. type="text"
  12. v-model="searchQuery"
  13. placeholder="请输入关键字"
  14. class="search-input"
  15. placeholder-class="ph-color"
  16. confirm-type="search"
  17. @confirm="fetchAssessments"
  18. />
  19. </view>
  20. </view>
  21. </view>
  22. <!-- ② 白色区域 -->
  23. <view class="white-section">
  24. <view class="horizontal-tabs-wrap">
  25. <view class="main-tabs">
  26. <view
  27. class="main-tab"
  28. :class="{ active: currentTab === 0 }"
  29. @click="handleTabChange(0)"
  30. >测评</view>
  31. <view
  32. class="main-tab"
  33. :class="{ active: currentTab === 1 }"
  34. @click="handleTabChange(1)"
  35. >培训</view>
  36. </view>
  37. <view class="record-btn" @click="goToRecords">
  38. <text class="record-text">{{ recordText }}</text>
  39. </view>
  40. </view>
  41. <view class="filter-row">
  42. <view
  43. v-for="(filter, index) in currentFilters"
  44. :key="index"
  45. class="filter-item"
  46. :class="{ active: activeFilterIndex === index }"
  47. @click="toggleFilter(index)"
  48. >
  49. {{ filter.selectedLabel || filter.label }}
  50. <image
  51. class="arrow-down"
  52. :class="{ rotate: activeFilterIndex === index }"
  53. src="/static/icons/arrow-down.svg"
  54. ></image>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 下拉面板 -->
  59. <view class="dropdown-wrapper" v-if="activeFilterIndex !== -1">
  60. <view class="mask" @click="closeFilter"></view>
  61. <view class="dropdown-content">
  62. <view
  63. v-for="(opt, idx) in currentOptions"
  64. :key="idx"
  65. class="option-item"
  66. :class="{ selected: (currentFilters[activeFilterIndex].selectedValue === opt.value) }"
  67. @click="selectOption(opt)"
  68. >
  69. <text>{{ opt.label }}</text>
  70. <image v-if="currentFilters[activeFilterIndex].selectedValue === opt.value" src="/static/icons/check.svg" class="check-icon"></image>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <!-- 可滚动的列表内容 (测评) -->
  76. <view class="loading-box" v-if="loading && assessments.length === 0 && currentTab === 0">
  77. <view class="loading-spinner"></view>
  78. <text class="loading-text">加载中...</text>
  79. </view>
  80. <scroll-view
  81. v-if="currentTab === 0 && (!loading || assessments.length > 0)"
  82. class="scroll-body"
  83. scroll-y
  84. :style="{ top: scrollTop + 'px' }"
  85. :show-scrollbar="false"
  86. :enhanced="true"
  87. >
  88. <view class="assessment-list">
  89. <view
  90. class="job-card card-anim"
  91. v-for="(item, index) in filteredAssessments"
  92. :key="index"
  93. @click="goToDetail(item)"
  94. >
  95. <view class="card-left">
  96. <image :src="item.cover" class="cover-img" mode="aspectFill"></image>
  97. </view>
  98. <view class="card-right">
  99. <view class="top-line">
  100. <text class="job-title">{{ item.title }}</text>
  101. <text class="job-level-tag">{{ item.level }}</text>
  102. </view>
  103. <view class="tag-row">
  104. <text class="tag-badge type-tag">{{ getTypeLabel(item.type) }}</text>
  105. <text class="tag-badge category-tag">{{ getCategoryLabel(item.category) }}</text>
  106. <text class="tag-badge" v-for="(tag, tIdx) in item.tags" :key="tIdx">{{ tag }}</text>
  107. </view>
  108. <view class="desc-text text-ellipsis-2">
  109. {{ item.desc }}
  110. </view>
  111. <view class="btn-wrap">
  112. <button v-if="item.isPassed && !item.isApplied" class="apply-btn" @click.stop="handleApply(item)">投递简历</button>
  113. <button v-if="item.isPassed && item.isApplied" class="applied-btn">已投递</button>
  114. <button v-if="item.hasRecord && !item.isPassed" class="report-btn" :class="{ disabled: !item.isCompleted }" @click.stop="viewAssessmentReport(item)">查看报告</button>
  115. <button v-if="item.hasRecord && !item.isPassed" class="retry-btn" @click.stop="goToDetail(item)">重新测评</button>
  116. <button v-if="!item.hasRecord" class="consult-btn" @click.stop="handleConsult(item)">咨询</button>
  117. <button v-if="item.hasPaid && !item.hasRecord" class="start-btn" @click.stop="goToDetail(item)">开始测评</button>
  118. </view>
  119. </view>
  120. </view>
  121. <view class="no-data" v-if="filteredAssessments.length === 0">
  122. <image src="/static/icons/empty.svg" class="empty-icon"></image>
  123. <text>暂无符合条件的测评内容</text>
  124. </view>
  125. <view class="no-more">—— 已到底啦~ ——</view>
  126. <view class="tabbar-placeholder"></view>
  127. </view>
  128. </scroll-view>
  129. <!-- 可滚动的列表内容 (培训) -->
  130. <view class="loading-box" v-if="trainingLoading && trainings.length === 0 && currentTab === 1">
  131. <view class="loading-spinner"></view>
  132. <text class="loading-text">加载中...</text>
  133. </view>
  134. <scroll-view
  135. v-if="currentTab === 1 && (!trainingLoading || trainings.length > 0)"
  136. class="scroll-body"
  137. scroll-y
  138. :style="{ top: scrollTop + 'px' }"
  139. :show-scrollbar="false"
  140. :enhanced="true"
  141. >
  142. <view class="training-list">
  143. <view v-for="(item, index) in filteredTrainings" :key="index">
  144. <!-- 1. 线下培训卡片 -->
  145. <view v-if="item.trainingType === 'offline'" class="training-card offline card-anim" @click="goToTrainingDetail(item)">
  146. <view class="card-header">
  147. <text class="t-title">{{ item.title }}</text>
  148. </view>
  149. <view class="tag-row">
  150. <text class="tag-badge type-tag">{{ getTypeLabel(item.type) }}</text>
  151. <text class="tag-badge category-tag">{{ getCategoryLabel(item.category) }}</text>
  152. <text class="tag-badge" v-for="(tag, tIdx) in item.tags" :key="tIdx">{{ tag }}</text>
  153. </view>
  154. <view class="info-list">
  155. <view class="info-item">
  156. <image src="/static/icons/location.svg" class="i-icon"></image>
  157. <text class="i-text">{{ item.location }}</text>
  158. </view>
  159. <view class="info-item">
  160. <image src="/static/icons/user.svg" class="i-icon"></image>
  161. <text class="i-text">主办单位:{{ item.organizer }}</text>
  162. </view>
  163. <view class="info-item">
  164. <image src="/static/icons/time.svg" class="i-icon"></image>
  165. <text class="i-text">培训时间:{{ item.trainingTime }}</text>
  166. </view>
  167. <view class="info-item">
  168. <image src="/static/icons/time.svg" class="i-icon"></image>
  169. <text class="i-text">截止时间:{{ item.deadline }}</text>
  170. <text v-if="item.isEnding" class="ending-tag">即将截止</text>
  171. </view>
  172. </view>
  173. </view>
  174. <!-- 2. 视频/直播培训卡片 -->
  175. <view v-else class="video-card card-anim" @click="goToTrainingDetail(item)">
  176. <view class="video-cover-wrap">
  177. <image :src="item.cover" mode="aspectFill" class="v-cover"></image>
  178. <view class="play-overlay">
  179. <image src="/static/icons/play_circle.svg" class="play-icon"></image>
  180. </view>
  181. <view class="v-bottom-info">
  182. <view class="v-info-left">
  183. <view class="play-mini-icon"></view>
  184. <text>{{ item.views }}</text>
  185. </view>
  186. <view class="v-info-right">
  187. <image src="/static/icons/clock_mini.svg" class="m-icon"></image>
  188. <text>{{ item.duration }}</text>
  189. </view>
  190. </view>
  191. <!-- 直播状态标签 -->
  192. <view v-if="item.trainingType === 'live'" class="live-status" :class="item.status">
  193. {{
  194. item.status === 'streaming' ? '直播中' :
  195. item.status === 'upcoming' ? '即将开始' :
  196. item.status === 'not-started' ? '未开始' :
  197. item.status === 'finished' ? '已结束' : '直播'
  198. }}
  199. </view>
  200. </view>
  201. <view class="v-content">
  202. <view class="v-title-row">
  203. <text class="v-title">{{ item.title }}</text>
  204. <view v-if="item.trainingType === 'live'" class="spectators">
  205. <image src="/static/icons/users_mini.svg" class="s-icon"></image>
  206. <text>{{ item.spectators }}</text>
  207. </view>
  208. </view>
  209. </view>
  210. </view>
  211. </view>
  212. <view class="no-data" v-if="filteredTrainings.length === 0">
  213. <image src="/static/icons/empty.svg" class="empty-icon"></image>
  214. <text>暂无符合条件的培训内容</text>
  215. </view>
  216. <view class="no-more">—— 已到底啦~ ——</view>
  217. <view class="tabbar-placeholder"></view>
  218. </view>
  219. </scroll-view>
  220. <custom-tabbar :activeIndex="1"></custom-tabbar>
  221. </view>
  222. </template>
  223. <script setup lang="js">
  224. import { ref, computed, onMounted, watch } from 'vue';
  225. import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app';
  226. import CustomTabbar from '../../components/custom-tabbar/custom-tabbar.vue';
  227. import { getAssessmentList, getTrainingList, getAssessmentRecordList, applyPosition } from '../../api/assessment.js';
  228. import { getDicts } from '../../api/dict.js';
  229. import { createOrGetSession } from '../../api/message.js';
  230. const statusBarHeight = ref(20);
  231. const titleBarMargin = ref(8);
  232. const menuButtonHeight = ref(32);
  233. const currentTab = ref(0);
  234. const searchQuery = ref('');
  235. const assessments = ref([]);
  236. const trainings = ref([]);
  237. const loading = ref(false);
  238. const trainingLoading = ref(false);
  239. const passedEvaluationIds = ref(new Set());
  240. // 所有有记录的测评ID(不管通过与否)
  241. const hasRecordEvaluationIds = ref(new Set());
  242. // 有记录且全部考完的测评ID(finalResult 有值)
  243. const completedEvaluationIds = ref(new Set());
  244. const decodeBase64Utf8 = (value) => {
  245. if (!value || typeof value !== 'string') return '';
  246. try {
  247. const binary = atob(value);
  248. const bytes = Array.from(binary, char => char.charCodeAt(0));
  249. return decodeURIComponent(bytes.map(byte => `%${byte.toString(16).padStart(2, '0')}`).join(''));
  250. } catch (e) {
  251. return value;
  252. }
  253. };
  254. const resolveDescription = (item, fallback = '') => {
  255. let desc = item.remark || item.description || item.desc;
  256. if (!desc && item.detail) {
  257. desc = /^[A-Za-z0-9+/=]+$/.test(item.detail)
  258. ? decodeBase64Utf8(item.detail)
  259. : item.detail;
  260. }
  261. return desc || fallback;
  262. };
  263. // 根据当前Tab显示对应的记录按钮文字
  264. const recordText = computed(() => {
  265. return currentTab.value === 0 ? '测评记录' : '培训记录';
  266. });
  267. const fetchAssessments = async () => {
  268. if (loading.value) return;
  269. loading.value = true;
  270. try {
  271. // 检查是否有通过的记录
  272. const userInfo = uni.getStorageSync('userInfo') || {};
  273. const userId = userInfo.studentId || null;
  274. if (userId) {
  275. const recordRes = await getAssessmentRecordList(userId);
  276. if (recordRes.code === 200 && recordRes.data) {
  277. const records = recordRes.data;
  278. // 通过的测评
  279. passedEvaluationIds.value = new Set(
  280. records.filter(r => r.finalResult === '1').map(r => r.evaluationId)
  281. );
  282. // 所有有记录的测评
  283. hasRecordEvaluationIds.value = new Set(records.map(r => r.evaluationId));
  284. // 已完成评分的测评(finalResult 为 1 或 2)
  285. completedEvaluationIds.value = new Set(
  286. records.filter(r => r.finalResult === '1' || r.finalResult === '2').map(r => r.evaluationId)
  287. );
  288. }
  289. }
  290. const typeFilter = assessmentFilterList.value[0].selectedValue;
  291. const levelFilter = assessmentFilterList.value[1].selectedValue;
  292. const params = {
  293. pageNum: 1,
  294. pageSize: 20,
  295. };
  296. if (searchQuery.value) params.evaluationName = searchQuery.value;
  297. if (typeFilter) params.positionType = typeFilter;
  298. if (levelFilter) params.grade = levelFilter;
  299. const res = await getAssessmentList(params);
  300. if (res.code === 200 && res.rows) {
  301. console.log('测评API返回数据:', res.rows[0]); // 调试信息
  302. // 过滤掉已下架或删除的数据 (status !== '1' 的不显示)
  303. assessments.value = res.rows
  304. .filter(item => item.status === '1')
  305. .map(item => {
  306. // 处理标题显示
  307. let title = item.evaluationName || item.name || item.title || '未知测评';
  308. const desc = resolveDescription(item, '专业技能评估,助力职业发展');
  309. // 判断是否已付款(从localStorage读取支付状态)
  310. const hasPaid = uni.getStorageSync(`audit_paid_${item.id}`) === true;
  311. // 检查是否已投递过该岗位
  312. const postId = item.positionId;
  313. const isApplied = postId ? uni.getStorageSync(`candidate_applied_${postId}`) === true : false;
  314. return {
  315. id: item.id,
  316. title: title,
  317. level: item.gradeLabel || item.grade || '',
  318. type: item.positionTypeLabel || item.positionType || '',
  319. category: item.positionLabel || item.position || '',
  320. desc: desc,
  321. cover: item.mainImageUrl || item.coverImage || '/static/images/assessment_default.svg',
  322. tags: item.tags ? item.tags.split(',') : [],
  323. price: item.price || '',
  324. isCollected: false,
  325. collectionId: null,
  326. isPassed: passedEvaluationIds.value.has(item.id),
  327. hasRecord: hasRecordEvaluationIds.value.has(item.id),
  328. isCompleted: completedEvaluationIds.value.has(item.id),
  329. hasPaid: hasPaid,
  330. postId: postId,
  331. isApplied: isApplied,
  332. };
  333. });
  334. }
  335. } catch (err) {
  336. console.error('获取测评列表失败', err);
  337. uni.showToast({ title: '加载失败,请重试', icon: 'none' });
  338. } finally {
  339. loading.value = false;
  340. }
  341. };
  342. // 获取培训列表
  343. const fetchTrainings = async () => {
  344. if (trainingLoading.value) return;
  345. trainingLoading.value = true;
  346. try {
  347. const trainingTypeFilter = trainingFilterList.value[0].selectedValue;
  348. const jobTypeFilter = trainingFilterList.value[1].selectedValue;
  349. const jobNameFilter = trainingFilterList.value[2].selectedValue;
  350. const params = {
  351. pageNum: 1,
  352. pageSize: 20,
  353. status: 1 // 只查询已发布的
  354. };
  355. if (trainingTypeFilter) params.trainingType = trainingTypeFilter;
  356. if (jobTypeFilter) params.jobType = jobTypeFilter;
  357. if (jobNameFilter) params.job = jobNameFilter;
  358. if (searchQuery.value) params.name = searchQuery.value;
  359. const res = await getTrainingList(params);
  360. if (res.code === 200 && res.rows) {
  361. console.log('培训API返回数据:', res.rows[0]); // 调试信息
  362. trainings.value = res.rows.map(item => {
  363. console.log('培训单项数据:', item); // 调试单个培训项
  364. // 处理标题显示
  365. let title = item.name || item.trainingName || item.title;
  366. // 如果标题不存在、为空、或者是测试数据(以test_开头),则生成友好标题
  367. if (!title || title.trim() === '' || title.startsWith('test_')) {
  368. // 根据岗位生成友好标题
  369. const job = item.job || item.position || '专业技能';
  370. title = `${job}培训课程`;
  371. }
  372. const desc = resolveDescription(item, '提升专业技能,助力职业发展');
  373. // 处理培训地点
  374. let location = '';
  375. if (item.trainingType === 'offline') {
  376. // 线下培训拼接地址
  377. const city = item.city || '';
  378. const area = item.area || '';
  379. const addressDetail = item.addressDetail || '';
  380. location = `${city}${area}${addressDetail}`.replace(/undefined|null/g, '').trim();
  381. if (!location) location = '线下培训';
  382. } else {
  383. location = '线上培训';
  384. }
  385. // 处理培训时间
  386. const trainingTime = item.trainingStartTime ?
  387. item.trainingStartTime.split(' ')[0] + (item.trainingEndTime ? ' 至 ' + item.trainingEndTime.split(' ')[0] : '') :
  388. '';
  389. // 处理报名截止时间
  390. const deadline = item.applyEndTime ? item.applyEndTime.split(' ')[0] : '';
  391. return {
  392. id: item.id,
  393. title: title,
  394. trainingType: item.trainingType || 'offline',
  395. type: item.jobType || '',
  396. category: item.job || '',
  397. tags: item.tags ? item.tags.split(',') : [],
  398. location: location,
  399. organizer: item.organizer || '平台推荐',
  400. trainingTime: trainingTime,
  401. deadline: deadline,
  402. isEnding: false, // 可以根据applyEndTime判断是否即将截止
  403. cover: item.thumbnailUrl || '/static/images/training_default.svg',
  404. views: item.learnCount || '0',
  405. duration: item.duration || '',
  406. status: item.status === 1 ? 'published' : 'not-started',
  407. spectators: item.participantCount || '0',
  408. desc: desc,
  409. };
  410. });
  411. }
  412. } catch (err) {
  413. console.error('获取培训列表失败', err);
  414. } finally {
  415. trainingLoading.value = false;
  416. }
  417. };
  418. const handleTabChange = (index) => {
  419. currentTab.value = index;
  420. if (index === 0 && assessments.value.length === 0) {
  421. fetchAssessments();
  422. } else if (index === 1 && trainings.value.length === 0) {
  423. fetchTrainings();
  424. }
  425. };
  426. watch(currentTab, (newTab) => {
  427. if (newTab === 0 && assessments.value.length === 0) {
  428. fetchAssessments();
  429. } else if (newTab === 1 && trainings.value.length === 0) {
  430. fetchTrainings();
  431. }
  432. });
  433. const goToRecords = () => {
  434. uni.showToast({ title: recordText.value, icon: 'none' });
  435. };
  436. const goToDetail = (item) => {
  437. uni.navigateTo({ url: `/pages/assessment/detail?id=${item.id}` });
  438. };
  439. const viewAssessmentReport = (item) => {
  440. if (!item.isCompleted) return; // 未考完不可点击
  441. uni.navigateTo({ url: `/pages/assessment/report?id=${item.id}` });
  442. };
  443. const handleApply = async (item) => {
  444. if (!item.postId) {
  445. uni.showToast({ title: '该测评未关联岗位,无法投递', icon: 'none' });
  446. return;
  447. }
  448. const userInfo = uni.getStorageSync('userInfo') || {};
  449. if (!userInfo.studentId) {
  450. uni.showToast({ title: '请先登录', icon: 'none' });
  451. setTimeout(() => {
  452. uni.navigateTo({ url: '/pages/login/login' });
  453. }, 1000);
  454. return;
  455. }
  456. try {
  457. uni.showLoading({ title: '投递中...' });
  458. const res = await applyPosition({ postId: item.postId });
  459. uni.hideLoading();
  460. if (res.code === 200) {
  461. uni.showToast({ title: '投递成功', icon: 'success' });
  462. // 标记为已投递
  463. item.isApplied = true;
  464. uni.setStorageSync(`candidate_applied_${item.postId}`, true);
  465. } else if (res.msg && res.msg.includes('已投递')) {
  466. // 已投递过,也标记为已投递状态
  467. item.isApplied = true;
  468. uni.setStorageSync(`candidate_applied_${item.postId}`, true);
  469. uni.showToast({ title: '您已投递过该岗位', icon: 'none' });
  470. } else {
  471. uni.showToast({ title: res.msg || '投递失败', icon: 'none' });
  472. }
  473. } catch (err) {
  474. uni.hideLoading();
  475. console.error('投递失败:', err);
  476. // 网络错误时检查是否是"已投递"导致的
  477. const errMsg = String(err?.msg || err?.message || '');
  478. if (errMsg.includes('已投递')) {
  479. item.isApplied = true;
  480. uni.setStorageSync(`candidate_applied_${item.postId}`, true);
  481. uni.showToast({ title: '您已投递过该岗位', icon: 'none' });
  482. } else {
  483. uni.showToast({ title: '网络错误,投递失败', icon: 'none' });
  484. }
  485. }
  486. };
  487. /**
  488. * 点击咨询按钮:创建/获取会话后跳转聊天页
  489. * @param {Object} item - 当前测评项目信息
  490. */
  491. const handleConsult = async (item) => {
  492. // 检查登录
  493. const userInfo = uni.getStorageSync('userInfo') || {};
  494. const userId = userInfo.studentId || null;
  495. if (!userId) {
  496. uni.showToast({ title: '请先登录', icon: 'none' });
  497. setTimeout(() => {
  498. uni.navigateTo({ url: '/pages/login/login' });
  499. }, 1000);
  500. return;
  501. }
  502. try {
  503. uni.showLoading({ title: '正在连接客服...' });
  504. const userName = userInfo.name || '用户';
  505. const userAvatar = userInfo.avatarUrl || '/static/images/user_avatar.svg';
  506. const res = await createOrGetSession({
  507. sessionType: 1,
  508. fromUserId: userId,
  509. fromUserName: userName,
  510. fromUserAvatar: userAvatar,
  511. sourceId: 'assessment_' + (item?.id || '')
  512. });
  513. uni.hideLoading();
  514. if (res.data) {
  515. const session = res.data;
  516. // 将测评信息编码后传入聊天页面,供初始卡片展示
  517. const assessmentTitle = encodeURIComponent(item ? (item.title || '') : '');
  518. const assessmentCover = encodeURIComponent(item ? (item.cover || '') : '');
  519. const assessmentId = item ? (item.id || '') : '';
  520. const assessmentLevel = encodeURIComponent(item ? (item.level || '') : '');
  521. const assessmentPrice = item ? (item.price || '') : '';
  522. uni.navigateTo({
  523. 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}`
  524. });
  525. } else {
  526. uni.showToast({ title: '创建会话失败', icon: 'none' });
  527. }
  528. } catch (err) {
  529. uni.hideLoading();
  530. console.error('创建会话失败:', err);
  531. uni.showToast({ title: '连接失败,请重试', icon: 'none' });
  532. }
  533. };
  534. const activeFilterIndex = ref(-1);
  535. const assessmentFilterList = ref([
  536. {
  537. label: '岗位类型',
  538. selectedLabel: '',
  539. selectedValue: '',
  540. options: [{ label: '全部', value: '' }]
  541. },
  542. {
  543. label: '岗位等级',
  544. selectedLabel: '',
  545. selectedValue: '',
  546. options: [{ label: '全部', value: '' }]
  547. },
  548. {
  549. label: '岗位名称',
  550. selectedLabel: '',
  551. selectedValue: '',
  552. options: [
  553. { label: '全部', value: '' },
  554. { label: '审计岗位', value: 'audit' },
  555. { label: '咨询岗位', value: 'consult' },
  556. { label: '税务岗位', value: 'tax' }
  557. ]
  558. }
  559. ]);
  560. const loadDicts = async () => {
  561. try {
  562. const [typeRes, levelRes] = await Promise.all([
  563. getDicts('main_position_type'),
  564. getDicts('main_position_level')
  565. ]);
  566. if (typeRes.code === 200) {
  567. const options = [
  568. { label: '全部', value: '' },
  569. ...typeRes.data.map(d => ({ label: d.dictLabel, value: d.dictValue }))
  570. ];
  571. assessmentFilterList.value[0].options = options;
  572. trainingFilterList.value[1].options = options;
  573. }
  574. if (levelRes.code === 200) {
  575. assessmentFilterList.value[1].options = [
  576. { label: '全部', value: '' },
  577. ...levelRes.data.map(d => ({ label: d.dictLabel, value: d.dictValue }))
  578. ];
  579. }
  580. } catch (e) {
  581. console.error('加载字典失败', e);
  582. }
  583. };
  584. const trainingFilterList = ref([
  585. {
  586. label: '培训类型',
  587. selectedLabel: '线下培训',
  588. selectedValue: 'offline',
  589. options: [
  590. { label: '线下培训', value: 'offline' },
  591. { label: '视频培训', value: 'video' },
  592. { label: '直播培训', value: 'live' }
  593. ]
  594. },
  595. {
  596. label: '职位类型',
  597. selectedLabel: '',
  598. selectedValue: '',
  599. options: [
  600. { label: '全部', value: '' },
  601. { label: '全职', value: 'full-time' },
  602. { label: '兼职', value: 'part-time' },
  603. { label: '实习', value: 'intern' }
  604. ]
  605. },
  606. {
  607. label: '岗位',
  608. selectedLabel: '',
  609. selectedValue: '',
  610. options: [
  611. { label: '全部', value: '' },
  612. { label: '审计', value: 'audit' },
  613. { label: '咨询', value: 'consult' },
  614. { label: '税务', value: 'tax' }
  615. ]
  616. }
  617. ]);
  618. const currentFilters = computed(() => {
  619. return currentTab.value === 0 ? assessmentFilterList.value : trainingFilterList.value;
  620. });
  621. const currentOptions = computed(() => {
  622. if (activeFilterIndex.value === -1) return [];
  623. return currentFilters.value[activeFilterIndex.value].options;
  624. });
  625. const toggleFilter = (index) => {
  626. if (activeFilterIndex.value === index) {
  627. activeFilterIndex.value = -1;
  628. } else {
  629. activeFilterIndex.value = index;
  630. }
  631. };
  632. const closeFilter = () => {
  633. activeFilterIndex.value = -1;
  634. };
  635. const selectOption = (opt) => {
  636. const filter = currentFilters.value[activeFilterIndex.value];
  637. filter.selectedValue = opt.value;
  638. filter.selectedLabel = opt.value === '' ? '' : opt.label;
  639. closeFilter();
  640. // 过滤变化后重新加载
  641. if (currentTab.value === 0) {
  642. fetchAssessments();
  643. } else {
  644. fetchTrainings();
  645. }
  646. };
  647. const getTypeLabel = (type) => {
  648. const map = { 'full-time': '全职', 'part-time': '兼职', 'intern': '实习' };
  649. return map[type] || type;
  650. };
  651. const getCategoryLabel = (cat) => {
  652. const map = { 'audit': '审计', 'consult': '咨询', 'tax': '税务' };
  653. return map[cat] || cat;
  654. };
  655. const filteredAssessments = computed(() => assessments.value);
  656. const filteredTrainings = computed(() => trainings.value);
  657. const goToTrainingDetail = (item) => {
  658. uni.navigateTo({
  659. url: `/pages/assessment/training-detail?type=${item.trainingType}&title=${item.title}&status=${item.status || ''}&views=${item.views || ''}&duration=${item.duration || ''}&spectators=${item.spectators || ''}`
  660. });
  661. };
  662. const scrollTop = computed(() => {
  663. // 顶部渐变区:状态栏 + 胶囊栏 + 20rpx 底部间距
  664. const gradientHeight = statusBarHeight.value + titleBarMargin.value + menuButtonHeight.value + uni.upx2px(20);
  665. // 白色内容区:Tabs(84rpx) + 筛选栏(74rpx) = 158rpx
  666. const whiteAreaHeight = uni.upx2px(158);
  667. return gradientHeight + whiteAreaHeight;
  668. });
  669. onMounted(() => {
  670. // #ifdef MP-WEIXIN
  671. try {
  672. const sysInfo = uni.getSystemInfoSync();
  673. const menuInfo = uni.getMenuButtonBoundingClientRect();
  674. if (sysInfo && menuInfo) {
  675. statusBarHeight.value = sysInfo.statusBarHeight || 20;
  676. titleBarMargin.value = menuInfo.top - sysInfo.statusBarHeight;
  677. menuButtonHeight.value = menuInfo.height;
  678. }
  679. } catch (e) {}
  680. // #endif
  681. console.log('assessment onMounted triggered');
  682. loadDicts();
  683. fetchAssessments();
  684. fetchTrainings();
  685. });
  686. onLoad(() => {
  687. console.log('assessment onLoad triggered');
  688. });
  689. onShow(() => {
  690. console.log('assessment onShow triggered');
  691. });
  692. onPullDownRefresh(async () => {
  693. // 禁止下拉刷新,直接停止
  694. uni.stopPullDownRefresh();
  695. });
  696. </script>
  697. <style lang="scss" scoped>
  698. .container {
  699. width: 100%; height: 100vh; background-color: #F8F9FB; position: relative; overflow: hidden;
  700. }
  701. .loading-box {
  702. display: flex;
  703. flex-direction: column;
  704. align-items: center;
  705. justify-content: center;
  706. height: 80vh;
  707. padding-top: 200rpx;
  708. .loading-spinner {
  709. width: 60rpx;
  710. height: 60rpx;
  711. border: 6rpx solid #f3f3f3;
  712. border-top: 6rpx solid #1F6CFF;
  713. border-radius: 50%;
  714. animation: spin 1s linear infinite;
  715. }
  716. .loading-text {
  717. margin-top: 20rpx;
  718. font-size: 28rpx;
  719. color: #999;
  720. }
  721. }
  722. @keyframes spin {
  723. 0% { transform: rotate(0deg); }
  724. 100% { transform: rotate(360deg); }
  725. }
  726. .fixed-header {
  727. position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  728. }
  729. .gradient-section {
  730. background: linear-gradient(180deg, #1F6CFF 0%, #FFFFFF 100%);
  731. padding: 0 40rpx 20rpx;
  732. }
  733. .search-bar {
  734. background: rgba(255, 255, 255, 0.95);
  735. border-radius: 40rpx;
  736. display: flex;
  737. align-items: center;
  738. padding: 0 30rpx;
  739. box-shadow: 0 4rpx 20rpx rgba(31, 108, 255, 0.1);
  740. margin-right: 200rpx;
  741. height: 100%;
  742. .search-icon { width: 32rpx; height: 32rpx; margin-right: 20rpx; opacity: 0.4; }
  743. .search-input { flex: 1; font-size: 28rpx; }
  744. .ph-color { color: #999; }
  745. }
  746. .white-section {
  747. background: #FFF; padding-bottom: 0;
  748. }
  749. .horizontal-tabs-wrap {
  750. display: flex; justify-content: space-between; align-items: center; padding: 20rpx 40rpx;
  751. .main-tabs {
  752. display: flex; gap: 40rpx;
  753. .main-tab {
  754. font-size: 34rpx; font-weight: bold; color: #888; position: relative; padding-bottom: 10rpx;
  755. &.active {
  756. color: #1A1A1A;
  757. &:after { content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 36rpx; height: 6rpx; background: #1F6CFF; border-radius: 3rpx; }
  758. }
  759. }
  760. }
  761. .record-text { font-size: 28rpx; color: #1F6CFF; }
  762. }
  763. .filter-row {
  764. display: flex; justify-content: space-between; padding: 20rpx 40rpx 20rpx;
  765. .filter-item {
  766. font-size: 28rpx; color: #333; font-weight: 500; display: flex; align-items: center;
  767. transition: all 0.3s;
  768. &.active { color: #1F6CFF; }
  769. .arrow-down {
  770. width: 24rpx; height: 24rpx; margin-left: 8rpx; opacity: 0.3;
  771. transition: transform 0.3s;
  772. &.rotate { transform: rotate(180deg); opacity: 0.8; }
  773. }
  774. }
  775. }
  776. .dropdown-wrapper {
  777. position: absolute; top: 100%; left: 0; right: 0; height: calc(100vh - 100%); z-index: 99;
  778. .mask {
  779. position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4);
  780. animation: fadeIn 0.3s ease-out;
  781. }
  782. .dropdown-content {
  783. background: #FFF; position: relative; z-index: 1; border-top: 1rpx solid #F0F0F0;
  784. border-radius: 0 0 32rpx 32rpx; padding: 10rpx 0;
  785. max-height: 60vh; overflow-y: auto;
  786. animation: slideDown 0.3s ease-out;
  787. .option-item {
  788. display: flex; justify-content: space-between; align-items: center;
  789. padding: 30rpx 40rpx; font-size: 28rpx; color: #333;
  790. &:active { background: #F8F9FB; }
  791. &.selected { color: #1F6CFF; font-weight: bold; }
  792. .check-icon { width: 32rpx; height: 32rpx; }
  793. }
  794. }
  795. }
  796. @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  797. @keyframes slideDown { from { transform: translateY(-20%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
  798. .scroll-body {
  799. position: fixed; left: 0; right: 0; bottom: 0; background-color: #F8F9FB;
  800. }
  801. .assessment-list {
  802. padding: 30rpx 40rpx; display: flex; flex-direction: column; gap: 30rpx;
  803. }
  804. .training-list {
  805. padding: 30rpx 40rpx; display: flex; flex-direction: column; gap: 30rpx;
  806. }
  807. .training-card {
  808. background: #FFF; border-radius: 32rpx; padding: 32rpx;
  809. box-shadow: 0 4rpx 24rpx rgba(0,0,0,0.03);
  810. .t-title { font-size: 32rpx; font-weight: bold; color: #1A1A1A; line-height: 1.4; display: block; margin-bottom: 20rpx; }
  811. .tag-row {
  812. display: flex; gap: 10rpx; margin: 12rpx 0;
  813. .tag-badge {
  814. font-size: 20rpx; color: #999; background: #F5F7FA; padding: 6rpx 14rpx; border-radius: 6rpx;
  815. &.type-tag { color: #1F6CFF; background: rgba(31, 108, 255, 0.08); }
  816. &.category-tag { color: #FF9500; background: rgba(255, 149, 0, 0.08); }
  817. }
  818. }
  819. .info-list {
  820. margin-top: 24rpx; display: flex; flex-direction: column; gap: 16rpx;
  821. .info-item {
  822. display: flex; align-items: center;
  823. .i-icon { width: 28rpx; height: 28rpx; margin-right: 16rpx; opacity: 0.5; }
  824. .i-text { font-size: 26rpx; color: #666; }
  825. .ending-tag { font-size: 22rpx; color: #FF4D4F; margin-left: 20rpx; }
  826. }
  827. }
  828. }
  829. .video-card {
  830. background: #FFF; border-radius: 32rpx; overflow: hidden;
  831. box-shadow: 0 4rpx 24rpx rgba(0,0,0,0.03);
  832. .video-cover-wrap {
  833. width: 100%; height: 380rpx; position: relative;
  834. .v-cover { width: 100%; height: 100%; }
  835. .play-overlay {
  836. position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  837. .play-icon { width: 100rpx; height: 100rpx; opacity: 0.9; }
  838. }
  839. .v-bottom-info {
  840. position: absolute; left: 0; right: 0; bottom: 0; height: 80rpx;
  841. background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.5) 100%);
  842. padding: 0 24rpx; display: flex; justify-content: space-between; align-items: center;
  843. color: #FFF; font-size: 24rpx;
  844. .m-icon { width: 24rpx; height: 24rpx; margin-right: 8rpx; }
  845. .play-mini-icon {
  846. width: 0; height: 0;
  847. border-left: 12rpx solid #FFF; border-top: 8rpx solid transparent; border-bottom: 8rpx solid transparent;
  848. margin-right: 10rpx;
  849. }
  850. .v-info-left, .v-info-right { display: flex; align-items: center; }
  851. }
  852. .live-status {
  853. position: absolute; right: 24rpx; top: 24rpx; border-radius: 8rpx; padding: 4rpx 12rpx; font-size: 22rpx; color: #FFF;
  854. &.streaming { background: #FF4D4F; }
  855. &.upcoming { background: #1F6CFF; }
  856. &.not-started { background: #999; }
  857. &.finished { background: #666; }
  858. }
  859. }
  860. .v-content {
  861. padding: 24rpx;
  862. .v-title { font-size: 32rpx; font-weight: bold; color: #1A1A1A; }
  863. .v-title-row { display: flex; justify-content: space-between; align-items: center; }
  864. .spectators {
  865. display: flex; align-items: center; color: #999; font-size: 24rpx;
  866. .s-icon { width: 24rpx; height: 24rpx; margin-right: 8rpx; }
  867. }
  868. }
  869. }
  870. .job-card {
  871. background: #FFF; border-radius: 32rpx; padding: 24rpx; display: flex;
  872. box-shadow: 0 4rpx 24rpx rgba(0,0,0,0.03);
  873. position: relative;
  874. .card-left {
  875. width: 220rpx; height: 220rpx; flex-shrink: 0; margin-right: 24rpx;
  876. .cover-img { width: 100%; height: 100%; border-radius: 16rpx; }
  877. }
  878. .card-right {
  879. flex: 1; display: flex; flex-direction: column; justify-content: space-between;
  880. .top-line {
  881. display: flex; justify-content: space-between; align-items: center;
  882. .job-title { font-size: 34rpx; font-weight: bold; color: #1A1A1A; }
  883. .job-level-tag { font-size: 22rpx; color: #1F6CFF; background: rgba(31, 108, 255, 0.1); padding: 4rpx 12rpx; border-radius: 8rpx; }
  884. }
  885. .tag-row {
  886. display: flex; gap: 10rpx; margin: 12rpx 0;
  887. .tag-badge {
  888. font-size: 20rpx; color: #999; background: #F5F7FA; padding: 6rpx 14rpx; border-radius: 6rpx;
  889. &.type-tag { color: #1F6CFF; background: rgba(31, 108, 255, 0.08); }
  890. &.category-tag { color: #FF9500; background: rgba(255, 149, 0, 0.08); }
  891. }
  892. }
  893. .desc-text { font-size: 24rpx; color: #888; line-height: 1.4; margin-bottom: 16rpx; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  894. .btn-wrap {
  895. display: flex; justify-content: flex-end; gap: 10rpx;
  896. .consult-btn {
  897. margin: 0; background: #FFB700; color: #FFF; border-radius: 30rpx; height: 56rpx; line-height: 56rpx; padding: 0 36rpx; font-size: 26rpx; font-weight: bold;
  898. &::after { border:none; }
  899. }
  900. .start-btn {
  901. margin: 0; background: linear-gradient(135deg, #1F6CFF 0%, #0056FF 100%); color: #FFF; border-radius: 30rpx; height: 56rpx; line-height: 56rpx; padding: 0 36rpx; font-size: 26rpx; font-weight: bold;
  902. &::after { border:none; }
  903. }
  904. .apply-btn {
  905. margin: 0; background: #1F6CFF; color: #FFF; border-radius: 30rpx; height: 56rpx; line-height: 56rpx; padding: 0 36rpx; font-size: 26rpx; font-weight: bold;
  906. &::after { border:none; }
  907. }
  908. .applied-btn {
  909. margin: 0; background: #E0E0E0; color: #999; border-radius: 30rpx; height: 56rpx; line-height: 56rpx; padding: 0 36rpx; font-size: 26rpx; font-weight: bold;
  910. &::after { border:none; }
  911. }
  912. .retry-btn {
  913. margin: 0; background: #E8F0FF; color: #2B5CFF; border-radius: 30rpx; height: 56rpx; line-height: 56rpx; padding: 0 36rpx; font-size: 26rpx; font-weight: bold;
  914. &::after { border:none; }
  915. }
  916. .report-btn {
  917. margin: 0; background: #E8F0FF; color: #2B5CFF; border-radius: 30rpx; height: 56rpx; line-height: 56rpx; padding: 0 36rpx; font-size: 26rpx; font-weight: bold;
  918. &::after { border:none; }
  919. &.disabled {
  920. background: #F0F2F5; color: #C0C4CC; pointer-events: none;
  921. }
  922. }
  923. }
  924. }
  925. }
  926. .text-ellipsis-2 {
  927. display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  928. }
  929. .no-data {
  930. display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 100rpx 0;
  931. .empty-icon { width: 200rpx; height: 200rpx; margin-bottom: 20rpx; opacity: 0.5; }
  932. text { font-size: 28rpx; color: #999; }
  933. }
  934. .no-more {
  935. text-align: center; font-size: 26rpx; color: #BBB; padding: 40rpx 0;
  936. }
  937. .tabbar-placeholder { height: 180rpx; }
  938. .card-anim {
  939. animation: fadeUp 0.6s ease-out backwards;
  940. @for $i from 1 through 5 { &:nth-child(#{$i}) { animation-delay: #{$i * 0.1s}; } }
  941. }
  942. @keyframes fadeUp {
  943. from { opacity: 0; transform: translateY(30rpx); }
  944. to { opacity: 1; transform: translateY(0); }
  945. }
  946. </style>