Commit 20827664 by liang ce

:wq

Merge branch 'dev' of http://gitlab.roboming.com/fengzhaoyu/schedule into dev
parents 8dc7918c 34fc0056
......@@ -131,9 +131,9 @@
<view onTap="changeTabBar" data-tabbar='1' data-title='日程'>
<view class="tabBarView tabBarView2 {{$data.tabBarIndex === '1' ? 'ischooseTabBar' : ''}}">
<view class="iconfont iconicon_Calendarbox1">
<text a:if="{{offset == 'before'}}" class="iconfont iconicon_days iconicon_Packup">
<text a:if="{{offset == 'before'}}" class="iconfont iconicon_days iconicon_open">
</text>
<text a:elif="{{offset == 'next'}}" class="iconfont iconicon_days iconicon_open">
<text a:elif="{{offset == 'next'}}" class="iconfont iconicon_days iconicon_Packup">
</text>
<text a:else class="iconfont iconicon_days iconicon_days{{iconDay}}">
</text>
......
......@@ -57,15 +57,20 @@ create.Page({
blankDataLengthAfter: 0,
minYear: minYear,
maxYear: maxYear,
todayIndex: 0,
onShow() {
//如果是重复会议重新算
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() {
......@@ -239,6 +244,10 @@ create.Page({
for (let i = 0; i < scheduleList.length; i++) {
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 =
......@@ -394,7 +403,7 @@ create.Page({
}
// 取出DateMap的value值平铺到DateList
const DateList = [];
DateMap.forEach(function(value, key) {
DateMap.forEach(function (value, key) {
const keyDate = new Date(key);
const year = keyDate.getFullYear();
const month = keyDate.getMonth();
......@@ -427,7 +436,7 @@ create.Page({
value: `第${getWeekNumber(year, month, date)}周,${month +
1}${date}日 - ${
rangeMonth2 == month ? "" : rangeMonth2 + 1 + "月"
}${rangeDay2}日`,
}${rangeDay2}日`,
dateStr: `${year}/${month + 1}/${date}-week`
});
}
......@@ -530,6 +539,7 @@ create.Page({
this.minYear--;
const yearData = getBlankList(this.minYear);
this.blankDataLength += yearData.length;
this.todayIndex += yearData.length;
this.scheduleList.unshift(...yearData);
this.totalPages = Math.ceil(this.scheduleList.length / this.pageSize);
this.currentPage = Math.floor((yearData.length * 2) / this.pageSize);
......@@ -550,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({
......@@ -596,67 +568,38 @@ 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 (offset == "next") {
for (let i = this.data.currentDataIndex; i < rect[0].length; i++) {
if (rect[0][i].top > 0) {
if (
this.data.scheduleList[i].dateStr.split("/")[1] !==
this.data.currentData.split("/")[1]
) {
this.setData({
currentData: this.data.scheduleList[i].dateStr,
currentDataIndex: i
});
}
break;
dd.createSelectorQuery().selectAll('.li').boundingClientRect().exec((rect) => {
//日程的上下箭头
this.setScrollOffset(rect);
if (offset == 'next') {
for (let i = this.data.currentDataIndex; i < rect[0].length; i++) {
if (rect[0][i].top > 0) {
if (this.data.scheduleList[i].dateStr.split('/')[1] !== this.data.currentData.split('/')[1]) {
this.setData({
currentData: this.data.scheduleList[i].dateStr,
currentDataIndex: i
})
}
break;
}
} else if (offset == "before") {
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]
) {
this.setData({
currentData: this.data.scheduleList[i].dateStr,
currentDataIndex: i
});
}
break;
}
} else if (offset == "before") {
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]) {
this.setData({
currentData: this.data.scheduleList[i].dateStr,
currentDataIndex: i
});
}
break;
}
}
});
}
});
},
//判断滚动方向
getScrollOffset(scrollTop) {
......@@ -671,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
......@@ -684,7 +649,7 @@ create.Page({
createMeeting() {
dd.navigateTo({ url: "./../createMeeting/createMeeting" });
},
nextDetail: throttle(function(e) {
nextDetail: throttle(function (e) {
dd.navigateTo({
url: `./../meetingDetail/meetingDetail?scheduleItem=${encodeURIComponent(
JSON.stringify(e.target.dataset.item)
......@@ -717,7 +682,6 @@ create.Page({
});
}
}
//需要先清空todayStr再设置才有效
this.setData(
{
......@@ -740,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