examTask.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. <!-- 考试承诺书弹窗 -->
  25. <uni-popup ref="preExamDialog" type="center" :mask-click="false">
  26. <view class="pre-exam-dialog">
  27. <view class="dialog-header">
  28. <text class="dialog-title">考试承诺书</text>
  29. </view>
  30. <view class="dialog-body">
  31. <scroll-view scroll-y class="content-scroll">
  32. <richTextPdf ref="richTextPdf" :content="richTextHtml" />
  33. </scroll-view>
  34. </view>
  35. <view class="dialog-footer">
  36. <view v-if="preButtonType" class="btn btn-border" @click="downloadCommitment">下载</view>
  37. <view class="btn btn-primary" @click="confirmCommitment">确认</view>
  38. </view>
  39. </view>
  40. </uni-popup>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. examUserExamStudyTaskList,
  46. } from '@/pages_safetyEducationExamination/api/index.js'
  47. import {
  48. goToExamPage,
  49. confirmCommitmentAndStart,
  50. startFormalExam,
  51. } from '@/pages_safetyEducationExamination/utils/index.js'
  52. import richTextPdf from '@/pages_safetyEducationExamination/component/richTextPdf.vue'
  53. export default {
  54. components: {
  55. richTextPdf
  56. },
  57. data() {
  58. return {
  59. onlineExamList: [],
  60. // 承诺书相关
  61. preButtonType: false,
  62. richTextHtml: '',
  63. preData: null,
  64. itemData:{},
  65. }
  66. },
  67. mounted() {
  68. this.loadTaskList();
  69. },
  70. methods: {
  71. goToPage(type, item) {
  72. if (type == 1) {
  73. uni.navigateTo({ url: '/pages_safetyEducationExamination/views/exam/index' });
  74. return;
  75. }else{
  76. this.$set(this,'itemData',item);
  77. goToExamPage(item, {
  78. openCommitmentDialog: (examItem) => {
  79. this.preButtonType = examItem.commitmentPrintEnabled == 1;
  80. this.richTextHtml = examItem.commitmentContent;
  81. this.preData = examItem;
  82. this.$refs.preExamDialog.open();
  83. },
  84. });
  85. }
  86. },
  87. // 下载承诺书
  88. downloadCommitment() {
  89. uni.showToast({ title: '正在下载,请耐心等候', icon: 'none' });
  90. this.$refs.richTextPdf.downloadPDF();
  91. },
  92. // 确认承诺书
  93. async confirmCommitment() {
  94. await confirmCommitmentAndStart(this.preData, () => {
  95. this.$refs.preExamDialog.close();
  96. startFormalExam(this.itemData);
  97. });
  98. },
  99. // 获取任务列表
  100. async loadTaskList() {
  101. try {
  102. const { data } = await examUserExamStudyTaskList({ page: 1, pageSize: 1, examStatus: 2, isSpecialExam: false });
  103. if (data.code === 200) {
  104. this.$set(this, 'onlineExamList', data.data.records);
  105. }
  106. } catch (e) { console.error('获取考试任务失败', e); }
  107. },
  108. },
  109. }
  110. </script>
  111. <style lang="stylus" scoped>
  112. .examTask-component {
  113. margin: 0 32rpx 32rpx;
  114. .card {
  115. background: #fff;
  116. border-radius: 24rpx;
  117. overflow: hidden;
  118. margin-bottom: 24rpx;
  119. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  120. border: 1px solid #dde3ed;
  121. }
  122. .card-header {
  123. padding: 20rpx 28rpx;
  124. display: flex;
  125. justify-content: space-between;
  126. align-items: center;
  127. .card-title {
  128. font-size: 28rpx;
  129. color: #333;
  130. }
  131. .header-subtitle{
  132. margin-top:10rpx;
  133. font-size:22rpx;
  134. color:#8896a7;
  135. }
  136. .header-link {
  137. padding:10rpx 20rpx;
  138. font-size: 24rpx;
  139. color: #1857d4;
  140. }
  141. }
  142. .card-body {
  143. padding: 0 28rpx 24rpx;
  144. .for-max-box:nth-child(1){
  145. margin-top:0;
  146. }
  147. .for-max-box{
  148. margin-top:20rpx;
  149. display: flex;
  150. background-color:#f4f6fa;
  151. padding: 20rpx 24rpx;
  152. border-radius: 16rpx;
  153. .left-box{
  154. flex:1;
  155. view:nth-child(1){
  156. font-size:26rpx;
  157. margin-bottom:4rpx;
  158. }
  159. view:nth-child(2){
  160. font-size:22rpx;
  161. color:#8896a7;
  162. }
  163. }
  164. .right-box{
  165. line-height:60rpx;
  166. font-size:40rpx;
  167. color:#8896a7;
  168. }
  169. }
  170. .empty-tip{
  171. text-align: center;
  172. line-height:40rpx;
  173. color:#8896a7;
  174. font-size:24rpx;
  175. }
  176. }
  177. }
  178. // 承诺书弹窗样式
  179. .pre-exam-dialog {
  180. width: 600rpx;
  181. max-height: 80vh;
  182. background: #fff;
  183. border-radius: 20rpx;
  184. overflow: hidden;
  185. }
  186. .dialog-header {
  187. padding: 32rpx;
  188. border-bottom: 1rpx solid #eee;
  189. .dialog-title {
  190. font-size: 32rpx;
  191. font-weight: 600;
  192. color: #333;
  193. }
  194. }
  195. .dialog-body {
  196. height: 800rpx;
  197. overflow: hidden;
  198. .content-scroll {
  199. height: 100%;
  200. }
  201. }
  202. .dialog-footer {
  203. display: flex;
  204. gap: 20rpx;
  205. padding: 24rpx 32rpx;
  206. border-top: 1rpx solid #eee;
  207. .btn {
  208. flex: 1;
  209. height: 72rpx;
  210. line-height: 72rpx;
  211. text-align: center;
  212. font-size: 28rpx;
  213. border-radius: 12rpx;
  214. }
  215. .btn-border {
  216. background: #fff;
  217. color: #1857d4;
  218. border: 1rpx solid #1857d4;
  219. }
  220. .btn-primary {
  221. background: #1857d4;
  222. color: #fff;
  223. }
  224. }
  225. </style>