From 730f6171c694c65cc8b35ba9cd18b5a6fa83b530 Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Wed, 18 Aug 2021 15:45:55 +0800 Subject: [PATCH] no message --- components/virtual-list/index.js | 164 ----------------------------- components/virtual-list/index.json | 7 -- components/virtual-list/index.wxml | 20 ---- components/virtual-list/index.wxss | 0 4 files changed, 191 deletions(-) delete mode 100644 components/virtual-list/index.js delete mode 100644 components/virtual-list/index.json delete mode 100644 components/virtual-list/index.wxml delete mode 100644 components/virtual-list/index.wxss diff --git a/components/virtual-list/index.js b/components/virtual-list/index.js deleted file mode 100644 index 5c19781..0000000 --- a/components/virtual-list/index.js +++ /dev/null @@ -1,164 +0,0 @@ -const util = require('../../utils/util') -const math = require('../../utils/math') - -Component({ - /** - * 组件样式隔离 - */ - options: { - addGlobalClass: true, - multipleSlots: true // 支持多个slot - }, - properties: { - height: { - type: Number, - value: 800 - }, - threshold: { // 下拉刷新阈值,下拉距离超过该值触发刷新 - type: Number, - value: 30 - }, - loading: { - type: Boolean, - value: true, - observer(value) { - if(value){ - this.reset() - } - } - }, - finished: { - type: Boolean, - value: false - }, - text: { - type: String, - value: '到底啦~' - }, - size: { - type: Number, - value: 15 - }, - pageList: { - type: Array, - value: [], - observer(value) { - if (!Array.isArray(value)) { - return - } - this.setList(value[0]) - } - } - }, - lifetimes: { - ready: function() { - const query = wx.createSelectorQuery().in(this) - query.select('#scrollview').boundingClientRect().exec((res) => { - this.data.scrollH = res[0].height - }) - } - }, - /** - * 组件的初始数据 - */ - data: { - current: 1, - headerHeight: 0, - bottomHeight: 0, - // pageList: [], // 每一页数据 - visiblist: [], // visible: false,// 当前是否显示 - pageHeight: [], // 每一页高度 - scrollH: 0,// 滚动框高度 - requesting: false - }, - /** - * 组件的方法列表 - */ - methods: { - reset: function(){ - this.setData({ current: 1, loading: true, finished: false, headerHeight: 0, bottomHeight: 0, pageList: [], pageHeight: [] }) - }, - setList: function(listData){ - this.data.requesting = false - if (!Array.isArray(listData)) { - return - } - if (listData.length < this.data.size) { - this.data.finished = true - } - this.data.current = this.data.current + 1 - if (Array.isArray(listData) && listData.length > 0) { - let pageHeight = this.data.pageHeight, visiblist = this.data.visiblist; - let nowList = `pageList[${this.data.pageList.length - 1}]` - visiblist.push(true) - pageHeight.push({ - top: 0, // 顶部在scroll里的高度 - height: this.data.virtualHeight, // 高度 - bottom: this.data.virtualHeight, // 底部在scroll里的高度 - }) - this.data.pageHeight = pageHeight - this.setData({ [nowList]: listData, visiblist, finished: this.data.finished }) - console.log(this.data.pageList.length) - console.log(visiblist.length) - console.log(this.data.pageHeight.length) - this.initPageHeight(this.data.current - 2) - } - }, - // 初始化首页高度 - initPageHeight: function(index) { - const query = wx.createSelectorQuery().in(this) - query.select(`#listPageId${index}`).boundingClientRect().exec((res) => { - let pageHeight = this.data.pageHeight; - pageHeight[index] = { - top: index > 0 ? pageHeight[index - 1].bottom + 1 : 0, // 顶部在scroll里的高度 - height: res[0].height, - bottom: index > 0 ? math.plus(pageHeight[index - 1].bottom + 1, res[0].height) : res[0].height // 底部在scroll里的高度 - } - this.data.pageHeight = pageHeight - }) - }, - bindscroll: util.throttle(function (e) { - // 实现虚拟列表 - let pageList = this.data.pageList - let visiblist = this.data.visiblist - let headerHeight = this.data.headerHeight - let bottomHeight = this.data.bottomHeight - this.data.pageHeight.forEach((item, index) => { - // 手指上滑 - if (e.detail.deltaY < 0 && item.bottom < math.minus(e.detail.scrollTop, 10) && visiblist[index] && pageList[index + 2]) { - // 隐藏头部 - visiblist[index] = false; - headerHeight += item.height; - // 显示底部 - if (!visiblist[index + 2]) { - visiblist[index + 2] = true; - // console.log('index>>>' + index) - // console.log(pageList.length) - // console.log(visiblist.length) - // console.log(this.data.pageHeight.length) - bottomHeight -= this.data.pageHeight[index + 2].height - } - } - // 手指下滑 - if (e.detail.deltaY > 0 && item.top > math.plus(e.detail.scrollTop, math.plus(this.data.scrollH, 10)) && visiblist[index] == true && pageList[index - 2]) { - // 隐藏头部 - visiblist[index] = false; - bottomHeight += item.height; - if (!visiblist[index - 2]) { - // 显示底部 - visiblist[index - 2] = true; - headerHeight -= this.data.pageHeight[index - 2].height - } - } - }) - this.setData({ visiblist, headerHeight, bottomHeight }) - }, 100), - scrolltolower: function(){ - if (this.data.requesting || this.data.finished) { - return - } - this.data.requesting = true - this.triggerEvent('loadmore') - } - } -}) \ No newline at end of file diff --git a/components/virtual-list/index.json b/components/virtual-list/index.json deleted file mode 100644 index d179519..0000000 --- a/components/virtual-list/index.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "component": true, - "usingComponents": { - "van-divider": "/components/divider/index", - "van-loading": "/components/loading/index" - } -} \ No newline at end of file diff --git a/components/virtual-list/index.wxml b/components/virtual-list/index.wxml deleted file mode 100644 index 1f12ee0..0000000 --- a/components/virtual-list/index.wxml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - {{loading? '正在加载' : '暂无数据'}} - - - - - - - - - - - {{finished?'到底啦~':'加载中...'}} - - \ No newline at end of file diff --git a/components/virtual-list/index.wxss b/components/virtual-list/index.wxss deleted file mode 100644 index e69de29..0000000