Skip to content

Commit

Permalink
Merge pull request #351 from treadpit/develop
Browse files Browse the repository at this point in the history
fix: #336
  • Loading branch information
todrfu authored Jul 19, 2020
2 parents bd76e7d + d357ffa commit b57ed40
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion calendar/index.js

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/component/calendar/func/week.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,17 @@ class WeekMode extends WxData {
}
});
}
updateYMWhenSwipeCalendarHasSelected(dates) {
const hasSelectedDate = dates.filter(date => date.choosed);
if (hasSelectedDate && hasSelectedDate.length) {
const { year, month } = hasSelectedDate[0];
return {
year,
month
};
}
return {};
}
/**
* 计算下一周的日期
*/
Expand Down Expand Up @@ -307,6 +318,14 @@ class WeekMode extends WxData {
}
}
days = this.initSelectedDay(days);
const {
year: updateYear,
month: updateMonth
} = this.updateYMWhenSwipeCalendarHasSelected(days);
if (updateYear && updateMonth) {
curYear = updateYear;
curMonth = updateMonth;
}
this.setEnableAreaOnWeekMode(days);
this.setData(
{
Expand Down Expand Up @@ -368,6 +387,14 @@ class WeekMode extends WxData {
days = days.concat(temp);
}
days = this.initSelectedDay(days);
const {
year: updateYear,
month: updateMonth
} = this.updateYMWhenSwipeCalendarHasSelected(days);
if (updateYear && updateMonth) {
curYear = updateYear;
curMonth = updateMonth;
}
this.setEnableAreaOnWeekMode(days);
this.setData(
{
Expand Down
4 changes: 4 additions & 0 deletions src/component/calendar/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ const conf = {
}
tmp['calendar.selectedDay'] = [];
}
if (config.weekMode) {
tmp['calendar.curYear'] = currentDay.year;
tmp['calendar.curMonth'] = currentDay.month;
}
setData(tmp);
},
gotoSetContinuousDates(start, end) {
Expand Down

0 comments on commit b57ed40

Please sign in to comment.