Commit 5cab2d6c authored by zhengke's avatar zhengke

修改

parent f33d5a3b
......@@ -19,10 +19,13 @@
</view>
</view>
<view class="listen" @click="play(item.FileUrl)">
<!-- <image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/laba2x.png"
mode="aspectFit" class="listenIcon"></image> -->
<i class="icon_audio_default" v-if="!isPlay"></i>
<i class="icon_audio_playing" v-else></i>
<template v-if="!isLoading">
<i class="icon_audio_default" v-if="!isPlay"></i>
<i class="icon_audio_playing" v-else></i>
</template>
<template v-else>
<van-loading type="spinner" color="#7b7f80" />
</template>
</view>
<view class="listenText">
播放读音
......@@ -63,13 +66,14 @@
default: () => {
return {}
}
}
},
},
setup(props) {
const data = reactive({
isPlay: false
let data = reactive({
isPlay: false,
isLoading: false
})
const methods = {
let methods = {
play(src) {
if(src){
innerAudioContext.src=encodeURI(src);
......@@ -77,10 +81,24 @@
innerAudioContext.src =
`https://fanyi.baidu.com/gettts?lan=jp&text=${encodeURIComponent(props.item.WordContent)}&spd=3&source=web`
}
innerAudioContext.play()
data.isPlay = true;
innerAudioContext.play();
if(!data.isPlay){
data.isLoading=true;
}
innerAudioContext.onCanplay(()=>{
data.isLoading=false;
data.isPlay = true;
})
innerAudioContext.onEnded((e)=>{
data.isPlay = false;
data.isLoading=false;
})
},
stopVoice(){
data.isPlay=false;
innerAudioContext.stop();
innerAudioContext.offCanplay(()=>{
})
}
}
......
......@@ -75,7 +75,15 @@
const total = data.reviewGroupList.length + data.prepGroupList.length
if (data.curTest == total) {
methods.submitWordsTest()
uni.removeStorageSync("testData", obj);
}
let obj = {
CourseId:data.msg.CourseId,
ChapterId:data.msg.ChapterId,
NextChapterId:data.msg.NextChapterId,
index:data.curTest
}
uni.setStorageSync("testData", obj);
},
next(val, item) {
if (val) {
......@@ -106,7 +114,23 @@
},
};
onMounted(() => {
data.startTime = getCurrentTime()
data.startTime = getCurrentTime();
let testObj = uni.getStorageSync('testData');
if(testObj){
if((data.msg.CourseId==testObj.CourseId)&&(data.msg.ChapterId==testObj.ChapterId)&&(data.msg.NextChapterId==testObj.NextChapterId)){
uni.showModal({
title: '提示',
content: `是否继续上次测试`,
success: function(res) {
if (res.confirm) {
data.curTest = testObj.index;
} else if (res.cancel) {
data.curTest = 0;
}
}
});
}
}
});
let that = methods;
return {
......
<template>
<view class="word">
<van-skeleton title row="10" v-if="loading" />
<van-empty description="暂无数据" v-if="nodata"/>
<van-empty description="暂无数据" v-if="nodata" />
<swiper class="swiper" next-margin="60rpx" @change="swiperChange" :current="current" v-if="!loading&&!nodata">
<swiper-item v-for="(item,index) in StudyList" v-if="Type==2" :key="index" class="swiper-item">
<Pronunciation :item="item" :cur="index+1" :total="StudyList.length"></Pronunciation>
<Pronunciation :item="item" :cur="index+1" :ref="'cur'+index" :total="StudyList.length"></Pronunciation>
</swiper-item>
<swiper-item v-for="(item,index) in ReviewList" v-if="Type==1" :key="index" class="swiper-item">
<Pronunciation :item="item" :cur="index+1" :total="ReviewList.length" :type="1"></Pronunciation>
<Pronunciation :item="item" :cur="index+1" :total="ReviewList.length" :type="1">
</Pronunciation>
</swiper-item>
<swiper-item></swiper-item>
</swiper>
......@@ -57,48 +58,118 @@
StudyNum: 0, //学习总单词数量
StudyType: 1, //1-预习,2-复习
},
Type:1, //1复习 2 单词
TotalHours:0,
CourseName:'',
Type: 1, //1复习 2 单词
TotalHours: 0,
CourseName: '',
loading: false,
nodata: false,
nodata: false
})
let methods = {
getData() {
data.loading=true
data.loading = true
proxy.$request('/AppletWords/GetStudyWords', data.msg).then(res => {
data.loading=false
data.loading = false
data.StudyList = res.Data.StudyList
data.ReviewList = res.Data.ReviewList;
data.current = 0
data.current = 0
if (data.StudyList.length === 0 && data.ReviewList.length == 0) {
data.nodata = true
}
}).catch(err=>{
data.loading=false
}).catch(err => {
data.loading = false
data.nodata = true
})
},
getCountine() {
if (data.StudyList.length > 0) {
let ChapterId = data.StudyList[0].ChapterId;
let CourseId = data.StudyList[0].CourseId;
let studyObj = uni.getStorageSync('studyData');
if (ChapterId == studyObj.ChapterId && CourseId == studyObj.CourseId) {
data.current = studyObj.index;
}
}
if (data.ReviewList.length > 0) {
let ChapterId = data.ReviewList[0].ChapterId;
let CourseId = data.ReviewList[0].CourseId;
let studyObj = uni.getStorageSync('reviewData');
if (ChapterId == studyObj.ChapterId && CourseId == studyObj.CourseId) {
data.current = studyObj.index;
}
}
},
swiperChange(val) {
data.current = val.detail.current
if(data.Type==1){
if (val.detail.current + 1 == data.ReviewList.length+1 && data.ReviewList.length > 1) {
if (data.Type == 1) {
if (val.detail.current + 1 == data.ReviewList.length + 1 && data.ReviewList.length > 1) {
uni.navigateTo({
url: `/pages/word/readComplete?ClassId=${data.readMsg.ClassId}&&CourseId=${data.readMsg.CourseId}&&CourseName=${data.CourseName}&&TotalHours=${data.TotalHours}`
})
uni.removeStorageSync("reviewData")
}
let obj = {
ChapterId: 0,
CourseId: 0,
index: 0
}
let name = 'cur' + val.detail.current;
if(val.detail.current+1<=data.ReviewList.length){
obj.ChapterId = data.ReviewList[data.current].ChapterId;
obj.CourseId = data.ReviewList[data.current].CourseId;
obj.index = data.current;
uni.setStorageSync("reviewData", obj);
this.$refs[name][0].stopVoice();
}
}
if(data.Type==2){
if (val.detail.current + 1 == data.StudyList.length+1 && data.StudyList.length > 1) {
if (data.Type == 2) {
if (val.detail.current + 1 == data.StudyList.length + 1 && data.StudyList.length > 1) {
uni.navigateTo({
url: `/pages/word/readComplete?ClassId=${data.readMsg.ClassId}&&CourseId=${data.readMsg.CourseId}&&CourseName=${data.CourseName}&&TotalHours=${data.TotalHours}`
})
uni.removeStorageSync("studyData")
}
let obj = {
ChapterId: 0,
CourseId: 0,
index: 0
}
let name = 'cur' + val.detail.current;
if(val.detail.current+1<=data.StudyList.length){
obj.ChapterId = data.StudyList[data.current].ChapterId;
obj.CourseId = data.StudyList[data.current].CourseId;
obj.index = data.current;
uni.setStorageSync("studyData", obj);
this.$refs[name][0].stopVoice();
}
}
},
}
onMounted(() => {
var studyObj = uni.getStorageSync("studyData");
if ((data.msg.ChapterId == studyObj.ChapterId) && (data.msg.CourseId == studyObj.CourseId)) {
let str = ''
if (data.Type == 1) {
str = '复习'
} else {
str = '学习'
}
if (studyObj && studyObj.index > 1) {
uni.showModal({
title: '提示',
content: `是否继续上次${str}?`,
success: function(res) {
if (res.confirm) {
that.getCountine();
} else if (res.cancel) {
data.current = 0;
}
}
});
}
}
})
let that = methods;
return {
......@@ -117,13 +188,13 @@
if (options.ChapterId && options.CourseId && options.ReviewChapterId) {
this.getData();
}
if(options.Type){
this.Type=options.Type
if (options.Type) {
this.Type = options.Type
}
if(options.CourseName){
this.CourseName = options.CourseName;
if (options.CourseName) {
this.CourseName = options.CourseName;
}
if(options.TotalHours){
if (options.TotalHours) {
this.TotalHours = options.TotalHours;
}
const userInfo = uni.getStorageSync('userInfo');
......
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