examTask.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <!-- 考试任务 -->
  2. <template>
  3. <view class="examTask-component">
  4. <view class="card">
  5. <view class="card-header">
  6. <view class="header-left">
  7. <view class="card-title">考试任务</view>
  8. <view class="header-subtitle">待完成的学习考试任务</view>
  9. </view>
  10. <text class="header-link" @click="goToPage('1')">更多 ›</text>
  11. </view>
  12. <view class="card-body">
  13. <view class="for-max-box" @click="goToPage('2',item)"
  14. v-for="(item,index) in onlineExamList" :key="index">
  15. <view class="left-box">
  16. <view>{{item.examName}}</view>
  17. <view>待完成</view>
  18. </view>
  19. <view class="right-box">›</view>
  20. </view>
  21. <view v-if="!onlineExamList[0]" class="empty-tip">暂无考试任务</view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. examUserExamStudyTaskList,
  29. } from '@/pages_safetyEducationExamination/api/index.js'
  30. export default {
  31. data() {
  32. return {
  33. onlineExamList:[],
  34. }
  35. },
  36. created() {
  37. },
  38. mounted() {
  39. this.examUserExamStudyTaskList();
  40. },
  41. methods: {
  42. goToPage(type,item){
  43. if(type == 1){
  44. //考试列表
  45. uni.navigateTo({
  46. url: '/pages_safetyEducationExamination/views/exam/index',
  47. });
  48. }else if(type == 2){
  49. //开始考试相关业务
  50. if(item.conditionType == 1){
  51. if(item.examStudy&&item.courseId){
  52. //学习课程
  53. let obj = {
  54. courseId: item.courseId,
  55. examId: item.examId,
  56. }
  57. //等待后续逻辑
  58. }else{
  59. //学时要求
  60. if(item.knowledgePointIds&&item.completedStudyHours&&item.studyHoursRequirement){
  61. //学时知识点
  62. uni.navigateTo({
  63. url: '/pages_safetyEducationExamination/views/studyHourTask/index',
  64. });
  65. }else{
  66. //无知识点要求
  67. uni.navigateTo({
  68. url: '/pages_safetyEducationExamination/views/study/index',
  69. });
  70. }
  71. }
  72. }else if(item.conditionType == 2){
  73. //学习课程
  74. let obj = {
  75. courseId: item.courseId,
  76. examId: item.examId,
  77. }
  78. //等待后续逻辑
  79. }else if(item.conditionType == 3){
  80. //模拟考试
  81. if(item.mockExamId){
  82. let obj = {
  83. examId: item.examId,
  84. attemptId: item.mockExamId,
  85. }
  86. //等待后续逻辑
  87. }else{
  88. this.examUserExamStart({examId:item.examId,examScene:2});
  89. }
  90. }else if(item.conditionType == 4){
  91. //开始考试
  92. }
  93. }
  94. },
  95. //模拟考试获取试卷
  96. async examUserExamStart(obj) {
  97. try {
  98. const { data } = await examUserExamStart(obj);
  99. if (data.code === 200) {
  100. let obj = {
  101. examId: item.examId,
  102. attemptId: response.data.attemptId,
  103. }
  104. //等待后续逻辑
  105. }
  106. } catch (e) { console.error('模拟考试获取试卷失败', e); }
  107. },
  108. //开始考试判断是否有承诺书
  109. setRichExamData(item){
  110. if(item.commitmentEnabled == 1 && !item.commitmentConfirmed){
  111. //富文本弹窗考试承诺书
  112. this.$set(this,'preButtonType',item.commitmentPrintEnabled == 1?true:false);
  113. this.$set(this,'richTextHtml',item.commitmentContent);
  114. this.$set(this,'preData',item);
  115. this.$set(this,'preExamDialogType',true);
  116. }else{
  117. if(item.attemptId){
  118. //上次考试未完成继续考试
  119. let obj = {
  120. attemptId: item.attemptId,
  121. type: '1',
  122. examKind:item.examKind,
  123. }
  124. //等待后续逻辑
  125. }else{
  126. //开始新考试
  127. this.examUserExamStart(item);
  128. }
  129. }
  130. },
  131. //开始考试
  132. async examUserExamStart(item) {
  133. try {
  134. let obj = {examId:item.examId,examScene:1};
  135. const { data } = await examUserExamStudyTaskList(obj);
  136. if (data.code === 200) {
  137. let obj = {
  138. examId: item.examId,
  139. attemptId: response.data.attemptId,
  140. type: '1',
  141. examKind:item.examKind,
  142. }
  143. //等待后续逻辑
  144. }
  145. } catch (e) { console.error('获取考试任务失败', e); }
  146. },
  147. //获取任务列表
  148. async examUserExamStudyTaskList() {
  149. try {
  150. let obj = { page: 1, pageSize: 1, examStatus: 2, isSpecialExam: false };
  151. const { data } = await examUserExamStudyTaskList(obj);
  152. if (data.code === 200) {
  153. this.$set(this,'onlineExamList',data.data.records);
  154. }
  155. } catch (e) { console.error('获取考试任务失败', e); }
  156. },
  157. },
  158. }
  159. </script>
  160. <style lang="stylus" scoped>
  161. .examTask-component {
  162. margin: 0 32rpx 32rpx;
  163. .card {
  164. background: #fff;
  165. border-radius: 24rpx;
  166. overflow: hidden;
  167. margin-bottom: 24rpx;
  168. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  169. border: 1px solid #dde3ed;
  170. }
  171. .card-header {
  172. padding: 20rpx 28rpx;
  173. display: flex;
  174. justify-content: space-between;
  175. align-items: center;
  176. .card-title {
  177. font-size: 28rpx;
  178. color: #333;
  179. }
  180. .header-subtitle{
  181. margin-top:10rpx;
  182. font-size:22rpx;
  183. color:#8896a7;
  184. }
  185. .header-link {
  186. padding:10rpx 20rpx;
  187. font-size: 24rpx;
  188. color: #1857d4;
  189. }
  190. }
  191. .card-body {
  192. padding: 0 28rpx 24rpx;
  193. .for-max-box:nth-child(1){
  194. margin-top:0;
  195. }
  196. .for-max-box{
  197. margin-top:20rpx;
  198. display: flex;
  199. background-color:#f4f6fa;
  200. padding: 20rpx 24rpx;
  201. border-radius: 16rpx;
  202. .left-box{
  203. flex:1;
  204. view:nth-child(1){
  205. font-size:26rpx;
  206. margin-bottom:4rpx;
  207. }
  208. view:nth-child(2){
  209. font-size:22rpx;
  210. color:#8896a7;
  211. }
  212. }
  213. .right-box{
  214. line-height:60rpx;
  215. font-size:40rpx;
  216. color:#8896a7;
  217. }
  218. }
  219. .empty-tip{
  220. text-align: center;
  221. line-height:40rpx;
  222. color:#8896a7;
  223. font-size:24rpx;
  224. }
  225. }
  226. }
  227. </style>