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

@@ -2,6 +2,10 @@
// launchtype项可配置值为local或remote, local代表前端连本地云函数remote代表前端连云端云函数 // launchtype项可配置值为local或remote, local代表前端连本地云函数remote代表前端连云端云函数
"version": "0.0", "version": "0.0",
"configurations": [{ "configurations": [{
"app-plus" :
{
"launchtype" : "local"
},
"default" : "default" :
{ {
"launchtype" : "local" "launchtype" : "local"

View File

@@ -1,5 +1,5 @@
{ {
"name" : "word-pratice", "name" : "管制员英语词汇",
"appid" : "__UNI__7D81F71", "appid" : "__UNI__7D81F71",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
@@ -43,7 +43,41 @@
/* ios */ /* ios */
"ios" : {}, "ios" : {},
/* SDK */ /* SDK */
"sdkConfigs" : {} "sdkConfigs" : {
"ad" : {}
},
"icons" : {
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
},
"ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
}
}
}
} }
}, },
/* */ /* */

View File

@@ -7,7 +7,7 @@
<!-- 题目选项卡模块开始 --> <!-- 题目选项卡模块开始 -->
<view class="answer-box"> <view class="answer-box">
<view class="title"> <view class="title">
<text class="left-title">单选题难度等级{{item.difficulty}}</text> <text class="left-title">单选题难度等级{{item.difficulty}}</text>
<text class="right-condition"> <text class="right-condition">
<text>{{index+1}}</text> <text>{{index+1}}</text>
<text>/{{pageNum}}</text> <text>/{{pageNum}}</text>
@@ -121,6 +121,7 @@
this.currentIndex++; this.currentIndex++;
console.log('跳转到下一题', source) console.log('跳转到下一题', source)
}, },
// 提交成功获取的信息 // 提交成功获取的信息
messageToggle(type) { messageToggle(type) {
for (let i = 0; i < this.pageNum; i++) { for (let i = 0; i < this.pageNum; i++) {
@@ -135,7 +136,7 @@
this.testRes = '恭喜及格!' this.testRes = '恭喜及格!'
this.confirmText = '继续下一难度' this.confirmText = '继续下一难度'
} else if (this.score >= 60 && this.level == 6) { } else if (this.score >= 60 && this.level == 6) {
this.level = 1; this.level++
this.testRes = '恭喜及格!' this.testRes = '恭喜及格!'
this.confirmText = '去加强巩固' this.confirmText = '去加强巩固'
} else { } else {
@@ -145,33 +146,40 @@
this.msgType = type this.msgType = type
this.$refs.alertDialog.open() this.$refs.alertDialog.open()
}, },
//右边选项 //右边选项(继续下一难度||背单词 ||加强巩固)
dialogConfirm() { dialogConfirm() {
if (this.score < 60) { if (this.score < 60 ) {
this.resetParams(0); this.resetParams();
uni.switchTab({ uni.switchTab({
url:"../recitation/index" url:"../recitation/index"
}) })
} else if (this.score >= 60) { } else if (this.score >= 60 && this.level <=6) {
console.log('当前难度等级',this.level) console.log('当前难度等级',this.level)
if (this.level <= 6) { this.resetParams()
this.resetParams(1) }else if(this.score >= 60 && this.level == 7){
} else { this.level =1;
this.resetParams(2) this.resetParams()
} }
}
this.setStorageData()
this.$refs.alertDialog.open() this.$refs.alertDialog.open()
}, },
// 左边选项(重新做题) // 左边选项(重新做题)
dialogClose() { dialogClose() {
this.resetParams(0); if(this.score>=60 && this.level <=6){
this.setStorageData() this.level = this.level -1;
// console.log('继续下一难度') }else if(this.level == 7){
this.level = 6;
}
this.resetParams();
console.log('重新做题')
}, },
// 调用云函数获取数据 // 调用云函数获取数据
async getApiQuestionData() { async getApiQuestionData() {
uni.showLoading({
title: '加载中'
});
try { try {
const { const {
result result
@@ -186,12 +194,15 @@
this.wordData.forEach(item => { this.wordData.forEach(item => {
this.rightSelectArr.push(item.means) this.rightSelectArr.push(item.means)
}) })
this.setStorageData();
console.log('题目数据获取', result) console.log('题目数据获取', result)
console.log('正确答案', this.rightSelectArr) console.log('正确答案', this.rightSelectArr)
uni.hideLoading();
} catch (e) { } catch (e) {
console.error(e) console.error(e)
uni.hideLoading();
//TODO handle the exception //TODO handle the exception
} }
@@ -199,16 +210,12 @@
}, },
// 初始化参数 // 初始化参数
resetParams(condition){ resetParams(){
this.wordData = []; this.wordData = [];
this.mySelectArr = []; this.mySelectArr = [];
this.rightSelectArr = []; this.rightSelectArr = [];
this.currentIndex = 0; this.currentIndex = 0;
this.score = 0; this.score = 0;
//0=分数及格 1=不及格 2=难度到达6
if(condition == 2){
this.level = 1;
}
this.getApiQuestionData(); this.getApiQuestionData();
}, },
@@ -228,6 +235,7 @@
console.log('当前难度等级:', this.level) console.log('当前难度等级:', this.level)
}, },
onShow() { onShow() {
// this.getApiQuestionData()
console.log('背单词页面显示') console.log('背单词页面显示')
// this.$forceUpdate(); // this.$forceUpdate();
@@ -340,6 +348,7 @@
} }
.isSelected { .isSelected {
transition: all 0.2s;
border: 2rpx solid #007AFF; border: 2rpx solid #007AFF;
background-color: rgba(52, 152, 219, 0.3) 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: { methods: {
// 获取上一题 // 获取上一题
@@ -91,7 +100,7 @@
// 获取下一题 // 获取下一题
next(index, wordName) { next(index, wordName) {
this.currentIndex++; this.currentIndex++;
if (this.currentIndex % 20 == 1) { if (this.currentIndex % 20 == 17) {
this.getApiQuestionData(); this.getApiQuestionData();
} }
this.audio = this.wordData[index + 1].wordName; this.audio = this.wordData[index + 1].wordName;
@@ -101,33 +110,39 @@
// 调用云函数获取数据 // 调用云函数获取数据
async getApiQuestionData() { async getApiQuestionData() {
this.getLevelFromStorage(); this.getLevelFromStorage();
uni.showLoading({
title: '加载中'
});
try { try {
const { const {
result result
} = await uniCloud.callFunction({ } = await uniCloud.callFunction({
name: 'reciteWords', name: 'reciteWords',
data: { data: {
pageSize: this.pageSize, pageSize: this.pageSize,
level:this.level level: this.level
} }
}) })
if (this.wordData)
result.res.data.forEach(e => { result.res.data.forEach(e => {
this.wordData.push(e); this.wordData.push(e);
}) })
// this.wordData.reverse();
this.pageNum = result.res.total this.pageNum = result.res.total
if (this.wordData.length < 22) { if (this.wordData.length < 22) {
this.audio = this.wordData[0].wordName; this.audio = this.wordData[0].wordName;
this.getAudioResource() this.getAudioResource()
} }
uni.hideLoading();
console.log('题目数据获取', this.wordData) console.log('题目数据获取', this.wordData)
} catch (e) { } catch (e) {
console.error(e) console.error(e)
//TODO handle the exception
} }
@@ -140,22 +155,26 @@
}, },
// 从缓存中获取到难度等级 // 从缓存中获取到难度等级
getLevelFromStorage(){ getLevelFromStorage() {
try{ try {
const value = uni.getStorageSync('level_type') const value = uni.getStorageSync('level_type')
this.level = value; this.level = value;
if(this.level){ if (this.level) {
console.log('目前的缓存中的题目难度',this.level) console.log('目前的缓存中的题目难度', this.level)
} }
}catch(e){ } catch (e) {
console.log(e) console.log(e)
} }
} }
}, },
onLoad() { onLoad() {
this.getApiQuestionData() // this.getApiQuestionData()
}, },
onShow(){ onShow() {
this.getLevelFromStorage();
console.log('获取背诵题目')
} }
} }
</script> </script>