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