Commit bbda57b4 authored by Damon's avatar Damon

feat: 答题模式切换&&倒计时

parent 176a8ba0
...@@ -9,8 +9,7 @@ ...@@ -9,8 +9,7 @@
> >
<swiper-item v-for="(item, index) in swiperList" :key="index"> <swiper-item v-for="(item, index) in swiperList" :key="index">
<view class="u-flex subject"> <view class="u-flex subject">
<view class="type">{{ type[item.type - 1] }}</view> <view class="title"><text>{{ type[item.type - 1] }}</text>{{ item.title }}</view>
<view class="title">{{ item.title }}</view>
<view class="content"> <view class="content">
<answer-sheet <answer-sheet
ref="answerSheet" ref="answerSheet"
...@@ -239,6 +238,14 @@ export default { ...@@ -239,6 +238,14 @@ export default {
font-weight: bold; font-weight: bold;
width: 100%; width: 100%;
text-align: left; text-align: left;
text {
background: #9EA5BB;
color: #fff;
padding: 8rpx 20rpx;
margin-right: 10rpx;
font-size: 20rpx;
border-radius: 50rpx;
}
} }
.content, .explain, .btn { .content, .explain, .btn {
width: 100%; width: 100%;
......
...@@ -8,15 +8,25 @@ ...@@ -8,15 +8,25 @@
title="答题" title="答题"
title-bold title-bold
></u-navbar> ></u-navbar>
<view class="head">
<view class="u-flex tab" v-if="type === 1">
<view :class="['tab-list', {'active': model === 1}]" @click="changeModel(1)">答题模式</view>
<view :class="['tab-list', {'active': model === 2}]" @click="changeModel(2)">学习模式</view>
</view>
<view class="u-flex count-down" v-if="type === 2">
<view>倒计时:<u-count-down :timestamp="timestamp" bg-color="" :show-hours="false"></u-count-down></view>
</view>
</view>
<view class="swiper"> <view class="swiper">
<swiper-limited-load <swiper-limited-load
ref="swiper" ref="swiper"
:swiperHeight="500" :swiperHeight="500"
:swiperDuration="swiperDuration" :swiperDuration="swiperDuration"
:list="list" :list="list"
:current="current" :current="current"
@answerChange="answerChange" @answerChange="answerChange"
@change="swiperChange"> @change="swiperChange"
>
</swiper-limited-load> </swiper-limited-load>
</view> </view>
<view class="u-flex u-row-around bottom"> <view class="u-flex u-row-around bottom">
...@@ -39,12 +49,21 @@ ...@@ -39,12 +49,21 @@
</view> </view>
<answer-operation-tips :show.sync="show" /> <answer-operation-tips :show.sync="show" />
<answer-complete-pop
:numberList="[1, 2, 3]"
type="fail"
:visible.sync="visible"
@cancel="visible = false"
@submit="submit"
>
</answer-complete-pop>
</view> </view>
</template> </template>
<script> <script>
import swiperLimitedLoad from '@/components/swiper-limited-load/index.vue' import swiperLimitedLoad from '@/components/swiper-limited-load/index.vue'
import answerOperationTips from '@/components/answer-operation-tips/index.vue' import answerOperationTips from '@/components/answer-operation-tips/index.vue'
import answerCompletePop from '@/components/answer-complete-pop/index.vue'
const NO_PREV_PAGE = -1 const NO_PREV_PAGE = -1
const NO_NEXT_PAGE = -2 const NO_NEXT_PAGE = -2
...@@ -52,24 +71,25 @@ const app = getApp() ...@@ -52,24 +71,25 @@ const app = getApp()
export default { export default {
components: { components: {
swiperLimitedLoad, swiperLimitedLoad,
answerOperationTips answerOperationTips,
answerCompletePop,
}, },
data() { data() {
return { return {
visible: false,
show: false, show: false,
type: 1, // 1 练习 2 考试
dataLength: 0, type: 1,
index: 0, // 1 答题模式 2 学习模式
lists: [], model: 1,
answerList: [], timestamp: 60 * 60,
list: [], list: [],
current: 0, current: 0,
currentIndex: 0, currentIndex: 0,
swiperDuration: "0" swiperDuration: '0',
} }
}, },
computed: { computed: {},
},
created() { created() {
const lists = [ const lists = [
{ {
...@@ -86,13 +106,15 @@ export default { ...@@ -86,13 +106,15 @@ export default {
}, },
], ],
answer: 'A', answer: 'A',
explain: '极性电介质在外电场作用下,由偶极子分子的转向形成的极化称为偶极子式极化。', explain:
'极性电介质在外电场作用下,由偶极子分子的转向形成的极化称为偶极子式极化。',
index: 0, index: 0,
rightKey: ['A'] rightKey: ['A'],
}, },
{ {
type: 2, type: 2,
title: '空气间隙的操作冲击击穿电压数值大小不仅与间隙距离、电极形状、电极极性有关,而且与操作冲击电压波的波前时间的长短有关。', title:
'空气间隙的操作冲击击穿电压数值大小不仅与间隙距离、电极形状、电极极性有关,而且与操作冲击电压波的波前时间的长短有关。',
answerList: [ answerList: [
{ {
sort: 'A', sort: 'A',
...@@ -104,9 +126,10 @@ export default { ...@@ -104,9 +126,10 @@ export default {
}, },
], ],
answer: 'B', answer: 'B',
explain: '极性电介质在外电场作用下,由偶极子分子的转向形成的极化称为偶极子式极化。', explain:
'极性电介质在外电场作用下,由偶极子分子的转向形成的极化称为偶极子式极化。',
index: 1, index: 1,
rightKey: ['B'] rightKey: ['B'],
}, },
{ {
type: 3, type: 3,
...@@ -130,10 +153,11 @@ export default { ...@@ -130,10 +153,11 @@ export default {
}, },
], ],
answer: 'B,C', answer: 'B,C',
explain: '双臂电桥是在单臂电桥的基础上增加特殊机构,以消除测试时连接线和接线柱接触电阻对测量结果的影响。', explain:
'双臂电桥是在单臂电桥的基础上增加特殊机构,以消除测试时连接线和接线柱接触电阻对测量结果的影响。',
index: 2, index: 2,
rightKey: ['B','C'] rightKey: ['B', 'C'],
} },
] ]
this.requestQuestionInfo(lists) this.requestQuestionInfo(lists)
...@@ -144,36 +168,41 @@ export default { ...@@ -144,36 +168,41 @@ export default {
this.list = lists this.list = lists
setTimeout(() => { setTimeout(() => {
// 比如上次答到了第20题 // 比如上次答到了第20题
this.$refs.swiper.init(0); this.$refs.swiper.init(0)
// 初始化后再把动画弄出来,否则初始的current不是0,界面会自动跳动到当前位置,体验不太好 // 初始化后再把动画弄出来,否则初始的current不是0,界面会自动跳动到当前位置,体验不太好
this.swiperDuration = '250' this.swiperDuration = '250'
// 全局记一下list, 答题卡页暂时就直接用了 // 全局记一下list, 答题卡页暂时就直接用了
app.globalData.questionList = lists app.globalData.questionList = lists
}, 1000) }, 1000)
}, },
swiperChange(e) { swiperChange(e) {
let current = e.current let current = e.current
this.currentIndex = current this.currentIndex = current
if (current == NO_PREV_PAGE) { if (current == NO_PREV_PAGE) {
uni.showToast({ uni.showToast({
title: "已经是第一题了", title: '已经是第一题了',
icon: "none" icon: 'none',
}) })
return return
} }
if (current == NO_NEXT_PAGE) { if (current == NO_NEXT_PAGE) {
uni.showModal({ uni.showModal({
title: "提示", title: '提示',
content: "您已经答完所有题,是否退出?", content: '您已经答完所有题,是否退出?',
}) })
return return
} }
}, },
changeModel(i) {
this.model = i
},
answerChange(e) { answerChange(e) {
console.log("e", e) console.log('e', e)
},
submit() {
console.log("提前交卷")
} }
}, },
} }
...@@ -186,6 +215,32 @@ export default { ...@@ -186,6 +215,32 @@ export default {
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%); background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx; background-size: 100% 520rpx;
background-repeat: no-repeat; background-repeat: no-repeat;
.head {
width: 100%;
flex: 1;
.tab {
margin:10rpx auto;
border: 2rpx solid #2953FF;
border-radius: 10rpx;
width: 300rpx;
.tab-list {
flex: 1;
padding: 10rpx 25rpx;
font-size: 24rpx;
color: #191C27;
}
.active {
background: #2953FF;
color: #fff;
}
}
.count-down {
color: #5A6073;
font-size: 32rpx;
margin:10rpx auto;
width: 230rpx;
}
}
.swiper { .swiper {
width: 100%; width: 100%;
flex: 1; flex: 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment