Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75705e8955 | ||
|
|
edc7d2bb04 | ||
|
|
76cad44e76 | ||
|
|
7b1ce82f7c | ||
|
|
8fc534f067 | ||
|
|
91d82a277d | ||
|
|
634db893dc | ||
|
|
71f81cdbc9 | ||
|
|
f69b49f8f0 | ||
|
|
6be56d44d7 | ||
|
|
e2db5842d3 | ||
|
|
50efc1d10c | ||
|
|
6b1b6d180d |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/uni_modules/
|
||||||
@@ -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"
|
||||||
@@ -10,7 +14,15 @@
|
|||||||
{
|
{
|
||||||
"launchtype" : "local"
|
"launchtype" : "local"
|
||||||
},
|
},
|
||||||
"type" : "uniCloud"
|
"mp-weixin" :
|
||||||
|
{
|
||||||
|
"launchtype" : "local"
|
||||||
|
},
|
||||||
|
"type" : "uniCloud",
|
||||||
|
"uniapp" :
|
||||||
|
{
|
||||||
|
"launchtype" : "local"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
5
App.vue
5
App.vue
@@ -12,6 +12,9 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style lang="scss">
|
||||||
/*每个页面公共css */
|
/*每个页面公共css */
|
||||||
|
.container{
|
||||||
|
padding: 0 30rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* 快应用特有相关 */
|
/* 快应用特有相关 */
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/home/index",
|
"path": "pages/home/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "单词学习APP"
|
"navigationBarTitleText": "管制员英语词汇"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
,{
|
,{
|
||||||
"path" : "pages/recitation/index",
|
"path" : "pages/recitation/index",
|
||||||
"style" :
|
"style" :
|
||||||
{
|
{
|
||||||
"navigationBarTitleText": "",
|
"navigationBarTitleText": "单词背诵",
|
||||||
"enablePullDownRefresh": false
|
"enablePullDownRefresh": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,52 +1,404 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
|
<view class="answer-root">
|
||||||
|
<view class="container">
|
||||||
|
<view v-for="(item,index) in wordData" :key="wordData._id">
|
||||||
|
<view v-if="index == currentIndex">
|
||||||
|
<!-- 题目选项卡模块开始 -->
|
||||||
|
<view class="answer-box">
|
||||||
|
<view class="title">
|
||||||
|
<text class="left-title">单选题(难度等级:{{item.difficulty}})</text>
|
||||||
|
<text class="right-condition">
|
||||||
|
<text>{{index+1}}</text>
|
||||||
|
<text>/{{pageNum}}</text>
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<image class="logo" src="/static/logo.png"></image>
|
<view>{{item.wordName}}</view>
|
||||||
<view class="text-area">
|
</view>
|
||||||
<text class="title">{{title}}</text>
|
<view class="select-item">
|
||||||
|
<text v-for="(itemOptions,indexOptions) in item.options" :key="indexOptions"
|
||||||
|
@click="getSelectedItem(itemOptions,index)"
|
||||||
|
:class="{'isSelected': mySelectArr[index] == itemOptions}"> {{itemOptions}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
</view>
|
||||||
|
<!-- 题目选项卡模块结束 -->
|
||||||
|
|
||||||
|
<!-- 翻页按钮模块开始 -->
|
||||||
|
<view class="page-btn">
|
||||||
|
<view class="btn">
|
||||||
|
<button type="default" @tap="previous(index,item)" v-if="currentIndex >= 1">
|
||||||
|
上一题
|
||||||
|
</button>
|
||||||
|
<button type="default" @tap="next(index,item)" v-if="currentIndex < 9">
|
||||||
|
下一题
|
||||||
|
</button>
|
||||||
|
<button type="default" @tap="messageToggle('error')"
|
||||||
|
v-if="currentIndex == 9 && mySelectArr.length==10">
|
||||||
|
提交!
|
||||||
|
</button>
|
||||||
|
<button type="default" v-if="currentIndex == 9 && mySelectArr.length<10">
|
||||||
|
还有题目未完成!
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
<!-- 翻页按钮模块结束 -->
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view>
|
||||||
|
|
||||||
|
<!-- 提示窗示例 -->
|
||||||
|
<uni-popup ref="alertDialog" type="dialog">
|
||||||
|
<uni-popup-dialog :type="msgType" cancelText="重新做题" :confirmText="confirmText" :title="testRes"
|
||||||
|
:content="resultDialog" @confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
|
||||||
|
</uni-popup>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="stance-box">
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
title: '测试'
|
// 默认每页题目数量
|
||||||
}
|
pageSize: 1,
|
||||||
|
// 默认题目总数
|
||||||
|
pageNum: 10,
|
||||||
|
// 默认选择
|
||||||
|
currentIndex: 0,
|
||||||
|
// 默认分数
|
||||||
|
score: 0,
|
||||||
|
// 默认难度
|
||||||
|
level: 1,
|
||||||
|
// 题库数据
|
||||||
|
wordData: [],
|
||||||
|
// 是否居中弹窗
|
||||||
|
type: 'center',
|
||||||
|
// 成功信息样式
|
||||||
|
msgType: 'success',
|
||||||
|
// 成功信息内容
|
||||||
|
messageText: '',
|
||||||
|
// 我的答案
|
||||||
|
mySelectArr: [],
|
||||||
|
// 正确答案
|
||||||
|
rightSelectArr: [],
|
||||||
|
testRes: '',
|
||||||
|
// 成绩结果
|
||||||
|
resultDialog: '',
|
||||||
|
// 确定内容
|
||||||
|
confirmText: '',
|
||||||
|
};
|
||||||
},
|
},
|
||||||
onLoad() {
|
watch: {
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 获取当前选中的选项并存到数组中
|
||||||
|
getSelectedItem(item, index) {
|
||||||
|
this.mySelectArr.splice(index, 1, item)
|
||||||
|
console.log('当前的选项', this.mySelectArr)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取上一题
|
||||||
|
previous(index, source) {
|
||||||
|
this.currentIndex--;
|
||||||
|
console.log('回到上一题', source)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取下一题
|
||||||
|
next(index, source) {
|
||||||
|
this.currentIndex++;
|
||||||
|
console.log('跳转到下一题', source)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 提交成功获取的信息
|
||||||
|
messageToggle(type) {
|
||||||
|
for (let i = 0; i < this.pageNum; i++) {
|
||||||
|
if (this.mySelectArr[i].slice(3) == this.rightSelectArr[i]) {
|
||||||
|
this.score++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.score = this.score * 10
|
||||||
|
this.resultDialog = `您最后的分数为:${this.score}`
|
||||||
|
if (this.score >= 60 && this.level < 6) {
|
||||||
|
this.level++
|
||||||
|
this.testRes = '恭喜及格!'
|
||||||
|
this.confirmText = '继续下一难度'
|
||||||
|
} else if (this.score >= 60 && this.level == 6) {
|
||||||
|
this.level++
|
||||||
|
this.testRes = '恭喜及格!'
|
||||||
|
this.confirmText = '去加强巩固'
|
||||||
|
} else {
|
||||||
|
this.testRes = '不及格哦!'
|
||||||
|
this.confirmText = '去背单词'
|
||||||
|
}
|
||||||
|
this.msgType = type
|
||||||
|
this.$refs.alertDialog.open()
|
||||||
|
},
|
||||||
|
//右边选项(继续下一难度||背单词 ||加强巩固)
|
||||||
|
dialogConfirm() {
|
||||||
|
if (this.score < 60 ) {
|
||||||
|
this.resetParams();
|
||||||
|
uni.switchTab({
|
||||||
|
url:"../recitation/index"
|
||||||
|
})
|
||||||
|
} else if (this.score >= 60 && this.level <=6) {
|
||||||
|
console.log('当前难度等级',this.level)
|
||||||
|
this.resetParams()
|
||||||
|
}else if(this.score >= 60 && this.level == 7){
|
||||||
|
this.level =1;
|
||||||
|
this.resetParams()
|
||||||
|
}
|
||||||
|
this.$refs.alertDialog.open()
|
||||||
|
},
|
||||||
|
|
||||||
|
// 左边选项(重新做题)
|
||||||
|
dialogClose() {
|
||||||
|
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() {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '加载中'
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
result
|
||||||
|
} = await uniCloud.callFunction({
|
||||||
|
name: 'provideQuestion',
|
||||||
|
data: {
|
||||||
|
level: this.level,
|
||||||
|
pageSize: this.pageSize
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.wordData = result.resData
|
||||||
|
this.wordData.forEach(item => {
|
||||||
|
this.rightSelectArr.push(item.means)
|
||||||
|
})
|
||||||
|
this.setStorageData();
|
||||||
|
console.log('题目数据获取', result)
|
||||||
|
console.log('正确答案', this.rightSelectArr)
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
|
//TODO handle the exception
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
// 初始化参数
|
||||||
|
resetParams(){
|
||||||
|
this.wordData = [];
|
||||||
|
this.mySelectArr = [];
|
||||||
|
this.rightSelectArr = [];
|
||||||
|
this.currentIndex = 0;
|
||||||
|
this.score = 0;
|
||||||
|
this.getApiQuestionData();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 设置缓存
|
||||||
|
setStorageData(){
|
||||||
|
uni.setStorage({
|
||||||
|
key:"level_type",
|
||||||
|
data:this.level
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad(option) {
|
||||||
|
this.setStorageData()
|
||||||
|
this.getApiQuestionData()
|
||||||
|
console.log('当前难度等级:', this.level)
|
||||||
|
},
|
||||||
|
onShow() {
|
||||||
|
// this.getApiQuestionData()
|
||||||
|
console.log('背单词页面显示')
|
||||||
|
|
||||||
|
// this.$forceUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style lang="scss" scoped>
|
||||||
.content {
|
page {
|
||||||
display: flex;
|
background-color: #f2f5f8;
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.answer-root {
|
||||||
height: 200rpx;
|
position: relative;
|
||||||
width: 200rpx;
|
top: 60rpx;
|
||||||
margin-top: 200rpx;
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
margin-bottom: 50rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-area {
|
.answer-box {
|
||||||
display: flex;
|
word-wrap: break-word;
|
||||||
justify-content: center;
|
word-break: break-all;
|
||||||
}
|
box-sizing: border-box;
|
||||||
|
padding: 30rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
width: 100%;
|
||||||
|
box-shadow: 5px 4px 20px rgba(0, 0, 0, 0.16);
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-size: 36rpx;
|
display: flex;
|
||||||
color: #8f8f94;
|
align-items: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding-bottom: 20rpx;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
border-bottom: 2rpx solid #eeeeee;
|
||||||
|
|
||||||
|
.left-title {
|
||||||
|
font-weight: bolder;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
border-left: 8rpx solid #007AFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-condition {
|
||||||
|
text {
|
||||||
|
&:nth-child(1) {
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
margin: 0 6rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:nth-child(2) {
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
.read {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
image {
|
||||||
|
// line-height: 36rpx;
|
||||||
|
vertical-align: middle;
|
||||||
|
width: 36rpx;
|
||||||
|
height: 36rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
view {
|
||||||
|
min-height: 100rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
&:nth-child(1) {
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:nth-child(2) {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 28rpx;
|
||||||
|
|
||||||
|
text {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-item {
|
||||||
|
|
||||||
|
text {
|
||||||
|
min-height: 100rpx;
|
||||||
|
margin: 20rpx 0;
|
||||||
|
|
||||||
|
&:nth-child(4) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
border: 2rpx solid #dee1e6;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
padding:15rpx;
|
||||||
|
background-color: #f2f5f8;
|
||||||
|
display: block;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.isSelected {
|
||||||
|
transition: all 0.2s;
|
||||||
|
border: 2rpx solid #007AFF;
|
||||||
|
background-color: rgba(52, 152, 219, 0.3)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-btn {
|
||||||
|
margin: 30px;
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
button {
|
||||||
|
box-shadow: 0 2px 5px 0 rgba(50, 50, 105, 0.15), 0 1px 1px 0 rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.noData {
|
||||||
|
font-size: 30rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-home {
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
line-height: 100rpx;
|
||||||
|
// padding: 20rpx;
|
||||||
|
margin-bottom: 50rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
border-bottom: 2rpx solid #EEEEEE;
|
||||||
|
|
||||||
|
|
||||||
|
text {
|
||||||
|
padding: 30rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.stance-box{
|
||||||
|
width: 100%;
|
||||||
|
height: 60rpx;
|
||||||
|
// background-color: red;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,22 +1,348 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<view class="answer-root">
|
||||||
|
<view class="container">
|
||||||
|
<view v-for="(item,index) in wordData" :key="wordData._id">
|
||||||
|
|
||||||
|
<view v-if="index == currentIndex">
|
||||||
|
<!-- 题目选项卡模块开始 -->
|
||||||
|
<view class="answer-box">
|
||||||
|
<view class="title">
|
||||||
|
<text class="left-title">背单词 (词汇难度:{{item.difficulty}})</text>
|
||||||
|
<text class="right-condition">
|
||||||
|
<!-- <text>{{index+1}}</text> -->
|
||||||
|
<!-- <text>/{{pageNum}}</text> -->
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<view class="content">
|
||||||
|
<view>{{item.wordName}}</view>
|
||||||
|
<view class="read">
|
||||||
|
<text>音标:{{item.phonetic}}</text>
|
||||||
|
<text @tap="getAudioResource">读音:{{item.pronunciation}}
|
||||||
|
<image src="../../static/icon/listen.png" mode="widthFix"></image>
|
||||||
|
<audio :src="current.src" controls></audio>
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="select-item">
|
||||||
|
<text> {{item.means}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
</view>
|
||||||
|
<!-- 题目选项卡模块结束 -->
|
||||||
|
<!-- 翻页按钮模块开始 -->
|
||||||
|
<view class="page-btn">
|
||||||
|
<view class="btn">
|
||||||
|
<button type="default" @tap="previous(index,item.wordName)" v-if="currentIndex >= 1">
|
||||||
|
上一个单词
|
||||||
|
</button>
|
||||||
|
<button type="default" @tap="next(index,item.wordName)" v-if="currentIndex < pageNum">
|
||||||
|
下一个单词
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
<!-- 翻页按钮模块结束 -->
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
<view>
|
<view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
pageSize: 21,
|
||||||
|
pageNum: '',
|
||||||
|
currentIndex: 0,
|
||||||
|
level: '',
|
||||||
|
wordData: [],
|
||||||
|
type: 'center',
|
||||||
|
msgType: 'success',
|
||||||
|
messageText: '',
|
||||||
|
value: '',
|
||||||
|
resultDialog: '',
|
||||||
|
audio: '',
|
||||||
|
current: {
|
||||||
|
src: '',
|
||||||
|
audioAction: {
|
||||||
|
method: 'pause'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
level(newName, oldName) {
|
||||||
|
console.log('值发生变化')
|
||||||
|
this.wordData.length = 0;
|
||||||
|
this.getApiQuestionData()
|
||||||
|
// this.wordData.reverse();
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
// 获取上一题
|
||||||
|
previous(index, wordName) {
|
||||||
|
|
||||||
|
this.currentIndex--;
|
||||||
|
this.audio = this.wordData[index - 1].wordName;
|
||||||
|
this.getAudioResource()
|
||||||
|
console.log('回到上一题', index, this.wordData[index - 1].wordName)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取下一题
|
||||||
|
next(index, wordName) {
|
||||||
|
this.currentIndex++;
|
||||||
|
if (this.currentIndex % 20 == 17) {
|
||||||
|
this.getApiQuestionData();
|
||||||
|
}
|
||||||
|
this.audio = this.wordData[index + 1].wordName;
|
||||||
|
this.getAudioResource()
|
||||||
|
console.log('跳转到下一题', index, this.wordData[index + 1].wordName)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 调用云函数获取数据
|
||||||
|
async getApiQuestionData() {
|
||||||
|
|
||||||
|
this.getLevelFromStorage();
|
||||||
|
uni.showLoading({
|
||||||
|
title: '加载中'
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
|
||||||
|
const {
|
||||||
|
result
|
||||||
|
} = await uniCloud.callFunction({
|
||||||
|
name: 'reciteWords',
|
||||||
|
data: {
|
||||||
|
pageSize: this.pageSize,
|
||||||
|
level: this.level
|
||||||
|
}
|
||||||
|
})
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取音频链接
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
// this.getApiQuestionData()
|
||||||
|
},
|
||||||
|
onShow() {
|
||||||
|
this.getLevelFromStorage();
|
||||||
|
console.log('获取背诵题目')
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style lang="scss" scoped>
|
||||||
|
page {
|
||||||
|
background-color: #f2f5f8;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.answer-root {
|
||||||
|
position: relative;
|
||||||
|
top: 60rpx;
|
||||||
|
|
||||||
|
.answer-box {
|
||||||
|
word-wrap: break-word;
|
||||||
|
word-break: break-all;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 30rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
width: 100%;
|
||||||
|
box-shadow: 5px 4px 20px rgba(0, 0, 0, 0.16);
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding-bottom: 20rpx;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
border-bottom: 2rpx solid #eeeeee;
|
||||||
|
|
||||||
|
.left-title {
|
||||||
|
font-weight: bolder;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
border-left: 8rpx solid #007AFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-condition {
|
||||||
|
text {
|
||||||
|
&:nth-child(1) {
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
margin: 0 6rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:nth-child(2) {
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
.read {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
|
||||||
|
image {
|
||||||
|
// line-height: 36rpx;
|
||||||
|
vertical-align: middle;
|
||||||
|
width: 36rpx;
|
||||||
|
height: 36rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
view {
|
||||||
|
min-height: 100rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
&:nth-child(1) {
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:nth-child(2) {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 28rpx;
|
||||||
|
|
||||||
|
text {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-item {
|
||||||
|
text {
|
||||||
|
min-height: 100rpx;
|
||||||
|
margin: 20rpx 0;
|
||||||
|
|
||||||
|
|
||||||
|
&:nth-child(4) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
border: 2rpx solid #dee1e6;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
padding: 20rpx;
|
||||||
|
background-color: #f2f5f8;
|
||||||
|
display: block;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.isSelected {
|
||||||
|
border: 2rpx solid #007AFF;
|
||||||
|
background-color: rgba(52, 152, 219, 0.3)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-btn {
|
||||||
|
margin: 30px;
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
button {
|
||||||
|
box-shadow: 0 2px 5px 0 rgba(50, 50, 105, 0.15), 0 1px 1px 0 rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
BIN
static/icon/listen.png
Normal file
BIN
static/icon/listen.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
BIN
static/icon/listening.png
Normal file
BIN
static/icon/listening.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
BIN
static/logo.png
BIN
static/logo.png
Binary file not shown.
|
Before Width: | Height: | Size: 3.9 KiB |
65
uniCloud-aliyun/cloudfunctions/provideQuestion/index.js
Normal file
65
uniCloud-aliyun/cloudfunctions/provideQuestion/index.js
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
'use strict';
|
||||||
|
const db = uniCloud.database();
|
||||||
|
exports.main = async (event, context) => {
|
||||||
|
//event为客户端上传的参数
|
||||||
|
let difficultLevel = event.level.toString()
|
||||||
|
// 根据level字段随机返回数据库中不同的数据40组
|
||||||
|
let res = await db.collection('allWordList').aggregate().match({
|
||||||
|
difficulty: difficultLevel
|
||||||
|
}).sample({
|
||||||
|
size: 40
|
||||||
|
}).limit(40).end()
|
||||||
|
let data = res.data
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
// 将后30组数据中的单词含义赋值到前10组数据中的数组中
|
||||||
|
data.forEach((item, index) => {
|
||||||
|
if (item.options) {
|
||||||
|
for (let i = 1; i < 4; i++) {
|
||||||
|
item.options.push(optionData[count])
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 打乱题目选项
|
||||||
|
let resData = [];
|
||||||
|
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]}`
|
||||||
|
}
|
||||||
|
if(index<10){
|
||||||
|
resData.push(item)
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
console.log('选项列表', optionData)
|
||||||
|
console.log('入参:页码+难度', event, res)
|
||||||
|
//返回数据给客户端
|
||||||
|
return {
|
||||||
|
code: 200,
|
||||||
|
msg: 'success',
|
||||||
|
resData,
|
||||||
|
}
|
||||||
|
};
|
||||||
25
uniCloud-aliyun/cloudfunctions/reciteWords/index.js
Normal file
25
uniCloud-aliyun/cloudfunctions/reciteWords/index.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
'use strict';
|
||||||
|
const db = uniCloud.database();
|
||||||
|
exports.main = async (event, context) => {
|
||||||
|
//event为客户端上传的参数
|
||||||
|
let count = await db.collection('allWordList').count()
|
||||||
|
// 根据level字段随机返回不同的数据
|
||||||
|
const level = event.level.toString();
|
||||||
|
let res = await db.collection('allWordList').aggregate().match({
|
||||||
|
difficulty: level
|
||||||
|
}).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