<template>
|
<view class="box">
|
<view class="m-p-15">
|
<view class="card-list">
|
<scroll-view v-if="examList && examList.length>0" scroll-y="true" class="scroll-Y" @scrolltoupper="upper" @scrolltolower="lower" lower-threshold="150" @scroll="scrollView" style="height:100%">
|
<view class="paper-card" v-for="(item,index) in examList" :key="index" @tap="toDetail(item,2)">
|
<!-- <view class="isPassed">
|
{{item.passed == 0?'不合格':'合格'}}
|
</view> -->
|
<view class="paper-card-l">
|
<view class="paper-card-t">{{item.examPaper.name}}</view>
|
<view style="color: #999;margin-bottom: 10px;font-size: 12px">{{item.examPaper.code}}</view>
|
<view style="display: flex;align-items: center">
|
<u-tag :text="item.examPaper.categoryName" plain size="mini"></u-tag>
|
<u-tag :text="item.createName" plain type="warning" size="mini"></u-tag>
|
</view>
|
</view>
|
<view class="paper-card-r">
|
<view class="score" :class="item.passed == 0?'red':'green'">
|
<view>{{item.score}}</view>
|
丨
|
<view>{{item.passed == 0?'不合格':'合格'}}</view>
|
</view>
|
<u-button @tap.stop="reExam(item)" class="re-exam-button" plain type="warning" text="重新考试" shape="circle" size="small"></u-button>
|
</view>
|
</view>
|
</scroll-view>
|
<u-empty v-else text="暂无已完成的考试记录" mode="list"></u-empty>
|
</view>
|
<!-- <view>-->
|
<!-- <u-button @click="loginOut" type="primary" text="退出登录" style="width: 80%" shape="circle"></u-button>-->
|
<!-- </view>-->
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {getExamList, loginOut} from "../../../api";
|
import {getCleanRecord, postAgainExam} from "../../../api/wearhouse";
|
export default {
|
components:{},
|
data() {
|
return {
|
page: 'pages/tabBar/count/countDetail',
|
statusBarHeight: '',
|
examParams: {
|
pageNum: 1,
|
pageSize: 10,
|
state: 2
|
},
|
examList: [],
|
totalPage: 0
|
}
|
|
},
|
onLoad() {
|
this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
|
this.getExamList()
|
},
|
// onBackPress(options) { // 监听物理返回键或左上角返回按钮
|
// if (options.from === 'backbutton') {
|
// uni.redirectTo({
|
// url: '/pages/tabBar/count/count' // 跳转到目标页
|
// });
|
// return true; // 阻止默认返回行为
|
// }
|
// },
|
onUnload() {
|
uni.switchTab({
|
url: '/pages/tabBar/count/count'
|
});
|
},
|
methods: {
|
goBack() {
|
const url = uni.getStorageSync("prevPage");
|
if(url){
|
uni.reLaunch({
|
url: url
|
});
|
} else{
|
uni.reLaunch({
|
url: '/pages/tabBar/count/count'
|
})
|
}
|
},
|
getExamList(){
|
getExamList(this.examParams).then(res => {
|
if(res.code == 200) {
|
let list = res.data.list?res.data.list: [];
|
if (res.data.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)
|
}
|
})
|
},
|
async reExam(item){
|
const t = this
|
if(item.examPaper.deadline){
|
const deadline = item.examPaper.deadline
|
const deadlineTime = new Date(deadline).getTime()
|
const currentTime = new Date().getTime()
|
if (currentTime > deadlineTime) {
|
uni.$u.toast('已超过考试截止时间,不可重新考试')
|
return
|
}
|
}
|
|
uni.showModal({
|
title: '提示',
|
content: '是否重新考试?',
|
success: async function (res) {
|
if (res.confirm) {
|
const res = await postAgainExam({paperId: item.paperId,studentId: uni.getStorageSync('uid')})
|
if(res.code == 200){
|
uni.$u.toast(res.message)
|
t.getExamList()
|
}else{
|
uni.$u.toast(res.message)
|
}
|
} else if (res.cancel) {
|
console.log('用户点击取消');
|
}
|
}
|
})
|
|
},
|
toDetail(item,type){
|
uni.setStorageSync("prevPage", '/pages/tabBar/count/countDetail');
|
uni.navigateTo({
|
url: `/pages/tabBar/firstPage/exam?bank=` + encodeURIComponent(JSON.stringify(item)) + `&type=` + encodeURIComponent(JSON.stringify(type))
|
})
|
},
|
|
loginOut(){
|
uni.showModal({
|
title: '提示',
|
content: '是否确认退出该账号?',
|
success: async function (res) {
|
if (res.confirm) {
|
loginOut().then(res=>{
|
if(res.code == 200){
|
uni.showToast({
|
title: '账户已退出',
|
duration: 1000
|
})
|
setTimeout(()=>{
|
uni.clearStorageSync();
|
uni.clearStorage();
|
uni.navigateTo({
|
url: '/pages/index/index'
|
})
|
},1000)
|
}
|
})
|
} else if (res.cancel) {
|
console.log('用户点击取消');
|
}
|
}
|
})
|
},
|
|
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)
|
},
|
}
|
}
|
|
</script>
|
|
<style lang='scss' scoped>
|
.box {
|
display: flex;
|
flex-direction: column;
|
width: 100%;
|
height: 100%;
|
}
|
|
.m-p-15{
|
width: 100%;
|
|
.card-list{
|
width: 100%;
|
height: 100vh;
|
padding: 20px 0 15px;
|
box-sizing: border-box;
|
::v-deep .u-empty{
|
margin-top: 300rpx !important;
|
}
|
.paper-card{
|
width: calc(100% - 30px);
|
position: relative;
|
background: #fff;
|
border-radius: 20rpx;
|
padding: 15px;
|
margin: 0 auto 15px;
|
box-sizing: border-box;
|
box-shadow: 0 3px 8px rgba(150,150,150,.1);
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
|
.isPassed{
|
position: absolute;
|
right: 0;
|
top: 0;
|
width: 100rpx;
|
height: 50rpx;
|
}
|
|
.paper-card-l{
|
width: 65%;
|
|
.paper-card-t{
|
font-size: 36rpx;
|
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;
|
}
|
|
::v-deep .u-tag{
|
margin-right: 10rpx !important;
|
}
|
}
|
|
.paper-card-r{
|
width: 35%;
|
|
.score{
|
color: #fff;
|
height: 60rpx;
|
border-radius: 99rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-size: 28rpx;
|
margin-bottom: 10rpx;
|
}
|
|
.green{
|
background: #5fb734;
|
}
|
.red{
|
background: #ed6464
|
}
|
}
|
}
|
}
|
}
|
</style>
|