This commit is contained in:
进进啊
2022-04-16 15:23:28 +08:00
parent 76cad44e76
commit edc7d2bb04
4 changed files with 193 additions and 127 deletions

View File

@@ -7,7 +7,7 @@
<!-- 题目选项卡模块开始 -->
<view class="answer-box">
<view class="title">
<text class="left-title">单选题难度等级{{item.difficulty}}</text>
<text class="left-title">单选题难度等级{{item.difficulty}}</text>
<text class="right-condition">
<text>{{index+1}}</text>
<text>/{{pageNum}}</text>
@@ -120,7 +120,8 @@
next(index, source) {
this.currentIndex++;
console.log('跳转到下一题', source)
},
},
// 提交成功获取的信息
messageToggle(type) {
for (let i = 0; i < this.pageNum; i++) {
@@ -135,7 +136,7 @@
this.testRes = '恭喜及格!'
this.confirmText = '继续下一难度'
} else if (this.score >= 60 && this.level == 6) {
this.level = 1;
this.level++
this.testRes = '恭喜及格!'
this.confirmText = '去加强巩固'
} else {
@@ -145,33 +146,40 @@
this.msgType = type
this.$refs.alertDialog.open()
},
//右边选项
//右边选项(继续下一难度||背单词 ||加强巩固)
dialogConfirm() {
if (this.score < 60) {
this.resetParams(0);
if (this.score < 60 ) {
this.resetParams();
uni.switchTab({
url:"../recitation/index"
})
} else if (this.score >= 60) {
} else if (this.score >= 60 && this.level <=6) {
console.log('当前难度等级',this.level)
if (this.level <= 6) {
this.resetParams(1)
} else {
this.resetParams(2)
}
}
this.setStorageData()
this.resetParams()
}else if(this.score >= 60 && this.level == 7){
this.level =1;
this.resetParams()
}
this.$refs.alertDialog.open()
},
},
// 左边选项(重新做题)
dialogClose() {
this.resetParams(0);
this.setStorageData()
// console.log('继续下一难度')
if(this.score>=60 && this.level <=6){
this.level = this.level -1;
}else if(this.level == 7){
this.level = 6;
}
this.resetParams();
console.log('重新做题')
},
// 调用云函数获取数据
async getApiQuestionData() {
async getApiQuestionData() {
uni.showLoading({
title: '加载中'
});
try {
const {
result
@@ -186,12 +194,15 @@
this.wordData.forEach(item => {
this.rightSelectArr.push(item.means)
})
this.setStorageData();
console.log('题目数据获取', result)
console.log('正确答案', this.rightSelectArr)
console.log('正确答案', this.rightSelectArr)
uni.hideLoading();
} catch (e) {
console.error(e)
console.error(e)
uni.hideLoading();
//TODO handle the exception
}
@@ -199,16 +210,12 @@
},
// 初始化参数
resetParams(condition){
resetParams(){
this.wordData = [];
this.mySelectArr = [];
this.rightSelectArr = [];
this.currentIndex = 0;
this.score = 0;
//0=分数及格 1=不及格 2=难度到达6
if(condition == 2){
this.level = 1;
}
this.getApiQuestionData();
},
@@ -223,11 +230,12 @@
},
onLoad(option) {
this.setStorageData()
this.setStorageData()
this.getApiQuestionData()
console.log('当前难度等级:', this.level)
},
onShow() {
// this.getApiQuestionData()
console.log('背单词页面显示')
// this.$forceUpdate();
@@ -339,7 +347,8 @@
justify-content: space-between;
}
.isSelected {
.isSelected {
transition: all 0.2s;
border: 2rpx solid #007AFF;
background-color: rgba(52, 152, 219, 0.3)
}

View File

@@ -78,6 +78,15 @@
}
};
},
watch: {
level(newName, oldName) {
console.log('值发生变化')
this.wordData.length = 0;
this.getApiQuestionData()
// this.wordData.reverse();
},
immediate: true
},
methods: {
// 获取上一题
@@ -91,7 +100,7 @@
// 获取下一题
next(index, wordName) {
this.currentIndex++;
if (this.currentIndex % 20 == 1) {
if (this.currentIndex % 20 == 17) {
this.getApiQuestionData();
}
this.audio = this.wordData[index + 1].wordName;
@@ -100,34 +109,40 @@
},
// 调用云函数获取数据
async getApiQuestionData() {
async getApiQuestionData() {
this.getLevelFromStorage();
uni.showLoading({
title: '加载中'
});
try {
const {
result
} = await uniCloud.callFunction({
name: 'reciteWords',
data: {
pageSize: this.pageSize,
level:this.level
pageSize: this.pageSize,
level: this.level
}
})
result.res.data.forEach(e => {
this.wordData.push(e);
})
if (this.wordData)
result.res.data.forEach(e => {
this.wordData.push(e);
})
// this.wordData.reverse();
this.pageNum = result.res.total
if (this.wordData.length < 22) {
this.audio = this.wordData[0].wordName;
this.getAudioResource()
}
uni.hideLoading();
console.log('题目数据获取', this.wordData)
} catch (e) {
console.error(e)
//TODO handle the exception
}
@@ -137,25 +152,29 @@
getAudioResource() {
this.current.src = 'http://dict.youdao.com/dictvoice?type=0&audio=' + this.audio
console.log(this.current.src)
},
// 从缓存中获取到难度等级
getLevelFromStorage(){
try{
const value = uni.getStorageSync('level_type')
this.level = value;
if(this.level){
console.log('目前的缓存中的题目难度',this.level)
}
}catch(e){
console.log(e)
}
},
// 从缓存中获取到难度等级
getLevelFromStorage() {
try {
const value = uni.getStorageSync('level_type')
this.level = value;
if (this.level) {
console.log('目前的缓存中的题目难度', this.level)
}
} catch (e) {
console.log(e)
}
}
},
onLoad() {
this.getApiQuestionData()
},
onShow(){
onLoad() {
// this.getApiQuestionData()
},
onShow() {
this.getLevelFromStorage();
console.log('获取背诵题目')
}
}
</script>