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
59203b55
Commit
59203b55
authored
Jul 28, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 搜索-添加分页
parent
3425f23b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
199 additions
and
161 deletions
+199
-161
uni-list.vue
src/components/uni-list/uni-list.vue
+1
-2
detail.vue
src/pages/search/detail.vue
+198
-159
No files found.
src/components/uni-list/uni-list.vue
View file @
59203b55
...
@@ -59,7 +59,6 @@ export default {
...
@@ -59,7 +59,6 @@ export default {
/* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */
display
:
flex
;
display
:
flex
;
/* #endif */
/* #endif */
background-color
:
$uni-bg-color
;
position
:
relative
;
position
:
relative
;
flex-direction
:
column
;
flex-direction
:
column
;
}
}
...
...
src/pages/search/detail.vue
View file @
59203b55
...
@@ -21,32 +21,32 @@
...
@@ -21,32 +21,32 @@
></u-search>
></u-search>
</view>
</view>
<view
v-if=
"lists.length > 0"
>
<view
v-if=
"lists.length > 0"
class=
"results"
>
<view
class=
"title"
<view
class=
"title"
>
共找到含有
<text>
“
{{
keyword
}}
”
</text>
相关试题
<text>
{{
count
}}
</text>
道
</view
>
共找到含有
<text>
“
{{
keyword
}}
”
</text>
相关试题
<text>
{{
count
}}
</text
>
道
</view
>
>
<view
class=
"result"
>
<view
class=
"result"
>
<u-collapse
:item-style=
"itemStyle"
event-type=
"close"
>
<uni-list
:border=
"false"
>
<uni-list
:border=
"false"
>
<u-collapse-item
<view
:ref=
"`collapse$
{index}`"
v-for=
"item in lists"
:index="index"
:key=
"item.id"
@change="itemChange"
@
click
.
stop=
"itemChange(item.id)"
v-for="(item, index) in lists"
class=
"list-item"
:key="index"
>
<view
:class=
"['u-flex', 'head',
{ selected: item.id === arrIndex }]"
>
>
<view
slot=
"title-all"
:class=
"['u-flex','head',
{'selected': index === arrIndex}]">
<view
class=
"titles"
>
<view
class=
"titles"
>
<text>
{{
item
.
type
}}
</text
<text>
{{
item
.
type
}}
</text
>
{{
item
.
title
}}
>
{{
item
.
title
}}
</view>
</view>
<view
class=
"u-flex arrow"
v-show=
"index
!== arrIndex"
>
<view
class=
"u-flex arrow"
v-show=
"item.id
!== arrIndex"
>
<text>
展开
</text>
<text>
展开
</text>
<u-icon
name=
"arrow-down"
color=
"#9EA5BB"
></u-icon>
<u-icon
name=
"arrow-down"
color=
"#9EA5BB"
></u-icon>
</view>
</view>
</view>
</view>
<view
class=
"u-flex subject
"
>
<view
class=
"u-flex subject"
v-show=
"item.id === arrIndex
"
>
<view
class=
"content"
>
<view
class=
"content"
>
<answer-sheet
<answer-sheet
ref=
"answerSheet"
ref=
"answerSheet"
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
></answer-explanation>
></answer-explanation>
</view>
</view>
</view>
</view>
<view
class=
"u-flex opera
"
>
<view
class=
"u-flex opera"
v-show=
"item.id === arrIndex
"
>
<view
class=
"opera-list"
@
click=
"collection(item)"
>
<view
class=
"opera-list"
@
click=
"collection(item)"
>
<u-image
<u-image
:src=
"collectImg"
:src=
"collectImg"
...
@@ -76,15 +76,14 @@
...
@@ -76,15 +76,14 @@
/>
/>
<text>
{{
collectionFlag
?
'已收藏'
:
'收藏'
}}
</text>
<text>
{{
collectionFlag
?
'已收藏'
:
'收藏'
}}
</text>
</view>
</view>
<view
class=
"opera-list"
@
click
=
"arrowUp(index)"
>
<view
class=
"opera-list"
@
click
.
stop
=
"arrowUp(index)"
>
<text>
收起
</text>
<text>
收起
</text>
<u-icon
name=
"arrow-up"
color=
"#9EA5BB"
></u-icon>
<u-icon
name=
"arrow-up"
color=
"#9EA5BB"
></u-icon>
</view>
</view>
</view>
</view>
</u-collapse-item
>
</view
>
</uni-list>
</uni-list>
</u-collapse>
<u-loadmore
:status=
"loadStatus"
:margin-bottom=
"40"
/>
</view>
</view>
</view>
</view>
...
@@ -107,7 +106,7 @@ export default {
...
@@ -107,7 +106,7 @@ export default {
components
:
{
components
:
{
answerSheet
,
answerSheet
,
answerExplanation
,
answerExplanation
,
uniList
uniList
,
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -115,11 +114,15 @@ export default {
...
@@ -115,11 +114,15 @@ export default {
background
:
'#fff'
,
background
:
'#fff'
,
padding
:
'0rpx 20rpx'
,
padding
:
'0rpx 20rpx'
,
margin
:
'10rpx 0'
,
margin
:
'10rpx 0'
,
'border-radius'
:
'30rpx 30rpx 0 0'
'border-radius'
:
'30rpx 30rpx 0 0'
,
},
},
keyword
:
''
,
keyword
:
''
,
lists
:
[],
lists
:
[],
arrIndex
:
null
,
arrIndex
:
''
,
currentPage
:
1
,
pageSize
:
10
,
loadStatus
:
'loadmore'
,
isLoadMore
:
false
,
//是否加载中
}
}
},
},
onLoad
(
e
)
{
onLoad
(
e
)
{
...
@@ -134,36 +137,50 @@ export default {
...
@@ -134,36 +137,50 @@ export default {
return
this
.
lists
.
length
return
this
.
lists
.
length
},
},
collectImg
()
{
collectImg
()
{
const
info
=
this
.
lists
.
find
(
v
=>
v
.
index
===
this
.
arrIndex
)
const
info
=
this
.
lists
.
find
(
(
v
)
=>
v
.
index
===
this
.
arrIndex
)
const
name
=
info
?.
collectionFlag
?
'collected.png'
:
'collect.png'
const
name
=
info
?.
collectionFlag
?
'collected.png'
:
'collect.png'
return
process
.
uniEnv
.
qn_base_url
+
name
return
process
.
uniEnv
.
qn_base_url
+
name
},
},
collectionFlag
()
{
collectionFlag
()
{
const
info
=
this
.
lists
.
find
(
v
=>
v
.
index
===
this
.
arrIndex
)
const
info
=
this
.
lists
.
find
(
(
v
)
=>
v
.
index
===
this
.
arrIndex
)
return
info
?
info
.
collectionFlag
:
false
return
info
?
info
.
collectionFlag
:
false
},
},
onReachBottom
()
{
//上拉触底函数
if
(
!
this
.
isLoadMore
)
{
//此处判断,上锁,防止重复请求
this
.
isLoadMore
=
true
this
.
currentPage
+=
1
this
.
init
()
}
}
},
},
methods
:
{
methods
:
{
init
()
{
init
()
{
const
data
=
{
const
data
=
{
questionWarehouseId
:
this
.
questionWarehouseId
,
questionWarehouseId
:
this
.
questionWarehouseId
,
keyWord
:
this
.
keyword
keyword
:
this
.
keyword
,
current
:
this
.
currentPage
,
size
:
this
.
pageSize
,
}
}
uni
.
showLoading
({
uni
.
showLoading
({
title
:
'加载中'
title
:
'加载中'
,
})
})
this
.
$u
.
api
.
searchQuestion
(
data
).
then
(
res
=>
{
this
.
loadStatus
=
'loading'
this
.
$u
.
api
.
searchQuestion
(
data
).
then
((
res
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
this
.
lists
=
res
.
length
>
0
?
res
.
map
((
v
,
i
)
=>
{
const
lists
=
res
?.
records
.
length
>
0
?
res
?.
records
.
map
((
v
,
i
)
=>
{
const
rightKey
=
v
.
answer
.
split
(
','
)
const
rightKey
=
v
.
answer
.
split
(
','
)
const
content
=
JSON
.
parse
(
v
.
content
)
const
content
=
JSON
.
parse
(
v
.
content
)
const
answerList
=
content
.
choiceList
.
map
(
item
=>
{
const
answerList
=
content
.
choiceList
.
map
((
item
)
=>
{
return
{
return
{
sort
:
item
.
value
,
sort
:
item
.
value
,
text
:
item
.
label
,
text
:
item
.
label
,
checked
:
rightKey
.
includes
(
item
.
value
),
checked
:
rightKey
.
includes
(
item
.
value
),
confirm
:
rightKey
.
includes
(
item
.
value
)
confirm
:
rightKey
.
includes
(
item
.
value
),
}
}
})
})
...
@@ -177,18 +194,30 @@ export default {
...
@@ -177,18 +194,30 @@ export default {
explain
:
v
.
analysis
,
explain
:
v
.
analysis
,
rightKey
:
rightKey
,
rightKey
:
rightKey
,
collectionFlag
:
v
.
collectionFlag
,
collectionFlag
:
v
.
collectionFlag
,
submitStatus
:
true
submitStatus
:
true
,
}
}
})
:
[]
})
:
[]
this
.
lists
=
this
.
lists
.
concat
(
lists
)
if
(
res
.
records
.
length
<
this
.
pageSize
)
{
//判断接口返回数据量小于请求数据量,则表示此为最后一页
this
.
isLoadMore
=
true
this
.
loadStatus
=
'nomore'
}
else
{
this
.
isLoadMore
=
false
}
this
.
status
=
'nomore'
})
})
},
},
itemChange
(
e
)
{
itemChange
(
e
)
{
this
.
arrIndex
=
e
.
show
?
e
.
index
:
null
this
.
arrIndex
=
e
},
},
search
(
val
)
{
search
(
val
)
{
if
(
val
){
if
(
val
)
{
this
.
keyword
=
val
this
.
keyword
=
val
let
history
=
this
.
searchHistory
.
filter
(
v
=>
v
!==
val
)
let
history
=
this
.
searchHistory
.
filter
(
(
v
)
=>
v
!==
val
)
history
.
unshift
(
val
)
history
.
unshift
(
val
)
if
(
history
.
length
>
9
)
{
if
(
history
.
length
>
9
)
{
history
.
splice
(
9
,
1
)
history
.
splice
(
9
,
1
)
...
@@ -199,17 +228,17 @@ export default {
...
@@ -199,17 +228,17 @@ export default {
},
},
collection
(
item
)
{
collection
(
item
)
{
const
action
=
item
.
collectionFlag
?
'removeCollection'
:
'joinCollection'
const
action
=
item
.
collectionFlag
?
'removeCollection'
:
'joinCollection'
this
.
$u
.
api
[
action
]({
questionId
:
item
.
id
}).
then
(
res
=>
{
this
.
$u
.
api
[
action
]({
questionId
:
item
.
id
}).
then
((
res
)
=>
{
if
(
res
)
{
if
(
res
)
{
const
msg
=
item
.
collectionFlag
?
'取消收藏成功'
:
'收藏成功'
const
msg
=
item
.
collectionFlag
?
'取消收藏成功'
:
'收藏成功'
this
.
$u
.
toast
(
msg
)
this
.
$u
.
toast
(
msg
)
item
.
collectionFlag
=
!
item
.
collectionFlag
item
.
collectionFlag
=
!
item
.
collectionFlag
}
}
})
})
},
},
arrowUp
(
index
)
{
arrowUp
()
{
this
.
$refs
[
`collapse
${
index
}
`
][
0
].
headClick
()
this
.
arrIndex
=
''
}
}
,
},
},
}
}
</
script
>
</
script
>
...
@@ -237,9 +266,17 @@ export default {
...
@@ -237,9 +266,17 @@ export default {
color
:
#2953ff
;
color
:
#2953ff
;
}
}
}
}
.results
{
width
:
100%
;
}
.result
{
.result
{
margin-top
:
30rpx
;
margin-top
:
30rpx
;
width
:
100%
;
width
:
100%
;
.list-item
{
background
:
#fff
;
padding
:
30rpx
20rpx
;
margin
:
10rpx
0
;
border-radius
:
30rpx
30rpx
0
0
;
.head
{
.head
{
width
:
100%
;
width
:
100%
;
height
:
60rpx
;
height
:
60rpx
;
...
@@ -263,6 +300,7 @@ export default {
...
@@ -263,6 +300,7 @@ export default {
}
}
.arrow
{
.arrow
{
padding-left
:
20rpx
;
padding-left
:
20rpx
;
margin-top
:
-10rpx
;
text
{
text
{
color
:
#2953ff
;
color
:
#2953ff
;
font-size
:
28rpx
;
font-size
:
28rpx
;
...
@@ -295,7 +333,7 @@ export default {
...
@@ -295,7 +333,7 @@ export default {
}
}
}
}
.opera
{
.opera
{
padding
:
30rpx
0
;
padding-top
:
30rpx
;
justify-content
:
space-between
;
justify-content
:
space-between
;
color
:
#5a6073
;
color
:
#5a6073
;
font-size
:
28rpx
;
font-size
:
28rpx
;
...
@@ -315,12 +353,13 @@ export default {
...
@@ -315,12 +353,13 @@ export default {
}
}
}
}
}
}
}
.default
{
.default
{
flex-flow
:
column
;
flex-flow
:
column
;
flex
:
1
;
flex
:
1
;
justify-content
:
center
;
justify-content
:
center
;
.no-result
{
.no-result
{
color
:
#9
EA5BB
;
color
:
#9
ea5bb
;
font-size
:
28rpx
;
font-size
:
28rpx
;
}
}
}
}
...
...
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