123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- const searchList = new Vue({
- el: '#searchList',
- data: {
- listQuery: {
- shopId: '',
- id: '', //词条id,
- name: '', //词条名称
- typeId: '', //分类id
- auditStatus: 2, //百科审核状态:1待审核,2审核通过,3审核失败
- onlineStatus: 2, //百科上线状态:1待上线,2已上线,3已下线
- status: '', //状态:0保存草稿箱,1已发布
- pageNum: 1, //页数
- pageSize: 10 //条数
- },
- totalPage: 0,
- totalRecord: 0,
- hasNextPage: false,
- list: [],
- },
- created() {
- this.listQuery.name = decodeURIComponent(CAIMEI.getUrlParam('keyword'))
- 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() {
- const self = this
- if (this.listQuery.pageNum > this.totalPage) {
- this.listQuery.pageNum = this.totalPage
- }
- if (this.listQuery.pageNum < 1) {
- this.listQuery.pageNum = 1
- }
- shopBikeApi.FetchEntryList(this.listQuery, function (res) {
- 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++
- })
- }
- }
- })
|