diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json
index 07c1d5f..3a90961 100644
--- a/.hbuilderx/launch.json
+++ b/.hbuilderx/launch.json
@@ -10,7 +10,11 @@
{
"launchtype" : "local"
},
- "type" : "uniCloud"
+ "type" : "uniCloud",
+ "uniapp" :
+ {
+ "launchtype" : "local"
+ }
}
]
}
diff --git a/pages/answer-detail/answer-detail.vue b/pages/answer-detail/answer-detail.vue
index 2926196..0a312ab 100644
--- a/pages/answer-detail/answer-detail.vue
+++ b/pages/answer-detail/answer-detail.vue
@@ -135,7 +135,7 @@ this.currentIndex++;
data:{level:this.level,pageSize:this.pageSize}
})
this.wordData = result.data
- console.log('题目数据获取',result.data)
+ console.log('题目数据获取',result)
}catch(e){
console.error(e)
diff --git a/pages/recitation/index.vue b/pages/recitation/index.vue
index 880c89a..799774c 100644
--- a/pages/recitation/index.vue
+++ b/pages/recitation/index.vue
@@ -17,8 +17,9 @@
{{item.wordName}}
音标:{{item.phonetic}}
- 读音:{{item.pronunciation}}
+ 读音:{{item.pronunciation}}
+
@@ -32,10 +33,10 @@
-
@@ -64,8 +65,8 @@
data() {
return {
selectIndex: -1,
- pageSize: 1,
- pageNum: 3155,
+ pageSize: 21,
+ pageNum: '',
currentIndex:0,
level: '',
wordData:[],
@@ -73,39 +74,49 @@
msgType: 'success',
messageText: '这是一条成功提示',
value: '',
- resultDialog: '您的成绩合格!'
+ resultDialog: '您的成绩合格!',
+ audio:'',
+ current: {
+ src: '',
+ audioAction: {
+ method: 'pause'
+ },
+ }
};
},
methods: {
// 获取上一题
- previous(index) {
- // if (this.pageSize > 1) {
- // this.pageSize--
- // }
- this.currentIndex--;
- console.log('回到上一题',this.currentIndex,index)
+ previous(index,wordName) {
+ this.getAudioResource()
+ this.currentIndex--;
+ this.audio = this.wordData[index-1].wordName;
+ console.log('回到上一题',index,this.wordData[index-1].wordName)
},
// 获取下一题
- next(index) {
- // if (this.pageSize < 10) {
- // this.pageSize++
- // }
-this.currentIndex++;
- // this.getApiQuestionData()
- console.log('跳转到下一题',index)
+ next(index,wordName) {
+ this.currentIndex++;
+ if(this.currentIndex % 20 == 1){
+ this.getApiQuestionData();
+ }
+ this.audio = this.wordData[index+1].wordName;
+ this.getAudioResource()
+ console.log('跳转到下一题',index,this.wordData[index+1].wordName)
},
+
// 提交成功获取的信息
messageToggle(type) {
this.msgType = type
this.$refs.alertDialog.open()
},
+
//确认提交
dialogConfirm() {
console.log('点击确认')
this.$refs.alertDialog.open()
},
+
// 关闭提交窗口
dialogClose() {
uni.switchTab({
@@ -118,11 +129,21 @@ this.currentIndex++;
async getApiQuestionData(){
try{
const {result} = await uniCloud.callFunction({
- name:'provideQuestion',
- data:{level:this.level,pageSize:this.pageSize}
- })
- this.wordData = result.data
- console.log('题目数据获取',result.data)
+ name:'reciteWords',
+ data:{pageSize:this.pageSize}
+ })
+ result.res.data.forEach(e=>{
+ this.wordData.push(e);
+ })
+ this.pageNum = result.res.total
+ if(this.wordData.length<22){
+ this.audio = this.wordData[0].wordName;
+ this.getAudioResource()
+ }
+
+
+
+ console.log('题目数据获取',this.wordData)
}catch(e){
console.error(e)
@@ -130,13 +151,23 @@ this.currentIndex++;
}
+ },
+
+ // 获取音频链接
+ getAudioResource(){
+ this.current.src = 'http://dict.youdao.com/dictvoice?type=0&audio=' + this.audio
+ console.log(this.current.src)
}
-
},
- onLoad(option) {
- this.level = option.wordId;
- this.getApiQuestionData()
- console.log('获取到', this.level)
+ onLoad(option) {
+
+ this.getApiQuestionData()
+ // setTimeout(()=>{
+ // this.audio = this.wordData[0].wordName;
+ // this.getAudioResource()
+ // },2000)
+
+
}
}
@@ -194,7 +225,9 @@ this.currentIndex++;
.content {
.read{
display: flex;
- align-items: center;
+ align-items: center;
+ position: relative;
+
image{
// line-height: 36rpx;
@@ -228,15 +261,15 @@ this.currentIndex++;
.select-item {
text {
min-height: 100rpx;
- margin: 20rpx 0;
+ margin: 20rpx 0;
+
&:nth-child(4) {
margin-bottom: 0;
}
-
border: 2rpx solid #dee1e6;
border-radius: 8rpx;
- padding: 0 20rpx;
+ padding: 20rpx;
background-color: #f2f5f8;
display: block;
display: flex;
@@ -270,5 +303,32 @@ this.currentIndex++;
.noData{
font-size: 30rpx;
text-align: center;
- }
+ }
+ /deep/ .uni-audio-default{
+ min-width:0rpx !important;
+ position: absolute;
+ padding: 0 !important;
+ margin: 0 !important;
+ height: 40rpx;
+ width: 40rpx;
+
+ top: 30rpx;
+ right: 190rpx;
+ opacity: 0;
+ }
+ /deep/ .uni-audio-right{
+ display: none !important;
+
+ }
+ /deep/ .uni-audio-button{
+ margin: 0 !important;
+ height: 40rpx;
+ width: 40rpx;
+ }
+ /deep/ .uni-audio-left{
+ // height: 40rpx;
+ // display: none !important;
+
+ }
+
diff --git a/uniCloud-aliyun/cloudfunctions/provideQuestion/index.js b/uniCloud-aliyun/cloudfunctions/provideQuestion/index.js
index 564c6f6..61237d7 100644
--- a/uniCloud-aliyun/cloudfunctions/provideQuestion/index.js
+++ b/uniCloud-aliyun/cloudfunctions/provideQuestion/index.js
@@ -3,12 +3,13 @@ const db = uniCloud.database();
exports.main = async (event, context) => {
//event为客户端上传的参数
// const count = await db.collection('questionList').count()
- // 根据level字段随机返回不同的数据
+ // 根据level字段随机返回不同的数据
+
let res = await db.collection('allWordList').aggregate().match({
difficulty: event.level
}).sample({
size: 10
- }).addFields({
+ }).limit(10).addFields({
'options':["$means",'B. v.爬升,上升.n.爬升率,上升率;上升距离','C adv.不变地;经常地;坚持不懈地','D n.积云;组合,集结;累积;形成']
}).end()
diff --git a/uniCloud-aliyun/cloudfunctions/reciteWords/index.js b/uniCloud-aliyun/cloudfunctions/reciteWords/index.js
new file mode 100644
index 0000000..7a337c1
--- /dev/null
+++ b/uniCloud-aliyun/cloudfunctions/reciteWords/index.js
@@ -0,0 +1,23 @@
+'use strict';
+const db = uniCloud.database();
+exports.main = async (event, context) => {
+ //event为客户端上传的参数
+ let count = await db.collection('allWordList').count()
+ // 根据level字段随机返回不同的数据
+
+ let res = await db.collection('allWordList').aggregate().sample({
+ size: event.pageSize
+ }).limit(event.pageSize).end()
+ res.total = count.total;
+ let data = res.data
+ console.log('入参:页码+难度', event, res,count)
+
+ // let res
+ //返回数据给客户端
+ return {
+ code: 200,
+ msg: 'success',
+ res,
+
+ }
+};