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 @@ ...@@ -131,9 +131,9 @@
<view onTap="changeTabBar" data-tabbar='1' data-title='日程'> <view onTap="changeTabBar" data-tabbar='1' data-title='日程'>
<view class="tabBarView tabBarView2 {{$data.tabBarIndex === '1' ? 'ischooseTabBar' : ''}}"> <view class="tabBarView tabBarView2 {{$data.tabBarIndex === '1' ? 'ischooseTabBar' : ''}}">
<view class="iconfont iconicon_Calendarbox1"> <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>
<text a:elif="{{offset == 'next'}}" class="iconfont iconicon_days iconicon_open"> <text a:elif="{{offset == 'next'}}" class="iconfont iconicon_days iconicon_Packup">
</text> </text>
<text a:else class="iconfont iconicon_days iconicon_days{{iconDay}}"> <text a:else class="iconfont iconicon_days iconicon_days{{iconDay}}">
</text> </text>
......
...@@ -57,15 +57,20 @@ create.Page({ ...@@ -57,15 +57,20 @@ create.Page({
blankDataLengthAfter: 0, blankDataLengthAfter: 0,
minYear: minYear, minYear: minYear,
maxYear: maxYear, maxYear: maxYear,
todayIndex: 0,
onShow() { onShow() {
//如果是重复会议重新算 //如果是重复会议重新算
if (this.$store.data.indexNeedUpdate) { if (this.$store.data.indexNeedUpdate) {
DateMap = getDateMap(this.minYear, this.maxYear); DateMap = getDateMap(this.minYear, this.maxYear);
this.onLoad(); this.onLoad();
this.$store.data.indexNeedUpdate = false;
this.update();
} }
//单次会议往DateMap中添加 //单次会议往DateMap中添加
if (this.$store.data.onceMeetingContent) { if (this.$store.data.onceMeetingContent) {
this.getScheduleList(this.$store.data.onceMeetingContent, "once"); this.getScheduleList(this.$store.data.onceMeetingContent, "once");
this.$store.data.onceMeetingContent = null;
this.update();
} }
}, },
onLoad() { onLoad() {
...@@ -239,6 +244,10 @@ create.Page({ ...@@ -239,6 +244,10 @@ create.Page({
for (let i = 0; i < scheduleList.length; i++) { for (let i = 0; i < scheduleList.length; i++) {
if (scheduleList[i].dateStr == toLocaleDateString(currentDate)) { if (scheduleList[i].dateStr == toLocaleDateString(currentDate)) {
const centerPage = Math.floor(i / this.pageSize); const centerPage = Math.floor(i / this.pageSize);
this.todayIndex = i;
this.setData({
currentDataIndex: i
})
// firstPage转为4的倍数,一次下拉加载40条 // firstPage转为4的倍数,一次下拉加载40条
const firstPage = centerPage - 2; const firstPage = centerPage - 2;
this.firstPage = this.firstPage =
...@@ -394,7 +403,7 @@ create.Page({ ...@@ -394,7 +403,7 @@ create.Page({
} }
// 取出DateMap的value值平铺到DateList // 取出DateMap的value值平铺到DateList
const DateList = []; const DateList = [];
DateMap.forEach(function(value, key) { DateMap.forEach(function (value, key) {
const keyDate = new Date(key); const keyDate = new Date(key);
const year = keyDate.getFullYear(); const year = keyDate.getFullYear();
const month = keyDate.getMonth(); const month = keyDate.getMonth();
...@@ -427,7 +436,7 @@ create.Page({ ...@@ -427,7 +436,7 @@ create.Page({
value: `第${getWeekNumber(year, month, date)}周,${month + value: `第${getWeekNumber(year, month, date)}周,${month +
1}${date}日 - ${ 1}${date}日 - ${
rangeMonth2 == month ? "" : rangeMonth2 + 1 + "月" rangeMonth2 == month ? "" : rangeMonth2 + 1 + "月"
}${rangeDay2}日`, }${rangeDay2}日`,
dateStr: `${year}/${month + 1}/${date}-week` dateStr: `${year}/${month + 1}/${date}-week`
}); });
} }
...@@ -530,6 +539,7 @@ create.Page({ ...@@ -530,6 +539,7 @@ create.Page({
this.minYear--; this.minYear--;
const yearData = getBlankList(this.minYear); const yearData = getBlankList(this.minYear);
this.blankDataLength += yearData.length; this.blankDataLength += yearData.length;
this.todayIndex += yearData.length;
this.scheduleList.unshift(...yearData); this.scheduleList.unshift(...yearData);
this.totalPages = Math.ceil(this.scheduleList.length / this.pageSize); this.totalPages = Math.ceil(this.scheduleList.length / this.pageSize);
this.currentPage = Math.floor((yearData.length * 2) / this.pageSize); this.currentPage = Math.floor((yearData.length * 2) / this.pageSize);
...@@ -550,45 +560,7 @@ create.Page({ ...@@ -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) { 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) { if (e.detail.scrollTop == 0) {
this.setData({ this.setData({
...@@ -596,67 +568,38 @@ create.Page({ ...@@ -596,67 +568,38 @@ create.Page({
currentDataIndex: 0 currentDataIndex: 0
}); });
} }
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => {
this.setData({
offset: "stop"
});
}, 500);
//每次计算偏移值 //每次计算偏移值
const offset = this.getScrollOffset(e.detail.scrollTop); const offset = this.getScrollOffset(e.detail.scrollTop);
if (this.data.offset !== offset) { dd.createSelectorQuery().selectAll('.li').boundingClientRect().exec((rect) => {
if (!this.resetToview) { //日程的上下箭头
this.setData({ this.setScrollOffset(rect);
offset if (offset == 'next') {
}); for (let i = this.data.currentDataIndex; i < rect[0].length; i++) {
} if (rect[0][i].top > 0) {
this.resetToview = false; if (this.data.scheduleList[i].dateStr.split('/')[1] !== this.data.currentData.split('/')[1]) {
} this.setData({
dd.createSelectorQuery() currentData: this.data.scheduleList[i].dateStr,
.selectAll(".li") currentDataIndex: i
.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;
} }
break;
} }
} else if (offset == "before") { }
let i = Math.min( } else if (offset == "before") {
this.data.currentDataIndex, let i = Math.min(this.data.currentDataIndex, this.data.scheduleList.length - 1);
this.data.scheduleList.length - 1 for (; i > 0; i--) {
); if (rect[0][i].top < 50) {
for (; i > 0; i--) { if (this.data.scheduleList[i].dateStr.split("/")[1] !== this.data.currentData.split("/")[1]) {
if (rect[0][i].top < 50) { this.setData({
if ( currentData: this.data.scheduleList[i].dateStr,
this.data.scheduleList[i].dateStr.split("/")[1] !== currentDataIndex: i
this.data.currentData.split("/")[1] });
) {
this.setData({
currentData: this.data.scheduleList[i].dateStr,
currentDataIndex: i
});
}
break;
} }
break;
} }
} }
}); }
});
}, },
//判断滚动方向 //判断滚动方向
getScrollOffset(scrollTop) { getScrollOffset(scrollTop) {
...@@ -671,6 +614,28 @@ create.Page({ ...@@ -671,6 +614,28 @@ create.Page({
this.scrollTop = scrollTop; this.scrollTop = scrollTop;
return offset; 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() { closePop() {
this.setData({ this.setData({
show: false show: false
...@@ -684,7 +649,7 @@ create.Page({ ...@@ -684,7 +649,7 @@ create.Page({
createMeeting() { createMeeting() {
dd.navigateTo({ url: "./../createMeeting/createMeeting" }); dd.navigateTo({ url: "./../createMeeting/createMeeting" });
}, },
nextDetail: throttle(function(e) { nextDetail: throttle(function (e) {
dd.navigateTo({ dd.navigateTo({
url: `./../meetingDetail/meetingDetail?scheduleItem=${encodeURIComponent( url: `./../meetingDetail/meetingDetail?scheduleItem=${encodeURIComponent(
JSON.stringify(e.target.dataset.item) JSON.stringify(e.target.dataset.item)
...@@ -717,7 +682,6 @@ create.Page({ ...@@ -717,7 +682,6 @@ create.Page({
}); });
} }
} }
//需要先清空todayStr再设置才有效 //需要先清空todayStr再设置才有效
this.setData( this.setData(
{ {
...@@ -740,13 +704,27 @@ create.Page({ ...@@ -740,13 +704,27 @@ create.Page({
dd.setNavigationBar({ dd.setNavigationBar({
title: title title: title
}); });
if (tabbar == "1" && lastTimeTabBarIndex == tabbar) {
this.backToToday();
}
if (this.isFirstLoad) { if (this.isFirstLoad) {
this.backToToday("first"); this.backToToday("first");
this.isFirstLoad = false; 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