From aaae9c0a6ecda07e3a1494d9dff124df97e062ce Mon Sep 17 00:00:00 2001 From: 马宇豪 <978517621@qq.com> Date: 星期二, 16 七月 2024 16:33:58 +0800 Subject: [PATCH] 提交 --- pages/tabBar/firstPage/firstPage.vue | 412 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 348 insertions(+), 64 deletions(-) diff --git a/pages/tabBar/firstPage/firstPage.vue b/pages/tabBar/firstPage/firstPage.vue index 010e28c..4fc9317 100644 --- a/pages/tabBar/firstPage/firstPage.vue +++ b/pages/tabBar/firstPage/firstPage.vue @@ -7,92 +7,230 @@ <!-- 真正的导航栏内容 --> <view class="navBar"> <view class="barText">首页</view> +<!-- <view >--> +<!-- <u-button type="text" @click="loginOut" style="color: #1890ff;margin-right: 5px;width: 65px;">退出</u-button>--> +<!-- </view>--> </view> </view> - <view style="display: flex;flex-direction: column;padding: 10px 15px;"> - <view class="first" @click="goExamine"> - 预警审核 - </view> - <view class="first" - @click="goCurrent" - style="background-color:rgb(249, 130, 180) ;" - > - 信息查看 - </view> - <view class="first" - style="background-color: rgb(41, 203, 280);" - @click="goWeather" - > - 实时气象 - </view> - <view class="first" - style="background-color: rgb(11, 246, 158) ;" - @click="goCount" - > - 统计分析 - </view> - - </view> - <tabBar :currentPagePath="page"></tabBar> + <view style="width: 100%;padding: 0 15px;box-sizing: border-box;margin: 20px 0"> + <u-swiper :list="swiperList"></u-swiper> + </view> + <view class="m-p-15"> + <view class="card" style="width:100%"> + <view class="card-t"> + <span class="card-t-l">我的线上课程</span> + <span class="card-t-r" @click="toCourses">查看全部</span> + </view> + <view class="card-c"> + <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> + <!-- <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> + </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-button class="study-button" type="primary" text="开始学习" shape="circle" size="small" @click="toStudy(item.id)"></u-button> + </view> + </view> + </view> + </view> + </view> + </view> + <view class="m-p-15"> + <view class="card" style="width:100%"> + <view class="card-t"> + <span class="card-t-l">我的考试</span> + </view> + <view class="card-c card-d"> + <scroll-view scroll-y="true" class="scroll-Y" @scrolltoupper="upper" + @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> + <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> + <view> + <u-button v-if="item.completed == 0" @click="toExam(item,1)" class="exam-button" type="primary" text="开始考试" shape="circle" size="small"></u-button> + <u-button v-if="item.completed == 1" @click="toExam(item,2)" class="exam-button" type="primary" text="查看" shape="circle" size="small"></u-button> + </view> + </view> + </view> + </scroll-view> + </view> + </view> + </view> + <tabBar :currentPagePath="page"></tabBar> </view> </template> <script> import tabBar from '../tabBarIndex.vue' + import {getClassList, getExamList, getSwiperList} from '../../../api/index.js' + import VUE_APP_BASE_URL from 'common/constant.js' +import { Value } from 'sass'; export default { components:{ tabBar }, data() { return { + swiperList: [ + '/static/home/swiperPic.png','/static/home/swiperPic.png','/static/home/swiperPic.png' + ], + titleList:[ + { + label: '默认排序', + value: 1, + } + ], + classList: [], + examList: [], + totalPage: 0, page: 'pages/tabBar/firstPage/firstPage', statusBarHeight: '', - leaderType: 'da' + classParams:{ + pageNum: 1, + pageSize: 3, + }, + examParams: { + pageNum: 1, + pageSize: 10, + }, + role: '', + realname:'' } }, onLoad() { //获取手机状态栏高度 this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight']; - uni.hideTabBar(); + // uni.hideTabBar(); + this.examList = [] + this.classParams.pageNum = 1 + this.examParams.pageNum = 1 + this.getSwiper() + this.getClass() + this.getExamList() + }, + onShow(){ + // this.role = uni.getStorageSync('roleName'); + // this.realname = uni.getStorageSync('user').realName + // this.tabBarLists = uni.getStorageSync('tabBarList'); + }, methods: { - goExamine() { - uni.switchTab({ - url: '/pages/tabBar/examine/examine' + loginOut() { + uni.clearStorageSync(); + uni.clearStorage(); + uni.navigateTo({ + url: '/pages/index/index' }) }, - goCurrent() { - uni.switchTab({ - url: '/pages/tabBar/current/current' + + async getSwiper(){ + const res = await getSwiperList() + if(res.code == 200){ + let list = res.data.list || [] + if(list.length>0){ + this.swiperList = list.map(i=>VUE_APP_BASE_URL + '/api/' + i.imgUrl) + } + }else{ + uni.$u.toast(res.message) + } + }, + + getClass(){ + getClassList(this.classParams).then(res => { + if(res.code == 200) { + if(res.data && res.data.list.length > 0){ + this.classList = res.data.list + }else { + this.classList = [] + } + }else{ + uni.$u.toast(res.message) + } }) }, - goCount() { - uni.switchTab({ - url: '/pages/tabBar/count/count' - }) - }, - goWeather(){ - uni.switchTab({ - url: '/pages/tabBar/weather/weather' - }) - } + getExamList(){ + getExamList(this.examParams).then(res => { + if(res.code == 200) { + let list = res.data.list?res.data.list: []; + if (res.pageNum != 1) { + this.examList = this.examList.concat(list) + } else { + this.examList = res.data.list + } + this.totalPage = res.data.totalPage + }else{ + uni.$u.toast(res.message) + } + }) + }, + + getImageUrl(logo) { + return logo ? VUE_APP_BASE_URL + '/api/' + logo : '/static/defaultCover.jpg'; + }, + + toStudy(id) { + uni.setStorageSync("prevPage", '/pages/tabBar/firstPage/firstPage'); + uni.navigateTo({ + url: `/pages/tabBar/current/detail?phase_id=` + encodeURIComponent(JSON.stringify(id)) + }) + }, + + 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)) + }) + }, + + upper(e) { + // console.log(e) + }, + lower(e) { + //并且让页码+1,调用获取数据的方法获取第二页数据 + this.examParams.pageNum++ + //此处调用自己获取数据列表的方法 + if (this.examParams.pageNum > this.totalPage){ + uni.$u.toast('已加载全部数据') + return + } + this.getExamList() + }, + scrollView(e) { + // console.log(e) + }, + + toCourses(){ + uni.switchTab({ + url: '/pages/tabBar/current/current' + }) + }, + } } </script> -<style> +<style lang="scss"> .navBarBox .navBar { - background-color:lightgrey; - height: 45px; - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - font-size: 16px; - /* text-align: center; */ - font-weight: 600; + 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; @@ -102,19 +240,165 @@ width: 100%; z-index: 1; } +.barText{ + /* text-align: center; */ + font-size: 16px; + font-weight: 600; + flex: 2; + margin-left: 45%; +} .statusBar{ background-color:lightgrey; } -.first{ - width: 100%; - height: 110px; - background-color: red; - text-align: center; - line-height: 110px; - border-radius: 20px; - background-color: rgb(246,191,170); - border: 1px solid lightgrey; - font-size: 18px; - margin-top: 40px; +.m-p-15{ + width: 100%; + box-sizing: border-box; + padding: 0 15px; } +.card{ + width: 100%; + margin-bottom: 40rpx; + + .card-t{ + width: 100%; + padding: 0 6rpx; + box-sizing: border-box; + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 20rpx; + + .card-t-l{ + font-size: 32rpx; + font-weight: bold; + } + .card-t-r{ + color: #999; + cursor: pointer; + } + } + + .card-c{ + background: #fff; + border-radius: 16px; + padding: 15px; + + .card-i{ + padding-bottom: 15px; + margin-bottom: 15px; + border-bottom: 1px solid #f0f0f0; + position: relative; + display: flex; + align-items: flex-start; + box-sizing: border-box; + + &:last-of-type{ + margin-bottom: 0; + padding-bottom: 0; + border-bottom: none; + } + .card-i-t{ + position: absolute; + width: 250rpx; + height: 30px; + border-radius: 8rpx; + line-height: 30px; + color: #fff; + padding: 0 10rpx; + box-sizing: border-box; + left: 0; + bottom: 0; + background: rgba(0,0,0,.4); + } + .card-i-r{ + width: 100%; + height: 200rpx; + margin-left: 20rpx; + display: flex; + flex-direction: column; + justify-content: space-between; + .card-i-r-t{ + view{ + font-size: 32rpx; + margin-bottom: 10rpx; + font-family: "PingFang SC"; + font-weight: 800; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + } + } + .card-i-r-b{ + width: 100%; + display: flex; + align-items: center; + justify-content: space-between; + + .study-button{ + width: 240rpx; + margin: 0; + box-shadow: 3px 3px 12px rgba(51,133,217,.3), -2px -2px 6px #fff; + border: 1px solid rgba(255,255,255,.8); + } + } + } + } + } + .card-d{ + background: none; + padding: 0; + .paper-card{ + background: #fff; + margin-bottom: 15px; + padding: 15px; + box-sizing: border-box; + position: relative; + border-radius: 16px; + + &:last-of-type{ + margin-bottom: 0; + } + + .paper-card-t{ + font-size: 32rpx; + margin-bottom: 10rpx; + font-family: "PingFang SC"; + font-weight: 800; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + + .green{ + font-size: 28rpx; + color: #5ac725 + } + .red{ + font-size: 28rpx; + color: #f56c6c + } + } + + .paper-card-b{ + display: flex; + align-items: center; + justify-content: space-between; + + .exam-button{ + width: 240rpx; + margin: 0; + box-shadow: 3px 3px 12px rgba(51,133,217,.3), -2px -2px 6px #fff; + border: 1px solid rgba(255,255,255,.8); + } + } + } + } +} + +.badge span{ + text-align: center; + width: 100%; +} + </style> \ No newline at end of file -- Gitblit v1.9.2