Commit 0d665535 by liang ce

首页去详情页参数

parent 622be814
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
</view> </view>
<view class="index"> <view class="index">
<view a:if="{{true}}"> <view a:if="{{true}}">
<scroll-view class="indexScrollView" a:if="{{todayStr !== ''}}" scroll-y="{{true}}" upper-threshold="50" lower-threshold="1000" onScrollToLower="lower" onScroll="onScroll" scroll-into-view="{{todayStr}}"> <scroll-view class="indexScrollView" a:if="{{todayStr !== ''}}" scroll-y="{{true}}" lower-threshold="1000" onScrollToLower="lower" scroll-into-view="{{todayStr}}">
<block a:for="{{scheduleList}}" a:for-item="scheduleYearList"> <block a:for="{{scheduleList}}" a:for-item="scheduleYearList">
<block a:for="{{scheduleYearList}}"> <block a:for="{{scheduleYearList}}">
<block a:if="{{item.type == 'year'}}"> <block a:if="{{item.type == 'year'}}">
......
...@@ -117,12 +117,14 @@ Component({ ...@@ -117,12 +117,14 @@ Component({
); );
}); });
}, },
didUpdate() { }, didUpdate() {},
didUnmount() { }, didUnmount() {},
methods: { methods: {
nextDetail: throttle(function (e) { nextDetail: throttle(function(e) {
let item = e.target.dataset.item let item = e.target.dataset.item;
dd.navigateTo({ url: `./../editMeeting/editMeeting?scheduleItem=${JSON.stringify(item)}` }) dd.navigateTo({
url: `./../editMeeting/editMeeting?scheduleItem=${JSON.stringify(item)}`
});
}, 1000), }, 1000),
closePop() { closePop() {
this.setData({ this.setData({
...@@ -203,6 +205,7 @@ Component({ ...@@ -203,6 +205,7 @@ Component({
confirmAttendance: item.confirmAttendance, confirmAttendance: item.confirmAttendance,
endTime: getFormatDate(endTime, "yyyyMMdd HH:mm:ss"), endTime: getFormatDate(endTime, "yyyyMMdd HH:mm:ss"),
id: item.id, id: item.id,
scheduleTemplateId: item.scheduleTemplateId,
startTime: startTime, startTime: startTime,
title: item.title, title: item.title,
planDate: getFormatDate(item2, "yyyyMMdd") planDate: getFormatDate(item2, "yyyyMMdd")
...@@ -218,8 +221,8 @@ Component({ ...@@ -218,8 +221,8 @@ Component({
item.recurrenceModel.startTime; item.recurrenceModel.startTime;
let endTime = new Date( let endTime = new Date(
getFormatDate(item2, "yyyyMMdd") + getFormatDate(item2, "yyyyMMdd") +
" " + " " +
item.recurrenceModel.startTime item.recurrenceModel.startTime
); );
endTime.setMinutes( endTime.setMinutes(
endTime.getMinutes() + item.recurrenceModel.duration endTime.getMinutes() + item.recurrenceModel.duration
...@@ -230,6 +233,7 @@ Component({ ...@@ -230,6 +233,7 @@ Component({
confirmAttendance: item.confirmAttendance, confirmAttendance: item.confirmAttendance,
endTime: getFormatDate(endTime, "yyyyMMdd HH:mm:ss"), endTime: getFormatDate(endTime, "yyyyMMdd HH:mm:ss"),
id: item.id, id: item.id,
scheduleTemplateId: item.scheduleTemplateId,
startTime: startTime, startTime: startTime,
title: item.title, title: item.title,
planDate: getFormatDate(item2, "yyyyMMdd") planDate: getFormatDate(item2, "yyyyMMdd")
...@@ -254,7 +258,7 @@ Component({ ...@@ -254,7 +258,7 @@ Component({
); );
} }
}); });
scheduleMap.forEach(function (value, key, map) { scheduleMap.forEach(function(value, key, map) {
scheduleList.push(value); scheduleList.push(value);
}); });
return scheduleList; return scheduleList;
...@@ -262,29 +266,6 @@ Component({ ...@@ -262,29 +266,6 @@ Component({
return []; return [];
} }
}, },
returnMonthActionAndEndDate(year, month, date) {
let days = this.returnDayMany(year, month, date);
let startDay =
new Date(year, month, 1).getDay() === 0
? 1
: 7 - new Date(year, month, 1).getDay() + 1;
let endDay = days + 7 - new Date(year, month, days).getDay();
return {
startDay: startDay,
endDay: endDay
};
},
// 生成一月内的渲染数据
returnMonthMap(year, month, date) {
let monthDay = this.returnMonthActionAndEndDate(year, month, date);
let monthMap = new Map();
for (let i = monthDay.startDay; i < monthDay.endDay; i++) {
monthMap.set(`${new Date(year, month, i).toLocaleDateString()}`, {
scheduleList: []
});
}
return monthMap;
},
returnScheduleList(year) { returnScheduleList(year) {
let that = this; let that = this;
let weekList = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]; let weekList = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
...@@ -334,7 +315,9 @@ Component({ ...@@ -334,7 +315,9 @@ Component({
let AllScheduleList = this.getCalendarList(); let AllScheduleList = this.getCalendarList();
// 遍历所有日程 // 遍历所有日程
for (let y = 0; y < AllScheduleList.length; y++) { for (let y = 0; y < AllScheduleList.length; y++) {
let date1 = AllScheduleList[y].startTime.slice(0, 10).replace(/-/g, "/"); let date1 = AllScheduleList[y].startTime
.slice(0, 10)
.replace(/-/g, "/");
let date2 = AllScheduleList[y].endTime.slice(0, 10).replace(/-/g, "/"); let date2 = AllScheduleList[y].endTime.slice(0, 10).replace(/-/g, "/");
let count = this.count(date1, date2); let count = this.count(date1, date2);
// 不跨天 // 不跨天
...@@ -357,7 +340,9 @@ Component({ ...@@ -357,7 +340,9 @@ Component({
thisDayEndTime: AllScheduleList[y].endTime.slice(11, 16), thisDayEndTime: AllScheduleList[y].endTime.slice(11, 16),
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
}); });
...@@ -392,9 +377,9 @@ Component({ ...@@ -392,9 +377,9 @@ Component({
duration: count + 1, duration: count + 1,
isBeOverdue: isBeOverdue:
new Date().getTime() > new Date().getTime() >
new Date( new Date(
AllScheduleList[y].endTime.replace(/-/g, "/") AllScheduleList[y].endTime.replace(/-/g, "/")
).getTime() ).getTime()
? true ? true
: false : false
}); });
...@@ -411,7 +396,7 @@ Component({ ...@@ -411,7 +396,7 @@ Component({
value: year value: year
}); });
let thisDay = new Date().toLocaleDateString(); let thisDay = new Date().toLocaleDateString();
DateMap.forEach(function (value, key, map) { DateMap.forEach(function(value, key, map) {
if ( if (
new Date(key).getDay() === 0 && new Date(key).getDay() === 0 &&
that.count( that.count(
...@@ -437,7 +422,7 @@ Component({ ...@@ -437,7 +422,7 @@ Component({
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: key dayStr: key
}); });
} }
...@@ -453,13 +438,16 @@ Component({ ...@@ -453,13 +438,16 @@ Component({
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: key dayStr: key
}); });
} }
} else if ( } else if (
new Date(key).getDay() === 0 && new Date(key).getDay() === 0 &&
that.count(new Date(key), new Date(year, 0, isLeapYear ? 366 : 365) < 7) that.count(
new Date(key),
new Date(year, 0, isLeapYear ? 366 : 365) < 7
)
) { ) {
let rangeYear1 = new Date(key).getFullYear(); let rangeYear1 = new Date(key).getFullYear();
let rangeMonth1 = new Date(key).getMonth(); let rangeMonth1 = new Date(key).getMonth();
...@@ -472,7 +460,7 @@ Component({ ...@@ -472,7 +460,7 @@ Component({
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: key dayStr: key
}); });
} }
...@@ -507,8 +495,6 @@ Component({ ...@@ -507,8 +495,6 @@ Component({
}); });
} }
if (value.scheduleList.length === 0 && key === thisDay) { if (value.scheduleList.length === 0 && key === thisDay) {
console.log(key);
console.log(111111);
DateList.push({ DateList.push({
type: "thisDay", type: "thisDay",
value: { value: {
...@@ -525,179 +511,6 @@ Component({ ...@@ -525,179 +511,6 @@ Component({
}); });
return DateList; return DateList;
}, },
// returnScheduleList(date) {
// let that = this;
// let argumentsDate = new Date(date);
// let year = argumentsDate.getFullYear();
// let month = argumentsDate.getMonth();
// let day = argumentsDate.getDate();
// let calendarList = this.getCalendarList();
// let monthMap = this.returnMonthMap(year, month, day);
// let weekList = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
// // 遍历所有日程
// for (let y = 0; y < calendarList.length; y++) {
// let date1 = calendarList[y].startTime.slice(0, 10).replace(/-/g, "/");
// let date2 = calendarList[y].endTime.slice(0, 10).replace(/-/g, "/");
// let count = this.count(date1, date2);
// // 不跨天
// if (count == 0) {
// // 每年的第一周和跨天的那几天有日程就push进去
// if (
// monthMap.get(
// `${new Date(
// calendarList[y].startTime.replace(/-/g, "/")
// ).toLocaleDateString()}`
// )
// ) {
// monthMap
// .get(
// `${new Date(
// calendarList[y].startTime.replace(/-/g, "/")
// ).toLocaleDateString()}`
// )
// .scheduleList.push({
// ...calendarList[y],
// thisDayStartTime: calendarList[y].startTime.slice(11, 16),
// thisDayEndTime: calendarList[y].endTime.slice(11, 16),
// isBeOverdue:
// new Date().getTime() >
// new Date(calendarList[y].endTime.replace(/-/g, "/")).getTime()
// ? true
// : false
// });
// }
// }
// // 跨天
// else {
// for (let j = 0; j <= count; j++) {
// let time = new Date(date1);
// time.setDate(time.getDate() + j);
// if (
// monthMap.get(
// new Date(
// time.getFullYear(),
// time.getMonth(),
// time.getDate()
// ).toLocaleDateString()
// )
// ) {
// monthMap
// .get(
// new Date(
// time.getFullYear(),
// time.getMonth(),
// time.getDate()
// ).toLocaleDateString()
// )
// .scheduleList.push({
// ...calendarList[y],
// isfirstDayOrEndDay: j === 0 ? "0" : j === count ? "2" : "1", // 0 第一天,1中间的天,2结束的天
// thisDayStartTime: calendarList[y].startTime.slice(11, 16),
// thisDayEndTime: calendarList[y].endTime.slice(11, 16),
// isFewDays: j + 1,
// duration: count + 1,
// isBeOverdue:
// new Date().getTime() >
// new Date(
// calendarList[y].endTime.replace(/-/g, "/")
// ).getTime()
// ? true
// : false
// });
// }
// }
// }
// }
// let DateList = [];
// // 第一个月的第一天
// let thisDay = new Date().toLocaleDateString();
// monthMap.forEach(function(value, key, map) {
// if (new Date(key).getDay() === 0) {
// let rangeYear1 = new Date(key).getFullYear();
// let rangeMonth1 = new Date(key).getMonth();
// let rangeDay1 = new Date(key).getDate();
// let rangeDate = new Date(rangeYear1, rangeMonth1, rangeDay1 + 6);
// let rangeMonth2 = new Date(rangeDate).getMonth();
// let rangeDay2 = new Date(rangeDate).getDate();
// DateList.push({
// type: "week",
// value: `第${that.getYearWeek(key)}周,${rangeMonth1 +
// 1}月${rangeDay1}日 - ${
// rangeMonth2 == rangeMonth1 ? "" : rangeMonth2 + 1 + "月"
// }${rangeDay2}日`,
// dayStr: key
// });
// }
// // 有日程长度 并且不是今天
// if (value.scheduleList.length !== 0 && key !== thisDay) {
// DateList.push({
// type: "day",
// isThisDay: true,
// value: {
// value: value.scheduleList,
// day:
// new Date(key).getDate() < 10
// ? "0" + new Date(key).getDate()
// : new Date(key).getDate(),
// week: weekList[new Date(key).getDay()]
// }
// });
// }
// // 有日程长度,并且是今天
// else if (value.scheduleList.length !== 0 && key === thisDay) {
// DateList.push({
// type: "today",
// value: {
// value: value.scheduleList,
// day:
// new Date(key).getDate() < 10
// ? "0" + new Date(key).getDate()
// : new Date(key).getDate(),
// week: weekList[new Date(key).getDay()],
// dateStr: key
// }
// });
// }
// if (value.scheduleList.length === 0 && key === thisDay) {
// DateList.push({
// type: "thisDay",
// value: {
// value: value.scheduleList,
// day:
// new Date(key).getDate() < 10
// ? "0" + new Date(key).getDate()
// : new Date(key).getDate(),
// week: weekList[new Date(key).getDay()],
// dateStr: key
// }
// });
// }
// });
// DateList.unshift({
// type: "month",
// value: month + 1
// });
// if (month === 0) {
// DateList.unshift({
// type: "year",
// value: year
// });
// }
// return DateList;
// },
// 获取今天是每个月的第几周
getYearWeek(date) {
/*
date1是当前日期
date2是当年第一天
d是当前日期是今年第多少天
用d + 当前年的第一天的周差距的和在除以7就是本年第几周
*/
var date1 = new Date(date);
var date2 = new Date(date1.getFullYear(), 0, 1);
var d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000);
return Math.ceil((d + (date2.getDay() + 1 - 1)) / 7);
},
// 是否跨天 返回跨天数 // 是否跨天 返回跨天数
count(date1, date2) { count(date1, date2) {
var date1 = new Date(date1); var date1 = new Date(date1);
...@@ -707,133 +520,15 @@ Component({ ...@@ -707,133 +520,15 @@ Component({
(1000 * 60 * 60 * 24); /*不用考虑闰年否*/ (1000 * 60 * 60 * 24); /*不用考虑闰年否*/
return date; return date;
}, },
// 返回指定月份天数
returnDayMany(year, month, date) {
var selectedDate = new Date(year, month, date);
var selectedMonth = selectedDate.getMonth() + 1;
selectedDate.setMonth(selectedMonth);
selectedDate.setDate(0);
return selectedDate.getDate();
},
onScroll(e) {
// console.log(e);
// if (!this.data.scrollHeight || !this.data.timeStamp) {
// this.setData({
// scrollHeight: e.detail.scrollTop,
// timeStamp: e.timeStamp
// });
// } else {
// let height = e.detail.scrollTop - this.data.scrollHeight;
// let time = e.timeStamp - this.data.timeStamp;
// let v = height / time;
// console.log(v);
// this.setData({
// scrollHeight: e.detail.scrollTop,
// timeStamp: e.timeStamp
// });
// }
},
// onScrollToUpper() {
// let that = this;
// let now = new Date(this.data.pageStartTime);
// let year = now.getFullYear();
// let month = now.getMonth() + 1;
// let day = now.getDate();
// let parmsDate = this.returnMonthActionAndEndDate(year, month - 1, day);
// let startTime = getFormatDate(
// new Date(year, month - 1, parmsDate.startDay),
// "yyyyMMdd",
// "-"
// );
// let endTime = getFormatDate(
// new Date(year, month - 1, parmsDate.endDay),
// "yyyyMMdd",
// "-"
// );
// let data = {
// startTime: `${startTime} 00:00:00`,
// endTime: `${endTime} 23:59:59`
// };
// getHomeUserSchedule1(data).then(res => {
// this.setData(
// {
// response: res.data.data
// },
// () => {
// let scheduleList = [...this.data.scheduleList];
// let forDate = new Date(year, month, 1);
// scheduleList.unshift.apply(
// scheduleList,
// that.returnScheduleList(forDate.toLocaleDateString())
// );
// this.setData({
// scheduleList: scheduleList,
// pageStartTime: new Date(year, month - 2, 1).toLocaleDateString()
// });
// }
// );
// });
// },
lower() { lower() {
let year = this.data.maxYear + 1 let year = this.data.maxYear + 1;
let DateList = this.returnScheduleList(year) let DateList = this.returnScheduleList(year);
this.data.scheduleList.push(DateList) this.data.scheduleList.push(DateList);
let scheduleList = [...this.data.scheduleList] let scheduleList = [...this.data.scheduleList];
this.setData({ this.setData({
scheduleList: scheduleList, scheduleList: scheduleList,
maxYear: year maxYear: year
}) });
},
loadMoreDate() {
for (let i = 0; i < 10; i++) {
let now = new Date(this.data.pageEndTime);
let year = now.getFullYear();
let month = now.getMonth() + 1;
let day = now.getDate();
let parmsDate = this.returnMonthActionAndEndDate(year, month + 1, day);
let forDate = new Date(year, month, 1);
let scheduleList = this.returnScheduleList(
forDate.toLocaleDateString()
);
this.$spliceData({
scheduleList: [this.data.scheduleList.length, 0, scheduleList],
pageEndTime: new Date(year, month, 1).toLocaleDateString()
});
this.setData({
pageEndTime: new Date(year, month, 1).toLocaleDateString()
});
}
// let startTime = getFormatDate(
// new Date(year, month + 1, parmsDate.startDay),
// "yyyyMMdd",
// "-"
// );
// let endTime = getFormatDate(
// new Date(year, month + 1, parmsDate.endDay),
// "yyyyMMdd",
// "-"
// );
// let data = {
// startTime: `${startTime} 00:00:00`,
// endTime: `${endTime} 23:59:59`
// };
// getHomeUserSchedule1(data).then(res => {
// that.setData(
// {
// response: res.data.data
// },
// () => {
// let forDate = new Date(year, month, 1);
// let scheduleList = that.returnScheduleList(
// forDate.toLocaleDateString()
// );
// that.$spliceData({
// scheduleList: [that.data.scheduleList.length, 0, scheduleList],
// pageEndTime: new Date(year, month, 1).toLocaleDateString()
// });
// }
// );
// });
} }
} }
}); });
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