Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
todrfu committed Nov 24, 2020
2 parents 079b8f0 + ae8dc33 commit ba1e973
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/component/v2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ Component({
}
}
return renderCalendar.call(this, calendarData, config).then(() => {
this.triggerEvent('whenChangeMonth', {
let triggerEventName = 'whenChangeMonth'
if (config.weekMode) {
triggerEventName = 'whenChangeWeek'
}
this.triggerEvent(triggerEventName, {
current: {
year: +curYear,
month: +curMonth
Expand Down
2 changes: 1 addition & 1 deletion src/component/v2/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<!-- 本月日期格子 -->
<view wx:for="{{calendar.dates}}" wx:key="index" data-idx="{{index}}" data-info="{{item}}" bindtap="tapDate" class="grid {{item.class ? item.class : ''}} {{config.theme}}_normal-date b ac pc">
<view class="date-wrap b cc {{config.emphasisWeek && (item.week === 0 || item.week === 6) ? config.theme + '_weekend-color' : ''}}">
<view class="date b ac pc {{item.class ? item.class : ''}} {{item.isToday && config.highlightToday ? config.theme + '_today' : ''}} {{item.choosed ? config.theme + '_choosed' : ''}} {{item.disable ? config.theme + '_date-disable' : ''}} {{config.chooseAreaMode ? 'date-area-mode' : ''}}">
<view class="date b ac pc {{item.class ? item.class : ''}} {{item.isToday && config.highlightToday ? config.theme + '_today' : ''}} {{item.choosed ? config.theme + '_choosed' : ''}} {{item.disable ? config.theme + '_date-disable' : ''}} {{config.chooseAreaMode ? 'date-area-mode' : ''}} {{calendar.todoLabelCircle && item.showTodoLabel && !item.choosed ? config.theme + '_todo-circle todo-circle' : '' }}">
{{config.markToday && item.isToday ? config.markToday : item.date}}
<view
wx:if="{{(config.showLunar && item.lunar && !item.showTodoLabel) || (item.showTodoLabel && calendar.todoLabelPos !== 'bottom') || config.showHolidays}}"
Expand Down
13 changes: 8 additions & 5 deletions src/component/v2/plugins/week.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,21 @@ function dateIsInDatesRange(target, dates) {
function getDatesWhenTargetInFirstWeek(target, firstWeekDates) {
const { year, month } = target
const prevMonthInfo = dateUtil.getPrevMonthInfo({ year, month })
let lastMonthDatsCount = dateUtil.getDatesCountOfMonth(year, month)
let lastMonthDatesCount = dateUtil.getDatesCountOfMonth(
prevMonthInfo.year,
prevMonthInfo.month
)
let dates = firstWeekDates
let firstWeekCount = firstWeekDates.length
for (let i = 0; i < 7 - firstWeekCount; i++) {
const week = dateUtil.getDayOfWeek(+year, +month, lastMonthDatsCount)
const week = dateUtil.getDayOfWeek(+year, +month, lastMonthDatesCount)
dates.unshift({
year: prevMonthInfo.year,
month: prevMonthInfo.month,
date: lastMonthDatsCount,
date: lastMonthDatesCount,
week
})
lastMonthDatsCount -= 1
lastMonthDatesCount -= 1
}
return dates
}
Expand Down Expand Up @@ -209,7 +212,7 @@ function calculatePrevWeekDates(calendarData = {}) {
const firstDateIdx = calendarDates.findIndex(
date => dateUtil.toTimeStr(date) === dateUtil.toTimeStr(firstDateInThisWeek)
)
if (firstDateInThisWeek.date - 7 >= 0) {
if (firstDateIdx - 7 >= 0) {
const startIdx = firstDateIdx - 7
return {
dates: calendarDates.splice(startIdx, 7),
Expand Down
4 changes: 2 additions & 2 deletions src/pages/calendarV2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ plugin
const conf = {
data: {
calendarConfig: {
// theme: 'elegant',
theme: 'elegant'
// showHolidays: true,
// emphasisWeek: true,
chooseAreaMode: true
// chooseAreaMode: true
// defaultDate: '2020-9-8',
// autoChoosedWhenJump: true
},
Expand Down

0 comments on commit ba1e973

Please sign in to comment.