Commit a326fa69 authored by Damon's avatar Damon

refactor: 搜索

parent afbdea00
...@@ -64,7 +64,8 @@ ...@@ -64,7 +64,8 @@
"name": "searchDetail", "name": "searchDetail",
"style": { "style": {
"navigationBarTitleText": "搜索结果", "navigationBarTitleText": "搜索结果",
"navigationStyle": "custom" "navigationStyle": "custom",
"disableScroll": true
} }
} }
] ]
......
...@@ -26,16 +26,18 @@ ...@@ -26,16 +26,18 @@
>共找到含有<text>“{{ keyword }}”</text>相关试题<text>{{ total }}</text >共找到含有<text>“{{ keyword }}”</text>相关试题<text>{{ total }}</text
>道</view >道</view
> >
<view class="result"> <view class="u-flex result">
<my-section <scroll-view :scroll-top="scrollTop" scroll-y class="scroll-Y" @scrolltolower="scrolltolower">
v-for="(item, index) in section" <my-section
:key="index" v-for="(item, index) in section"
:begin="item.begin" :key="index"
:arrId.sync="arrId" :begin="item.begin"
:end="item.end" :arrId.sync="arrId"
:keyword="keyword" :end="item.end"
></my-section> :keyword="keyword"
<u-loadmore :status="loadStatus" :margin-bottom="40" /> ></my-section>
</scroll-view>
<u-loadmore class="more" :status="loadStatus" :margin-bottom="40" />
</view> </view>
</view> </view>
...@@ -84,15 +86,7 @@ export default { ...@@ -84,15 +86,7 @@ export default {
return process.uniEnv.qn_base_url + 'no-search.png' return process.uniEnv.qn_base_url + 'no-search.png'
} }
}, },
onReachBottom() {
//上拉触底函数
if (!this.isLoadMore) {
//此处判断,上锁,防止重复请求
this.isLoadMore = true
this.currentPage += 1
this.init()
}
},
methods: { methods: {
init() { init() {
const data = { const data = {
...@@ -142,7 +136,7 @@ export default { ...@@ -142,7 +136,7 @@ export default {
end: this.lists.length, end: this.lists.length,
}) })
this.arrId = this.lists[0].id this.arrId = this.lists[0].id
if (records.length < this.pageSize) { if (res.pages === this.currentPage) {
//判断接口返回数据量小于请求数据量,则表示此为最后一页 //判断接口返回数据量小于请求数据量,则表示此为最后一页
this.isLoadMore = true this.isLoadMore = true
this.loadStatus = 'nomore' this.loadStatus = 'nomore'
...@@ -168,8 +162,17 @@ export default { ...@@ -168,8 +162,17 @@ export default {
this.arrId = '' this.arrId = ''
this.init() this.init()
} }
},
scrolltolower() {
//上拉触底函数
if (!this.isLoadMore) {
//此处判断,上锁,防止重复请求
this.isLoadMore = true
this.currentPage += 1
this.init()
}
} }
}, }
} }
</script> </script>
...@@ -202,6 +205,13 @@ export default { ...@@ -202,6 +205,13 @@ export default {
.result { .result {
margin-top: 30rpx; margin-top: 30rpx;
width: 100%; width: 100%;
flex-flow: column;
.scroll-Y {
height: calc(100vh - 230px);
}
.more {
margin-top: 20rpx;
}
} }
.default { .default {
flex-flow: column; flex-flow: column;
......
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