YNUtdPlatform/pages/YNEduApp/prac/pracDetail.vue

328 lines
8.0 KiB
Vue

<template>
<view class="wrapper">
<u-navbar title="练习" @leftClick="leftClick" placeholder />
<!-- <div class="top-container">
<u-avatar :src="avatar" size="60" />
<div class="name">{{ userName }}</div>
</div> -->
<div class="title">{{ title }}</div>
<div class="center-container">
<div class="left">
<div class="item">
<u-icon name="/static/images/accuracy.png" size="50" />
<div class="text">
<div>正确率</div>
<div>{{ correctRate }}</div>
</div>
</div>
<div class="item">
<u-icon name="/static/images/accumulative-answer.png" size="50" />
<div class="text">
<div>累计作答</div>
<div>{{ totalAnswer }}</div>
</div>
</div>
<div class="item">
<u-icon name="/static/images/accumulative-total.png" size="50" />
<div class="text">
<div>累计答对</div>
<div>{{ totalCorrect }}</div>
</div>
</div>
</div>
<div class="right">
<div class="right-top">
<div class="right-text">顺序练习</div>
<div class="btn" v-if="!isNew">
<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>
</div>
<div class="right-bottom">
<div class="right-text">随机练习</div>
<div class="btn" v-if="!isNew">
<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>
</div>
</div>
</div>
<!-- 目前不要选择题库 -->
<!-- <div class="bottom">
<div class="bottom-text">选择题库</div>
<u-icon class="bottom-icon" name="/static/images/select -question-bank.png" width="140" height="100" />
</div> -->
</view>
</template>
<script>
import { getPracticeQuestionRate } from '@/api/eduApp'
import config from '@/config'
export default {
data() {
return {
practiceId: '', // 练习id
recordId: '', // 记录id
// 头像
avatar: '/static/images/user.png',
// 姓名
userName: '',
// 练习标题
title: '',
// 正确率
correctRate: '',
// 累计作答
totalAnswer: 0,
// 累计答对
totalCorrect: 0,
studyId: '', // 学习id
isNew: true // 是否新练习
}
},
onShow() {
},
onLoad(opt) {
opt = JSON.parse(opt.params)
console.log('🚀 ~ onLoad ~ opt:', opt)
this.practiceId = opt.practiceId
this.title = opt.title
this.studyId = opt.studyId || '' // 学习id
this.isNew = opt.isNew
this.getData()
},
methods: {
async getData() {
const params = {
id: this.practiceId
}
this.$verificationToken()
uni.request({
url: config.baseUrl + '/exam-student/studentPractice/getPracticeQuestionRate',
method: 'post',
data: params,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: uni.getStorageSync('access_token')
},
success: res => {
res = res.data
console.log('🚀 ~ handleSubmit ~ res:', res)
this.title = res.data.name
this.userName = res.data.userName
this.correctRate = res.data.trueRate || '0%'
this.totalAnswer = res.data.allQuestionNum || 0
this.totalCorrect = res.data.trueQuestionNum || 0
this.recordId = res.data.recordId
},
fail: err => {
console.log(err)
}
})
},
handleExercises(type) {
console.log('type', type)
const params = {
practiceId: this.practiceId,
recordId: this.recordId,
isError: false,
studyId: this.studyId // 学习id
}
if (type === 1) {
params.isOutOfOrder = '0'
params.isNew = '0'
} else if (type === 2) {
params.isOutOfOrder = '0'
params.isNew = '1'
} else if (type === 3) {
params.isOutOfOrder = 1
params.isNew = '0'
} else if (type === 4) {
params.isOutOfOrder = '1'
params.isNew = '1'
}
console.log('params', params)
uni.reLaunch({
url: `/pages/YNEduApp/prac/exercises?params=${JSON.stringify(params)}`
})
},
leftClick() {
let from = uni.getStorageSync('from')
if (this.studyId) {
from = from + '?id=' + this.studyId
}
uni.reLaunch({
url: from
})
}
}
}
</script>
<style lang="scss" scoped>
.wrapper {
height: 94vh;
background: url('/static/images/exercises-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: 80px;
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;
.btn {
width: 60%;
margin: 5px auto;
}
.right-top {
height: 98px;
// background: #e7ac67;
background: url('/static/images/order-exercises.png') no-repeat;
background-size: 100% 98px;
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>