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
74c9a136
Commit
74c9a136
authored
Jul 23, 2021
by
Facius
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 专项列表
parent
bc051b9a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
182 additions
and
63 deletions
+182
-63
index.vue
src/pages/index/index.vue
+2
-6
selectSpecial.vue
src/pages/learn/selectSpecial.vue
+112
-0
index.js
src/store/index.js
+68
-57
No files found.
src/pages/index/index.vue
View file @
74c9a136
...
@@ -136,7 +136,7 @@ export default {
...
@@ -136,7 +136,7 @@ export default {
},
},
{
{
name
:
'模拟考试'
,
name
:
'模拟考试'
,
label
:
this
.
simulateText
,
label
:
'真题模拟强化'
,
image
:
process
.
uniEnv
.
qn_base_url
+
'monishiti.png'
,
image
:
process
.
uniEnv
.
qn_base_url
+
'monishiti.png'
,
},
},
]
]
...
@@ -147,11 +147,6 @@ export default {
...
@@ -147,11 +147,6 @@ export default {
?
'/'
+
this
.
selected
.
totalExam
?
'/'
+
this
.
selected
.
totalExam
:
'题库进阶练习'
:
'题库进阶练习'
},
},
simulateText
()
{
return
this
.
selected
.
cardId
?
'上次成绩'
+
this
.
selected
.
totalExam
+
'分'
:
'真题模拟强化'
},
info
()
{
info
()
{
return
{
return
{
id
:
this
.
selected
.
id
,
id
:
this
.
selected
.
id
,
...
@@ -282,6 +277,7 @@ export default {
...
@@ -282,6 +277,7 @@ export default {
if
(
this
.
info
.
experience
)
{
if
(
this
.
info
.
experience
)
{
this
.
selected
.
state
=
false
this
.
selected
.
state
=
false
// 体验
// 体验
// ...
}
else
{
}
else
{
// 绑卡提示
// 绑卡提示
this
.
type
=
'bound'
this
.
type
=
'bound'
...
...
src/pages/learn/selectSpecial.vue
0 → 100644
View file @
74c9a136
<
template
>
<view
class=
"selected-special"
>
<u-navbar
back-icon-color=
"#333333"
background=
"transparent"
title=
"已选题库"
titleColor=
"#191C27"
:border-bottom=
"false"
title-bold
></u-navbar>
<view
class=
"selected-list-content"
>
<view
class=
"label-content"
>
<view
v-for=
"(value, key) in lables"
:key=
"key"
class=
"label-item"
>
</view>
</view>
<!-- 无数据 -->
<view
class=
"tag-loading-view"
v-if=
"list.length
<
=
0
"
>
暂无数据
</view>
</view>
</view>
</
template
>
<
script
>
import
QuestionBankCell
from
'@/components/question-bank-cell'
export
default
{
components
:
{
QuestionBankCell
,
},
data
()
{
return
{
info
:
{},
// 已选题库列表
loading
:
true
,
}
},
computed
:
{
lables
()
{
return
{
oneAnswerCount
:
'单选题'
,
anyAnswerCount
:
'多选题'
,
trueOrFalseCount
:
'判断题'
,
trueAnswerCount
:
'判断题(结果为正确)'
,
}
},
},
onLoad
(
e
)
{
this
.
loadList
()
// 获取已选题库列表
},
methods
:
{
getPageInfo
()
{
var
pages
=
getCurrentPages
()
if
(
pages
.
length
>=
2
)
{
var
page
=
pages
[
pages
.
length
-
2
]
this
.
selected
=
page
.
info
}
},
// 点击了添加按钮
handleClick
(
index
)
{},
},
}
</
script
>
<
style
lang=
"scss"
scoped
>
::-webkit-scrollbar
{
width
:
0
;
height
:
0
;
color
:
transparent
;
display
:
none
;
}
.selected-special
{
height
:
100vh
;
display
:
flex
;
flex-direction
:
column
;
background-color
:
#f8fafd
;
background-image
:
linear-gradient
(
to
top
,
#f8fafd
0%
,
#e9f3ff
50%
);
background-size
:
100%
520rpx
;
background-repeat
:
no-repeat
;
padding
:
0
24rpx
0rpx
24rpx
;
.selected-list-content
{
height
:
100%
;
overflow
:
auto
;
.label-content
{
margin-bottom
:
44rpx
;
.label-item
{
margin-bottom
:
24rpx
;
}
}
}
.tag-loading-view
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
margin-top
:
400rpx
;
color
:
#999999
;
text-align
:
center
;
position
:
absolute
;
width
:
100%
;
padding-right
:
11rpx
;
}
.bottom-view
{
margin-bottom
:
44rpx
;
.button-icon
{
margin-right
:
10rpx
;
font-size
:
46rpx
;
font-weight
:
bold
;
}
}
}
</
style
>
src/store/index.js
View file @
74c9a136
...
@@ -2,69 +2,80 @@ import Vue from 'vue'
...
@@ -2,69 +2,80 @@ import Vue from 'vue'
import
Vuex
from
'vuex'
import
Vuex
from
'vuex'
Vue
.
use
(
Vuex
)
Vue
.
use
(
Vuex
)
let
lifeData
=
{}
;
let
lifeData
=
{}
try
{
try
{
// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
lifeData
=
uni
.
getStorageSync
(
'lifeData'
);
lifeData
=
uni
.
getStorageSync
(
'lifeData'
)
}
catch
(
e
){
}
catch
(
e
)
{}
}
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
let
saveStateKeys
=
[
'userInfo'
,
'vuex_token'
,
'openId'
,
'searchHistory'
,
'questionList'
,
'lastIndex'
,
'tipStatus'
,
'questionWarehouseId'
];
let
saveStateKeys
=
[
'userInfo'
,
'vuex_token'
,
'openId'
,
'searchHistory'
,
'questionList'
,
'lastIndex'
,
'tipStatus'
,
'questionWarehouseId'
,
'experience'
,
]
// 保存变量到本地存储中
// 保存变量到本地存储中
const
saveLifeData
=
function
(
key
,
value
){
const
saveLifeData
=
function
(
key
,
value
)
{
// 判断变量名是否在需要存储的数组中
// 判断变量名是否在需要存储的数组中
if
(
saveStateKeys
.
indexOf
(
key
)
!=
-
1
)
{
if
(
saveStateKeys
.
indexOf
(
key
)
!=
-
1
)
{
// 获取本地存储的lifeData对象,将变量添加到对象中
// 获取本地存储的lifeData对象,将变量添加到对象中
let
tmp
=
uni
.
getStorageSync
(
'lifeData'
);
let
tmp
=
uni
.
getStorageSync
(
'lifeData'
)
// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
tmp
=
tmp
?
tmp
:
{};
tmp
=
tmp
?
tmp
:
{}
tmp
[
key
]
=
value
;
tmp
[
key
]
=
value
// 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中
// 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中
uni
.
setStorageSync
(
'lifeData'
,
tmp
);
uni
.
setStorageSync
(
'lifeData'
,
tmp
)
}
}
}
}
const
store
=
new
Vuex
.
Store
({
const
store
=
new
Vuex
.
Store
({
// 下面这些值仅为示例,使用过程中请删除
// 下面这些值仅为示例,使用过程中请删除
state
:
{
state
:
{
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
// 加上vuex_前缀,是防止变量名冲突,也让人一目了然
// 加上vuex_前缀,是防止变量名冲突,也让人一目了然
userInfo
:
lifeData
.
userInfo
?
lifeData
.
userInfo
:
{},
userInfo
:
lifeData
.
userInfo
?
lifeData
.
userInfo
:
{},
vuex_token
:
lifeData
.
vuex_token
?
lifeData
.
vuex_token
:
''
,
vuex_token
:
lifeData
.
vuex_token
?
lifeData
.
vuex_token
:
''
,
openId
:
lifeData
.
openId
?
lifeData
.
openId
:
''
,
experience
:
lifeData
.
experience
?
lifeData
.
experience
:
''
,
searchHistory
:
lifeData
.
searchHistory
?
lifeData
.
searchHistory
:
[],
// 搜索历史记录
openId
:
lifeData
.
openId
?
lifeData
.
openId
:
''
,
questionList
:
lifeData
.
questionList
?
lifeData
.
questionList
:
[],
// 练习列表
searchHistory
:
lifeData
.
searchHistory
?
lifeData
.
searchHistory
:
[],
// 搜索历史记录
lastIndex
:
lifeData
.
lastIndex
?
lifeData
.
lastIndex
:
0
,
// 上次做到第几题
questionList
:
lifeData
.
questionList
?
lifeData
.
questionList
:
[],
// 练习列表
tipStatus
:
lifeData
.
tipStatus
?
lifeData
.
tipStatus
:
false
,
// 滑动提示
lastIndex
:
lifeData
.
lastIndex
?
lifeData
.
lastIndex
:
0
,
// 上次做到第几题
questionWarehouseId
:
lifeData
.
questionWarehouseId
?
lifeData
.
questionWarehouseId
:
'1414854649273384960'
,
// 科目ID
tipStatus
:
lifeData
.
tipStatus
?
lifeData
.
tipStatus
:
false
,
// 滑动提示
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
questionWarehouseId
:
lifeData
.
questionWarehouseId
vuex_version
:
'1.0.0'
,
?
lifeData
.
questionWarehouseId
},
:
'1414854649273384960'
,
// 科目ID
mutations
:
{
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
$uStore
(
state
,
payload
)
{
vuex_version
:
'1.0.0'
,
// 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
},
let
nameArr
=
payload
.
name
.
split
(
'.'
);
mutations
:
{
let
saveKey
=
''
;
$uStore
(
state
,
payload
)
{
let
len
=
nameArr
.
length
;
// 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
if
(
nameArr
.
length
>=
2
)
{
let
nameArr
=
payload
.
name
.
split
(
'.'
)
let
obj
=
state
[
nameArr
[
0
]];
let
saveKey
=
''
for
(
let
i
=
1
;
i
<
len
-
1
;
i
++
)
{
let
len
=
nameArr
.
length
obj
=
obj
[
nameArr
[
i
]];
if
(
nameArr
.
length
>=
2
)
{
}
let
obj
=
state
[
nameArr
[
0
]]
obj
[
nameArr
[
len
-
1
]]
=
payload
.
value
;
for
(
let
i
=
1
;
i
<
len
-
1
;
i
++
)
{
saveKey
=
nameArr
[
0
];
obj
=
obj
[
nameArr
[
i
]]
}
else
{
}
// 单层级变量,在state就是一个普通变量的情况
obj
[
nameArr
[
len
-
1
]]
=
payload
.
value
state
[
payload
.
name
]
=
payload
.
value
;
saveKey
=
nameArr
[
0
]
saveKey
=
payload
.
name
;
}
else
{
}
// 单层级变量,在state就是一个普通变量的情况
// 保存变量到本地,见顶部函数定义
state
[
payload
.
name
]
=
payload
.
value
saveLifeData
(
saveKey
,
state
[
saveKey
])
saveKey
=
payload
.
name
}
}
}
// 保存变量到本地,见顶部函数定义
saveLifeData
(
saveKey
,
state
[
saveKey
])
},
},
})
})
export
default
store
export
default
store
\ No newline at end of file
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