<template>
|
<view class="box">
|
<!-- 自定义导航栏 -->
|
<view class="navBarBox fix">
|
<!-- 状态栏占位 -->
|
<view class="statusBar" :style="{ paddingTop: statusBarHeight + 'px' }"></view>
|
<!-- 真正的导航栏内容 -->
|
<view class="navBar">
|
<u-icon style=" margin-left: 13px;" name="arrow-left" color="black" size="17" @click="goBack"/>
|
<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 class="m-p-15">
|
<view class="cardList">
|
<scroll-view scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
|
@scrolltolower="lower" lower-threshold="150" @scroll="scrollView" style="height:100%">
|
<view class="card-i" v-for="(item,index) in quizList" :key="index">
|
<view class="card-i-l">
|
<view>{{item.name}}</view>
|
<span style="display:block;color: #999;font-size: 12px;margin-bottom: 20px;">已刷{{item.exerciseCount}}/{{item.totalCount}}</span>
|
<span style="display:block;color: #999;font-size: 12px;">创建时间:{{item.createTime}}</span>
|
</view>
|
<view class="card-i-r">
|
<u-button v-if="item.exerciseCount == 0" class="study-button" type="success" text="开始刷题" shape="circle" size="small" @click="getQuestionIds(item,1)"></u-button>
|
<u-button v-if="item.exerciseCount > 0" class="study-button" type="success" text="继续刷题" shape="circle" size="small" @click="getQuestionIds(item,2)"></u-button>
|
<u-button class="study-button" type="error" text="查看错题" shape="circle" size="small" @click="getQuestionIds(item.id,3)"></u-button>
|
<u-button class="study-button" text="重置" shape="circle" size="small" @click="reSet(item.id)"></u-button>
|
</view>
|
</view>
|
</scroll-view>
|
</view>
|
</view>
|
<tabBar :currentPagePath="page"></tabBar>
|
</view>
|
</template>
|
|
<script>
|
import tabBar from '../tabBarIndex.vue'
|
import {getQuizHouse,getCleanRecord} from '../../../api/wearhouse.js'
|
import tebBar from '../tabBarIndex.vue'
|
import VUE_APP_BASE_URL from "../../../common/constant";
|
export default {
|
components:{
|
tabBar
|
},
|
data() {
|
return {
|
page: 'pages/tabBar/wearhouse/wearhouse',
|
statusBarHeight: 0,
|
classParams: {
|
pageNum: 1,
|
pageSize: 10,
|
},
|
quizList: [],
|
totalPage: 0
|
}
|
},
|
onLoad() {
|
// this.unitType = uni.getStorageSync('unittype') + 1;
|
//获取手机状态栏高度
|
this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
|
},
|
onShow() {
|
// this.role = uni.getStorageSync('roleName');
|
this.classParams.pageNum = 1
|
|
},
|
mounted(){
|
this.getQuizList()
|
},
|
methods: {
|
loginOut() {
|
uni.clearStorageSync();
|
uni.clearStorage();
|
uni.navigateTo({
|
url: '/pages/index/index'
|
})
|
},
|
goBack() {
|
uni.switchTab({
|
url:'/pages/tabBar/firstPage/firstPage'
|
});
|
},
|
getQuizList(){
|
getQuizHouse(this.classParams).then(res => {
|
if(res.code == 200) {
|
let list = res.data.list?res.data.list: [];
|
if (res.pageNum != 1) {
|
this.quizList = this.quizList.concat(list)
|
} else {
|
this.quizList = list
|
// this.$set(this, 'quizList', list)
|
}
|
this.totalPage = res.data.totalPage
|
}else{
|
uni.$u.toast(res.message)
|
}
|
})
|
},
|
|
async getQuestionIds(item,type){
|
if(type == 1 && item.totalCount == 0){
|
uni.$u.toast('该题库暂无题目')
|
return
|
}
|
if(type == 2 && item.totalCount == item.exerciseCount){
|
uni.$u.toast('该题库所有题目已刷完')
|
return
|
}
|
uni.setStorageSync("prevPage", '/pages/tabBar/wearhouse/wearhouse');
|
uni.navigateTo({
|
url: `/pages/tabBar/wearhouse/questions?bank=` + encodeURIComponent(JSON.stringify(item))
|
})
|
},
|
|
reSet(id){
|
const t = this
|
uni.showModal({
|
title: '提示',
|
content: '是否重置所选题库的刷题记录?',
|
success: async function (res) {
|
if (res.confirm) {
|
const res = await getCleanRecord({bankId: id})
|
if(res.code == 200){
|
uni.showToast({
|
title: '刷题记录已重置',
|
duration: 1000
|
});
|
|
uni.reLaunch({
|
url: '/pages/tabBar/wearhouse/wearhouse'
|
})
|
}else{
|
uni.showToast({
|
title: '记录重置失败,请稍后再试',
|
duration: 1000
|
});
|
}
|
} else if (res.cancel) {
|
console.log('用户点击取消');
|
}
|
}
|
});
|
},
|
upper(e) {
|
// console.log(e)
|
},
|
lower(e) {
|
//并且让页码+1,调用获取数据的方法获取第二页数据
|
this.classParams.pageNum++
|
//此处调用自己获取数据列表的方法
|
if (this.classParams.pageNum > this.totalPage){
|
uni.$u.toast('已加载全部数据')
|
return
|
}
|
this.getQuizList()
|
},
|
scrollView(e) {
|
// console.log(e)
|
}
|
}
|
}
|
|
</script>
|
|
<style lang="scss" scoped>
|
.box {
|
display: flex;
|
flex-direction: column;
|
width: 100%;
|
height: 100%;
|
}
|
.fix{
|
position: sticky;
|
top: 0;
|
left: 0;
|
right: 0;
|
width: 100%;
|
z-index: 1;
|
}
|
.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);
|
}
|
.barText{
|
margin-left: 55px;
|
text-align: center;
|
width: 85%;
|
font-size: 16px;
|
/* text-align: center; */
|
font-weight: 600;
|
}
|
.statusBar{
|
background-color:lightgrey;
|
}
|
|
.controlBar{
|
margin: 12px 12px 0;
|
padding: 12px;
|
height: 90px;
|
box-sizing: border-box;
|
display: flex;
|
flex-direction: column;
|
justify-content: space-between;
|
width: calc(100% - 24px);
|
background: #fff;
|
border-radius: 5px;
|
box-shadow: 0 3px 12px rgba(0,0,0,0.05);
|
|
.buttonGroup{
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-bottom: 12px;
|
}
|
|
.listHead{
|
display: flex;
|
align-items: center;
|
justify-content: flex-end;
|
}
|
}
|
.buttonItem{
|
width: calc(20% - 4px);
|
color: white;
|
display: flex;
|
flex-direction: row;
|
justify-content: center;
|
align-items: center;
|
height: 30px;
|
border-radius: 5px;
|
&.active{
|
border: 1px solid rgba(0,0,0,.4);
|
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
}
|
}
|
.all {
|
background-color: rgb(17,204,33);
|
&.active{
|
background-image: linear-gradient(#22992d,#12da23);
|
}
|
}
|
.active {
|
border: 1.5px solid #8d8d8d;
|
}
|
.red {
|
background-color: #ff5555;
|
&.active{
|
background:linear-gradient(#dc2f2f, #ff5b5b);
|
}
|
}
|
.orange {
|
background-color: rgb(251, 158, 13);
|
&.active{
|
background: linear-gradient(#e28e0c,#ffa90e);
|
}
|
}
|
.yellow {
|
background-color: rgb(255, 223, 37);
|
&.active{
|
background: linear-gradient(#e6c921,#ffef28);
|
}
|
}
|
.blue {
|
background-color: #409EFF;
|
&.active{
|
background: linear-gradient(#3a8ee6,#44a9ff);
|
}
|
}
|
.switchBtn{
|
display: flex;
|
align-items: center;
|
}
|
.examineList{
|
margin-top: 12px;
|
height: calc(100vh - 246px);
|
overflow: hidden;
|
overflow-y: scroll;
|
}
|
.listContent{
|
display: flex;
|
flex-direction: column;
|
width: calc(100% - 24px);
|
margin: 0 12px;
|
// margin-bottom: 30px;
|
background: #fff;
|
border-radius: 5px;
|
box-shadow: 0 3px 12px rgba(0,0,0,0.05);
|
height: 100%;
|
}
|
.itemContent{
|
color: #333;
|
font-size: 16px;
|
margin-top: 15px;
|
padding: 0 12px 10px;
|
border-bottom: 1px solid #ebebeb;
|
}
|
.content{
|
.tit{
|
width: 100%;
|
text-overflow: ellipsis;
|
overflow: hidden;
|
white-space: nowrap;
|
}
|
.cont{
|
width: 100%;
|
font-size: 14px;
|
color: #666;
|
display: block;
|
text-overflow: ellipsis;
|
overflow: hidden;
|
white-space: nowrap;
|
margin-bottom: 6px;
|
}
|
.btnGroup{
|
width: 100%;
|
display: flex;
|
justify-content: space-between;
|
}
|
}
|
.buttonCo{
|
margin-top: 5px;
|
margin-bottom: 10px;
|
}
|
.m-p-15{
|
width: 100%;
|
box-sizing: border-box;
|
padding: 0 15px;
|
}
|
.cardList{
|
width: 100%;
|
height: calc(100vh - 160px);
|
background: #fff;
|
border-radius: 8px;
|
margin: 20px 0;
|
padding: 15px;
|
box-sizing: border-box;
|
|
.card-i{
|
padding-bottom: 15px;
|
margin-bottom: 15px;
|
border-bottom: 1px solid #f0f0f0;
|
position: relative;
|
display: flex;
|
align-items: flex-start;
|
justify-content: space-between;
|
box-sizing: border-box;
|
&:last-of-type{
|
margin-bottom: 0;
|
padding-bottom: 0;
|
border-bottom: none;
|
}
|
|
.card-i-l{
|
width: 70%;
|
view{
|
width: 100%;
|
font-size: 32rpx;
|
margin-bottom: 10rpx;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
display: -webkit-box;
|
-webkit-line-clamp: 2;
|
-webkit-box-orient: vertical;
|
}
|
}
|
.card-i-r{
|
width: 25%;
|
height: 100%;
|
display: flex;
|
flex-direction: column;
|
justify-content: space-between;
|
.study-button{
|
width: 100%;
|
margin-bottom: 10rpx;
|
|
&:last-of-type{
|
margin-bottom: 0;
|
}
|
}
|
}
|
}
|
}
|
|
</style>
|