Commit 34fc0056 by xiexiaoqin

feat: 修改日程日历的上下箭头表现

parent 166ed587
......@@ -63,10 +63,14 @@ create.Page({
if (this.$store.data.indexNeedUpdate) {
DateMap = getDateMap(this.minYear, this.maxYear);
this.onLoad();
this.$store.data.indexNeedUpdate = false;
this.update();
}
//单次会议往DateMap中添加
if (this.$store.data.onceMeetingContent) {
this.getScheduleList(this.$store.data.onceMeetingContent, "once");
this.$store.data.onceMeetingContent = null;
this.update();
}
},
onLoad() {
......@@ -241,6 +245,9 @@ create.Page({
if (scheduleList[i].dateStr == toLocaleDateString(currentDate)) {
const centerPage = Math.floor(i / this.pageSize);
this.todayIndex = i;
this.setData({
currentDataIndex: i
})
// firstPage转为4的倍数,一次下拉加载40条
const firstPage = centerPage - 2;
this.firstPage =
......@@ -553,45 +560,7 @@ create.Page({
);
}
},
//计算高度
caculateHeight(scrollTop) {
let height = 0;
let i = 0;
while (height <= scrollTop) {
if (this.data.scheduleList[i].type.indexOf("day") !== "-1") {
height += this.dateHeight;
} else {
height += this.otherHeight;
}
i++;
}
return i;
},
scroll(e) {
//计算有偏差
// const index = this.caculateHeight(e.detail.scrollTop);
// console.log(index)
// if (this.data.scheduleList[index].dateStr.split('/')[1] !== this.data.currentData.split('/')[1]) {
// console.log('setDate: ' + this.data.scheduleList[index].dateStr)
// this.setData({
// currentData: this.data.scheduleList[index].dateStr
// })
// }
//循环次数过多
// dd.createSelectorQuery().selectAll('.li').boundingClientRect().exec((rect) => {
// for (let i = rect[0].length; i > 0; i--) {
// if (rect[0][i] && rect[0][i].top < 50) {
// if (this.data.scheduleList[i].dateStr.split('/')[1] !== this.data.currentData.split('/')[1]) {
// this.setData({
// currentData: this.data.scheduleList[i].dateStr,
// })
// }
// break;
// }
// }
// })
// 一次性惯性拉到顶速度跟不上,重置
if (e.detail.scrollTop == 0) {
this.setData({
......@@ -599,48 +568,11 @@ create.Page({
currentDataIndex: 0
});
}
// if (this.timer) {
// clearTimeout(this.timer)
// }
// this.timer = setTimeout(() => {
// this.setData({
// offset: 'stop'
// })
// }, 500)
//每次计算偏移值
const offset = this.getScrollOffset(e.detail.scrollTop);
// if (this.data.offset !== offset) {
// if (!this.resetToview) {
// this.setData({
// offset
// });
// }
// this.resetToview = false
// }
dd.createSelectorQuery().selectAll('.li').boundingClientRect().exec((rect) => {
if (rect[0][this.todayIndex]) {
if (rect[0][this.todayIndex].top < 50 && rect[0][this.todayIndex].top > 20) {
if (this.data.offset !== 'stop') {
this.setData({ offset: 'stop' })
}
} else if (rect[0][this.todayIndex].top < 50) {
if (this.data.offset !== 'next') {
this.setData({ offset: 'next' })
}
} else if (rect[0][this.todayIndex].top > 20) {
if (this.data.offset !== 'before') {
this.setData({ offset: 'before' })
}
}
} else {
if (this.data.offset !== 'before') {
this.setData({ offset: 'before' })
}
}
//日程的上下箭头
this.setScrollOffset(rect);
if (offset == 'next') {
for (let i = this.data.currentDataIndex; i < rect[0].length; i++) {
if (rect[0][i].top > 0) {
......@@ -650,19 +582,14 @@ create.Page({
currentDataIndex: i
})
}
break;
}
}
} else if (offset == "before") {
let i = Math.min(
this.data.currentDataIndex,
this.data.scheduleList.length - 1
);
let i = Math.min(this.data.currentDataIndex, this.data.scheduleList.length - 1);
for (; i > 0; i--) {
if (rect[0][i].top < 50) {
if (
this.data.scheduleList[i].dateStr.split("/")[1] !==
this.data.currentData.split("/")[1]
) {
if (this.data.scheduleList[i].dateStr.split("/")[1] !== this.data.currentData.split("/")[1]) {
this.setData({
currentData: this.data.scheduleList[i].dateStr,
currentDataIndex: i
......@@ -687,6 +614,28 @@ create.Page({
this.scrollTop = scrollTop;
return offset;
},
setScrollOffset(rect) {
if (rect[0][this.todayIndex]) {
if (rect[0][this.todayIndex].top <= 50 && rect[0][this.todayIndex].top >= 20) {
if (this.data.offset !== 'stop') {
this.setData({ offset: 'stop' })
}
} else if (rect[0][this.todayIndex].top < 50) {
if (this.data.offset !== 'next') {
this.setData({ offset: 'next' })
}
} else if (rect[0][this.todayIndex].top > 20) {
if (this.data.offset !== 'before') {
this.setData({ offset: 'before' })
}
}
} else {
if (this.data.offset !== 'before') {
this.setData({ offset: 'before' })
}
}
},
closePop() {
this.setData({
show: false
......@@ -733,7 +682,6 @@ create.Page({
});
}
}
//需要先清空todayStr再设置才有效
this.setData(
{
......@@ -756,13 +704,27 @@ create.Page({
dd.setNavigationBar({
title: title
});
if (tabbar == "1" && lastTimeTabBarIndex == tabbar) {
this.backToToday();
}
if (this.isFirstLoad) {
this.backToToday("first");
this.isFirstLoad = false;
this.resetToview = true;
}
if (lastTimeTabBarIndex == tabbar) {
if (tabbar == "1") {
this.backToToday();
}
} else {
//切换到动态页面时,日程重置成当前日期
if (tabbar == "0") {
this.lastOffset = this.data.offset;
this.setData({
offset: 'stop'
})
} else if (!this.isFirstLoad) {
this.setData({
offset: this.lastOffset
})
}
}
},
......
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