Commit e9f2e85e by xiexiaoqin

fix: 下拉数据过长时点击回到今天不重置数据

parent 34fc0056
...@@ -572,7 +572,9 @@ create.Page({ ...@@ -572,7 +572,9 @@ create.Page({
const offset = this.getScrollOffset(e.detail.scrollTop); const offset = this.getScrollOffset(e.detail.scrollTop);
dd.createSelectorQuery().selectAll('.li').boundingClientRect().exec((rect) => { dd.createSelectorQuery().selectAll('.li').boundingClientRect().exec((rect) => {
//日程的上下箭头 //日程的上下箭头
this.setScrollOffset(rect); if (rect[0]) {
this.setScrollOffset(rect);
}
if (offset == 'next') { if (offset == 'next') {
for (let i = this.data.currentDataIndex; i < rect[0].length; i++) { for (let i = this.data.currentDataIndex; i < rect[0].length; i++) {
if (rect[0][i].top > 0) { if (rect[0][i].top > 0) {
...@@ -658,11 +660,9 @@ create.Page({ ...@@ -658,11 +660,9 @@ create.Page({
}, 1000), }, 1000),
backToToday(type) { backToToday(type) {
if (!type) { if (!type) {
//如果当前的日期还没加载出来点击无效,下拉积累数据过长可以去掉 //如果当前的日期还没加载出来点击无效
const isFindArr = this.data.scheduleList.filter( const isFindArr = this.data.scheduleList.filter(it => it.dateStr == toLocaleDateString(currentDate));
it => it.dateStr == toLocaleDateString(currentDate) if (isFindArr.length == 0) {
);
if (isFindArr.length == 0 || this.data.scheduleList.length > 100) {
//去掉头部空数据 //去掉头部空数据
if (this.minYear < minYear) { if (this.minYear < minYear) {
this.scheduleList.splice(0, this.blankDataLength); this.scheduleList.splice(0, this.blankDataLength);
...@@ -675,10 +675,7 @@ create.Page({ ...@@ -675,10 +675,7 @@ create.Page({
} }
this.getPagination(this.scheduleList); this.getPagination(this.scheduleList);
this.setData({ this.setData({
scheduleList: this.scheduleList.slice( scheduleList: this.scheduleList.slice(this.firstPage * this.pageSize, this.currentPage * this.pageSize)
this.firstPage * this.pageSize,
this.currentPage * this.pageSize
)
}); });
} }
} }
......
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