YNUtdPlatform/pages/YNEduApp/prac/pracDetail.vue

305 lines
7.3 KiB
Vue
Raw Normal View History

2024-08-19 17:53:53 +08:00
<template>
<view class="wrapper">
<u-navbar title="学习项目" @leftClick="leftClick" placeholder />
<div class="top-container">
<u-avatar :src="avatar" size="60" />
<div class="name">{{ name }}</div>
</div>
<div class="title">{{ title }}</div>
<div class="center-container">
<div class="left">
<div class="item">
<u-icon name="/static/images/正确率.png" size="50" />
<div class="text">
<div>正确率</div>
<div>{{ correctRate }}</div>
</div>
</div>
<div class="item">
<u-icon name="/static/images/累计作答.png" size="50" />
<div class="text">
<div>累计作答</div>
<div>{{ totalAnswer }}</div>
</div>
</div>
<div class="item">
<u-icon name="/static/images/累计答对.png" size="50" />
<div class="text">
<div>累计答对</div>
<div>{{ totalCorrect }}</div>
</div>
</div>
</div>
<div class="right">
2024-08-23 20:10:40 +08:00
<div class="right-top">
2024-08-19 17:53:53 +08:00
<div class="right-text">顺序练习</div>
2024-08-23 20:10:40 +08:00
<!-- <u-icon class="top-icon" name="/static/images/顺序练习.png" width="84" height="73" /> -->
<div class="btn">
<u-button
type="primary"
plain
shape="circle"
text="继续上次练习"
size="small"
@click="handleExercises(1)"
></u-button>
</div>
<div class="btn">
<u-button
type="primary"
plain
shape="circle"
text="开始新的练习"
size="small"
@click="handleExercises(2)"
></u-button>
</div>
2024-08-19 17:53:53 +08:00
</div>
2024-08-23 20:10:40 +08:00
<div class="right-bottom">
2024-08-19 17:53:53 +08:00
<div class="right-text">随机练习</div>
2024-08-23 20:10:40 +08:00
<!-- <u-icon class="bottom-icon" name="/static/images/随机练习.png" width="84" height="73" /> -->
<div class="btn">
<u-button
type="primary"
plain
shape="circle"
text="继续上次练习"
size="small"
@click="handleExercises(3)"
></u-button>
</div>
<div class="btn">
<u-button
type="primary"
plain
shape="circle"
text="开始新的练习"
size="small"
@click="handleExercises(4)"
></u-button>
</div>
2024-08-19 17:53:53 +08:00
</div>
</div>
</div>
<!-- 目前不要选择题库 -->
<!-- <div class="bottom">
<div class="bottom-text">选择题库</div>
<u-icon class="bottom-icon" name="/static/images/选择题库.png" width="140" height="100" />
</div> -->
</view>
</template>
<script>
2024-08-23 20:10:40 +08:00
import { getPracticeQuestionRate } from '@/api/eduApp'
2024-08-19 17:53:53 +08:00
export default {
data() {
return {
2024-08-23 20:10:40 +08:00
practiceId: '', // 练习id
recordId: '', // 记录id
2024-08-19 17:53:53 +08:00
// 头像
2024-08-23 20:10:40 +08:00
avatar: '/static/images/user.png',
2024-08-19 17:53:53 +08:00
// 姓名
name: '张三',
// 练习标题
2024-08-23 20:10:40 +08:00
title: '',
2024-08-19 17:53:53 +08:00
// 正确率
2024-08-23 20:10:40 +08:00
correctRate: '',
2024-08-19 17:53:53 +08:00
// 累计作答
2024-08-23 20:10:40 +08:00
totalAnswer: 0,
2024-08-19 17:53:53 +08:00
// 累计答对
2024-08-23 20:10:40 +08:00
totalCorrect: 0
2024-08-19 17:53:53 +08:00
}
},
2024-08-23 20:10:40 +08:00
onLoad(opt) {
opt = JSON.parse(opt.params)
console.log('🚀 ~ onLoad ~ opt:', opt)
this.practiceId = opt.practiceId
this.title = opt.title
},
mounted() {
this.getData()
},
2024-08-19 17:53:53 +08:00
methods: {
2024-08-23 20:10:40 +08:00
async getData() {
const params = {
id: this.practiceId
}
const res = await getPracticeQuestionRate(params)
this.title = res.data.name
this.correctRate = res.data.trueRate
this.totalAnswer = res.data.allQuestionNum
this.totalCorrect = res.data.trueQuestionNum
this.recordId = res.data.recordId
console.log('🚀 ~ getData ~ res:', res)
},
2024-08-19 17:53:53 +08:00
handleExercises(type) {
console.log('type', type)
2024-08-23 20:10:40 +08:00
const params = {
practiceId: this.practiceId,
recordId: this.recordId,
isError: false
}
if (type === 1) {
2024-08-24 18:27:34 +08:00
params.isOutOfOrder = '0'
params.isNew = '0'
2024-08-23 20:10:40 +08:00
} else if (type === 2) {
2024-08-24 18:27:34 +08:00
params.isOutOfOrder = '0'
params.isNew = '1'
2024-08-23 20:10:40 +08:00
} else if (type === 3) {
params.isOutOfOrder = 1
2024-08-24 18:27:34 +08:00
params.isNew = '0'
2024-08-23 20:10:40 +08:00
} else if (type === 4) {
2024-08-24 18:27:34 +08:00
params.isOutOfOrder = '1'
params.isNew = '1'
2024-08-23 20:10:40 +08:00
}
console.log('params', params)
2024-08-19 17:53:53 +08:00
uni.navigateTo({
2024-08-23 20:10:40 +08:00
url: `/pages/YNEduApp/prac/exercises?params=${JSON.stringify(params)}`
2024-08-19 17:53:53 +08:00
})
},
leftClick() {
const from = uni.getStorageSync('from')
uni.navigateTo({
url: from
})
}
}
}
</script>
<style lang="scss" scoped>
.wrapper {
height: 94vh;
background: url('/static/images/练习-bg.png') no-repeat;
background-size: 100% 100%;
padding: 20px;
.top-container {
margin-top: 40px;
display: flex;
align-items: center;
.name {
font-weight: 500;
font-size: 17px;
color: #ffffff;
margin-left: 20px;
}
}
.title {
margin-top: 50px;
margin-bottom: 30px;
font-weight: 800;
font-size: 26px;
color: #fff;
line-height: 30px;
text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.5);
text-align: center;
}
.center-container {
display: flex;
justify-content: space-between;
.left {
width: 52%;
height: 209px;
background: #5185ed;
border-radius: 8px;
display: flex;
flex-direction: column;
justify-content: space-around;
.item {
padding: 0 15px;
display: flex;
align-items: center;
justify-content: space-around;
&:first-child {
margin-left: -8px;
}
.text {
color: #fff;
font-size: 16px;
font-weight: 500;
margin-left: 10px;
display: flex;
flex-direction: column;
align-items: center;
}
}
}
.right {
width: 43%;
display: flex;
flex-direction: column;
justify-content: space-between;
2024-08-23 20:10:40 +08:00
.btn {
width: 60%;
margin: 5px auto;
}
2024-08-19 17:53:53 +08:00
.right-top {
height: 98px;
2024-08-23 20:10:40 +08:00
// background: #e7ac67;
background: url('/static/images/顺序练习.png') no-repeat;
background-size: 100% 98px;
2024-08-19 17:53:53 +08:00
border-radius: 8px;
position: relative;
// top-icon - 在当前位置的右下角
.top-icon {
position: absolute;
right: 0;
bottom: 0;
}
}
.right-bottom {
height: 98px;
background: #73c2f7;
border-radius: 8px 8px 8px 8px;
position: relative;
// bottom-icon - 在当前位置的左下角
.bottom-icon {
position: absolute;
left: 0;
bottom: 0;
}
}
.right-text {
font-weight: 500;
font-size: 15px;
color: #fff;
margin: 5px 0 0 10px;
}
}
}
.bottom {
margin-top: 20px;
width: 100%;
height: 120px;
background: #226de3;
border-radius: 8px;
position: relative;
.bottom-icon {
position: absolute;
right: 0;
bottom: 0;
}
.bottom-text {
font-weight: 400;
font-size: 30px;
color: #ffffff;
line-height: 120px;
margin: auto 20px;
}
}
}
</style>