result.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view class="result-container" v-if="!loading">
  3. <!-- 自定义导航栏 -->
  4. <view class="nav-bar">
  5. <view class="nav-back" @click="goBack">
  6. <image src="/static/icons/arrow_left.svg" class="nav-back-icon" mode="aspectFit"></image>
  7. </view>
  8. <text class="nav-title">测评结果</text>
  9. <view class="nav-placeholder"></view>
  10. </view>
  11. <!-- 1. 结果状态区 -->
  12. <view class="status-card">
  13. <view class="result-icon-wrap" :class="resultData.finalResult === '1' ? 'pass' : 'fail'">
  14. <view v-if="resultData.finalResult === '1'" class="css-check"></view>
  15. <view v-else class="css-cross"></view>
  16. </view>
  17. <text class="status-title">{{ resultData.finalResult === '1' ? '恭喜你!达到投递标准' : '很遗憾!未达到投递标准' }}</text>
  18. <view class="action-btns">
  19. <button v-if="resultData.finalResult === '2'" class="btn-retry" @click="goToAssessment">去练习</button>
  20. <button class="btn-report" @click="viewReport">查看报告</button>
  21. </view>
  22. </view>
  23. <!-- 2. 能力分布 -->
  24. <view class="chart-card">
  25. <view class="card-title">测评情况</view>
  26. <view class="ability-list">
  27. <view v-for="(item, index) in resultData.abilityResults" :key="index" class="ability-item">
  28. <text class="name">{{ item.name }}</text>
  29. <view class="score-wrap">
  30. <text class="score" :class="item.isPass ? 'pass' : 'fail'">{{ item.score }}分</text>
  31. <text class="status-symbol" :class="item.isPass ? 'pass' : 'fail'">{{ item.isPass ? '√' : '×' }}</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 3. 培训推荐 (仅在未通过时显示) -->
  37. <view v-if="resultData.finalResult === '2'" class="training-recommend">
  38. <view class="section-title">培训推荐</view>
  39. <view class="training-list">
  40. <view
  41. v-for="(item, index) in trainingList"
  42. :key="index"
  43. class="training-card offline"
  44. @click="goToTrainingDetail(item)"
  45. >
  46. <view class="card-header">
  47. <text class="t-title">{{ item.title }}</text>
  48. </view>
  49. <view class="tag-row">
  50. <text class="tag-badge type-tag">{{ getTypeLabel(item.type) }}</text>
  51. <text class="tag-badge category-tag">{{ getCategoryLabel(item.category) }}</text>
  52. <text class="tag-badge" v-for="(tag, tIdx) in item.tags" :key="tIdx">{{ tag }}</text>
  53. </view>
  54. <view class="info-list">
  55. <view class="info-item">
  56. <image src="/static/icons/location.svg" class="i-icon"></image>
  57. <text class="i-text">{{ item.location }}</text>
  58. </view>
  59. <view class="info-item">
  60. <image src="/static/icons/user.svg" class="i-icon"></image>
  61. <text class="i-text">主办单位:{{ item.organizer }}</text>
  62. </view>
  63. <view class="info-item">
  64. <image src="/static/icons/time.svg" class="i-icon"></image>
  65. <text class="i-text">培训时间:{{ item.trainingTime }}</text>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script setup>
  74. import { ref } from 'vue'
  75. import { onLoad } from '@dcloudio/uni-app'
  76. import { getEvaluationResult, getTrainingList } from '../../api/assessment.js'
  77. const loading = ref(true)
  78. const resultData = ref({})
  79. const trainingList = ref([])
  80. const assessmentId = ref('')
  81. onLoad(async (options) => {
  82. // 兼容不同的参数名
  83. assessmentId.value = options.id || options.assessmentId || ''
  84. if (!assessmentId.value || assessmentId.value === 'undefined') {
  85. uni.showToast({ title: '测评ID缺失', icon: 'none' })
  86. return
  87. }
  88. await loadData()
  89. })
  90. const loadData = async () => {
  91. if (!assessmentId.value || assessmentId.value === 'undefined') return
  92. try {
  93. const userInfo = uni.getStorageSync('userInfo') || {}
  94. const studentId = userInfo.studentId || userInfo.id
  95. if (!studentId) {
  96. uni.showToast({ title: '登录信息失效', icon: 'none' })
  97. return
  98. }
  99. const res = await getEvaluationResult(assessmentId.value, studentId)
  100. if (res.code === 200) {
  101. resultData.value = res.data
  102. // 无论通过与否,都加载培训推荐作为兜底
  103. loadTrainings()
  104. }
  105. } catch (e) {
  106. console.error(e)
  107. } finally {
  108. loading.value = false
  109. }
  110. }
  111. const resolveDescription = (item, fallback = '') => {
  112. return item.remark || item.description || item.desc || fallback;
  113. };
  114. const getTypeLabel = (type) => {
  115. const map = { 'full-time': '全职', 'part-time': '兼职', 'intern': '实习' };
  116. return map[type] || type;
  117. };
  118. const getCategoryLabel = (cat) => {
  119. const map = { 'audit': '审计', 'consult': '咨询', 'tax': '税务' };
  120. return map[cat] || cat;
  121. };
  122. const loadTrainings = async () => {
  123. try {
  124. const res = await getTrainingList({ pageNum: 1, pageSize: 5, status: 1 })
  125. if (res.code === 200 && res.rows) {
  126. trainingList.value = res.rows.map(item => {
  127. let title = item.name || item.trainingName || item.title;
  128. if (!title || title.trim() === '' || title.startsWith('test_')) {
  129. const job = item.job || item.position || '专业技能';
  130. title = `${job}培训课程`;
  131. }
  132. let location = '';
  133. if (item.trainingType === 'offline') {
  134. const city = item.city || '';
  135. const area = item.area || '';
  136. const addressDetail = item.addressDetail || '';
  137. location = `${city}${area}${addressDetail}`.replace(/undefined|null/g, '').trim();
  138. if (!location) location = '线下培训';
  139. } else {
  140. location = '线上培训';
  141. }
  142. const trainingTime = item.trainingStartTime ?
  143. item.trainingStartTime.split(' ')[0] + (item.trainingEndTime ? ' 至 ' + item.trainingEndTime.split(' ')[0] : '') :
  144. '';
  145. return {
  146. id: item.id,
  147. title: title,
  148. trainingType: item.trainingType || 'offline',
  149. type: item.jobType || '',
  150. category: item.job || '',
  151. tags: item.tags ? item.tags.split(',') : [],
  152. location: location,
  153. organizer: item.organizer || '平台推荐',
  154. trainingTime: trainingTime,
  155. mainImage: item.thumbnailUrl || '/static/images/training_default.svg',
  156. };
  157. });
  158. }
  159. } catch (e) {
  160. console.error('加载培训列表失败:', e)
  161. }
  162. }
  163. const goToAssessment = () => {
  164. if (!assessmentId.value || assessmentId.value === 'undefined') {
  165. uni.navigateBack()
  166. return
  167. }
  168. uni.redirectTo({
  169. url: `/pages/common/webview?mode=kaoshixing&assessmentId=${encodeURIComponent(assessmentId.value)}`
  170. })
  171. }
  172. const viewReport = () => {
  173. if (!assessmentId.value || assessmentId.value === 'undefined') {
  174. uni.showToast({ title: '参数错误', icon: 'none' })
  175. return
  176. }
  177. // 直接跳转到本地原生的图形化报告页 report.vue
  178. uni.navigateTo({
  179. url: `/pages/assessment/report?id=${assessmentId.value}`
  180. })
  181. }
  182. const goToTrainingDetail = (item) => {
  183. uni.navigateTo({
  184. url: `/pages/assessment/training-detail?type=${item.trainingType}&title=${item.title}`
  185. });
  186. };
  187. const goBack = () => {
  188. uni.navigateBack();
  189. };
  190. </script>
  191. <style lang="scss" scoped>
  192. .result-container { padding: 0 30rpx 30rpx; background-color: #f8f9fb; min-height: 100vh; }
  193. /* 导航栏 */
  194. .nav-bar {
  195. display: flex;
  196. align-items: center;
  197. justify-content: space-between;
  198. padding: 20rpx 10rpx;
  199. margin-bottom: 16rpx;
  200. position: sticky;
  201. top: 0;
  202. z-index: 100;
  203. background-color: #f8f9fb;
  204. }
  205. .nav-back {
  206. width: 64rpx;
  207. height: 64rpx;
  208. display: flex;
  209. align-items: center;
  210. justify-content: center;
  211. }
  212. .nav-back-icon {
  213. width: 40rpx;
  214. height: 40rpx;
  215. }
  216. .nav-title {
  217. font-size: 34rpx;
  218. font-weight: bold;
  219. color: #1A1A1A;
  220. }
  221. .nav-placeholder {
  222. width: 64rpx;
  223. }
  224. .status-card { background: #fff; border-radius: 20rpx; padding: 60rpx 40rpx; display: flex; flex-direction: column; align-items: center; margin-bottom: 30rpx; }
  225. /* 结果图标样式 */
  226. .result-icon-wrap {
  227. width: 120rpx;
  228. height: 120rpx;
  229. border-radius: 50%;
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. margin-bottom: 30rpx;
  234. &.pass { background-color: #52c41a; }
  235. &.fail { background-color: #ff4d4f; }
  236. }
  237. .css-check {
  238. width: 50rpx;
  239. height: 25rpx;
  240. border-left: 6rpx solid #fff;
  241. border-bottom: 6rpx solid #fff;
  242. transform: rotate(-45deg);
  243. margin-top: -10rpx;
  244. }
  245. .css-cross {
  246. position: relative;
  247. width: 50rpx;
  248. height: 50rpx;
  249. &::before, &::after {
  250. content: '';
  251. position: absolute;
  252. top: 50%;
  253. left: 0;
  254. width: 100%;
  255. height: 6rpx;
  256. background-color: #fff;
  257. border-radius: 3rpx;
  258. }
  259. &::before { transform: rotate(45deg); }
  260. &::after { transform: rotate(-45deg); }
  261. }
  262. .status-title { font-size: 34rpx; font-weight: bold; margin-bottom: 50rpx; }
  263. .action-btns { display: flex; width: 100%; gap: 20rpx; }
  264. .btn-retry { flex: 1; background: #e8f0ff; color: #2b5cff; border-radius: 40rpx; font-size: 28rpx; height: 80rpx; line-height: 80rpx; }
  265. .btn-report { flex: 1; background: #2b5cff; color: #fff; border-radius: 40rpx; font-size: 28rpx; height: 80rpx; line-height: 80rpx; }
  266. .chart-card { background: #fff; border-radius: 20rpx; padding: 30rpx; margin-bottom: 30rpx; }
  267. .card-title { font-size: 30rpx; font-weight: bold; margin-bottom: 30rpx; }
  268. .ability-list { display: grid; grid-template-columns: 1fr 1fr; gap: 20rpx; }
  269. .ability-item { padding: 20rpx; background: #f8f9fb; border-radius: 12rpx; display: flex; flex-direction: column; gap: 10rpx; }
  270. .ability-item .name { font-size: 26rpx; color: #666; }
  271. .score-wrap { display: flex; align-items: center; justify-content: space-between; }
  272. .score { font-size: 32rpx; font-weight: bold; }
  273. .score.pass { color: #52c41a; }
  274. .score.fail { color: #ff4d4f; }
  275. .status-symbol { font-size: 28rpx; font-weight: bold; }
  276. .status-symbol.pass { color: #52c41a; }
  277. .status-symbol.fail { color: #ff4d4f; }
  278. .training-recommend { margin-top: 40rpx; }
  279. .section-title { font-size: 32rpx; font-weight: bold; margin-bottom: 20rpx; }
  280. /* 培训卡片样式 - 同首页 */
  281. .training-card {
  282. background: #FFF; border-radius: 32rpx; padding: 32rpx; margin-bottom: 20rpx;
  283. box-shadow: 0 4rpx 24rpx rgba(0,0,0,0.03);
  284. }
  285. .training-card .t-title { font-size: 32rpx; font-weight: bold; color: #1A1A1A; line-height: 1.4; display: block; margin-bottom: 20rpx; }
  286. .tag-row { display: flex; gap: 10rpx; margin: 12rpx 0; }
  287. .tag-badge {
  288. font-size: 20rpx; color: #999; background: #F5F7FA; padding: 6rpx 14rpx; border-radius: 6rpx;
  289. }
  290. .tag-badge.type-tag { color: #1F6CFF; background: rgba(31, 108, 255, 0.08); }
  291. .tag-badge.category-tag { color: #FF9500; background: rgba(255, 149, 0, 0.08); }
  292. .info-list { margin-top: 24rpx; display: flex; flex-direction: column; gap: 16rpx; }
  293. .info-item { display: flex; align-items: center; }
  294. .i-icon { width: 28rpx; height: 28rpx; margin-right: 16rpx; opacity: 0.5; }
  295. .i-text { font-size: 26rpx; color: #666; }
  296. </style>