This commit is contained in:
进进啊
2022-04-11 22:00:36 +08:00
parent e2db5842d3
commit 6be56d44d7
8 changed files with 112 additions and 102 deletions

View File

@@ -1,54 +1,58 @@
<template> <template>
<view class="answer-root"> <view class="answer-root">
<view class="container" v-if="wordData.wordName"> <view class="container" >
<!-- 题目选项卡模块开始 --> <view v-for="(item,index) in wordData" :key="wordData._id" >
<view class="answer-box" >
<view class="title">
<text class="left-title">单选题难度等级{{wordData.level}}</text>
<text class="right-condition">
<text>{{pageSize}}</text>
<text>/{{pageNum}}</text>
</text>
</view>
<view class="content">
<view>{{wordData.wordName}}</view>
<view>
<text>音标{{wordData.phonetic}}</text>
<text>读音{{wordData.pronunciation}} </text>
</view>
</view>
<view class="select-item">
<text v-for="(item,index) in wordData.options" :key="item.itemId"
:class="{'isSelected':index == selectIndex}"
@click="getSelectedItem(item,index)">{{item.itemId}} {{item.itemContent}}</text>
</view> <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>读音{{item.pronunciation}}
<image src="../../static/icon/listen.png" mode="widthFix"></image>
</text>
</view>
</view>
<!-- <view class="select-item">
<text v-for="(item,index) in wordData.options" :key="item.itemId"
:class="{'isSelected':index == selectIndex}"
@click="getSelectedItem(item,index)">{{item.itemId}} {{item.itemContent}}</text>
</view> -->
</view> </view>
<!-- 题目选项卡模块结束 --> <!-- 题目选项卡模块结束 -->
<!-- 翻页按钮模块开始 --> <!-- 翻页按钮模块开始 -->
<view class="page-btn"> <view class="page-btn">
<view class="btn"> <view class="btn">
<button type="default" @tap="previous" v-if="pageSize != 1"> <button type="default" @tap="previous(index)" v-if="currentIndex > 2">
上一题 上一题
</button> </button>
<button type="default" @tap="next" v-if="pageSize != 10"> <button type="default" @tap="next(index)" v-if="currentIndex < 11">
下一题 下一题
</button> </button>
<button type="default" @tap="messageToggle('error')" v-if="pageSize == 10"> <button type="default" @tap="messageToggle('error')" v-if="currentIndex == 11">
提交 提交
</button> </button>
</view> </view>
</view> </view>
<!-- 翻页按钮模块结束 --> <!-- 翻页按钮模块结束 -->
</view>
</view>
</view> </view>
<view class="noData" v-else-if="!wordData.worName">
<text>暂无数据~</text>
</view>
<view> <view>
<!-- 提示窗示例 --> <!-- 提示窗示例 -->
@@ -67,8 +71,9 @@
selectIndex: -1, selectIndex: -1,
pageSize: 1, pageSize: 1,
pageNum: 10, pageNum: 10,
currentIndex:0,
level: '', level: '',
wordData:{}, wordData:[],
type: 'center', type: 'center',
msgType: 'success', msgType: 'success',
messageText: '这是一条成功提示', messageText: '这是一条成功提示',
@@ -78,30 +83,31 @@
}, },
methods: { methods: {
// 获取当前选中的选项 // 获取当前选中的选项
getSelectedItem(item, itemIndex) { // getSelectedItem(item, itemIndex) {
this.selectIndex = itemIndex // this.selectIndex = itemIndex
if (item.right) { // if (item.right) {
console.log('选择正确') // console.log('选择正确')
} // }
console.log(item, '选中的项') // console.log(item, '选中的项')
}, // },
// 获取上一题 // 获取上一题
previous() { previous(index) {
if (this.pageSize > 1) { // if (this.pageSize > 1) {
this.pageSize-- // this.pageSize--
} // }
this.currentIndex--;
console.log('回到上一题') console.log('回到上一题',this.currentIndex,index)
}, },
// 获取下一题 // 获取下一题
next() { next(index) {
if (this.pageSize < 10) { // if (this.pageSize < 10) {
this.pageSize++ // this.pageSize++
} // }
this.getApiQuestionData() this.currentIndex++;
console.log('跳转到下一题') // this.getApiQuestionData()
console.log('跳转到下一题',index)
}, },
// 提交成功获取的信息 // 提交成功获取的信息
messageToggle(type) { messageToggle(type) {
@@ -128,10 +134,8 @@
name:'provideQuestion', name:'provideQuestion',
data:{level:this.level,pageSize:this.pageSize} data:{level:this.level,pageSize:this.pageSize}
}) })
if(result.data[0] != undefined){ this.wordData = result.data
this.wordData = result.data[0].wordData console.log('题目数据获取',result.data)
console.log('题目数据获取',result.data[0])
}
}catch(e){ }catch(e){
console.error(e) console.error(e)
@@ -201,6 +205,12 @@
} }
.content { .content {
.read{
image{
width: 40rpx;
height: 40rpx;
}
}
view { view {
min-height: 100rpx; min-height: 100rpx;
display: flex; display: flex;

View File

@@ -30,9 +30,6 @@
},{ },{
id:'6', id:'6',
text:'六级词汇难度' text:'六级词汇难度'
},{
id:'7',
text:'七级词汇难度'
}] }]
} }
}, },
@@ -70,6 +67,9 @@
&:nth-child(1){ &:nth-child(1){
margin-top: 30rpx; margin-top: 30rpx;
} }
// &:nth-child(n+1){
// opacity: 0.5;
// }
&:nth-child(odd){ &:nth-child(odd){
background: linear-gradient(135deg,#43cbff,#9708cc); background: linear-gradient(135deg,#43cbff,#9708cc);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB