assessment.vue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  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 } 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. // 投递简历:跳转到选择简历页面
  444. const handleApply = (item) => {
  445. if (!item.postId) {
  446. uni.showToast({ title: '该测评未关联岗位,无法投递', icon: 'none' });
  447. return;
  448. }
  449. const userInfo = uni.getStorageSync('userInfo') || {};
  450. if (!userInfo.studentId) {
  451. uni.showToast({ title: '请先登录', icon: 'none' });
  452. setTimeout(() => {
  453. uni.navigateTo({ url: '/pages/login/login' });
  454. }, 1000);
  455. return;
  456. }
  457. uni.navigateTo({
  458. url: `/pages/my/select-resume?postId=${item.postId}`
  459. });
  460. };
  461. /**
  462. * 点击咨询按钮:创建/获取会话后跳转聊天页
  463. * @param {Object} item - 当前测评项目信息
  464. */
  465. const handleConsult = async (item) => {
  466. // 检查登录
  467. const userInfo = uni.getStorageSync('userInfo') || {};
  468. const userId = userInfo.studentId || null;
  469. if (!userId) {
  470. uni.showToast({ title: '请先登录', icon: 'none' });
  471. setTimeout(() => {
  472. uni.navigateTo({ url: '/pages/login/login' });
  473. }, 1000);
  474. return;
  475. }
  476. try {
  477. uni.showLoading({ title: '正在连接客服...' });
  478. const userName = userInfo.name || '用户';
  479. const userAvatar = userInfo.avatarUrl || '/static/images/user_avatar.svg';
  480. const res = await createOrGetSession({
  481. sessionType: 1,
  482. fromUserId: userId,
  483. fromUserName: userName,
  484. fromUserAvatar: userAvatar,
  485. sourceId: 'assessment_' + (item?.id || '')
  486. });
  487. uni.hideLoading();
  488. if (res.data) {
  489. const session = res.data;
  490. // 将测评信息编码后传入聊天页面,供初始卡片展示
  491. const assessmentTitle = encodeURIComponent(item ? (item.title || '') : '');
  492. const assessmentCover = encodeURIComponent(item ? (item.cover || '') : '');
  493. const assessmentId = item ? (item.id || '') : '';
  494. const assessmentLevel = encodeURIComponent(item ? (item.level || '') : '');
  495. const assessmentPrice = item ? (item.price || '') : '';
  496. uni.navigateTo({
  497. 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}`
  498. });
  499. } else {
  500. uni.showToast({ title: '创建会话失败', icon: 'none' });
  501. }
  502. } catch (err) {
  503. uni.hideLoading();
  504. console.error('创建会话失败:', err);
  505. uni.showToast({ title: '连接失败,请重试', icon: 'none' });
  506. }
  507. };
  508. const activeFilterIndex = ref(-1);
  509. const assessmentFilterList = ref([
  510. {
  511. label: '岗位类型',
  512. selectedLabel: '',
  513. selectedValue: '',
  514. options: [{ label: '全部', value: '' }]
  515. },
  516. {
  517. label: '岗位等级',
  518. selectedLabel: '',
  519. selectedValue: '',
  520. options: [{ label: '全部', value: '' }]
  521. },
  522. {
  523. label: '岗位名称',
  524. selectedLabel: '',
  525. selectedValue: '',
  526. options: [
  527. { label: '全部', value: '' },
  528. { label: '审计岗位', value: 'audit' },
  529. { label: '咨询岗位', value: 'consult' },
  530. { label: '税务岗位', value: 'tax' }
  531. ]
  532. }
  533. ]);
  534. const loadDicts = async () => {
  535. try {
  536. const [typeRes, levelRes] = await Promise.all([
  537. getDicts('main_position_type'),
  538. getDicts('main_position_level')
  539. ]);
  540. if (typeRes.code === 200) {
  541. const options = [
  542. { label: '全部', value: '' },
  543. ...typeRes.data.map(d => ({ label: d.dictLabel, value: d.dictValue }))
  544. ];
  545. assessmentFilterList.value[0].options = options;
  546. trainingFilterList.value[1].options = options;
  547. }
  548. if (levelRes.code === 200) {
  549. assessmentFilterList.value[1].options = [
  550. { label: '全部', value: '' },
  551. ...levelRes.data.map(d => ({ label: d.dictLabel, value: d.dictValue }))
  552. ];
  553. }
  554. } catch (e) {
  555. console.error('加载字典失败', e);
  556. }
  557. };
  558. const trainingFilterList = ref([
  559. {
  560. label: '培训类型',
  561. selectedLabel: '线下培训',
  562. selectedValue: 'offline',
  563. options: [
  564. { label: '线下培训', value: 'offline' },
  565. { label: '视频培训', value: 'video' },
  566. { label: '直播培训', value: 'live' }
  567. ]
  568. },
  569. {
  570. label: '职位类型',
  571. selectedLabel: '',
  572. selectedValue: '',
  573. options: [
  574. { label: '全部', value: '' },
  575. { label: '全职', value: 'full-time' },
  576. { label: '兼职', value: 'part-time' },
  577. { label: '实习', value: 'intern' }
  578. ]
  579. },
  580. {
  581. label: '岗位',
  582. selectedLabel: '',
  583. selectedValue: '',
  584. options: [
  585. { label: '全部', value: '' },
  586. { label: '审计', value: 'audit' },
  587. { label: '咨询', value: 'consult' },
  588. { label: '税务', value: 'tax' }
  589. ]
  590. }
  591. ]);
  592. const currentFilters = computed(() => {
  593. return currentTab.value === 0 ? assessmentFilterList.value : trainingFilterList.value;
  594. });
  595. const currentOptions = computed(() => {
  596. if (activeFilterIndex.value === -1) return [];
  597. return currentFilters.value[activeFilterIndex.value].options;
  598. });
  599. const toggleFilter = (index) => {
  600. if (activeFilterIndex.value === index) {
  601. activeFilterIndex.value = -1;
  602. } else {
  603. activeFilterIndex.value = index;
  604. }
  605. };
  606. const closeFilter = () => {
  607. activeFilterIndex.value = -1;
  608. };
  609. const selectOption = (opt) => {
  610. const filter = currentFilters.value[activeFilterIndex.value];
  611. filter.selectedValue = opt.value;
  612. filter.selectedLabel = opt.value === '' ? '' : opt.label;
  613. closeFilter();
  614. // 过滤变化后重新加载
  615. if (currentTab.value === 0) {
  616. fetchAssessments();
  617. } else {
  618. fetchTrainings();
  619. }
  620. };
  621. const getTypeLabel = (type) => {
  622. const map = { 'full-time': '全职', 'part-time': '兼职', 'intern': '实习' };
  623. return map[type] || type;
  624. };
  625. const getCategoryLabel = (cat) => {
  626. const map = { 'audit': '审计', 'consult': '咨询', 'tax': '税务' };
  627. return map[cat] || cat;
  628. };
  629. const filteredAssessments = computed(() => assessments.value);
  630. const filteredTrainings = computed(() => trainings.value);
  631. const goToTrainingDetail = (item) => {
  632. uni.navigateTo({
  633. url: `/pages/assessment/training-detail?type=${item.trainingType}&title=${item.title}&status=${item.status || ''}&views=${item.views || ''}&duration=${item.duration || ''}&spectators=${item.spectators || ''}`
  634. });
  635. };
  636. const scrollTop = computed(() => {
  637. // 顶部渐变区:状态栏 + 胶囊栏 + 20rpx 底部间距
  638. const gradientHeight = statusBarHeight.value + titleBarMargin.value + menuButtonHeight.value + uni.upx2px(20);
  639. // 白色内容区:Tabs(84rpx) + 筛选栏(74rpx) = 158rpx
  640. const whiteAreaHeight = uni.upx2px(158);
  641. return gradientHeight + whiteAreaHeight;
  642. });
  643. onMounted(() => {
  644. // #ifdef MP-WEIXIN
  645. try {
  646. const sysInfo = uni.getSystemInfoSync();
  647. const menuInfo = uni.getMenuButtonBoundingClientRect();
  648. if (sysInfo && menuInfo) {
  649. statusBarHeight.value = sysInfo.statusBarHeight || 20;
  650. titleBarMargin.value = menuInfo.top - sysInfo.statusBarHeight;
  651. menuButtonHeight.value = menuInfo.height;
  652. }
  653. } catch (e) {}
  654. // #endif
  655. console.log('assessment onMounted triggered');
  656. loadDicts();
  657. });
  658. onLoad(() => {
  659. console.log('assessment onLoad triggered');
  660. });
  661. onShow(() => {
  662. console.log('assessment onShow triggered');
  663. fetchAssessments();
  664. fetchTrainings();
  665. });
  666. onPullDownRefresh(async () => {
  667. // 禁止下拉刷新,直接停止
  668. uni.stopPullDownRefresh();
  669. });
  670. </script>
  671. <style lang="scss" scoped>
  672. .container {
  673. width: 100%; height: 100vh; background-color: #F8F9FB; position: relative; overflow: hidden;
  674. }
  675. .loading-box {
  676. display: flex;
  677. flex-direction: column;
  678. align-items: center;
  679. justify-content: center;
  680. height: 80vh;
  681. padding-top: 200rpx;
  682. .loading-spinner {
  683. width: 60rpx;
  684. height: 60rpx;
  685. border: 6rpx solid #f3f3f3;
  686. border-top: 6rpx solid #1F6CFF;
  687. border-radius: 50%;
  688. animation: spin 1s linear infinite;
  689. }
  690. .loading-text {
  691. margin-top: 20rpx;
  692. font-size: 28rpx;
  693. color: #999;
  694. }
  695. }
  696. @keyframes spin {
  697. 0% { transform: rotate(0deg); }
  698. 100% { transform: rotate(360deg); }
  699. }
  700. .fixed-header {
  701. position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  702. }
  703. .gradient-section {
  704. background: linear-gradient(180deg, #1F6CFF 0%, #FFFFFF 100%);
  705. padding: 0 40rpx 20rpx;
  706. }
  707. .search-bar {
  708. background: rgba(255, 255, 255, 0.95);
  709. border-radius: 40rpx;
  710. display: flex;
  711. align-items: center;
  712. padding: 0 30rpx;
  713. box-shadow: 0 4rpx 20rpx rgba(31, 108, 255, 0.1);
  714. margin-right: 200rpx;
  715. height: 100%;
  716. .search-icon { width: 32rpx; height: 32rpx; margin-right: 20rpx; opacity: 0.4; }
  717. .search-input { flex: 1; font-size: 28rpx; }
  718. .ph-color { color: #999; }
  719. }
  720. .white-section {
  721. background: #FFF; padding-bottom: 0;
  722. }
  723. .horizontal-tabs-wrap {
  724. display: flex; justify-content: space-between; align-items: center; padding: 20rpx 40rpx;
  725. .main-tabs {
  726. display: flex; gap: 40rpx;
  727. .main-tab {
  728. font-size: 34rpx; font-weight: bold; color: #888; position: relative; padding-bottom: 10rpx;
  729. &.active {
  730. color: #1A1A1A;
  731. &:after { content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 36rpx; height: 6rpx; background: #1F6CFF; border-radius: 3rpx; }
  732. }
  733. }
  734. }
  735. .record-text { font-size: 28rpx; color: #1F6CFF; }
  736. }
  737. .filter-row {
  738. display: flex; justify-content: space-between; padding: 20rpx 40rpx 20rpx;
  739. .filter-item {
  740. font-size: 28rpx; color: #333; font-weight: 500; display: flex; align-items: center;
  741. transition: all 0.3s;
  742. &.active { color: #1F6CFF; }
  743. .arrow-down {
  744. width: 24rpx; height: 24rpx; margin-left: 8rpx; opacity: 0.3;
  745. transition: transform 0.3s;
  746. &.rotate { transform: rotate(180deg); opacity: 0.8; }
  747. }
  748. }
  749. }
  750. .dropdown-wrapper {
  751. position: absolute; top: 100%; left: 0; right: 0; height: calc(100vh - 100%); z-index: 99;
  752. .mask {
  753. position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4);
  754. animation: fadeIn 0.3s ease-out;
  755. }
  756. .dropdown-content {
  757. background: #FFF; position: relative; z-index: 1; border-top: 1rpx solid #F0F0F0;
  758. border-radius: 0 0 32rpx 32rpx; padding: 10rpx 0;
  759. max-height: 60vh; overflow-y: auto;
  760. animation: slideDown 0.3s ease-out;
  761. .option-item {
  762. display: flex; justify-content: space-between; align-items: center;
  763. padding: 30rpx 40rpx; font-size: 28rpx; color: #333;
  764. &:active { background: #F8F9FB; }
  765. &.selected { color: #1F6CFF; font-weight: bold; }
  766. .check-icon { width: 32rpx; height: 32rpx; }
  767. }
  768. }
  769. }
  770. @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  771. @keyframes slideDown { from { transform: translateY(-20%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
  772. .scroll-body {
  773. position: fixed; left: 0; right: 0; bottom: 0; background-color: #F8F9FB;
  774. }
  775. .assessment-list {
  776. padding: 30rpx 40rpx; display: flex; flex-direction: column; gap: 30rpx;
  777. }
  778. .training-list {
  779. padding: 30rpx 40rpx; display: flex; flex-direction: column; gap: 30rpx;
  780. }
  781. .training-card {
  782. background: #FFF; border-radius: 32rpx; padding: 32rpx;
  783. box-shadow: 0 4rpx 24rpx rgba(0,0,0,0.03);
  784. .t-title { font-size: 32rpx; font-weight: bold; color: #1A1A1A; line-height: 1.4; display: block; margin-bottom: 20rpx; }
  785. .tag-row {
  786. display: flex; gap: 10rpx; margin: 12rpx 0;
  787. .tag-badge {
  788. font-size: 20rpx; color: #999; background: #F5F7FA; padding: 6rpx 14rpx; border-radius: 6rpx;
  789. &.type-tag { color: #1F6CFF; background: rgba(31, 108, 255, 0.08); }
  790. &.category-tag { color: #FF9500; background: rgba(255, 149, 0, 0.08); }
  791. }
  792. }
  793. .info-list {
  794. margin-top: 24rpx; display: flex; flex-direction: column; gap: 16rpx;
  795. .info-item {
  796. display: flex; align-items: center;
  797. .i-icon { width: 28rpx; height: 28rpx; margin-right: 16rpx; opacity: 0.5; }
  798. .i-text { font-size: 26rpx; color: #666; }
  799. .ending-tag { font-size: 22rpx; color: #FF4D4F; margin-left: 20rpx; }
  800. }
  801. }
  802. }
  803. .video-card {
  804. background: #FFF; border-radius: 32rpx; overflow: hidden;
  805. box-shadow: 0 4rpx 24rpx rgba(0,0,0,0.03);
  806. .video-cover-wrap {
  807. width: 100%; height: 380rpx; position: relative;
  808. .v-cover { width: 100%; height: 100%; }
  809. .play-overlay {
  810. position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  811. .play-icon { width: 100rpx; height: 100rpx; opacity: 0.9; }
  812. }
  813. .v-bottom-info {
  814. position: absolute; left: 0; right: 0; bottom: 0; height: 80rpx;
  815. background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.5) 100%);
  816. padding: 0 24rpx; display: flex; justify-content: space-between; align-items: center;
  817. color: #FFF; font-size: 24rpx;
  818. .m-icon { width: 24rpx; height: 24rpx; margin-right: 8rpx; }
  819. .play-mini-icon {
  820. width: 0; height: 0;
  821. border-left: 12rpx solid #FFF; border-top: 8rpx solid transparent; border-bottom: 8rpx solid transparent;
  822. margin-right: 10rpx;
  823. }
  824. .v-info-left, .v-info-right { display: flex; align-items: center; }
  825. }
  826. .live-status {
  827. position: absolute; right: 24rpx; top: 24rpx; border-radius: 8rpx; padding: 4rpx 12rpx; font-size: 22rpx; color: #FFF;
  828. &.streaming { background: #FF4D4F; }
  829. &.upcoming { background: #1F6CFF; }
  830. &.not-started { background: #999; }
  831. &.finished { background: #666; }
  832. }
  833. }
  834. .v-content {
  835. padding: 24rpx;
  836. .v-title { font-size: 32rpx; font-weight: bold; color: #1A1A1A; }
  837. .v-title-row { display: flex; justify-content: space-between; align-items: center; }
  838. .spectators {
  839. display: flex; align-items: center; color: #999; font-size: 24rpx;
  840. .s-icon { width: 24rpx; height: 24rpx; margin-right: 8rpx; }
  841. }
  842. }
  843. }
  844. .job-card {
  845. background: #FFF; border-radius: 32rpx; padding: 24rpx; display: flex;
  846. box-shadow: 0 4rpx 24rpx rgba(0,0,0,0.03);
  847. position: relative;
  848. .card-left {
  849. width: 220rpx; height: 220rpx; flex-shrink: 0; margin-right: 24rpx;
  850. .cover-img { width: 100%; height: 100%; border-radius: 16rpx; }
  851. }
  852. .card-right {
  853. flex: 1; display: flex; flex-direction: column; justify-content: space-between;
  854. .top-line {
  855. display: flex; justify-content: space-between; align-items: center;
  856. .job-title { font-size: 34rpx; font-weight: bold; color: #1A1A1A; }
  857. .job-level-tag { font-size: 22rpx; color: #1F6CFF; background: rgba(31, 108, 255, 0.1); padding: 4rpx 12rpx; border-radius: 8rpx; }
  858. }
  859. .tag-row {
  860. display: flex; gap: 10rpx; margin: 12rpx 0;
  861. .tag-badge {
  862. font-size: 20rpx; color: #999; background: #F5F7FA; padding: 6rpx 14rpx; border-radius: 6rpx;
  863. &.type-tag { color: #1F6CFF; background: rgba(31, 108, 255, 0.08); }
  864. &.category-tag { color: #FF9500; background: rgba(255, 149, 0, 0.08); }
  865. }
  866. }
  867. .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; }
  868. .btn-wrap {
  869. display: flex; justify-content: flex-end; gap: 10rpx;
  870. .consult-btn {
  871. margin: 0; background: #FFB700; color: #FFF; border-radius: 30rpx; height: 56rpx; line-height: 56rpx; padding: 0 36rpx; font-size: 26rpx; font-weight: bold;
  872. &::after { border:none; }
  873. }
  874. .start-btn {
  875. 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;
  876. &::after { border:none; }
  877. }
  878. .apply-btn {
  879. margin: 0; background: #1F6CFF; color: #FFF; border-radius: 30rpx; height: 56rpx; line-height: 56rpx; padding: 0 36rpx; font-size: 26rpx; font-weight: bold;
  880. &::after { border:none; }
  881. }
  882. .applied-btn {
  883. margin: 0; background: #E0E0E0; color: #999; border-radius: 30rpx; height: 56rpx; line-height: 56rpx; padding: 0 36rpx; font-size: 26rpx; font-weight: bold;
  884. &::after { border:none; }
  885. }
  886. .retry-btn {
  887. margin: 0; background: #E8F0FF; color: #2B5CFF; border-radius: 30rpx; height: 56rpx; line-height: 56rpx; padding: 0 36rpx; font-size: 26rpx; font-weight: bold;
  888. &::after { border:none; }
  889. }
  890. .report-btn {
  891. margin: 0; background: #E8F0FF; color: #2B5CFF; border-radius: 30rpx; height: 56rpx; line-height: 56rpx; padding: 0 36rpx; font-size: 26rpx; font-weight: bold;
  892. &::after { border:none; }
  893. &.disabled {
  894. background: #F0F2F5; color: #C0C4CC; pointer-events: none;
  895. }
  896. }
  897. }
  898. }
  899. }
  900. .text-ellipsis-2 {
  901. display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  902. }
  903. .no-data {
  904. display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 100rpx 0;
  905. .empty-icon { width: 200rpx; height: 200rpx; margin-bottom: 20rpx; opacity: 0.5; }
  906. text { font-size: 28rpx; color: #999; }
  907. }
  908. .no-more {
  909. text-align: center; font-size: 26rpx; color: #BBB; padding: 40rpx 0;
  910. }
  911. .tabbar-placeholder { height: 180rpx; }
  912. .card-anim {
  913. animation: fadeUp 0.6s ease-out backwards;
  914. @for $i from 1 through 5 { &:nth-child(#{$i}) { animation-delay: #{$i * 0.1s}; } }
  915. }
  916. @keyframes fadeUp {
  917. from { opacity: 0; transform: translateY(30rpx); }
  918. to { opacity: 1; transform: translateY(0); }
  919. }
  920. </style>