123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <template>
- <view class="container">
- <!-- 设置圆角 -->
- <view style="padding: 10px 30px 10px 30px;">
- <uni-search-bar :radius="100" @input="search" placeholder="搜索考试"></uni-search-bar>
- </view>
- <view style="background: #f5f5f5">
- <uni-segmented-control :current="current" :values="tabs" @clickItem="changeTab" styleType="text"
- activeColor="#007aff">
- </uni-segmented-control>
- </view>
- <yf-more-list url="/api/exam/exam/online-paging" :params="queryParams" ref="moreList">
- <template v-slot:item="{ data }">
- <!-- link="navigateTo"
- :to="'/pages/exam/detail?id='+data.id" -->
- <!-- :clickable="true" @click="funJump(data)" -->
- <uni-list-item :show-arrow="true" :title="data.title"
- :note="'关联培训:'+ (data.associate === 1? '是': '否') +' \n 发布时间:'+data.createTime"
- :rightText="data.timeLimit?'限时': '不限时'" :to="'/pages/exam/detail?id='+data.id" link="navigateTo">
- </uni-list-item>
- </template>
- </yf-more-list>
- </view>
- </template>
- <script>
- import {
- checkProcess
- } from '@/api/exam.js'
- export default {
- data() {
- return {
- current: 0,
- tabs: ['全部', '考试中', '未开始', '已结束'],
- queryParams: {
- title: '',
- examState: ''
- }
- }
- },
- onPullDownRefresh() {
- // 加载数据
- this.$refs.moreList.loadData()
- this.checkExam()
- },
- onReachBottom() {
- // 加载数据
- this.$refs.moreList.loadData()
- },
- onShow() {
- if (this.$refs.moreList) {
- this.$refs.moreList.initData()
- }
- this.checkExam()
- },
- methods: {
- funJump(obj) {
- if (obj.associate === 1) {
- uni.showModal({
- cancelText: "取消", // 取消按钮的文字
- confirmText: "确认", // 确认按钮文字
- title: '培训提示',
- content: '该考试已关联培训,是否跳转培训?',
- success: res => {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/course/detail?id=' + obj.courseId
- })
- }else{
- uni.navigateTo({
- url: '/pages/exam/detail?id=' + obj.id
- })
- }
- }
- });
- } else {
- uni.navigateTo({
- url: '/pages/exam/detail?id=' + obj.id
- })
- }
- },
- checkExam() {
- checkProcess().then(data => {
- if (data && data.id) {
- uni.showModal({
- cancelText: "取消", // 取消按钮的文字
- confirmText: "确认", // 确认按钮文字
- title: '删除提示',
- content: '您有正在进行的考试,是否继续考试?',
- success: res => {
- if (res.confirm) {
- this.continueExam(data.id)
- }
- }
- });
- }
- })
- },
- // 考试详情页
- search(e) {
- this.queryParams.title = e
- },
- changeTab(e) {
- if (this.current != e.currentIndex) {
- this.current = e.currentIndex;
- }
- let state = null;
- if (e.currentIndex != 0) {
- state = e.currentIndex - 1
- }
- this.queryParams.examState = state
- },
- // 继续考试
- continueExam(id) {
- uni.redirectTo({
- url: '/pages/exam/exam?id=' + id
- });
- },
- }
- }
- </script>
- <style>
- .container {
- font-size: 14rpx;
- }
- .exam-item {
- display: flex;
- align-items: center;
- line-height: 25px;
- }
- .exam-item .left {
- text-align: left;
- flex-grow: 1;
- }
- .exam-item .left .desc {
- color: #888;
- }
- .exam-item .left .icons {
- font-size: 10px;
- display: flex;
- align-items: center;
- color: #666;
- }
- .exam-item .right {
- text-align: right;
- }
- .pass {
- color: #007AFF !important;
- margin-right: 5px;
- }
- .fail {
- color: #ff0000 !important;
- margin-right: 5px;
- }
- </style>
|