diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index 716f35f..2a5ce8f 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -2,6 +2,10 @@ // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 "version": "0.0", "configurations": [{ + "app-plus" : + { + "launchtype" : "local" + }, "default" : { "launchtype" : "local" diff --git a/manifest.json b/manifest.json index a0f0664..2d7ba56 100644 --- a/manifest.json +++ b/manifest.json @@ -1,72 +1,106 @@ -{ - "name" : "word-pratice", - "appid" : "__UNI__7D81F71", - "description" : "", - "versionName" : "1.0.0", - "versionCode" : "100", - "transformPx" : false, - /* 5+App特有相关 */ - "app-plus" : { - "usingComponents" : true, - "nvueStyleCompiler" : "uni-app", - "compilerVersion" : 3, - "splashscreen" : { - "alwaysShowBeforeRender" : true, - "waiting" : true, - "autoclose" : true, - "delay" : 0 - }, - /* 模块配置 */ - "modules" : {}, - /* 应用发布信息 */ - "distribute" : { - /* android打包配置 */ - "android" : { - "permissions" : [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ] - }, - /* ios打包配置 */ - "ios" : {}, - /* SDK配置 */ - "sdkConfigs" : {} - } - }, - /* 快应用特有相关 */ - "quickapp" : {}, - /* 小程序特有相关 */ - "mp-weixin" : { - "appid" : "", - "setting" : { - "urlCheck" : false - }, - "usingComponents" : true - }, - "mp-alipay" : { - "usingComponents" : true - }, - "mp-baidu" : { - "usingComponents" : true - }, - "mp-toutiao" : { - "usingComponents" : true - }, - "uniStatistics" : { - "enable" : false - }, - "vueVersion" : "2" -} +{ + "name" : "管制员英语词汇", + "appid" : "__UNI__7D81F71", + "description" : "", + "versionName" : "1.0.0", + "versionCode" : "100", + "transformPx" : false, + /* 5+App特有相关 */ + "app-plus" : { + "usingComponents" : true, + "nvueStyleCompiler" : "uni-app", + "compilerVersion" : 3, + "splashscreen" : { + "alwaysShowBeforeRender" : true, + "waiting" : true, + "autoclose" : true, + "delay" : 0 + }, + /* 模块配置 */ + "modules" : {}, + /* 应用发布信息 */ + "distribute" : { + /* android打包配置 */ + "android" : { + "permissions" : [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + /* ios打包配置 */ + "ios" : {}, + /* SDK配置 */ + "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" + } + } + } + } + }, + /* 快应用特有相关 */ + "quickapp" : {}, + /* 小程序特有相关 */ + "mp-weixin" : { + "appid" : "", + "setting" : { + "urlCheck" : false + }, + "usingComponents" : true + }, + "mp-alipay" : { + "usingComponents" : true + }, + "mp-baidu" : { + "usingComponents" : true + }, + "mp-toutiao" : { + "usingComponents" : true + }, + "uniStatistics" : { + "enable" : false + }, + "vueVersion" : "2" +} diff --git a/pages/home/index.vue b/pages/home/index.vue index 143dbbc..a23cb4d 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -7,7 +7,7 @@ - 单选题(难度等级{{item.difficulty}}) + 单选题(难度等级:{{item.difficulty}}) {{index+1}} /{{pageNum}} @@ -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) } diff --git a/pages/recitation/index.vue b/pages/recitation/index.vue index 1684cb9..62707a5 100644 --- a/pages/recitation/index.vue +++ b/pages/recitation/index.vue @@ -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('获取背诵题目') + + } }