Commit a0cac04c by xiexiaoqin

scheduleList add page data

parent dcfdfa55
......@@ -9,7 +9,7 @@
</view>
</view>
</view>
<scroll-view class="indexScrollView" scroll-y="{{true}}" style="background: #FFFFFF" lower-threshold="1000" onScrollToLower="lower" scroll-into-view="{{todayStr}}">
<scroll-view class="indexScrollView" scroll-y="{{true}}" style="background: #FFFFFF" lower-threshold="100" onScrollToLower="lower" onScrollToUpper="upper" scroll-into-view="{{todayStr}}">
<block a:for="{{scheduleList}}" key="{{item.dateStr}}">
<!-- 年 -->
<block a:if="{{item.type == 'year'}}">
......@@ -25,7 +25,7 @@
</block>
<!-- 周 -->
<block a:elif="{{item.type == 'week'}}">
<view class="week" id="{{item.dayStr}}">
<view class="week" id="{{item.dateStr}}">
{{item.value}}
</view>
</block>
......
......@@ -6,6 +6,7 @@ import {
getCurrentMonthLast,
throttle
} from "../../utils/utils";
const currentDate = new Date().toLocaleDateString();
import create from "dd-store";
create.Page({
data: {
......@@ -26,6 +27,7 @@ create.Page({
loading: true
},
onLoad() {
this.resetPagination();
this.getDate();
this.setData({
userMsg: {
......@@ -37,7 +39,25 @@ create.Page({
this.locationScheduleList();
};
},
getDate: throttle(function(e) {
resetPagination() {
this.pageSize = 20;
this.totalPages = 1;
this.currentPage = 1;
this.firstPage = 1;
this.scheduleList = [];
},
getPagination(scheduleList = []) {
this.scheduleList = scheduleList;
this.totalPages = Math.ceil(scheduleList.length / this.pageSize);
for (let i = 0; i < scheduleList.length; i++) {
if (scheduleList[i].dateStr == currentDate) {
this.firstPage = Math.floor(i / this.pageSize);
this.currentPage = this.firstPage + 1;
break
}
}
},
getDate: throttle(function (e) {
let data = {
startTime: "2020-01-01 00:00:00",
endTime: "2025-12-30 23:59:59"
......@@ -52,21 +72,23 @@ create.Page({
let now = new Date();
let year = now.getFullYear();
let scheduleList = [];
for (let i = 0; i <= year - 2020; i++) {
for (let i = 0; i <= year - 2000; i++) {
scheduleList.push.apply(
scheduleList,
that.returnScheduleList(2020 + i)
that.returnScheduleList(2000 + i)
);
}
this.getPagination(scheduleList);
// 第一次加载
console.log(scheduleList);
const finalDate = new Date();
that.setData({
scheduleList: scheduleList,
todayStr: finalDate.toLocaleDateString(),
scheduleList: scheduleList.slice(this.firstPage * this.pageSize, this.currentPage * this.pageSize),
todayStr: currentDate,
thisYear: year,
maxYear: year
});
console.log(this.data.scheduleList)
}
);
that.setData({
......@@ -74,7 +96,7 @@ create.Page({
});
});
}, 1000),
nextDetail: throttle(function(e) {
nextDetail: throttle(function (e) {
let item = e.target.dataset.item;
dd.navigateTo({
url: `./../meetingDetail/meetingDetail?scheduleItem=${JSON.stringify(
......@@ -168,8 +190,8 @@ create.Page({
item.recurrenceModel.startTime;
let endTime = new Date(
getFormatDate(time, "yyyyMMdd") +
" " +
item.recurrenceModel.startTime
" " +
item.recurrenceModel.startTime
);
endTime.setMinutes(
endTime.getMinutes() + item.recurrenceModel.duration
......@@ -197,8 +219,8 @@ create.Page({
item.recurrenceModel.startTime;
let endTime = new Date(
getFormatDate(time, "yyyyMMdd") +
" " +
item.recurrenceModel.startTime
" " +
item.recurrenceModel.startTime
);
endTime.setMinutes(
endTime.getMinutes() + item.recurrenceModel.duration
......@@ -237,7 +259,7 @@ create.Page({
);
}
});
scheduleMap.forEach(function(value, key, map) {
scheduleMap.forEach(function (value, key, map) {
scheduleList.push(value);
});
return scheduleList;
......@@ -297,7 +319,7 @@ create.Page({
duration: count + 1,
isBeOverdue:
new Date().getTime() >
new Date(AllScheduleList[y].endTime.replace(/-/g, "/")).getTime()
new Date(AllScheduleList[y].endTime.replace(/-/g, "/")).getTime()
? true
: false
});
......@@ -309,7 +331,7 @@ create.Page({
// 第一个月的第一天
let listWeek = new Date(year, 0, 1).getDay() === 0 ? 1 : 2;
let thisDay = new Date().toLocaleDateString();
DateMap.forEach(function(value, key, map) {
DateMap.forEach(function (value, key, map) {
const keyDate = new Date(key);
if (keyDate.getMonth() === 0 && keyDate.getDate() === 1) {
DateList.push({
......@@ -336,8 +358,8 @@ create.Page({
type: "week",
value: `第${listWeek}周,${rangeMonth1 + 1}${rangeDay1}日 - ${
rangeMonth2 == rangeMonth1 ? "" : rangeMonth2 + 1 + "月"
}${rangeDay2}日`,
dayStr: `${keyDate.getFullYear()}/${rangeMonth1 +
}${rangeDay2}日`,
dateStr: `${keyDate.getFullYear()}/${rangeMonth1 +
1}/${rangeDay1}-week`
});
listWeek += 1;
......@@ -413,15 +435,40 @@ create.Page({
return date;
},
lower() {
let year = this.data.maxYear + 1;
let DateList = this.returnScheduleList(year);
let scheduleList = this.data.scheduleList;
scheduleList.push.apply(DateList);
this.setData({
scheduleList,
maxYear: year
});
// let year = this.data.maxYear + 1;
// let DateList = this.returnScheduleList(year);
// let scheduleList = this.data.scheduleList;
// scheduleList.push.apply(DateList);
// this.setData({
// scheduleList,
// maxYear: year
// });
if (this.currentPage < this.totalPages) {
this.currentPage++;
this.setData({
scheduleList: this.scheduleList.slice(this.firstPage * this.pageSize, this.currentPage * this.pageSize)
});
console.log(this.data.scheduleList)
}
},
upper: throttle(function () {
console.log(this.firstPage);
if (this.firstPage > 0) {
this.firstPage--;
this.setData({
scheduleList: this.scheduleList.slice(this.firstPage * this.pageSize, this.currentPage * this.pageSize)
});
this.setData({
todayStr: ''
}, () => {
this.setData({
todayStr: this.scheduleList[(this.firstPage + 1) * this.pageSize - (this.pageSize / 2)].dateStr
})
})
console.log(this.scheduleList[this.firstPage * this.pageSize - (this.pageSize / 2)].dateStr)
console.log(this.data.scheduleList)
}
}),
nextPage() {
dd.navigateTo({ url: "./../createMeeting/createMeeting" });
},
......
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