<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" v-if="quizList && quizList.length>0">
|
<scroll-view scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
|
@scrolltolower="lower" lower-threshold="150" @scroll="scrollView" style="height:100%">
|
<view style="padding: 20px 0 20px">
|
<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:flex;align-items: center;color: #999;font-size: 12px;"><u-icon name="clock" color="#999" size="18" style="margin-bottom: 0;margin-right: 2px"></u-icon>{{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,3)"></u-button>
|
<u-button class="study-button" text="重置" shape="circle" size="small" @click="reSet(item.id)"></u-button>
|
</view>
|
</view>
|
</view>
|
</scroll-view>
|
</view>
|
<u-empty style="margin-top: 80px" v-else text="暂无记录" mode="data"></u-empty>
|
</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'];
|
this.classParams.pageNum = 1
|
this.getQuizList()
|
},
|
onShow() {
|
// this.role = uni.getStorageSync('roleName');
|
},
|
created(){
|
uni.hideTabBar()
|
},
|
mounted(){
|
|
},
|
methods: {
|
loginOut() {
|
uni.clearStorageSync();
|
uni.clearStorage();
|
uni.navigateTo({
|
url: '/pages/index/index'
|
})
|
},
|
goBack() {
|
uni.switchTab({
|
url:'/pages/tabBar/firstPage/firstPage'
|
});
|
},
|
|
getQuizList(){
|
const t = this
|
getQuizHouse(t.classParams).then(res => {
|
if(res.code == 200) {
|
let list = res.data.list?res.data.list: [];
|
if (res.data.pageNum != 1) {
|
t.quizList = t.quizList.concat(list)
|
} else {
|
t.quizList = list
|
}
|
t.totalPage = res.data.totalPage
|
}else{
|
uni.$u.toast(res.message)
|
}
|
})
|
},
|
|
async getQuestionIds(item,type){
|
if(item.totalCount == 0){
|
uni.showToast({
|
title: '该题库暂无题目',
|
duration: 1000
|
});
|
return
|
}
|
// if(type == 2 && item.totalCount == item.exerciseCount){
|
// uni.showToast({
|
// title: '该题库所有题目已刷完',
|
// duration: 1000
|
// });
|
// return
|
// }
|
uni.setStorageSync("prevPage", '/pages/tabBar/wearhouse/wearhouse');
|
uni.navigateTo({
|
url: `/pages/tabBar/wearhouse/questions?bank=` + encodeURIComponent(JSON.stringify(item)) + `&type=` + encodeURIComponent(JSON.stringify(type))
|
})
|
},
|
|
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
|
});
|
// t.classParams.pageNum = 1
|
// t.getQuizList()
|
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>
|
.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;
|
top: 0;
|
left: 0;
|
right: 0;
|
width: 100%;
|
z-index: 1;
|
}
|
.barText{
|
/* text-align: center; */
|
font-size: 16px;
|
font-weight: 600;
|
flex: 2;
|
margin-left: 45%;
|
}
|
.statusBar{
|
background-color:lightgrey;
|
}
|
|
.m-p-15{
|
width: 100%;
|
}
|
.cardList{
|
width: 100%;
|
height: calc(100vh - 130px);
|
box-sizing: border-box;
|
|
.card-i{
|
width: calc(100% - 30px);
|
background: #fff;
|
border-radius: 20px;
|
padding: 15px;
|
margin: 0 auto 15px;
|
position: relative;
|
display: flex;
|
align-items: flex-start;
|
box-sizing: border-box;
|
box-shadow: 4px 4px 12px rgba(150,150,150,.05);
|
|
&:last-of-type{
|
margin-bottom: 0;
|
}
|
|
.card-i-l{
|
width: 75%;
|
&>view{
|
width: 100%;
|
font-size: 32rpx;
|
font-family: "PingFang SC";
|
font-weight: 800;
|
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>
|