Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
todrfu committed Oct 16, 2020
2 parents 4439b0d + f9ad3e3 commit f6c88bd
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 74 deletions.
11 changes: 0 additions & 11 deletions docs/v2/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,6 @@ calendar.chooseDateArea(['2020-10-20', '2020-10-30'])
## 节假日
### 显示法定节假日班/休情况
配置日历config:
```js {2}
calendarConfig: {
showHolidays: true,
... // 更多配置待接入
}
```
### 获取日历面板当前年份节假日信息
```js
Expand Down
4 changes: 3 additions & 1 deletion docs/v2/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ const conf = {
inverse: true, // 单选模式下是否支持取消选中,
markToday: '', // 当天日期展示不使用默认数字,用特殊文字标记
takeoverTap: true, // 是否完全接管日期点击事件(日期不会选中)
emphasisWeek: true, // 是否高亮显示周末日期
chooseAreaMode: true, // 开启日期范围选择模式,该模式下只可选择时间段
showHolidays: true, // 显示法定节假日班/休情况,需引入holidays插件
showFestival: true, // 显示节日信息(如教师节等),需引入holidays插件
highlightToday: true, // 是否高亮显示当天,区别于选中样式(初始化时当天高亮并不代表已选中当天)
defaultDate: '2018-3-6', // 默认选中指定某天,如需选中需配置 autoChoosedWhenJump: true
preventSwipe: true, // 是否禁用日历滑动切换月份
firstDayOfWeek: 'Mon', // 每周第一天为周一还是周日,默认按周日开始
onlyShowCurrentMonth: true, // 日历面板是否只显示本月日期
autoChoosedWhenJump: true, // 跳转到指定日期后是否需要自动选中
autoChoosedWhenJump: true, // 设置默认日期及跳转到指定日期后是否需要自动选中
disableMode: {
// 禁用某一天之前/之后的所有日期
type: 'after', // [‘before’, 'after']
Expand Down
13 changes: 7 additions & 6 deletions src/app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"pages":[
"pages": [
"pages/index/index",
"pages/calendar/index",
"pages/calendarV2/index",
Expand All @@ -8,10 +8,11 @@
"pages/calendarMoreComponent/index",
"pages/datepickerTemplate/index"
],
"window":{
"backgroundTextStyle":"light",
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "小程序日历",
"navigationBarTextStyle":"black"
}
}
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json"
}
4 changes: 2 additions & 2 deletions src/component/v2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function calculatePrevMonthGrids(year, month, config) {
empytGrids.push({
...YMInfo,
date: i,
day: week || 7
week
})
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ function calculateNextMonthGrids(year, month, config) {
id: i - 1,
...YMInfo,
date: i,
day: week || 7
week: week || 7
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/component/v2/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
</view>
<!-- 本月日期格子 -->
<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 {{(item.week === 0 || item.week === 6) ? config.theme + '_weekend-color' : ''}}">
<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' : ''}}">
{{config.markToday && item.isToday ? config.markToday : item.date}}
<view
wx:if="{{(config.showLunar && item.lunar && !item.showTodoLabel) || (item.showTodoLabel && calendar.todoLabelPos !== 'bottom') || config.showHolidays}}"
class="date-desc {{config.theme}}_date-desc date-desc-bottom {{(item.choosed || item.isToday) ? 'date-desc-bottom-always' : ''}} {{item.disable ? config.theme + '_date-desc-disable' : ''}}">
<text class="{{config.showHolidays && !item.showTodoLabel && item.label && !item.choosed ? config.theme + '_date-desc-lunar' : ''}}">{{item.label || item.lunar.Term || item.lunar.IDayCn}}</text>
<text class="{{config.showHolidays && !item.showTodoLabel && item.label && !item.choosed ? config.theme + '_date-desc-lunar' : ''}} {{item.type === 'festival' ? config.theme + '_festival' : ''}}">{{item.label || item.lunar.Term || item.lunar.IDayCn}}</text>
</view>
<view
wx:if="{{item.showTodoLabel && !calendar.todoLabelCircle}}"
Expand Down
163 changes: 148 additions & 15 deletions src/component/v2/plugins/holidays/holidays-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,88 +3,221 @@
@Description: 数据来源于国务院办公厅关于2020年部分节假日安排的通知(国办发明电〔2019〕16号)_政府信息公开专栏,http://www.gov.cn/zhengce/content/2019-11/21/content_5454164.htm
@Date: 2020-10-12 14:29:45*
* @Last Modified by: drfu
* @Last Modified time: 2020-10-12 14:30:31
* @Last Modified time: 2020-10-16 17:38:08
*/

export default {
// 节日列表
export const festival = {
// 农历固定日期节日
lunar: {
1: {
1: {
type: 'festival',
name: '春节',
label: '春节'
},
8: {
type: 'festival',
name: '腊八节',
label: '腊八'
},
15: {
type: 'festival',
name: '元宵节',
label: '元宵'
}
},
7: {
7: {
type: 'festival',
name: '七夕节',
label: '七夕'
},
15: {
type: 'festival',
name: '中元节',
label: '中元节'
}
},
9: {
9: {
type: 'festival',
name: '重阳节',
label: '重阳节'
}
},
12: {
30: {
type: 'festival',
name: '除夕',
label: '除夕'
}
}
},
// 阳历固定日期节日
solar: {
2: {
14: {
type: 'festival',
name: '情人节',
label: '情人节'
}
},
3: {
12: {
type: 'festival',
name: '植树节',
label: '植树节'
}
},
4: {
1: {
type: 'festival',
name: '愚人节',
label: '愚人节'
},
5: {
type: 'festival',
name: '清明节',
label: '清明节'
}
},
5: {
1: {
type: 'festival',
name: '劳动节',
label: '劳动节'
},
6: {
type: 'festival',
name: '立夏',
label: '立夏'
}
},
6: {
1: {
type: 'festival',
name: '儿童节',
label: '儿童节'
}
},
7: {
1: {
type: 'festival',
name: '建党节',
label: '建党节'
}
},
8: {
1: {
type: 'festival',
name: '建军节',
label: '建军节'
}
},
9: {
10: {
type: 'festival',
name: '教师节',
label: '教师节'
}
},
10: {
1: {
type: 'festival',
name: '国庆节',
label: '国庆节'
}
},
12: {
25: {
type: 'festival',
name: '圣诞节',
label: '圣诞节'
}
}
}
}

export const holidays = {
2020: {
1: {
1: {
type: 'holiday',
name: '元旦',
text: '休'
label: '休'
},
19: {
type: 'work',
name: '调班',
text: '班'
label: '班'
},
'24-30': {
type: 'holiday',
name: '春节',
text: '休'
label: '休'
}
},
2: {
1: {
type: 'work',
name: '调班',
text: '班'
label: '班'
}
},
4: {
'4-6': {
type: 'holiday',
name: '清明节',
text: '休'
label: '休'
},
26: {
type: 'work',
name: '调班',
text: '班'
label: '班'
}
},
5: {
'1-5': {
type: 'holiday',
name: '劳动节',
text: '休'
label: '休'
},
9: {
type: 'work',
name: '调班',
text: '班'
label: '班'
}
},
6: {
'25-27': {
type: 'holiday',
name: '端午节',
text: '休'
label: '休'
},
28: {
type: 'work',
name: '调班',
text: '班'
label: '班'
}
},
9: {
27: {
type: 'work',
name: '调班',
text: '班'
label: '班'
}
},
10: {
'1-8': {
type: 'holiday',
name: '国庆节/中秋节',
text: '休'
label: '休'
},
10: {
type: 'work',
name: '调班',
text: '班'
label: '班'
}
}
}
Expand Down
Loading

0 comments on commit f6c88bd

Please sign in to comment.