Commit 5bb6ec6e authored by 黄奎's avatar 黄奎

页面更新

parent 5837f8f9
...@@ -7,35 +7,40 @@ ...@@ -7,35 +7,40 @@
<van-icon name="cross" size="40rpx" @click="goBack()" /> <van-icon name="cross" size="40rpx" @click="goBack()" />
</template> </template>
<template #title> <template #title>
<text class="Exam_Current">{{current+1}}</text><text class="Exam_Count">/{{Count}}</text> <text class="Exam_Current">{{ current + 1 }}</text>
<text class="Exam_Count">/{{ Count }}</text>
</template> </template>
</van-nav-bar> </van-nav-bar>
<swiper class="swiper-box" :style="{height: `calc(100vh - 180rpx)`}" :current="current" @change="onchange"> <swiper class="swiper-box" :style="{ height: `calc(100vh - 180rpx)` }" :current="current" @change="onchange">
<swiper-item v-for="(item1, index1) in dataList" :key="index1"> <swiper-item v-for="(item1, index1) in dataList" :key="index1">
<view class="My_listen" @click="play(item1.Src)"> <view class="My_listen" @click="play(item1.Src)">
<i class="icon_audio_default" v-if="!isPlay"></i> <i class="icon_audio_default" v-if="!isPlay"></i>
<i class="icon_audio_playing" v-else></i> <i class="icon_audio_playing" v-else></i>
</view> </view>
<view class="showtime">
<view class="">当前时长:{{ currentTime }}s /</view>
<view class="">总时长:{{ duration }}s</view>
</view>
<view class="item1" :style="{ height: `calc(100vh - 480rpx)` }"> <view class="item1" :style="{ height: `calc(100vh - 480rpx)` }">
<template v-if="item1.StudentAnswer.length<item1.QuestionContentObj.length"> <template v-if="item1.StudentAnswer.length < item1.QuestionContentObj.length">
<view class="questionView"> <view class="questionView">
<view v-for="(item2, index2) in item1.QuestionContentObj" :key="index2" class="item2"> <view v-for="(item2, index2) in item1.QuestionContentObj" :key="index2" class="item2">
<view class="flex questionTitle"> <view class="flex questionTitle">
<view>{{ index2 + 1 }}、({{item2.QuestionName.slice(0, 2)}})</view> <view>{{ index2 + 1 }}、({{ item2.QuestionName.slice(0, 2) }})</view>
<view v-html="item2.SubTitle"></view> <view v-html="item2.SubTitle"></view>
</view> </view>
<view v-for="(item3, index3) in item2.SubAnwser" :key="index3"> <view v-for="(item3, index3) in item2.SubAnwser" :key="index3">
<!-- 单选 、判断--> <!-- 单选 、判断-->
<view class="flex flex_start_center item3" <view class="flex flex_start_center item3" v-if="item2.QuestionKey === 'single'">
v-if="item2.QuestionKey === 'single'"> <view class="chooseNum" :class="{ myAnswer: item1.StudentAnswer[index2] == item3.Name }" @click="singerChange(item1, index2, item3)">
<view class="chooseNum" {{ item3.Name }}
:class="{ 'myAnswer': item1.StudentAnswer[index2]==item3.Name }"
@click="singerChange(item1, index2, item3)">{{ item3.Name }}
</view>
<view class="chooseName"
:class="{ 'myAnswer': item1.StudentAnswer[index2]==item3.Name }"
@click="singerChange(item1, index2, item3)" v-html="item3.Content">
</view> </view>
<view
class="chooseName"
:class="{ myAnswer: item1.StudentAnswer[index2] == item3.Name }"
@click="singerChange(item1, index2, item3)"
v-html="item3.Content"
></view>
</view> </view>
</view> </view>
</view> </view>
...@@ -45,37 +50,34 @@ ...@@ -45,37 +50,34 @@
<view class="questionView"> <view class="questionView">
<view v-for="(item2, index2) in item1.QuestionContentObj" :key="index2" class="item2"> <view v-for="(item2, index2) in item1.QuestionContentObj" :key="index2" class="item2">
<view class="flex questionTitle"> <view class="flex questionTitle">
<view>{{ index2 + 1 }}、({{item2.QuestionName.slice(0, 2)}})</view> <view>{{ index2 + 1 }}、({{ item2.QuestionName.slice(0, 2) }})</view>
<view v-html="item2.SubTitle"></view> <view v-html="item2.SubTitle"></view>
</view> </view>
<view v-for="(item3, index3) in item2.SubAnwser" :key="index3"> <view v-for="(item3, index3) in item2.SubAnwser" :key="index3">
<!-- 单选 、判断--> <!-- 单选 、判断-->
<view class="flex flex_start_center item3" <view class="flex flex_start_center item3" v-if="item2.QuestionKey === 'single'">
v-if="item2.QuestionKey === 'single'"> <view class="chooseNum" :class="{ isRightAnswer: item3.IsAnswer, isNotRightAnswer: getErrorAnswer(item1, index2, item3.Name) }">
<view class="chooseNum"
:class="{ 'isRightAnswer': item3.IsAnswer,'isNotRightAnswer':getErrorAnswer(item1,index2,item3.Name)}">
{{ item3.Name }} {{ item3.Name }}
</view> </view>
<view class="chooseName" <view
:class="{ 'isRightText': item3.IsAnswer,'isNotAnswer':getErrorAnswer(item1,index2,item3.Name)}" class="chooseName"
v-html="item3.Content"></view> :class="{ isRightText: item3.IsAnswer, isNotAnswer: getErrorAnswer(item1, index2, item3.Name) }"
v-html="item3.Content"
></view>
</view> </view>
</view> </view>
<view class="AnswerContent"> <view class="AnswerContent">
<view> <view>
<text style="color: #8c8a94">正确答案:</text> <text style="color: #8c8a94">正确答案:</text>
<text class="isTrueAnswer">{{item1.QuestionAnswerList[index2]}}</text> <text class="isTrueAnswer">{{ item1.QuestionAnswerList[index2] }}</text>
<text> <text>
您的答案: 您的答案:
<template v-if="item1.StudentAnswer.length>0"> <template v-if="item1.StudentAnswer.length > 0">
<text <text v-if="item1.StudentAnswer[index2] == item1.QuestionAnswerList[index2]" class="isTrueAnswer">
v-if="item1.StudentAnswer[index2] == item1.QuestionAnswerList[index2]"
class="isTrueAnswer">
{{ item1.StudentAnswer[index2] }},回答正确 {{ item1.StudentAnswer[index2] }},回答正确
</text> </text>
<text v-else class="isNotAnswer"> <text v-else class="isNotAnswer">{{ item1.StudentAnswer[index2] }},回答错误</text>
{{ item1.StudentAnswer[index2] }},回答错误
</text>
</template> </template>
<template v-else> <template v-else>
<text class="isNotAnswer">未回答</text> <text class="isNotAnswer">未回答</text>
...@@ -84,8 +86,7 @@ ...@@ -84,8 +86,7 @@
</view> </view>
</view> </view>
</view> </view>
<view style="word-wrap: break-word; margin-bottom:30rpx;display: flex;" <view style="word-wrap: break-word; margin-bottom:30rpx;display: flex;" class="AnswerContent" v-if="item1.AnswerParse">
class="AnswerContent" v-if="item1.AnswerParse">
<text style="color: #8c8a94;flex-shrink: 0;">解析:</text> <text style="color: #8c8a94;flex-shrink: 0;">解析:</text>
<view style="color: #000" v-html="item1.AnswerParse"></view> <view style="color: #000" v-html="item1.AnswerParse"></view>
</view> </view>
...@@ -93,9 +94,10 @@ ...@@ -93,9 +94,10 @@
</template> </template>
</view> </view>
<view class="AnswerBtn clear" style="display:none"> <view class="AnswerBtn clear" style="display:none">
<view class="AnswerBtnFirst" @click="getBeforeExam()" v-if="current!=0">上一题</view> <view class="AnswerBtnFirst" @click="getBeforeExam()" v-if="current != 0">上一题</view>
<view class="AnswerBtnSecond" :class="{'isCanNext':item1.StudentAnswer.length==0}" <view class="AnswerBtnSecond" :class="{ isCanNext: item1.StudentAnswer.length == 0 }" v-if="current != dataList.length" @click="getNextExam(item1)">
v-if="current!=dataList.length" @click="getNextExam(item1)">下一题</view> 下一题
</view>
</view> </view>
</swiper-item> </swiper-item>
</swiper> </swiper>
...@@ -104,25 +106,13 @@ ...@@ -104,25 +106,13 @@
</template> </template>
<script> <script>
import { import { ref, reactive, toRefs, toRef, getCurrentInstance, watch, computed, onMounted, onUnmounted } from 'vue';
ref, const innerAudioContext = uni.createInnerAudioContext();
reactive, innerAudioContext.autoplay = false;
toRefs, const bgAudioManager = uni.getBackgroundAudioManager();
toRef, import { SetStudentPractice } from '../../api/exam';
getCurrentInstance,
watch, export default {
computed,
onMounted,
onUnmounted,
} from "vue";
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = false;
const bgAudioManager = uni.getBackgroundAudioManager();
import {
SetStudentPractice
} from "../../api/exam";
export default {
props: { props: {
paperData: Array, paperData: Array,
Count: Number, Count: Number,
...@@ -130,34 +120,43 @@ ...@@ -130,34 +120,43 @@
StartIndex: Number StartIndex: Number
}, },
setup(props, context) { setup(props, context) {
let { let { refs } = getCurrentInstance();
refs
} = getCurrentInstance();
console.log(163, refs); console.log(163, refs);
let data = reactive({ let data = reactive({
dataList: props.paperData, dataList: props.paperData,
current: 0, //默认从第几个开始-用于从快捷菜单点入 current: 0, //默认从第几个开始-用于从快捷菜单点入
statusBarHeight: 0, statusBarHeight: 0,
audioAction: { audioAction: {
method: "pause" method: 'pause'
}, },
isIOS: false, isIOS: false,
isPlay: false isPlay: false,
currentTime: 0,
duration: 0
}); });
let UserInfo = uni.getStorageSync('userInfo'); let UserInfo = uni.getStorageSync('userInfo');
let sys = uni.getSystemInfoSync().system; let sys = uni.getSystemInfoSync().system;
watch(() => [...props.paperData], (val) => { watch(
() => [...props.paperData],
val => {
data.dataList = [...data.dataList, ...val]; data.dataList = [...data.dataList, ...val];
}) }
);
// watch(()=>props.StartIndex,(val)=>{ // watch(()=>props.StartIndex,(val)=>{
// if(val>-1){ // if(val>-1){
// data.current=val; // data.current=val;
// } // }
// }) // })
watch(()=>data.current, (newVal, oldValue) => { watch(
() => data.current,
(newVal, oldValue) => {
innerAudioContext.stop(); innerAudioContext.stop();
data.isPlay=false; data.isPlay = false;
},{deep:true}); innerAudioContext.src = data.dataList[newVal].Src;
data.duration = innerAudioContext.duration.toFixed(0);
},
{ deep: true }
);
let methods = { let methods = {
//阻止手动滑动 //阻止手动滑动
stopTouchMove() { stopTouchMove() {
...@@ -165,7 +164,7 @@ ...@@ -165,7 +164,7 @@
}, },
jumpPage() { jumpPage() {
uni.navigateTo({ uni.navigateTo({
url: "/pages/exam/examPaper", url: '/pages/exam/examPaper'
}); });
}, },
goBack() { goBack() {
...@@ -181,14 +180,16 @@ ...@@ -181,14 +180,16 @@
}, },
getErrorAnswer(item1, index, name) { getErrorAnswer(item1, index, name) {
if (item1.StudentAnswer[index] == name) { if (item1.StudentAnswer[index] == name) {
return true return true;
} else { } else {
return false return false;
} }
}, },
onchange(e) { onchange(e) {
data.currentTime = 0;
data.duration = 0;
data.current = e.detail.current; data.current = e.detail.current;
data.isPlay = false;
if (data.current + 1 == data.dataList.length) { if (data.current + 1 == data.dataList.length) {
this.$emit('getAfter'); this.$emit('getAfter');
} }
...@@ -199,19 +200,30 @@ ...@@ -199,19 +200,30 @@
data.isPlay = false; data.isPlay = false;
} else { } else {
innerAudioContext.src = Src; innerAudioContext.src = Src;
innerAudioContext.play() innerAudioContext.play();
data.isPlay = true; data.isPlay = true;
innerAudioContext.onEnded((e) => { innerAudioContext.onEnded(e => {
data.isPlay = false; data.isPlay = false;
}) });
const time = setInterval(() => {
data.currentTime = innerAudioContext.currentTime.toFixed(0); //当前播放位置
data.duration = innerAudioContext.duration.toFixed(0); //音频总长度
if (!data.isPlay) {
clearInterval(time);
}
}, 500);
} }
}, },
//点击上一题 //点击上一题
getBeforeExam() { getBeforeExam() {
data.current = data.current - 1; data.current = data.current - 1;
data.currentTime = 0;
data.duration = 0;
}, },
//点击下一题 //点击下一题
getNextExam(item) { getNextExam(item) {
data.currentTime = 0;
data.duration = 0;
let msg = { let msg = {
Id: 0, Id: 0,
StudentId: UserInfo.AccountId, StudentId: UserInfo.AccountId,
...@@ -228,61 +240,69 @@ ...@@ -228,61 +240,69 @@
IsAnswer: 0, IsAnswer: 0,
IsWrong: 0, IsWrong: 0,
Times: props.Times Times: props.Times
} };
if (data.dataList[data.current].StudentAnswer.length > 0) { if (data.dataList[data.current].StudentAnswer.length > 0) {
msg.IsAnswer = 1; msg.IsAnswer = 1;
} else { } else {
msg.IsAnswer = 0; msg.IsAnswer = 0;
} }
if (data.dataList[data.current].StudentAnswer.length == data.dataList[data.current] if (data.dataList[data.current].StudentAnswer.length == data.dataList[data.current].QuestionAnswerList.length) {
.QuestionAnswerList.length) { if (data.dataList[data.current].StudentAnswer.toString() == data.dataList[data.current].QuestionAnswerList.toString()) {
if (data.dataList[data.current].StudentAnswer.toString() == data.dataList[data.current] msg.IsWrong = 0;
.QuestionAnswerList.toString()) {
msg.IsWrong = 0
} else { } else {
msg.IsWrong = 1 msg.IsWrong = 1;
} }
} }
let res = SetStudentPractice(msg).then(res => { let res = SetStudentPractice(msg).then(res => {
if (res) { if (res) {
if (res.Code == 1) { if (res.Code == 1) {
} }
} }
}); });
if(msg.IsWrong == 0){ if (msg.IsWrong == 0) {
data.current = data.current + 1; data.current = data.current + 1;
innerAudioContext.stop(); innerAudioContext.stop();
data.isPlay = false; data.isPlay = false;
} }
}, }
}; };
onMounted(() => { onMounted(() => {
data.statusBarHeight = uni.getSystemInfoSync().statusBarHeight; data.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
}); });
onUnmounted(() => { onUnmounted(() => {
data.currentTime = 0;
data.duration = 0;
innerAudioContext.stop(); innerAudioContext.stop();
data.isPlay = true; data.isPlay = true;
}); });
let that = methods; let that = methods;
return { return {
...toRefs(data), ...toRefs(data),
...methods, ...methods
};
},
}; };
}
};
</script> </script>
<style scoped> <style scoped>
.AnswerBtn { swiper-item {
overflow-y: scroll;
}
.showtime {
height: 30px;
display: flex;
justify-content: center;
align-items: center;
}
.AnswerBtn {
margin-top: 38rpx; margin-top: 38rpx;
/* position: absolute; */ /* position: absolute; */
} }
.clear { .clear {
clear: both; clear: both;
} }
.AnswerBtnFirst { .AnswerBtnFirst {
width: 250rpx; width: 250rpx;
height: 60rpx; height: 60rpx;
text-align: center; text-align: center;
...@@ -291,9 +311,9 @@ ...@@ -291,9 +311,9 @@
border: 1px solid #00acf9; border: 1px solid #00acf9;
color: #00acf9; color: #00acf9;
float: left; float: left;
} }
.AnswerBtnSecond { .AnswerBtnSecond {
width: 250rpx; width: 250rpx;
height: 60rpx; height: 60rpx;
text-align: center; text-align: center;
...@@ -302,9 +322,9 @@ ...@@ -302,9 +322,9 @@
background-color: #00acf9; background-color: #00acf9;
color: #fff; color: #fff;
float: right; float: right;
} }
.name { .name {
height: 90rpx; height: 90rpx;
font-size: 30rpx; font-size: 30rpx;
font-family: PingFang SC; font-family: PingFang SC;
...@@ -313,64 +333,64 @@ ...@@ -313,64 +333,64 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
.isRightAnswer { .isRightAnswer {
background-color: green !important; background-color: green !important;
color: #fff !important; color: #fff !important;
} }
.isRightText { .isRightText {
color: green !important; color: green !important;
} }
.isTrueAnswer { .isTrueAnswer {
color: green !important; color: green !important;
} }
.isNotRightAnswer { .isNotRightAnswer {
background-color: red; background-color: red;
color: #fff !important; color: #fff !important;
} }
.isNotAnswer { .isNotAnswer {
color: red; color: red;
} }
.AnswerContent { .AnswerContent {
font-size: 30rpx; font-size: 30rpx;
padding: 25rpx; padding: 25rpx;
background-color: #f4f4f4; background-color: #f4f4f4;
border-radius: 5px; border-radius: 5px;
} }
.swiper-box { .swiper-box {
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
} }
.num { .num {
font-size: 30rpx; font-size: 30rpx;
font-family: PingFang SC; font-family: PingFang SC;
color: #111111; color: #111111;
} }
.item { .item {
position: relative; position: relative;
} }
.item1 { .item1 {
align-items: center; align-items: center;
overflow-y: auto; /* overflow-y: auto; */
margin-top: 30rpx; margin-top: 30rpx;
} }
.questionView { .questionView {
overflow-y: auto; overflow-y: auto;
z-index: 999; z-index: 999;
} }
.audioBox { .audioBox {
width: 120rpx; width: 120rpx;
height: 30rpx; height: 30rpx;
background: #b4ddfe; background: #b4ddfe;
...@@ -380,25 +400,25 @@ ...@@ -380,25 +400,25 @@
font-family: PingFang SC; font-family: PingFang SC;
font-weight: 500; font-weight: 500;
color: #00acf9; color: #00acf9;
} }
.item2 { .item2 {
box-sizing: border-box; box-sizing: border-box;
margin: 30rpx 0; margin: 30rpx 0;
/* padding: 0 30rpx; */ /* padding: 0 30rpx; */
} }
.item3 { .item3 {
padding-left: 25rpx; padding-left: 25rpx;
margin: 20rpx 0; margin: 20rpx 0;
} }
.myAnswer { .myAnswer {
background-color: #00acf9 !important; background-color: #00acf9 !important;
color: #ffffff !important; color: #ffffff !important;
} }
.chooseNum { .chooseNum {
width: 50rpx; width: 50rpx;
height: 50rpx; height: 50rpx;
text-align: center; text-align: center;
...@@ -410,52 +430,52 @@ ...@@ -410,52 +430,52 @@
font-family: PingFang SC; font-family: PingFang SC;
font-weight: bold; font-weight: bold;
color: #111111; color: #111111;
} }
.chooseName { .chooseName {
font-size: 30rpx; font-size: 30rpx;
font-family: PingFang SC; font-family: PingFang SC;
font-weight: 500; font-weight: 500;
color: #111111; color: #111111;
} }
.chooseName2 { .chooseName2 {
flex-grow: 1; flex-grow: 1;
border-bottom: 1px solid #111; border-bottom: 1px solid #111;
} }
.questionTitle { .questionTitle {
font-size: 28rpx; font-size: 28rpx;
font-family: PingFang SC; font-family: PingFang SC;
font-weight: bold; font-weight: bold;
color: #111111; color: #111111;
} }
.listen .van-count-down { .listen .van-count-down {
font-size: 22rpx !important; font-size: 22rpx !important;
color: #00acf9 !important; color: #00acf9 !important;
} }
.Exam_Current { .Exam_Current {
font-size: 35rpx; font-size: 35rpx;
color: red; color: red;
} }
.Exam_Count { .Exam_Count {
color: gray; color: gray;
font-size: 26rpx; font-size: 26rpx;
} }
.Exam_Score { .Exam_Score {
color: #999999; color: #999999;
font-size: 28rpx; font-size: 28rpx;
} }
.isCanNext { .isCanNext {
background-color: gray !important; background-color: gray !important;
} }
.icon_audio_default { .icon_audio_default {
background: transparent url('https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/iconloop.png') no-repeat 0 0; background: transparent url('https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/iconloop.png') no-repeat 0 0;
width: 18px; width: 18px;
height: 25px; height: 25px;
...@@ -464,9 +484,9 @@ ...@@ -464,9 +484,9 @@
-webkit-background-size: 54px 25px; -webkit-background-size: 54px 25px;
background-size: 54px 25px; background-size: 54px 25px;
background-position: -36px center; background-position: -36px center;
} }
.icon_audio_playing { .icon_audio_playing {
background: transparent url('https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/iconloop.png') no-repeat 0 0; background: transparent url('https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/iconloop.png') no-repeat 0 0;
width: 18px; width: 18px;
height: 25px; height: 25px;
...@@ -476,9 +496,9 @@ ...@@ -476,9 +496,9 @@
background-size: 54px 25px; background-size: 54px 25px;
-webkit-animation: audio_playing 1s infinite; -webkit-animation: audio_playing 1s infinite;
background-position: 0px center; background-position: 0px center;
} }
@-webkit-keyframes audio_playing { @-webkit-keyframes audio_playing {
30% { 30% {
background-position: 0px center; background-position: 0px center;
} }
...@@ -498,16 +518,16 @@ ...@@ -498,16 +518,16 @@
100% { 100% {
background-position: -36px center; background-position: -36px center;
} }
} }
.My_listen { .My_listen {
width: 150rpx; width: 150rpx;
height: 150rpx; height: 150rpx;
background-color: #E4E5FB; background-color: #e4e5fb;
border-radius: 50%; border-radius: 50%;
margin: 0 auto 30rpx; margin: 0 auto 30rpx;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment