Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
study
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Damon
study
Commits
a37cb701
Commit
a37cb701
authored
Jul 24, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 分离不同题库的数据
parent
658356a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
15 deletions
+15
-15
answer.vue
src/pages/learn/answer.vue
+10
-10
utils.js
src/pages/learn/utils.js
+3
-3
index.js
src/store/index.js
+2
-2
No files found.
src/pages/learn/answer.vue
View file @
a37cb701
...
...
@@ -244,10 +244,10 @@ export default {
}
if
(
this
.
source
===
1
){
// 顺序答题,如果答满则清空数据
const
check
=
this
.
questionList
.
every
(
v
=>
v
.
submitStatus
)
const
check
=
this
.
questionList
[
this
.
questionWarehouseId
]
?
this
.
questionList
[
this
.
questionWarehouseId
].
every
(
v
=>
v
.
submitStatus
)
:
false
if
(
check
)
{
this
.
$u
.
vuex
(
'lastIndex'
,
0
)
this
.
$u
.
vuex
(
'questionList'
,
[])
this
.
$u
.
vuex
(
`lastIndex.
${
this
.
questionWarehouseId
}
`
,
0
)
this
.
$u
.
vuex
(
`questionList.
${
this
.
questionWarehouseId
}
`
,
[])
}
}
...
...
@@ -282,7 +282,7 @@ export default {
this
.
cachePageDataMap
=
new
Map
()
// 上次答到了第几题
let
index
=
this
.
source
===
1
?
(
this
.
lastIndex
||
0
)
:
0
let
index
=
this
.
source
===
1
?
(
this
.
lastIndex
[
this
.
questionWarehouseId
]
||
0
)
:
0
this
.
refresh
(
index
)
})
},
...
...
@@ -403,12 +403,12 @@ export default {
// 顺序练习,更新答题卡
if
(
this
.
source
===
1
){
this
.
questionList
[
this
.
currentIndex
]
=
item
this
.
$u
.
vuex
(
'questionList'
,
this
.
questionList
)
this
.
$u
.
vuex
(
'lastIndex'
,
this
.
currentIndex
)
this
.
questionList
[
this
.
questionWarehouseId
][
this
.
currentIndex
]
=
item
this
.
$u
.
vuex
(
`questionList.
${
this
.
questionWarehouseId
}
`
,
this
.
questionList
[
this
.
questionWarehouseId
]
)
this
.
$u
.
vuex
(
`lastIndex.
${
this
.
questionWarehouseId
}
`
,
this
.
currentIndex
)
// 统计是否达满所有试题
const
count
=
this
.
questionList
.
reduce
((
accumulator
,
currentValue
)
=>
{
const
count
=
this
.
questionList
[
this
.
questionWarehouseId
]
.
reduce
((
accumulator
,
currentValue
)
=>
{
if
(
currentValue
.
submitStatus
)
accumulator
++
return
accumulator
},
0
)
...
...
@@ -515,8 +515,8 @@ export default {
if
(
res
)
{
info
.
collectionFlag
=
!
status
if
(
this
.
source
===
1
)
{
//更新缓存数据
this
.
questionList
[
this
.
currentIndex
]
=
info
this
.
$u
.
vuex
(
'questionList'
,
this
.
questionList
)
this
.
questionList
[
this
.
questionWarehouseId
][
this
.
currentIndex
]
=
info
this
.
$u
.
vuex
(
`questionList.
${
this
.
questionWarehouseId
}
`
,
this
.
questionList
[
this
.
questionWarehouseId
]
)
}
}
})
...
...
src/pages/learn/utils.js
View file @
a37cb701
...
...
@@ -152,7 +152,7 @@ function request({ currentPage, size, onSuccess, onFailed }, vm) {
}
// 回显已答题目
if
(
vm
.
source
===
1
)
{
// 练习模式回显
const
ansItem
=
vm
.
questionList
.
find
(
v
=>
v
.
index
===
item
.
index
)
const
ansItem
=
vm
.
questionList
[
vm
.
questionWarehouseId
]
.
find
(
v
=>
v
.
index
===
item
.
index
)
questionList
.
push
(
ansItem
?
ansItem
:
item
)
}
else
{
questionList
.
push
(
item
)
...
...
@@ -216,12 +216,12 @@ const getInitPageList = function(currentIndex, size, currentPage, total) {
}
function
initAnswerCardList
(
total
,
vm
)
{
if
(
!
vm
.
questionList
||
vm
.
questionList
.
length
===
0
)
{
if
(
!
vm
.
questionList
[
vm
.
questionWarehouseId
]
||
vm
.
questionList
[
vm
.
questionWarehouseId
]
.
length
===
0
)
{
let
list
=
[]
for
(
let
i
=
0
;
i
<
total
;
i
++
)
{
list
.
push
({})
}
vm
.
$u
.
vuex
(
'questionList'
,
list
)
vm
.
$u
.
vuex
(
`questionList.
${
vm
.
questionWarehouseId
}
`
,
list
)
}
}
...
...
src/store/index.js
View file @
a37cb701
...
...
@@ -43,8 +43,8 @@ const store = new Vuex.Store({
vuex_token
:
lifeData
.
vuex_token
?
lifeData
.
vuex_token
:
''
,
openId
:
lifeData
.
openId
?
lifeData
.
openId
:
''
,
searchHistory
:
lifeData
.
searchHistory
?
lifeData
.
searchHistory
:
[],
// 搜索历史记录
questionList
:
lifeData
.
questionList
?
lifeData
.
questionList
:
[]
,
// 练习列表
lastIndex
:
lifeData
.
lastIndex
?
lifeData
.
lastIndex
:
0
,
// 上次做到第几题
questionList
:
lifeData
.
questionList
?
lifeData
.
questionList
:
{}
,
// 练习列表
lastIndex
:
lifeData
.
lastIndex
?
lifeData
.
lastIndex
:
{}
,
// 上次做到第几题
tipStatus
:
lifeData
.
tipStatus
?
lifeData
.
tipStatus
:
false
,
// 滑动提示
questionWarehouseId
:
lifeData
.
questionWarehouseId
?
lifeData
.
questionWarehouseId
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment