Skip to content

Commit f351aff

Browse files
authored
Merge pull request #296 from ant-mini-program/verion/0.4.32
Verion/0.4.32
2 parents d7520a8 + b85d397 commit f351aff

File tree

27 files changed

+266
-51
lines changed

27 files changed

+266
-51
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## 0.4.31
2+
3+
`2019-08-28`
4+
25
- **Bug Fix**
36
- package.json 调整
47

components/calendar/index.axml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<view class="am-calendar {{className}}" a:if="{{dates.length > 0}}">
22
<view class="am-calendar-months">
3+
<view class="am-calendar-prev-month" onTap="onPrevYearTap" a:if="{{haveYear}}">
4+
<view class="am-calendar-arrow am-calendar-arrow_year"></view>
5+
</view>
36
<view class="am-calendar-prev-month" onTap="onPrevMonthTap">
47
<view class="am-calendar-arrow"></view>
58
</view>
69
<view class="am-calendar-selected-month">{{selectedYear}}年{{selectedMonth + 1}}月</view>
710
<view class="am-calendar-next-month" onTap="onNextMonthTap">
811
<view class="am-calendar-arrow next"></view>
912
</view>
13+
<view class="am-calendar-next-month" onTap="onNextYearTap" a:if="{{haveYear}}">
14+
<view class="am-calendar-arrow am-calendar-arrow_year next"></view>
15+
</view>
1016
</view>
1117
<view class="am-calendar-days">
1218
<block a:for="{{['日', '一', '二', '三', '四', '五', '六']}}">
@@ -38,7 +44,7 @@
3844
>{{item.date}}</view>
3945
<view class="am-calendar-tag" style="{{
4046
color: item.isSelected || item.isMiddle || item.isStart || item.isEnd ? '#fff' : (item.disable ? '#999' : item.color)
41-
}}">{{item.disable ? 'disable' : item.tag}}</view>
47+
}}">{{item.disable ? '' : item.tag}}</view>
4248
</view>
4349
</block>
4450
</view>

components/calendar/index.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
background-size: 8px 14px;
3333
background-position: left center;
3434
background-repeat: no-repeat;
35+
&_year {
36+
width: 13px;
37+
background-repeat: repeat-x;
38+
}
3539
}
3640

3741
&-arrow.next {

components/calendar/index.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
| 属性名 | 描述 | 类型 | 默认值 | 必选 |
1111
| ---- | ---- | ---- | ---- | ---- |
1212
| type | 选择类型 `single`: 单日 `range`: 日期区间 | String | single | false
13+
| haveYear | 是否展示年份控制箭头 | Boolean | false | false
1314
| tagData | 标记数据,其中包括日期`date`,标记`tag`,是否禁用`disable`,标记颜色`tagColor`,tagColor有4个可选值,1.#f5a911,2.#e8541e 3.#07a89b 4.#108ee9,5.#b5b5b5 | Array<date, tag, tagColor> | | false
1415
| onSelect | 选择区间回调 | ([startDate, endDate]) => void | | false
1516
| onMonthChange | 点击切换月份时回调,带两个参数currentMonth切换后月份和prevMonth切换前月份 | (currentMonth, prevMonth) => void | | false |
@@ -29,21 +30,32 @@
2930
```html
3031
<view>
3132
<calendar
32-
type="single"
33+
type="range"
34+
haveYear="{{true}}"
3335
tagData="{{tagData}}"
34-
onSelect="handleSelect" />
36+
onSelect="handleSelect"
37+
onMonthChange="onMonthChange"
38+
onYearChange="onYearChange"
39+
onSelectHasDisableDate="onSelectHasDisableDate" />
3540
</view>
3641
```
3742

3843
```javascript
3944
Page({
4045
data: {
4146
tagData: [
42-
{ date: '2018-05-14', tag: '还房贷', tagColor: 5 },
43-
{ date: '2018-05-28', tag: '公积金', tagColor: 2 },
47+
{ date: '2019-09-14', tag: '还房贷', tagColor: 5 },
48+
{ date: '2019-09-28', tag: '公积金', tagColor: 2 },
49+
{ date: '2019-09-18', tag: 'xx', disable: true },
4450
],
4551
},
4652
handleSelect() {},
4753
onMonthChange() {},
54+
onYearChange() {},
55+
onSelectHasDisableDate() {
56+
my.alert({
57+
content: 'SelectHasDisableDate',
58+
});
59+
},
4860
});
4961
```

components/calendar/index.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Component({
4848
className: '',
4949
tagData: [],
5050
type: 'single',
51+
haveYear: false,
5152
},
5253
didMount() {
5354
this.tapTimes = 1;
@@ -83,6 +84,40 @@ Component({
8384
});
8485
},
8586
methods: {
87+
onPrevYearTap() {
88+
const { selectedMonth, selectedYear } = this.data;
89+
let year = selectedYear;
90+
const month = selectedMonth;
91+
92+
year = selectedYear - 1;
93+
94+
if (this.props.onYearChange) {
95+
this.props.onYearChange(year, selectedYear);
96+
}
97+
98+
this.setData({
99+
selectedYear: year,
100+
});
101+
102+
this.refreshdates(month, year);
103+
},
104+
onNextYearTap() {
105+
const { selectedMonth, selectedYear } = this.data;
106+
let year = selectedYear;
107+
const month = selectedMonth;
108+
109+
year = selectedYear + 1;
110+
111+
if (this.props.onYearChange) {
112+
this.props.onYearChange(year, selectedYear);
113+
}
114+
115+
this.setData({
116+
selectedYear: year,
117+
});
118+
119+
this.refreshdates(month, year);
120+
},
86121
onPrevMonthTap() {
87122
const { selectedMonth, selectedYear } = this.data;
88123
let year = selectedYear;
@@ -352,7 +387,7 @@ Component({
352387
const dateObj = dates[i][j];
353388
if (dateObj.year === year && dateObj.month === month && dateObj.date === date) {
354389
if (dateObj.disable) {
355-
console.log(1111);
390+
// console.log(1111);
356391
isDisable = true;
357392
dateObj.isSelected = false;
358393
} else {

components/grid/index.less

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@
4848
color: @color_2;
4949
font-size: 12px;
5050
}
51-
.am-grid-no-line {
52-
.am-grid-item {
53-
padding-top: 110px;
54-
}
55-
.am-grid-border {
56-
border-right: none;
57-
border-bottom: none;
58-
}
59-
}
6051

6152
.am-grid-2 {
6253
.am-grid-item-wrapper {
@@ -131,6 +122,16 @@
131122
}
132123
}
133124

125+
.am-grid-no-line {
126+
.am-grid-item {
127+
padding-top: 110px;
128+
.am-grid-border {
129+
border-right: 0 none;
130+
border-bottom: 0 none;
131+
}
132+
}
133+
}
134+
134135
.am-grid-5 {
135136
padding-top: 6px;
136137
padding-bottom: 7px;

components/input-item/index.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
## InputItem 文本输入
2-
31
文本输入。
42

5-
扫码体验:
6-
3+
## 扫码体验
74
<img src="https://gw.alipayobjects.com/zos/rmsportal/HoUOLnPEOaymuHlbeyqR.jpeg" width="154" height="190" />
85

6+
## 效果示例
7+
![输入框.png](https://intranetproxy.alipay.com/skylark/lark/0/2019/png/188518/1564389321807-3fdc73ec-f8c4-454b-aa2b-69121edd0d25.png)
8+
9+
## 属性
910
| 属性名 | 描述 | 类型 | 默认值 |
1011
| ---- |----|----|----|
1112
| className | 自定义的class | String| '' |
@@ -14,7 +15,7 @@
1415
| last | 是否最后一行 | Boolean | false |
1516
| value | 初始内容 | String | '' |
1617
| name | 组件名字,用于表单提交获取数据 | String | '' |
17-
| type | input 的类型,有效值:`text`, `number`, `idcard`, `digit` | String | text |
18+
| type | input 的类型,有效值:`text`, `number`, `idcard`, `digit` | String | text |
1819
| password | 是否是密码类型 | Boolean | false |
1920
| placeholder | 占位符 | String | '' |
2021
| placeholderStyle | 指定 placeholder 的样式 | String | '' |
@@ -29,15 +30,24 @@
2930
| onBlur | 失去焦点时触发 | (e: Object) => void | |
3031
| onClear | 点击清除icon时触发 | () => void | |
3132

33+
### type 属性值介绍
34+
* `text`: 字符输入框
35+
* `number`: 纯数字输入框( 0-9 之间的数字)
36+
* `idcard`:身份证输入框( 0-9 之间的数字,以及字符 x)
37+
* `digit`:数字输入框,( 0-9 之间的数字,以及小数点 . 字符,可用于含有小数的数字)
38+
39+
****`type` 的属性值影响的是真机中的键盘类型,在模拟器中并不一定会有效果。
40+
3241
## slots
3342

3443
| slotname | 说明 |
3544
| ---- | ---- |
3645
| extra | 可选,用于渲染input-item项右边说明 |
3746

38-
## 示例
47+
## 示例代码
3948

4049
```json
50+
// API-DEMO page/component/input-item/input-item.json
4151
{
4252
"defaultTitle": "小程序AntUI组件库",
4353
"usingComponents": {
@@ -49,7 +59,8 @@
4959
}
5060
```
5161

52-
```axml
62+
```html
63+
<!-- API-DEMO page/component/input-item/input-item.axml -->
5364
<view>
5465
<view style="margin-top: 10px;" />
5566
<list>
@@ -108,6 +119,7 @@
108119
```
109120

110121
```javascript
122+
// API-DEMO page/component/input-item/input-item.js
111123
const banks = ['网商银行', '建设银行', '工商银行', '浦发银行'];
112124

113125
Page({
@@ -159,6 +171,7 @@ Page({
159171
```
160172

161173
```css
174+
/* API-DEMO page/component/input-item/input-item.acss */
162175
.extra {
163176
background-image: url('https://gw.alipayobjects.com/zos/rmsportal/dOfSJfWQvYdvsZiJStvg.svg');
164177
background-size: contain;
@@ -169,4 +182,4 @@ Page({
169182
width: 20px;
170183
padding-left: 10px;
171184
}
172-
```
185+
```

components/list/index.axml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<view class="am-list-body">
66
<slot />
77
</view>
8+
<view class="am-list-load-more" a:if="{{loadMore === 'load'}}"><icon type="loading" size="16"/><text class="am-list-load-more-txt">{{loadContent[0]?loadContent[0]:''}}</text></view>
9+
<view class="am-list-load-over" a:if="{{loadMore === 'over'}}">{{loadContent[1]?loadContent[1]:''}}</view>
810
<view class="am-list-footer" a:if="{{$slots.footer}}">
911
<slot name="footer" />
1012
</view>

components/list/index.less

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,23 @@
1616
&-footer {
1717
padding: 8px 16px 16px 16px;
1818
}
19+
&-load-more {
20+
text-align: center;
21+
background: #fff;
22+
padding: 10px 16px;
23+
font-size: 15px;
24+
line-height: 1.4;
25+
color: @color-text-title;
26+
&-txt {
27+
padding: 0 10px;
28+
}
29+
}
30+
&-load-over {
31+
display: block;
32+
padding: 10px 16px;
33+
font-size: 10px;
34+
text-align: center;
35+
color: #ccc;
36+
text-shadow: 1px 1px #f0f0f0;
37+
}
1938
}

components/list/index.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,35 @@
1111
| 属性名 | 描述 | 类型 | 默认值 |
1212
| ---- | ---- | ---- | ---- |
1313
| className | 自定义class | String| |
14+
| loadMore | 显示加载更多 item。`load`:显示加载更多;`over`:显示加载完成无更多 | String| |
15+
| loadContent | 需结合 `loadMore` 属性使用,用于文案展示 | Array | ['加载更多...','-- 数据加载完了 --'] |
16+
17+
### loadMore 使用介绍
18+
当需要使用无限循环列表时,可将 `list` 组件放置入到 [`scroll-view`](https://docs.alipay.com/mini/component/scroll-view) 中,根据需求对 [`scroll-view`](https://docs.alipay.com/mini/component/scroll-view) 添加相对应的属性,比如:
19+
```xml
20+
<scroll-view style="height: 80vh;" scroll-y onScrollToLower="onScrollToLower" enable-back-to-top="true">
21+
<list loadMore="{{loadMore}}" loadContent="{{loadContent}}">
22+
<list-item>...</list-item>
23+
</list>
24+
</scroll-view>
25+
```
26+
```javascript
27+
Page({
28+
data: {
29+
loadMore: '',
30+
loadContent: [
31+
'马不停蹄加载更多数据中...',
32+
'-- 已经到底了,加不了咯 --',
33+
],
34+
},
35+
onScrollToLower() {
36+
// 根据实际数据加载情况设定 loadMore 的值即可,分别为 load 和 over
37+
this.setData({
38+
loadMore: 'load',
39+
})
40+
},
41+
})
42+
```
1443

1544
### slots
1645

0 commit comments

Comments
 (0)