index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view class="container">
  3. <!-- 设置圆角 -->
  4. <view style="padding: 10px 30px 10px 30px;">
  5. <uni-search-bar :radius="100" @input="search" placeholder="搜索考试"></uni-search-bar>
  6. </view>
  7. <view style="background: #f5f5f5">
  8. <uni-segmented-control :current="current" :values="tabs" @clickItem="changeTab" styleType="text"
  9. activeColor="#007aff">
  10. </uni-segmented-control>
  11. </view>
  12. <yf-more-list url="/api/exam/exam/online-paging" :params="queryParams" ref="moreList">
  13. <template v-slot:item="{ data }">
  14. <!-- link="navigateTo"
  15. :to="'/pages/exam/detail?id='+data.id" -->
  16. <!-- :clickable="true" @click="funJump(data)" -->
  17. <uni-list-item :show-arrow="true" :title="data.title"
  18. :note="'关联培训:'+ (data.associate === 1? '是': '否') +' \n 发布时间:'+data.createTime"
  19. :rightText="data.timeLimit?'限时': '不限时'" :to="'/pages/exam/detail?id='+data.id" link="navigateTo">
  20. </uni-list-item>
  21. </template>
  22. </yf-more-list>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. checkProcess
  28. } from '@/api/exam.js'
  29. export default {
  30. data() {
  31. return {
  32. current: 0,
  33. tabs: ['全部', '考试中', '未开始', '已结束'],
  34. queryParams: {
  35. title: '',
  36. examState: ''
  37. }
  38. }
  39. },
  40. onPullDownRefresh() {
  41. // 加载数据
  42. this.$refs.moreList.loadData()
  43. this.checkExam()
  44. },
  45. onReachBottom() {
  46. // 加载数据
  47. this.$refs.moreList.loadData()
  48. },
  49. onShow() {
  50. if (this.$refs.moreList) {
  51. this.$refs.moreList.initData()
  52. }
  53. this.checkExam()
  54. },
  55. methods: {
  56. funJump(obj) {
  57. if (obj.associate === 1) {
  58. uni.showModal({
  59. cancelText: "取消", // 取消按钮的文字
  60. confirmText: "确认", // 确认按钮文字
  61. title: '培训提示',
  62. content: '该考试已关联培训,是否跳转培训?',
  63. success: res => {
  64. if (res.confirm) {
  65. uni.navigateTo({
  66. url: '/pages/course/detail?id=' + obj.courseId
  67. })
  68. }else{
  69. uni.navigateTo({
  70. url: '/pages/exam/detail?id=' + obj.id
  71. })
  72. }
  73. }
  74. });
  75. } else {
  76. uni.navigateTo({
  77. url: '/pages/exam/detail?id=' + obj.id
  78. })
  79. }
  80. },
  81. checkExam() {
  82. checkProcess().then(data => {
  83. if (data && data.id) {
  84. uni.showModal({
  85. cancelText: "取消", // 取消按钮的文字
  86. confirmText: "确认", // 确认按钮文字
  87. title: '删除提示',
  88. content: '您有正在进行的考试,是否继续考试?',
  89. success: res => {
  90. if (res.confirm) {
  91. this.continueExam(data.id)
  92. }
  93. }
  94. });
  95. }
  96. })
  97. },
  98. // 考试详情页
  99. search(e) {
  100. this.queryParams.title = e
  101. },
  102. changeTab(e) {
  103. if (this.current != e.currentIndex) {
  104. this.current = e.currentIndex;
  105. }
  106. let state = null;
  107. if (e.currentIndex != 0) {
  108. state = e.currentIndex - 1
  109. }
  110. this.queryParams.examState = state
  111. },
  112. // 继续考试
  113. continueExam(id) {
  114. uni.redirectTo({
  115. url: '/pages/exam/exam?id=' + id
  116. });
  117. },
  118. }
  119. }
  120. </script>
  121. <style>
  122. .container {
  123. font-size: 14rpx;
  124. }
  125. .exam-item {
  126. display: flex;
  127. align-items: center;
  128. line-height: 25px;
  129. }
  130. .exam-item .left {
  131. text-align: left;
  132. flex-grow: 1;
  133. }
  134. .exam-item .left .desc {
  135. color: #888;
  136. }
  137. .exam-item .left .icons {
  138. font-size: 10px;
  139. display: flex;
  140. align-items: center;
  141. color: #666;
  142. }
  143. .exam-item .right {
  144. text-align: right;
  145. }
  146. .pass {
  147. color: #007AFF !important;
  148. margin-right: 5px;
  149. }
  150. .fail {
  151. color: #ff0000 !important;
  152. margin-right: 5px;
  153. }
  154. </style>