Commit c2d15fe7 authored by Damon's avatar Damon

feat: 答题模式完善

parent 79488961
......@@ -124,6 +124,7 @@ export default {
},
answerChange(status, lists) {
this.$set(this.swiperList[this.swiperIndex], 'errShow', this.type === 2 ? true : status === 'fail')
this.$set(this.swiperList[this.swiperIndex], 'submitStatus', true)
this.$emit("answerChange", status, lists)
},
clear () {
......
......@@ -8,9 +8,9 @@
title="答题"
title-bold
></u-navbar>
<view class="u-flex contents" v-if="list.length > 0 && ![4, 5].includes(type)">
<view class="head" v-if="type !== 3">
<view class="u-flex tab" v-if="type === 1">
<view class="u-flex contents" v-if="list.length > 0">
<view class="head" v-if="!daily">
<view class="u-flex tab" v-if="type !== 2">
<view :class="['tab-list', {'active': model === 1}]" @click="changeModel(1)">答题模式</view>
<view :class="['tab-list', {'active': model === 2}]" @click="changeModel(2)">学习模式</view>
</view>
......@@ -36,7 +36,7 @@
<view class="u-flex">
<view class="c-list">
<u-icon name="grid" color="#5A6073" size="40"></u-icon>
<text>1/2887</text>
<text>{{ currentIndex + 1 }}/{{ list.length }}</text>
</view>
</view>
<view class="u-flex">
......@@ -48,11 +48,15 @@
<u-icon name="file-text" color="#5A6073" size="40"></u-icon>
<text>交卷</text>
</view>
<view class="c-list" v-if="type === 4" @click="remove">
<u-icon name="order" color="#5A6073" size="40"></u-icon>
<text>移出</text>
</view>
</view>
</view>
</view>
<view class="u-flex default" v-if="list.length === 0 && [4, 5].includes(type)">
<view class="u-flex default" v-if="list.length === 0 && [3, 4].includes(type)">
<view>
<image :src="defaultImg" />
</view>
......@@ -64,9 +68,9 @@
<answer-operation-tips :show.sync="show" />
<answer-complete-pop
:numberList="result"
type="fail"
type="completeType"
:visible.sync="visible"
@cancel="visible = false"
@cancel="cancel"
@submit="submit"
>
</answer-complete-pop>
......@@ -91,16 +95,20 @@ export default {
return {
visible: false,
show: false,
// 1 练习 2 考试 3 每日一练 4 错题记录 5 收藏记录
// 1 练习 or 每日一练 2 考试 3 收藏记录 4 错题记录
type: 1,
// 1 答题模式 2 学习模式
model: 1,
// 每日一练
daily: false,
dailyCount: 0,
timestamp: 60 * 60,
list: [],
current: 0,
currentIndex: 0,
swiperDuration: '0',
result: [1, 2, 3]
result: [],
completeType: 'pass',
}
},
computed: {
......@@ -115,6 +123,10 @@ export default {
},
},
created() {
if (this.questionList.length === 0) {
this.show = true
}
const lists = [
{
type: 1,
......@@ -215,7 +227,7 @@ export default {
// 初始化后再把动画弄出来,否则初始的current不是0,界面会自动跳动到当前位置,体验不太好
this.swiperDuration = '250'
// 全局记一下list, 答题卡页暂时就直接用了
app.globalData.questionList = lists
this.$u.vuex('questionList', lists)
})
},
swiperChange(e) {
......@@ -229,27 +241,47 @@ export default {
}
if (current == NO_NEXT_PAGE) {
return uni.showToast({
title: '已经是最后一题了',
icon: 'none',
})
if (this.type === 2) {
this.$u.route({
url: 'pages/learn/source'
})
} else {
uni.showModal({
title: '提示',
content: '已经是最后一题了',
success: (res) => {
if (res.confirm) {
this.$u.route({
url: '/pages/index/index',
type: 'tab'
})
}
},
})
}
}
},
changeModel(i) {
this.model = i
},
collection() {
console.log("this.list[this.currentIndex]", this.list[this.currentIndex])
console.log("收藏")
},
// 作答完毕
answerChange(status, lists) {
// 保存答题状态
this.$set(this.list[this.currentIndex], 'submitStatus', lists)
this.$set(this.list[this.currentIndex], 'submitStatus', true)
this.$set(this.list[this.currentIndex], 'answerList', lists)
this.$set(this.list[this.currentIndex], 'result', status)
this.$set(this.list[this.currentIndex], 'errShow', this.type === 2 ? true : status === 'fail')
app.globalData.questionList = this.list
this.$u.vuex('questionList', this.list)
// 每日一练数量统计
if (this.daily) {
if (this.dailyCount < 9) this.dailyCount++
if (this.dailyCount === 9) {
this.completeType = 'daily'
this.visible = true
}
}
// 如果回答错误或者是考试模式,自动进入下一题
if (status === 'pass' || this.type === 2) {
if (this.currentIndex + 1 > this.list.length - 1) {
......@@ -260,15 +292,42 @@ export default {
},
// 交卷
handPapers() {
const fail = this.list.filter(v => v.result === 'fail').length
const noStart = this.list.filter(v => !v.result).length
this.result = [fail, noStart, 0]
const fail = this.list.filter(v => v.result === 'fail').length // 错题数
const noStart = this.list.filter(v => !v.result).length // 未做题数
const fraction = 0 // 分数
this.result = [fail, noStart, fraction]
this.completeType = 'pass'
this.visible = true
},
// 提前交卷
// 弹框确认
submit() {
console.log("提前交卷")
}
if (this.completeType = 'daily') {
this.visible = false
} else {
// 提前交卷
this.$u.route({
url: 'pages/learn/source'
})
}
},
// 弹框取消
cancel() {
if (this.completeType = 'daily') { // 查看记录
// this.$u.route('/pages/index/index')
} else {
this.visible = false
}
},
// 收藏
collection() {
console.log("this.list[this.currentIndex]", this.list[this.currentIndex])
console.log("收藏")
},
// 移除
remove() {
console.log("this.list[this.currentIndex]", this.list[this.currentIndex])
console.log("移除")
},
},
}
</script>
......
......@@ -12,7 +12,7 @@ try{
}
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
let saveStateKeys = ['userInfo', 'vuex_token', 'openId', 'searchHistory'];
let saveStateKeys = ['userInfo', 'vuex_token', 'openId', 'searchHistory', 'questionList'];
// 保存变量到本地存储中
const saveLifeData = function(key, value){
......@@ -35,9 +35,10 @@ const store = new Vuex.Store({
userInfo: lifeData.userInfo ? lifeData.userInfo : {},
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
openId: lifeData.openId ? lifeData.openId : '',
searchHistory: lifeData.searchHistory ? lifeData.searchHistory : [],
searchHistory: lifeData.searchHistory ? lifeData.searchHistory : [], // 搜索历史记录
questionList: lifeData.questionList ? lifeData.questionList : [], // 练习列表
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
vuex_version: '1.0.1',
vuex_version: '1.0.0',
},
mutations: {
$uStore(state, payload) {
......
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