diff --git a/pages.json b/pages.json index 25f554d..4662a8b 100644 --- a/pages.json +++ b/pages.json @@ -3,7 +3,7 @@ { "path": "pages/home/index", "style": { - "navigationBarTitleText": "单词学习宝典" + "navigationBarTitleText": "管制员英语词汇" } } ,{ diff --git a/pages/answer-detail/answer-detail.vue b/pages/answer-detail/answer-detail.vue index 0a312ab..2fc1d4f 100644 --- a/pages/answer-detail/answer-detail.vue +++ b/pages/answer-detail/answer-detail.vue @@ -101,12 +101,8 @@ }, // 获取下一题 - next(index) { - // if (this.pageSize < 10) { - // this.pageSize++ - // } -this.currentIndex++; - // this.getApiQuestionData() + next(index) { + this.currentIndex++; console.log('跳转到下一题',index) }, // 提交成功获取的信息 @@ -239,6 +235,7 @@ this.currentIndex++; } .select-item { + text { min-height: 100rpx; margin: 20rpx 0; @@ -249,7 +246,7 @@ this.currentIndex++; border: 2rpx solid #dee1e6; border-radius: 8rpx; - padding: 0 20rpx; + padding:15rpx; background-color: #f2f5f8; display: block; display: flex; diff --git a/uniCloud-aliyun/cloudfunctions/provideQuestion/index.js b/uniCloud-aliyun/cloudfunctions/provideQuestion/index.js index 61237d7..7a359cb 100644 --- a/uniCloud-aliyun/cloudfunctions/provideQuestion/index.js +++ b/uniCloud-aliyun/cloudfunctions/provideQuestion/index.js @@ -2,26 +2,58 @@ const db = uniCloud.database(); exports.main = async (event, context) => { //event为客户端上传的参数 - // const count = await db.collection('questionList').count() - // 根据level字段随机返回不同的数据 - + + // 根据level字段随机返回数据库中不同的数据40组 let res = await db.collection('allWordList').aggregate().match({ difficulty: event.level }).sample({ - size: 10 - }).limit(10).addFields({ - 'options':["$means",'B. v.爬升,上升.n.爬升率,上升率;上升距离','C adv.不变地;经常地;坚持不懈地','D n.积云;组合,集结;累积;形成'] - }).end() - - // let resMeans = await db.collection('allWordList').where({}) + size: 40 + }).limit(40).end() let data = res.data - console.log('入参:页码+难度', event, res) + let optionData = []; + // 设置计数器 + let count = 0; + // 前10组数据用于题目 后30组数据用于选项 + data.forEach((item, index) => { + if (index < 10) { + item.options = [item.means] + } else if (index >= 10 && index < 40) { + optionData.push(item.means) + } - // let res + }) + + // 将后30组数据中的单词含义赋值到前10组数据中的数组中 + data.forEach((item, index) => { + if (item.options) { + for (let i = 1; i < 4; i++) { + item.options.push(optionData[count]) + count++ + } + + } + }) + + // 打乱题目选项 + data.forEach((item, index) => { + if (item.options) { + item.options.sort(() => { + return (0.5 - Math.random()); + }); + // 添加题标 + item.options[0] = `A. ${item.options[0]}` + item.options[1] = `B. ${item.options[1]}` + item.options[2] = `C. ${item.options[2]}` + item.options[3] = `D. ${item.options[3]}` + } + }) + + console.log('选项列表', optionData) + console.log('入参:页码+难度', event, res) //返回数据给客户端 return { code: 200, msg: 'success', - data + data, } };