背诵部分完成
This commit is contained in:
@@ -10,7 +10,11 @@
|
|||||||
{
|
{
|
||||||
"launchtype" : "local"
|
"launchtype" : "local"
|
||||||
},
|
},
|
||||||
"type" : "uniCloud"
|
"type" : "uniCloud",
|
||||||
|
"uniapp" :
|
||||||
|
{
|
||||||
|
"launchtype" : "local"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ this.currentIndex++;
|
|||||||
data:{level:this.level,pageSize:this.pageSize}
|
data:{level:this.level,pageSize:this.pageSize}
|
||||||
})
|
})
|
||||||
this.wordData = result.data
|
this.wordData = result.data
|
||||||
console.log('题目数据获取',result.data)
|
console.log('题目数据获取',result)
|
||||||
|
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
|||||||
@@ -17,8 +17,9 @@
|
|||||||
<view>{{item.wordName}}</view>
|
<view>{{item.wordName}}</view>
|
||||||
<view class="read">
|
<view class="read">
|
||||||
<text>音标:{{item.phonetic}}</text>
|
<text>音标:{{item.phonetic}}</text>
|
||||||
<text>读音:{{item.pronunciation}}
|
<text @tap="getAudioResource">读音:{{item.pronunciation}}
|
||||||
<image src="../../static/icon/listen.png" mode="widthFix"></image>
|
<image src="../../static/icon/listen.png" mode="widthFix"></image>
|
||||||
|
<audio :src="current.src" controls></audio>
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -32,10 +33,10 @@
|
|||||||
<!-- 翻页按钮模块开始 -->
|
<!-- 翻页按钮模块开始 -->
|
||||||
<view class="page-btn">
|
<view class="page-btn">
|
||||||
<view class="btn">
|
<view class="btn">
|
||||||
<button type="default" @tap="previous(index)" v-if="currentIndex >= 1">
|
<button type="default" @tap="previous(index,item.wordName)" v-if="currentIndex >= 1">
|
||||||
上一个单词
|
上一个单词
|
||||||
</button>
|
</button>
|
||||||
<button type="default" @tap="next(index)" >
|
<button type="default" @tap="next(index,item.wordName)" v-if="currentIndex < pageNum" >
|
||||||
下一个单词
|
下一个单词
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
@@ -64,8 +65,8 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectIndex: -1,
|
selectIndex: -1,
|
||||||
pageSize: 1,
|
pageSize: 21,
|
||||||
pageNum: 3155,
|
pageNum: '',
|
||||||
currentIndex:0,
|
currentIndex:0,
|
||||||
level: '',
|
level: '',
|
||||||
wordData:[],
|
wordData:[],
|
||||||
@@ -73,39 +74,49 @@
|
|||||||
msgType: 'success',
|
msgType: 'success',
|
||||||
messageText: '这是一条成功提示',
|
messageText: '这是一条成功提示',
|
||||||
value: '',
|
value: '',
|
||||||
resultDialog: '您的成绩合格!'
|
resultDialog: '您的成绩合格!',
|
||||||
|
audio:'',
|
||||||
|
current: {
|
||||||
|
src: '',
|
||||||
|
audioAction: {
|
||||||
|
method: 'pause'
|
||||||
|
},
|
||||||
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
// 获取上一题
|
// 获取上一题
|
||||||
previous(index) {
|
previous(index,wordName) {
|
||||||
// if (this.pageSize > 1) {
|
this.getAudioResource()
|
||||||
// this.pageSize--
|
|
||||||
// }
|
|
||||||
this.currentIndex--;
|
this.currentIndex--;
|
||||||
console.log('回到上一题',this.currentIndex,index)
|
this.audio = this.wordData[index-1].wordName;
|
||||||
|
console.log('回到上一题',index,this.wordData[index-1].wordName)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取下一题
|
// 获取下一题
|
||||||
next(index) {
|
next(index,wordName) {
|
||||||
// if (this.pageSize < 10) {
|
|
||||||
// this.pageSize++
|
|
||||||
// }
|
|
||||||
this.currentIndex++;
|
this.currentIndex++;
|
||||||
// this.getApiQuestionData()
|
if(this.currentIndex % 20 == 1){
|
||||||
console.log('跳转到下一题',index)
|
this.getApiQuestionData();
|
||||||
|
}
|
||||||
|
this.audio = this.wordData[index+1].wordName;
|
||||||
|
this.getAudioResource()
|
||||||
|
console.log('跳转到下一题',index,this.wordData[index+1].wordName)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 提交成功获取的信息
|
// 提交成功获取的信息
|
||||||
messageToggle(type) {
|
messageToggle(type) {
|
||||||
this.msgType = type
|
this.msgType = type
|
||||||
this.$refs.alertDialog.open()
|
this.$refs.alertDialog.open()
|
||||||
},
|
},
|
||||||
|
|
||||||
//确认提交
|
//确认提交
|
||||||
dialogConfirm() {
|
dialogConfirm() {
|
||||||
console.log('点击确认')
|
console.log('点击确认')
|
||||||
this.$refs.alertDialog.open()
|
this.$refs.alertDialog.open()
|
||||||
},
|
},
|
||||||
|
|
||||||
// 关闭提交窗口
|
// 关闭提交窗口
|
||||||
dialogClose() {
|
dialogClose() {
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
@@ -118,11 +129,21 @@ this.currentIndex++;
|
|||||||
async getApiQuestionData(){
|
async getApiQuestionData(){
|
||||||
try{
|
try{
|
||||||
const {result} = await uniCloud.callFunction({
|
const {result} = await uniCloud.callFunction({
|
||||||
name:'provideQuestion',
|
name:'reciteWords',
|
||||||
data:{level:this.level,pageSize:this.pageSize}
|
data:{pageSize:this.pageSize}
|
||||||
})
|
})
|
||||||
this.wordData = result.data
|
result.res.data.forEach(e=>{
|
||||||
console.log('题目数据获取',result.data)
|
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){
|
}catch(e){
|
||||||
console.error(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) {
|
onLoad(option) {
|
||||||
this.level = option.wordId;
|
|
||||||
this.getApiQuestionData()
|
this.getApiQuestionData()
|
||||||
console.log('获取到', this.level)
|
// setTimeout(()=>{
|
||||||
|
// this.audio = this.wordData[0].wordName;
|
||||||
|
// this.getAudioResource()
|
||||||
|
// },2000)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -195,6 +226,8 @@ this.currentIndex++;
|
|||||||
.read{
|
.read{
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
|
||||||
image{
|
image{
|
||||||
// line-height: 36rpx;
|
// line-height: 36rpx;
|
||||||
@@ -230,13 +263,13 @@ this.currentIndex++;
|
|||||||
min-height: 100rpx;
|
min-height: 100rpx;
|
||||||
margin: 20rpx 0;
|
margin: 20rpx 0;
|
||||||
|
|
||||||
|
|
||||||
&:nth-child(4) {
|
&:nth-child(4) {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
border: 2rpx solid #dee1e6;
|
border: 2rpx solid #dee1e6;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
padding: 0 20rpx;
|
padding: 20rpx;
|
||||||
background-color: #f2f5f8;
|
background-color: #f2f5f8;
|
||||||
display: block;
|
display: block;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -271,4 +304,31 @@ this.currentIndex++;
|
|||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
text-align: center;
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ exports.main = async (event, context) => {
|
|||||||
//event为客户端上传的参数
|
//event为客户端上传的参数
|
||||||
// const count = await db.collection('questionList').count()
|
// const count = await db.collection('questionList').count()
|
||||||
// 根据level字段随机返回不同的数据
|
// 根据level字段随机返回不同的数据
|
||||||
|
|
||||||
let res = await db.collection('allWordList').aggregate().match({
|
let res = await db.collection('allWordList').aggregate().match({
|
||||||
difficulty: event.level
|
difficulty: event.level
|
||||||
}).sample({
|
}).sample({
|
||||||
size: 10
|
size: 10
|
||||||
}).addFields({
|
}).limit(10).addFields({
|
||||||
'options':["$means",'B. v.爬升,上升.n.爬升率,上升率;上升距离','C adv.不变地;经常地;坚持不懈地','D n.积云;组合,集结;累积;形成']
|
'options':["$means",'B. v.爬升,上升.n.爬升率,上升率;上升距离','C adv.不变地;经常地;坚持不懈地','D n.积云;组合,集结;累积;形成']
|
||||||
}).end()
|
}).end()
|
||||||
|
|
||||||
|
|||||||
23
uniCloud-aliyun/cloudfunctions/reciteWords/index.js
Normal file
23
uniCloud-aliyun/cloudfunctions/reciteWords/index.js
Normal file
@@ -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,
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user