Skip to content

Commit

Permalink
#83
Browse files Browse the repository at this point in the history
  • Loading branch information
付登荣 committed Feb 18, 2019
1 parent bc4ba77 commit f908fcf
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const conf = {
Page(conf);
```

更多配置及功能请 [参考文档](https://treadpit.github.io)
更多配置及功能请 [参考文档](http://calendar.isfeer.com)

### 日历模板效果图

Expand Down
14 changes: 12 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ import { setTodoLabels } from '../../template/calendar/index';
// 待办事项中若有 todoText 字段,则会在待办日期下面显示指定文字,如自定义节日等。

setTodoLabels({
pos: 'bottom',
dotColor: '#40',
// 待办点标记设置
pos: 'bottom', // 待办点标记位置 ['top', 'bottom']
dotColor: '#40', // 待办点标记颜色
// 待办圆圈标记设置(如圆圈标记已签到日期),该设置与点标记设置互斥
circle: true, // 待办
days: [{
year: 2018,
month: 1,
Expand Down Expand Up @@ -179,6 +182,13 @@ import { clearTodoLabels } from '../../template/calendar/index';
clearTodoLabels();
```

##### 6.4 获取所有代办日期
```js
import { getTodoLabels } from '../../template/calendar/index';

getTodoLabels();
```

#### 7. 禁选指定日期

```js
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<script src="https://unpkg.com/docute@3/dist/docute.js"></script>
<script>
docute.init({
url: docute.isDev ? location.origin : 'https://treadpit.github.io',
url: docute.isDev ? location.origin : 'http://calendar.isfeer.com',
routerMode: 'history'
})
</script>
Expand Down
7 changes: 5 additions & 2 deletions src/component/calendar/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@
data-disable="{{item.disable}}"
data-idx="{{index}}"
bindtap="tapDayItem">
<view class="day-with-dot box box-tb box-align-center box-pack-center">
<view wx:if="{{!calendar.todoLabelCircle}}" class="dot-day-height box box-tb box-align-center box-pack-center">
<view wx:if="{{item.showTodoLabel && calendar.todoLabelPos === 'top'}}" class="{{item.todoText ? 'todo-text' : 'todo-dot'}}" style="background-color: {{calendar.todoLabelColor}}">{{item.todoText}}</view>
<view class="day border-radius {{item.choosed ? 'day-choosed-color pink-bg' : ''}} {{ item.disable ? 'disable-day-color disable-day-circle' : '' }} box box-align-center box-pack-center">{{item.day}}</view>
<view class="day border-radius {{item.choosed ? 'day-choosed-color day-choosed-bg' : ''}} {{ item.disable ? 'disable-day-color disable-day-bg' : '' }} box box-align-center box-pack-center">{{item.day}}</view>
<view wx:if="{{item.showTodoLabel && calendar.todoLabelPos === 'bottom'}}" class="{{item.todoText ? 'todo-text' : 'todo-dot'}}" style="background-color: {{calendar.todoLabelColor}}">{{item.todoText}}</view>
</view>
<view wx:else class="dot-day-height box box-tb box-align-center box-pack-center">
<view class="day border-radius {{item.showTodoLabel ? 'day-circle' : '' }} {{item.choosed ? 'day-choosed-color day-choosed-bg' : ''}} {{ item.disable ? 'disable-day-color disable-day-bg' : '' }} box box-align-center box-pack-center">{{item.day}}</view>
</view>
</view>
<view class="grid disable-day-color box box-align-center box-pack-center"
wx:for="{{calendar.lastEmptyGrids}}"
Expand Down
11 changes: 8 additions & 3 deletions src/component/calendar/index.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,31 @@
color: #c2c2c2;
}

.day-with-dot {
.dot-day-height {
height: 72rpx;
}

.disable-day-color {
color: #cacaca;
}

.disable-day-circle {
.disable-day-bg {
background-color: #f6f6f7;
}

.day-circle {
border: 1rpx solid #88d2ac;
box-sizing: border-box;
}

.border-radius {
border-radius: 50%;
position: relative;
left: 0;
top: 0;
}

.pink-bg {
.day-choosed-bg {
background-color: #ff629a;
transition: all 0.3s;
animation-name: choosed;
Expand Down
23 changes: 19 additions & 4 deletions src/component/calendar/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,12 @@ const conf = {
}
const days = calendar.days.slice();
const { curYear, curMonth } = calendar;
const { days: todoDays = [], pos = 'bottom', dotColor = '' } = options;
const {
days: todoDays = [],
pos = 'bottom',
dotColor = '',
circle
} = options;
const { todoLabels = [], todoLabelPos, todoLabelColor } = calendar;
const shouldMarkerTodoDay = todoDays.filter(
item => +item.year === curYear && +item.month === curMonth
Expand All @@ -510,9 +515,13 @@ const conf = {
'calendar.days': days,
'calendar.todoLabels': uniqueTodoLabels(todoDays.concat(todoLabels))
};
if (pos && pos !== todoLabelPos) o['calendar.todoLabelPos'] = pos;
if (dotColor && dotColor !== todoLabelColor) {
o['calendar.todoLabelColor'] = dotColor;
if (!circle) {
if (pos && pos !== todoLabelPos) o['calendar.todoLabelPos'] = pos;
if (dotColor && dotColor !== todoLabelColor) {
o['calendar.todoLabelColor'] = dotColor;
}
} else {
o['calendar.todoLabelCircle'] = circle;
}
this.setData(o);
},
Expand Down Expand Up @@ -1016,6 +1025,12 @@ export const deleteTodoLabels = todos => {
export const clearTodoLabels = () => {
conf.clearTodoLabels.call(currentPage);
};
/**
* 获取所有 TODO 日期
*/
export const getTodoLabels = () => {
return currentPage && currentPage.data.calendar.todoLabels;
};
/**
* 切换周月视图
* @param {string} view 视图模式[week, month]
Expand Down
2 changes: 1 addition & 1 deletion src/pages/calendar/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<view wx:if="{{hasEmptyGrid}}" class="grid white-color box box-align-center box-pack-center" wx:for="{{empytGrids}}" wx:key="{{index}}" data-idx="{{index}}">
</view>
<view class="grid white-color box box-align-center box-pack-center" wx:for="{{days}}" wx:key="{{index}}" data-idx="{{index}}" bindtap="tapDayItem">
<view class="day {{item.choosed ? 'border-radius pink-bg' : ''}} box box-align-center box-pack-center">{{item.day}}</view>
<view class="day {{item.choosed ? 'border-radius day-choosed-bg' : ''}} box box-align-center box-pack-center">{{item.day}}</view>
</view>
</view>
</view>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/calendar/index.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ page {
color: #fff;
}

.pink-bg {
.day-choosed-bg {
background-color: #ff629a;
}

Expand Down
5 changes: 3 additions & 2 deletions src/pages/calendarTemplate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ const conf = {
const data = [
{
year: '2019',
month: '1',
month: '2',
day: '15'
},
{
year: 2019,
month: 1,
month: 2,
day: 18,
todoText: '待办'
}
Expand All @@ -61,6 +61,7 @@ const conf = {
setTodoLabels({
pos: 'bottom',
dotColor: '#40',
circle: true,
days: data
});
disableDay(1);
Expand Down
9 changes: 4 additions & 5 deletions src/pages/index/index.wxml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<view class="wrap">
<text>示例目前有独立页面和 template 两种模式,
<text>日历控件目前有 Component 和 template 两种方式引入,
<text class="comments">(模板介绍参考微信小程序官方文档)</text>
引入方法见 README</text>
<navigator class="navigator" url="/pages/calendarTemplate/index">日历控件template 示例</navigator>
<navigator class="navigator" url="/pages/calendarComponent/index">日历控件Component 示例</navigator>
<navigator class="navigator" url="/pages/datepickerTemplate/index">日期选择器template 示例</navigator>
<navigator class="navigator" url="/pages/calendar/index">日历独立页面(不维护)</navigator>
<navigator class="navigator" url="/pages/calendarTemplate/index">日历控件 Template 示例</navigator>
<navigator class="navigator" url="/pages/calendarComponent/index">日历控件 Component 示例</navigator>
<navigator class="navigator" url="/pages/datepickerTemplate/index">日期选择器 Template 示例</navigator>
</view>
23 changes: 19 additions & 4 deletions src/template/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,12 @@ const conf = {
}
const days = calendar.days.slice();
const { curYear, curMonth } = calendar;
const { days: todoDays = [], pos = 'bottom', dotColor = '' } = options;
const {
days: todoDays = [],
pos = 'bottom',
dotColor = '',
circle
} = options;
const { todoLabels = [], todoLabelPos, todoLabelColor } = calendar;
const shouldMarkerTodoDay = todoDays.filter(
item => +item.year === curYear && +item.month === curMonth
Expand All @@ -571,9 +576,13 @@ const conf = {
'calendar.days': days,
'calendar.todoLabels': uniqueTodoLabels(todoDays.concat(todoLabels))
};
if (pos && pos !== todoLabelPos) o['calendar.todoLabelPos'] = pos;
if (dotColor && dotColor !== todoLabelColor) {
o['calendar.todoLabelColor'] = dotColor;
if (!circle) {
if (pos && pos !== todoLabelPos) o['calendar.todoLabelPos'] = pos;
if (dotColor && dotColor !== todoLabelColor) {
o['calendar.todoLabelColor'] = dotColor;
}
} else {
o['calendar.todoLabelCircle'] = circle;
}
this.setData(o);
},
Expand Down Expand Up @@ -1111,6 +1120,12 @@ export const deleteTodoLabels = todos => {
export const clearTodoLabels = () => {
conf.clearTodoLabels.call(currentPage);
};
/**
* 获取所有 TODO 日期
*/
export const getTodoLabels = () => {
return currentPage && currentPage.data.calendar.todoLabels;
};
/**
* 切换周月视图
* @param {string} view 视图模式[week, month]
Expand Down
7 changes: 5 additions & 2 deletions src/template/calendar/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
data-disable="{{item.disable}}"
data-idx="{{index}}"
bindtap="tapDayItem">
<view class="day-with-dot box box-tb box-align-center box-pack-center">
<view wx:if="{{!todoLabelCircle}}" class="dot-day-height box box-tb box-align-center box-pack-center">
<view wx:if="{{item.showTodoLabel && todoLabelPos === 'top'}}" class="{{item.todoText ? 'todo-text' : 'todo-dot'}}" style="background-color: {{todoLabelColor}}">{{item.todoText}}</view>
<view class="day border-radius {{item.choosed ? 'day-choosed-color pink-bg' : ''}} {{ item.disable ? 'disable-day-color disable-day-circle' : '' }} box box-align-center box-pack-center">{{item.day}}</view>
<view class="day border-radius {{item.choosed ? 'day-choosed-color day-choosed-bg' : ''}} {{ item.disable ? 'disable-day-color disable-day-bg' : '' }} box box-align-center box-pack-center">{{item.day}}</view>
<view wx:if="{{item.showTodoLabel && todoLabelPos === 'bottom'}}" class="{{item.todoText ? 'todo-text' : 'todo-dot'}}" style="background-color: {{todoLabelColor}}">{{item.todoText}}</view>
</view>
<view wx:else class="dot-day-height box box-tb box-align-center box-pack-center">
<view class="day border-radius {{item.showTodoLabel ? 'day-circle' : '' }} {{item.choosed ? 'day-choosed-color day-choosed-bg' : ''}} {{ item.disable ? 'disable-day-color disable-day-bg' : '' }} box box-align-center box-pack-center">{{item.day}}</view>
</view>
</view>
<view class="grid disable-day-color box box-align-center box-pack-center"
wx:for="{{lastEmptyGrids}}"
Expand Down
11 changes: 8 additions & 3 deletions src/template/calendar/index.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,31 @@
color: #c2c2c2;
}

.day-with-dot {
.dot-day-height {
height: 72rpx;
}

.disable-day-color {
color: #cacaca;
}

.disable-day-circle {
.disable-day-bg {
background-color: #f6f6f7;
}

.day-circle {
border: 1rpx solid #88d2ac;
box-sizing: border-box;
}

.border-radius {
border-radius: 50%;
position: relative;
left: 0;
top: 0;
}

.pink-bg {
.day-choosed-bg {
background-color: #ff629a;
transition: all 0.3s;
animation-name: choosed;
Expand Down
2 changes: 1 addition & 1 deletion src/template/datepicker/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
data-idx="{{index}}"
data-disable="{{item.disable}}"
catchtap="tapDayItem">
<view class="day border-radius {{item.choosed ? 'day-choosed-color pink-bg' : ''}} {{ item.disable ? 'disable-day-color disable-day-circle' : '' }} box box-align-center box-pack-center">{{item.day}}</view>
<view class="day border-radius {{item.choosed ? 'day-choosed-color day-choosed-bg' : ''}} {{ item.disable ? 'disable-day-color disable-day-bg' : '' }} box box-align-center box-pack-center">{{item.day}}</view>
</view>
<view class="grid disable-day-color box box-align-center box-pack-center"
wx:for="{{lastEmptyGrids}}"
Expand Down
4 changes: 2 additions & 2 deletions src/template/datepicker/index.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
color: #ddd;
}

.disable-day-circle {
.disable-day-bg {
background-color: #fbfdff;
}

Expand All @@ -163,7 +163,7 @@
top: 0;
}

.pink-bg {
.day-choosed-bg {
background-color: #ff629a;
}

Expand Down

0 comments on commit f908fcf

Please sign in to comment.