马宇豪
2024-07-22 7ac5363a676588078fdce082a45a28300479e158
pages/tabBar/firstPage/firstPage.vue
@@ -13,7 +13,7 @@
         </view>
      </view>
    <view style="width: 100%;padding: 0 15px;box-sizing: border-box;margin: 20px 0">
      <u-swiper :list="swiperList"></u-swiper>
      <u-swiper :list="swiperList" indicatorMode="dot" circular height="160" indicator previousMargin="30" nextMargin="30"></u-swiper>
    </view>
    <view class="m-p-15">
      <view class="card" style="width:100%">
@@ -32,7 +32,7 @@
                <span style="color: #999;font-size: 12px;display: flex;align-items: center"><u-icon name="account" color="#999" size="18" style="margin-bottom: 0;margin-right: 2px"></u-icon>{{item.createName +'('+ item.createTime +')'}}</span>
              </view>
              <view class="card-i-r-b">
                <u-tag icon="clock" :text="item.course.period + '分钟'" type="success" size="mini" shape="circle" plain plainFill></u-tag>
                <u-tag icon="clock" :text="secondsToHms(item.course.period)" type="success" size="mini" shape="circle" plain plainFill></u-tag>
                <u-button class="study-button" type="primary" text="开始学习" shape="circle" size="small" @click="toStudy(item.id)"></u-button>
              </view>
            </view>
@@ -50,11 +50,12 @@
                       @scrolltolower="lower" lower-threshold="150" @scroll="scrollView" style="height:350px">
            <view class="paper-card" v-for="(item,index) in examList" :key="index">
              <view class="paper-card-t"><span :class="item.completed == 1?'green':'red'">[{{item.completed == 1?'已完成':'未完成'}}]</span>{{item.examPaper.name}}</view>
              <view style="color: #999;margin-bottom: 15px;font-size: 12px">{{item.examPaper.code}}</view>
              <u-tag style="margin-right: 20rpx;display: inline-block" :text="item.examPaper.categoryName" size="mini"></u-tag>
              <u-tag style="display: inline-block" :text="'时长:' + item.examPaper.limitTime + '分钟'" plain plainFill size="mini"></u-tag>
              <view class="paper-card-b">
                <view style="display: flex;align-items: center">
                  <u-tag style="margin-right: 20rpx" :text="item.examPaper.categoryName" size="mini"></u-tag>
                  <u-tag :text="item.createName" plain plainFill size="mini"></u-tag>
                <view style="font-size: 12px;margin-top: 10px;color: #999">
                  <view>创建人:{{item.createName}}</view>
                  <view>截止日期:{{item.examPaper.deadline.substring(0,10)}}</view>
                </view>
                <view>
                  <u-button v-if="item.completed == 0" @click="toExam(item,1)" class="exam-button" type="primary" text="开始考试" shape="circle" size="small"></u-button>
@@ -75,6 +76,7 @@
   import {getClassList, getExamList, getSwiperList} from '../../../api/index.js'
  import VUE_APP_BASE_URL from 'common/constant.js'
import { Value } from 'sass';
  import {postEndExam} from "../../../api/wearhouse";
   export default {
      components:{
         tabBar
@@ -187,10 +189,39 @@
      },
      toExam(item,type){
        uni.setStorageSync("prevPage", '/pages/tabBar/firstPage/firstPage');
        uni.navigateTo({
          url: `/pages/tabBar/firstPage/exam?bank=` + encodeURIComponent(JSON.stringify(item)) + `&type=` + encodeURIComponent(JSON.stringify(type))
        })
        if(type == 1 && !item.startTime){
          uni.showModal({
            title: '提示',
            content: '该考试限制时长为:' + item.examPaper.limitTime + '分钟,进入后开始计时,计时结束自动交卷,是否继续?',
            success: function (res) {
              if (res.confirm) {
                uni.setStorageSync("prevPage", '/pages/tabBar/firstPage/firstPage');
                uni.navigateTo({
                  url: `/pages/tabBar/firstPage/exam?bank=` + encodeURIComponent(JSON.stringify(item)) + `&type=` + encodeURIComponent(JSON.stringify(type))
                })
              } else if (res.cancel) {
                console.log('用户点击取消');
              }
            }
          })
        }else{
          uni.setStorageSync("prevPage", '/pages/tabBar/firstPage/firstPage');
          uni.navigateTo({
            url: `/pages/tabBar/firstPage/exam?bank=` + encodeURIComponent(JSON.stringify(item)) + `&type=` + encodeURIComponent(JSON.stringify(type))
          })
        }
      },
      secondsToHms(seconds) {
        seconds = Number(seconds);
        const h = Math.floor(seconds / 3600);
        const m = Math.floor(seconds % 3600 / 60);
        const s = Math.floor(seconds % 3600 % 60);
        const hDisplay = h > 0 ? String(h).padStart(2, '0') : '00';
        const mDisplay = m > 0 ? String(m).padStart(2, '0') : '00';
        const sDisplay = s > 0 ? String(s).padStart(2, '0') : '00';
        return `${hDisplay}:${mDisplay}:${sDisplay}`;
      },
      upper(e) {
@@ -280,7 +311,7 @@
  .card-c{
    background: #fff;
    border-radius: 16px;
    border-radius: 20px;
    padding: 15px;
    .card-i{
@@ -355,7 +386,7 @@
      padding: 15px;
      box-sizing: border-box;
      position: relative;
      border-radius: 16px;
      border-radius: 20px;
      &:last-of-type{
        margin-bottom: 0;
@@ -382,7 +413,7 @@
      .paper-card-b{
        display: flex;
        align-items: center;
        align-items: flex-end;
        justify-content: space-between;
        .exam-button{