|
@@ -1,4 +1,4 @@
|
|
|
-new Vue({
|
|
|
+const searchList = new Vue({
|
|
|
el: '#searchList',
|
|
|
data: {
|
|
|
listQuery: {
|
|
@@ -17,31 +17,43 @@ new Vue({
|
|
|
hasNextPage: false,
|
|
|
list: [],
|
|
|
},
|
|
|
- created(){
|
|
|
+ created() {
|
|
|
this.listQuery.name = decodeURIComponent(CAIMEI.getUrlParam('keyword'))
|
|
|
- this.$nextTick(()=>{
|
|
|
+ this.$nextTick(() => {
|
|
|
$('#searchInput').val(this.listQuery.name)
|
|
|
})
|
|
|
this.getList()
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ const self = this
|
|
|
+ window.addEventListener('scroll', debounce(function () {
|
|
|
+ const scrollTop = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset
|
|
|
+ if (document.body.scrollHeight <= window.screen.height + scrollTop) {
|
|
|
+ console.log('已经滚动到底部了')
|
|
|
+ if (!self.hasNextPage) return
|
|
|
+ self.getList()
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ },
|
|
|
methods: {
|
|
|
filterList() {
|
|
|
this.listQuery.pageNum = 1
|
|
|
this.getList()
|
|
|
},
|
|
|
- getList(){
|
|
|
+ getList() {
|
|
|
const self = this
|
|
|
- if(this.listQuery.pageNum > this.totalPage){
|
|
|
+ if (this.listQuery.pageNum > this.totalPage) {
|
|
|
this.listQuery.pageNum = this.totalPage
|
|
|
}
|
|
|
- if(this.listQuery.pageNum < 1){
|
|
|
+ if (this.listQuery.pageNum < 1) {
|
|
|
this.listQuery.pageNum = 1
|
|
|
}
|
|
|
shopBikeApi.FetchEntryList(this.listQuery, function (res) {
|
|
|
- self.list = res.data.results
|
|
|
+ self.list = [...self.list, ...res.data.results]
|
|
|
self.totalPage = res.data.totalPage
|
|
|
self.hasNextPage = res.data.hasNextPage
|
|
|
self.totalRecord = res.data.totalRecord
|
|
|
+ self.listQuery.pageNum++
|
|
|
})
|
|
|
}
|
|
|
}
|