examTask.vue 5.3 KB

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