Commit a0cac04c by xiexiaoqin

scheduleList add page data

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