安全教育平台微信小程序(hbuilder打开后运行到微信开发者程序)
祖安之光
2025-11-05 f4ed2c4a1412f7256614e04e18683ca15a89bb25
pages/tabBar/firstPage/firstPage.vue
@@ -1,18 +1,24 @@
<template>
   <view>
      <!-- 自定义导航栏 -->
<!--       <view class="navBarBox fix">
         <view class="statusBar" :style="{ paddingTop: statusBarHeight + 'px' }"></view>
         <view class="navBar">
            <view class="barText">首页</view>
   <view>
      <view class="custom-navbar">
         <view class="navbar-content">
            <view class="nav-left" @click="handleBack">
               <view class="back-btn">
                  <text class="back-text">返回</text>
         </view>
      </view> -->
            </view>
            <text class="navbar-title">安全教育</text>
            <view class="nav-right"></view>
         </view>
      </view>
      <view class="page-content" :style="{ paddingTop: navbarHeight + 'px' }">
    <view style="width: 100%;padding: 0 15px;box-sizing: border-box;margin: 20px 0">
      <u-swiper :list="swiperList" indicatorMode="dot" bgColor="#f5f7fa" circular height="160" indicator previousMargin="30" nextMargin="30"></u-swiper>
            <u-swiper :list="swiperList" indicatorMode="dot" bgColor="#f5f7fa" circular height="160" indicator
               previousMargin="30" nextMargin="30"></u-swiper>
    </view>
    <scroll-view scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
                 @scrolltolower="lower" lower-threshold="150" @scroll="scrollView" style="height:calc(100vh - 180px)">
         <scroll-view scroll-y="true" class="scroll-Y" @scrolltoupper="upper" @scrolltolower="lower"
            lower-threshold="150" @scroll="scrollView" style="height:calc(100vh - 244px)">
    <view class="m-p-15">
      <view class="card" style="width:100%">
        <view class="card-t">
@@ -21,17 +27,23 @@
        </view>
        <view class="card-c" v-if="Array.isArray(classList) && classList.length>0">
          <view class="card-i" v-for="(item,index) in classList" :key="index">
            <u-image radius="16px" width="200rpx" height="200rpx" :show-loading="true" :src="getImageUrl(item.course.logo)" mode="aspectFill">
                        <u-image radius="16px" width="200rpx" height="200rpx" :show-loading="true"
                           :src="getImageUrl(item.course.logo)" mode="aspectFill">
            </u-image>
            <!--            <view class="card-i-t">目前已学:{{item.totalProgress}}分钟</view>-->
            <view class="card-i-r">
              <view class="card-i-r-t">
                <view>{{item.phaseName + '-' + item.course.name}}</view>
                <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>
                              <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="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)"></u-button>
                              <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)"></u-button>
              </view>
            </view>
          </view>
@@ -61,13 +73,17 @@
              
        </view>
        <view class="card-c card-d" v-if="examList && examList.length>0">
            <view class="paper-card" v-for="(item,index) in examList" :key="index" @click="toExam(item)">
                     <view class="paper-card" v-for="(item,index) in examList" :key="index"
                        @click="toExam(item)">
              <view class="paper-card-t">
              <!-- <span :class="item.state == 0?'blue':item.state == 1?'red':'green'">[{{item.state == 0?'待考试':item.state == 1?'待批阅':'批阅完成'}}]</span> -->
              {{item.examPaper.name}}</view>
                           {{item.examPaper.name}}
                        </view>
              <view class="tag-area">
             <u-tag :text="item.examPaper.categoryName" plain size="mini"></u-tag>
             <u-tag :text="item.examPaper.limited == 1?'时长:' + item.examPaper.limitTime + '分钟':'不限时'" type="warning" plain size="mini"></u-tag>
                           <u-tag
                              :text="item.examPaper.limited == 1?'时长:' + item.examPaper.limitTime + '分钟':'不限时'"
                              type="warning" plain size="mini"></u-tag>
           </view>
              <view class="paper-card-b">
                <view style="font-size: 12px;margin-top: 5px;color: #999">
@@ -78,7 +94,8 @@
                  <u-button @click="toExam(item,1)" class="exam-button" type="primary" text="开始考试" shape="circle" size="small"></u-button>
                </view> -->
            <view class="btn-area" v-if="item.state == 2">
               <u-button @tap.stop="reExam(item)" class="exam-button" type="primary" text="重新考试" shape="circle" size="small"></u-button>
                              <u-button @tap.native.stop="reExam(item)" class="exam-button" type="primary"
                                 text="重新考试" shape="circle" size="small"></u-button>
               <!-- <u-button @click="toExam(item,2)" class="re-exam-button" type="primary" text="查看" shape="circle" size="small"></u-button> -->
            </view>
              </view>
@@ -92,26 +109,33 @@
    </scroll-view>
   </view>
   </view>
</template>
<script>
   import {getClassList, getExamList, getSwiperList} from '../../../api/index.js'
   import {
      getClassList,
      getExamList,
      getSwiperList
   } from '../../../api/index.js'
   import VUE_APP_BASE_URL from 'common/constant.js'
   import {postEndExam, postAgainExam} from "../../../api/wearhouse";
   import {
      postEndExam,
      postAgainExam
   } from "../../../api/wearhouse";
   export default {
      components:{},
      data() {
         return {
            navbarHeight: 0,
            showSelect:false,
        swiperList: [
          '/static/defaultCover.jpg','/static/defaultCover.jpg','/static/defaultCover.jpg'
        ],
      titleList:[
         {
            titleList: [{
            label: '默认排序',
            value: 1,
         }
      ],
            }],
        classList: [],
        examList: [],
        totalPage: 0,
@@ -127,9 +151,12 @@
          state: 0
        },
      currentTab: 0,
        examSelect: [
          { name: "待考试" },
          { name: "批阅完成" }
            examSelect: [{
                  name: "待考试"
               },
               {
                  name: "批阅完成"
               }
        ],
            role: '',
            realname:''
@@ -138,7 +165,7 @@
      },
      onLoad() {
         //获取手机状态栏高度
         this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
         this.getNavbarHeight()
   
      this.examList = []
      this.classParams.pageNum = 1
@@ -148,14 +175,21 @@
      this.getExamList()
      },
      onShow(){
         // this.role = uni.getStorageSync('roleName');
         // this.realname = uni.getStorageSync('user').realName
      // this.tabBarLists = uni.getStorageSync('tabBarList');
      },
    created(){
    },
      created() {},
      methods: {
         getNavbarHeight() {
            const systemInfo = uni.getSystemInfoSync()
            const statusBarHeight = systemInfo.statusBarHeight
            const navbarHeight = 44
            this.navbarHeight = statusBarHeight + navbarHeight
         },
         handleBack() {
            uni.navigateTo({
               url: '/pages/menuPage/index'
            })
         },
         loginOut() {
            uni.clearStorageSync();
            uni.clearStorage();
@@ -231,7 +265,6 @@
      },
      toExam(item){
        console.log(item,'item')
        if(item.state == 0 && item.examPaper.deadline){
         const deadline = item.examPaper.deadline
         const deadlineTime = new Date(deadline).getTime()
@@ -244,12 +277,15 @@
        if(item.state == 0){
          uni.showModal({
            title: '提示',
            content: item.examPaper.limited == 1?'该考试限制时长为:' + item.examPaper.limitTime + '分钟,进入后开始计时,计时结束自动交卷,是否继续?':'是否确认考试?',
                  content: item.examPaper.limited == 1 ? '该考试限制时长为:' + 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(1))
                           url: `/pages/tabBar/firstPage/exam?bank=` + encodeURIComponent(JSON
                              .stringify(item)) + `&type=` + encodeURIComponent(JSON
                              .stringify(1))
                })
              } else if (res.cancel) {
                console.log('用户点击取消');
@@ -259,7 +295,8 @@
        }else{
          uni.setStorageSync("prevPage", '/pages/tabBar/firstPage/firstPage');
          uni.navigateTo({
            url: `/pages/tabBar/firstPage/exam?bank=` + encodeURIComponent(JSON.stringify(item)) + `&type=` + encodeURIComponent(JSON.stringify(2))
                  url: `/pages/tabBar/firstPage/exam?bank=` + encodeURIComponent(JSON.stringify(item)) +
                     `&type=` + encodeURIComponent(JSON.stringify(2))
          })
        }
      },
@@ -280,7 +317,10 @@
           content: '是否重新考试?',
           success: async function (res) {
             if (res.confirm) {
               const res = await postAgainExam({paperId: item.paperId,studentId: uni.getStorageSync('uid')})
                     const res = await postAgainExam({
                        paperId: item.paperId,
                        studentId: uni.getStorageSync('uid')
                     })
               if(res.code == 200){
                  uni.$u.toast(res.message)
               t.currentTab = 0
@@ -334,43 +374,70 @@
      }
   }
</script>
<style lang="scss">
.navBarBox .navBar {
   background-color:#fff;
     height: 50px;
     display: flex;
     flex-direction: row;
     justify-content: center;
     align-items: center;
  box-shadow: 0 3px 12px rgba(0,0,0,0.05);
}
.fix{
   position: sticky;
<style lang="scss" scoped>
   .custom-navbar {
      position: fixed;
   top: 0;
   left: 0;
   right: 0;
   width: 100%;
   z-index: 1;
      z-index: 999;
      background: #ffffff;
      border-bottom: 1px solid #f0f0f0;
      .navbar-content {
         display: flex;
         align-items: center;
         justify-content: center;
         height: 44px;
         padding-top: var(--status-bar-height);
}
.barText{
  /* text-align: center; */
      .nav-left {
         flex-shrink: 0;
         width: 80px;
         padding-left: 15px;
         box-sizing: border-box;
      }
      .back-btn {
         display: flex;
         align-items: center;
         padding: 8px 12px 8px 0;
      }
      .back-text {
  font-size: 16px;
  font-weight: 600;
  flex: 2;
  margin-left: 45%;
         color: #000000;
}
.statusBar{
   background-color:lightgrey;
      .navbar-title {
         flex: 1;
         font-size: 16px;
         text-align: center;
         font-weight: bold;
         color: #000000;
}
      .nav-right {
         flex-shrink: 0;
         width: 80px;
      }
   }
   .page-content {
      min-height: calc(100vh - 44px);
   }
.m-p-15{
  width: 100%;
  box-sizing: border-box;
  padding: 0 15px;
}
.card{
  width: 100%;
  margin-bottom: 40rpx;
@@ -388,11 +455,13 @@
      font-size: 36rpx;
      font-weight: bold;
    }
    .card-t-r{
      color: #999;
      cursor: pointer;
     font-size: 28rpx;
    }
    .uni-stat__select{
      display: flex;
      align-items: center;
@@ -435,6 +504,7 @@
        padding-bottom: 0;
        border-bottom: none;
      }
      .card-i-t{
        position: absolute;
        width: 250rpx;
@@ -448,6 +518,7 @@
        bottom: 0;
        background: rgba(0,0,0,.4);
      }
      .card-i-r{
        width: 100%;
        height: 200rpx;
@@ -455,6 +526,7 @@
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        .card-i-r-t{
          view{
            font-size: 36rpx;
@@ -468,6 +540,7 @@
            -webkit-box-orient: vertical;
          }
        }
        .card-i-r-b{
          width: 100%;
          display: flex;
@@ -484,9 +557,11 @@
      }
    }
  }
  .card-d{
    background: none;
    padding: 0 0 15px;
    .paper-card{
      background: #fff;
      margin-bottom: 15px;
@@ -517,6 +592,7 @@
          font-size: 32rpx;
          color: #5ac725
        }
        .red{
          font-size: 32rpx;
          color: #f56c6c
@@ -549,6 +625,7 @@
            border: 1px solid rgba(255,255,255,.8);
         }
      }
      .btn-area2{
         display: flex;
         align-items: center;
@@ -573,5 +650,4 @@
   text-align: center;
   width: 100%;
}
</style>