YNUtdPlatform/pages/YNEduApp/prac/prac.vue

211 lines
5.1 KiB
Vue
Raw Normal View History

2024-08-13 19:03:13 +08:00
<template>
2024-08-19 17:53:53 +08:00
<view>
<u-navbar title="练习" @leftClick="leftClick" placeholder />
<div class="tab-wrapper">
<div v-for="(item, index) in tabList" :key="index" class="tab-item" @click="handleTab(item, index)">
<div :style="{ color: activeIndex === index ? '#409eff' : '#333' }">
{{ item.name }}
</div>
<div :class="{ 'tab-line': activeIndex === index }"></div>
</div>
2024-08-13 19:03:13 +08:00
</div>
2024-08-19 17:53:53 +08:00
<div class="content">
<div v-for="(item, index) in list" :key="index" class="item-wrapper">
2024-08-23 16:00:43 +08:00
<div class="title">{{ item.name }}</div>
2024-08-19 17:53:53 +08:00
<div class="name-status">
2024-08-23 16:00:43 +08:00
<div class="status">{{ item.alreadyNum > 0 ? '已练习' : '未练习' }}</div>
2024-08-13 19:03:13 +08:00
</div>
2024-08-23 16:00:43 +08:00
<div class="time">练习时长 {{ item.practiceDuration }}</div>
2024-08-19 17:53:53 +08:00
<div class="count-total">
2024-08-23 16:00:43 +08:00
<div class="count">{{ item.allQuestionNum || 0 }}, 已练习{{ item.alreadyNum || 0 }}</div>
2024-08-13 19:03:13 +08:00
</div>
2024-08-19 17:53:53 +08:00
<div class="bt-wrapper">
2024-08-23 16:00:43 +08:00
<div class="score">完成率{{ item.completionRate }}</div>
<div class="btn-wrapper">
2024-08-23 20:10:40 +08:00
<div class="btn" @click="handleExercise(item)">开始练习</div>
2024-08-23 16:00:43 +08:00
<div class="btn" @click="handleError(item)">错题消除({{ item.missNum }})</div>
</div>
2024-08-13 19:03:13 +08:00
</div>
</div>
2024-08-19 17:53:53 +08:00
<!-- 暂无数据 -->
<div class="no-data" v-if="list.length == 0">
<image src="/static/images/zanwuneirong.png" mode="aspectFit" />
<view class="no-data-text">暂无内容</view>
2024-08-13 19:03:13 +08:00
</div>
</div>
</view>
</template>
<script>
2024-08-23 16:00:43 +08:00
import { getStudentPracticeList } from '@/api/eduApp'
2024-08-13 19:03:13 +08:00
export default {
data() {
return {
2024-08-19 17:53:53 +08:00
tabList: [{ name: '全部' }, { name: '待练习' }, { name: '已练习' }],
activeIndex: 0,
list: [],
// 全部列表
2024-08-23 16:00:43 +08:00
allList: [],
2024-08-19 17:53:53 +08:00
// 待练习列表
waitList: [],
// 已练习列表
alreadyList: []
2024-08-13 19:03:13 +08:00
}
},
2024-08-19 17:53:53 +08:00
mounted() {
2024-08-23 16:00:43 +08:00
this.getList()
2024-08-19 17:53:53 +08:00
},
methods: {
2024-08-23 16:00:43 +08:00
async getList() {
const params = {
userId: 31,
source: 1
}
const res = await getStudentPracticeList(params)
this.list = this.allList = res.data
// 根据 alreadyNum 字段判断待练习和已练习
this.waitList = res.data.filter(item => item.alreadyNum === 0)
this.alreadyList = res.data.filter(item => item.alreadyNum > 0)
2024-08-23 20:10:40 +08:00
// console.log('🚀 ~ getList ~ res:', res)
2024-08-23 16:00:43 +08:00
},
2024-08-19 17:53:53 +08:00
handleTab(item, index) {
this.activeIndex = index
if (index === 0) {
this.list = this.allList
} else if (index === 1) {
this.list = this.waitList
} else if (index === 2) {
this.list = this.alreadyList
}
},
// 开始练习
2024-08-23 20:10:40 +08:00
handleExercise(item) {
const params = {
practiceId: item.id,
title: item.name,
}
2024-08-19 17:53:53 +08:00
uni.navigateTo({
2024-08-23 20:10:40 +08:00
url: '/pages/YNEduApp/prac/pracDetail?params=' + JSON.stringify(params)
2024-08-19 17:53:53 +08:00
})
uni.removeStorageSync('from')
uni.setStorageSync('from', '/pages/YNEduApp/prac/prac')
},
leftClick() {
uni.navigateTo({
url: '/pages/YNEduApp/index/index'
})
2024-08-23 16:00:43 +08:00
},
// 错题消除
handleError(item) {
2024-08-23 20:10:40 +08:00
const params = {
practiceId: item.id,
recordId: item.recordId,
isError: true
}
2024-08-23 16:00:43 +08:00
uni.navigateTo({
2024-08-23 20:10:40 +08:00
url: '/pages/YNEduApp/prac/exercises?params=' + JSON.stringify(params)
2024-08-23 16:00:43 +08:00
})
2024-08-19 17:53:53 +08:00
}
}
2024-08-13 19:03:13 +08:00
}
</script>
<style lang="scss" scoped>
2024-08-19 17:53:53 +08:00
.tab-wrapper {
display: flex;
justify-content: space-around;
/* background: #fff; */
margin-bottom: 10px;
2024-08-13 19:03:13 +08:00
2024-08-19 17:53:53 +08:00
.tab-item {
width: 25%;
2024-08-13 19:03:13 +08:00
display: flex;
2024-08-19 17:53:53 +08:00
flex-direction: column;
2024-08-13 19:03:13 +08:00
align-items: center;
2024-08-19 17:53:53 +08:00
padding: 10px 0;
.tab-line {
margin-top: 5px;
width: 30%;
height: 2px;
background-color: #409eff;
transition: width 0.3s;
2024-08-13 19:03:13 +08:00
}
}
2024-08-19 17:53:53 +08:00
}
.content {
padding: 0 10px;
.item-wrapper {
background: #fff;
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
.title {
font-size: 16px;
font-weight: bold;
margin-bottom: 10px;
}
.name-status {
2024-08-13 19:03:13 +08:00
display: flex;
2024-08-19 17:53:53 +08:00
justify-content: space-between;
.name {
2024-08-13 19:03:13 +08:00
display: flex;
2024-08-19 17:53:53 +08:00
.name-sub {
margin-left: 5px;
color: #999;
2024-08-13 19:03:13 +08:00
}
}
2024-08-19 17:53:53 +08:00
.status {
color: #409eff;
}
2024-08-13 19:03:13 +08:00
}
2024-08-19 17:53:53 +08:00
.time {
color: #999;
margin-top: 10px;
}
.count-total {
2024-08-13 19:03:13 +08:00
display: flex;
justify-content: space-between;
2024-08-19 17:53:53 +08:00
margin-top: 10px;
.count {
color: #999;
2024-08-13 19:03:13 +08:00
}
2024-08-19 17:53:53 +08:00
.total {
color: #999;
2024-08-13 19:03:13 +08:00
}
2024-08-19 17:53:53 +08:00
}
.bt-wrapper {
display: flex;
justify-content: space-between;
margin-top: 10px;
.score {
color: #999;
}
2024-08-23 16:00:43 +08:00
.btn-wrapper {
display: flex;
}
2024-08-19 17:53:53 +08:00
.btn {
2024-08-23 16:00:43 +08:00
margin-left: 5px;
2024-08-19 17:53:53 +08:00
padding: 5px 10px;
background: #409eff;
2024-08-13 19:03:13 +08:00
color: #fff;
2024-08-19 17:53:53 +08:00
border-radius: 5px;
2024-08-13 19:03:13 +08:00
}
}
}
2024-08-19 17:53:53 +08:00
.no-data {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 100px;
.no-data-text {
margin-top: 10px;
color: #999;
2024-08-13 19:03:13 +08:00
}
}
}
</style>