Skip to content

Commit 94e7353

Browse files
committed
v0.2版本更新: 1. fix bug 2. 【增强】 增加组件 form-page 表单页 3. 【增强】 增加组件 actionsheet 模拟原生actionsheet 4. 【优化】 优化 slideview 右滑操作UI
1 parent 6c40363 commit 94e7353

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1603
-264
lines changed

Diff for: src/actionsheet/actionsheet.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"component": true,
3+
"usingComponents": {}
4+
}

Diff for: src/actionsheet/actionsheet.less

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@import "../weui-wxss/src/style/widget/weui-tips/weui-mask.wxss";
2+
@import "../weui-wxss/src/style/widget/weui-tips/weui-actionsheet.wxss";
3+
4+
.weui-mask.weui-mask_hidden {
5+
opacity: 0;
6+
transform: scale3d(1, 1, 0)
7+
}
8+
.weui-mask{
9+
opacity: 1;
10+
transform: scale3d(1, 1, 1);
11+
transition: all 0.3s;
12+
}
13+

Diff for: src/actionsheet/actionsheet.ts

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Component({
2+
options: {
3+
multipleSlots: true, // 在组件定义时的选项中启用多slot支持
4+
addGlobalClass: true
5+
},
6+
properties: {
7+
title: { // 标题
8+
type: String,
9+
value: ''
10+
},
11+
showCancel: { // 是否显示取消按钮
12+
type: Boolean,
13+
value: true
14+
},
15+
cancelText: { // 取消按钮文案
16+
type: String,
17+
value: '取消'
18+
},
19+
maskClass: { // 遮罩层class
20+
type: String,
21+
value: ''
22+
},
23+
extClass: { // 弹出窗 class
24+
type: String,
25+
value: ''
26+
},
27+
maskClosable: { // 点击遮罩 关闭 actionsheet
28+
type: Boolean,
29+
value: true,
30+
},
31+
mask: { // 是否需要 遮罩层
32+
type: Boolean,
33+
value: true
34+
},
35+
show: { // 是否开启 actionsheet
36+
type: Boolean,
37+
value: false
38+
},
39+
actions: { // actions 列表
40+
type: Array,
41+
value: [], // {text, extClass}
42+
observer: '_groupChange'
43+
}
44+
},
45+
46+
methods: {
47+
_groupChange(e) {
48+
// 支持 一维数组 写法
49+
if(e.length > 0 && typeof e[0] !== 'string' && !(e[0] instanceof Array)) {
50+
this.setData({
51+
actions: [this.data.actions]
52+
})
53+
}
54+
},
55+
buttonTap(e) {
56+
const { value, groupindex, index } = e.currentTarget.dataset
57+
this.triggerEvent('actiontap', { value, groupindex, index })
58+
},
59+
closeActionSheet(e) {
60+
const { type } = e.currentTarget.dataset
61+
if(this.data.maskClosable || type) {
62+
// 点击 action 里面的 取消
63+
this.setData({
64+
show: false
65+
})
66+
// 关闭回调事件
67+
this.triggerEvent('close')
68+
}
69+
}
70+
}
71+
})

Diff for: src/actionsheet/actionsheet.wxml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<wxs module="utils">
2+
var join = function(a,b) {
3+
return a+b
4+
};
5+
var isNotSlot = function(v) {
6+
return typeof v !== 'string'
7+
}
8+
module.exports = {
9+
join: join,
10+
isNotSlot: isNotSlot
11+
}
12+
</wxs>
13+
14+
<view wx:if="{{mask}}" class="weui-mask {{show ? '' : 'weui-mask_hidden'}} {{maskClass}}" bindtap="closeActionSheet"></view>
15+
<view class="weui-actionsheet {{show ? 'weui-actionsheet_toggle' : ''}} {{extClass}}">
16+
<!-- 标题 -->
17+
<block wx:if="{{title}}">
18+
<view class="weui-actionsheet__title">
19+
<view class="weui-actionsheet__title-text">{{title}}</view>
20+
</view>
21+
</block>
22+
<slot name="title" wx:else></slot>
23+
<view
24+
class="{{ !showCancel && index === actions.length-1 ? 'weui-actionsheet__action' : 'weui-actionsheet__menu' }}"
25+
wx:key="{{index}}"
26+
wx:for-item="actionItem"
27+
wx:for-index="index"
28+
wx:for="{{actions}}"
29+
>
30+
<block wx:if="{{utils.isNotSlot(actionItem)}}">
31+
<view
32+
class="weui-actionsheet__cell {{item.type === 'warn' ? 'weui-actionsheet__cell_warn' : '' }}"
33+
wx:key="{{item.text}}"
34+
wx:for="{{actionItem}}"
35+
wx:for-index="actionIndex"
36+
data-groupindex="{{index}}"
37+
data-index="{{actionIndex}}"
38+
data-value="{{item.value}}"
39+
bindtap="buttonTap"
40+
>
41+
{{item.text}}
42+
</view>
43+
</block>
44+
<slot name="{{actionItem}}" wx:else></slot>
45+
</view>
46+
<!-- 取消按钮 -->
47+
<view class="weui-actionsheet__action" wx:if="{{showCancel}}">
48+
<view class="weui-actionsheet__cell" data-type="close" id="iosActionsheetCancel" bindtap="closeActionSheet">{{cancelText}}</view>
49+
</view>
50+
</view>

Diff for: src/badge/badge.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"component": true,
23
"usingComponents": {}
34
}

Diff for: src/cell/cell.ts

+16
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Component({
2020
type: String,
2121
value: ''
2222
},
23+
bodyClass: {
24+
type: String,
25+
value: ''
26+
},
2327
icon: {
2428
type: String,
2529
value: '',
@@ -55,6 +59,18 @@ Component({
5559
inline: { // 左右布局样式还是上下布局
5660
type: Boolean,
5761
value: true
62+
},
63+
hasHeader: {
64+
type: Boolean,
65+
value: true
66+
},
67+
hasFooter: {
68+
type: Boolean,
69+
value: true
70+
},
71+
hasBody: {
72+
type: Boolean,
73+
value: true
5874
}
5975
},
6076
relations: {

Diff for: src/cell/cell.wxml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<block wx:if="{{link}}">
22
<view bindtap="navigateTo" class="weui-cell weui-cell_access {{extClass}} {{outerClass}}{{inForm ? ' weui-cell-inform' : ''}}{{inline ? '' : ' .weui-cell_label-block'}}" hover-class="{{hover ? 'weui-cell_active' : ''}}">
3-
<view class="weui-cell__hd {{iconClass}}">
3+
<view wx:if="{{hasHeader}}" class="weui-cell__hd {{iconClass}}">
44
<block wx:if="{{icon}}">
55
<image src="{{icon}}" class="weui-cell__icon" mode="aspectFit"></image>
66
</block>
@@ -20,13 +20,13 @@
2020
</block>
2121
</block>
2222
</view>
23-
<view class="weui-cell__bd">
23+
<view wx:if="{{hasBody}}" class="weui-cell__bd">
2424
<block wx:if="{{value}}">{{value}}</block>
2525
<block wx:else>
2626
<slot></slot>
2727
</block>
2828
</view>
29-
<view class="weui-cell__ft weui-cell__ft_in-access {{footerClass}}">
29+
<view wx:if="{{hasFooter}}" class="weui-cell__ft weui-cell__ft_in-access {{footerClass}}">
3030
<block wx:if="{{footer}}">{{footer}}</block>
3131
<block wx:else>
3232
<slot name="footer"></slot>
@@ -36,7 +36,7 @@
3636
</block>
3737
<block wx:else>
3838
<view bindtap="navigateTo" class="weui-cell {{showError && error ? 'weui-cell_warn' : ''}} {{inForm ? 'weui-cell-inform' : ''}} {{extClass}} {{outerClass}}" hover-class="{{hover ? 'weui-cell_active' : ''}}">
39-
<view class="weui-cell__hd {{iconClass}}">
39+
<view wx:if="{{hasHeader}}" class="weui-cell__hd {{iconClass}}">
4040
<block wx:if="{{icon}}">
4141
<image src="{{icon}}" class="weui-cell__icon" mode="aspectFit"></image>
4242
</block>
@@ -56,13 +56,13 @@
5656
</block>
5757
</block>
5858
</view>
59-
<view class="weui-cell__bd">
59+
<view wx:if="{{hasBody}}" class="weui-cell__bd {{bodyClass}}">
6060
<block wx:if="{{value}}">{{value}}</block>
6161
<block wx:else>
6262
<slot></slot>
6363
</block>
6464
</view>
65-
<view class="weui-cell__ft {{footerClass}}">
65+
<view wx:if="{{hasFooter}}" class="weui-cell__ft {{footerClass}}">
6666
<block wx:if="{{footer}}">{{footer}}</block>
6767
<block wx:else>
6868
<slot name="footer"></slot>

Diff for: src/cells/cells.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ Component({
2020
data: {
2121
firstItem: null,
2222
checkboxCount: 0,
23-
checkboxIsMulti: false
23+
checkboxIsMulti: false,
24+
outerClass: '',
25+
childClass: '',
2426
},
2527
relations: {
2628
'../cell/cell': {
@@ -34,6 +36,9 @@ Component({
3436
}
3537
},
3638
},
39+
'../form-page/form-page': {
40+
type: 'ancestor',
41+
},
3742
'../checkbox-group/checkbox-group': {
3843
type: 'descendant',
3944
linked(target) {
@@ -55,6 +60,16 @@ Component({
5560
this.setData({
5661
checkboxIsMulti: multi
5762
})
58-
}
63+
},
64+
setCellsClass(className) {
65+
this.setData({
66+
childClass: className
67+
})
68+
},
69+
setOuterClass(className) {
70+
this.setData({
71+
outerClass: className
72+
})
73+
},
5974
}
6075
})

Diff for: src/cells/cells.wxml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<view class="{{extClass}}">
1+
<view class="{{extClass}} weui-cells__group {{outerClass}} {{childClass}}">
22
<view wx:if="{{title}}" class="weui-cells__title">{{title}}</view>
3-
<view class="weui-cells weui-cells_after-title {{checkboxCount > 0 && checkboxIsMulti ? 'weui-cells_checkbox' : ''}}">
3+
<view class="weui-cells weui-cells_after-title weui-cells_form {{checkboxCount > 0 && checkboxIsMulti ? 'weui-cells_checkbox' : ''}}">
44
<slot></slot>
55
</view>
6-
<view v-if="{{footer}}" class="weui-cells__tips">{{footer}}</view>
7-
<template v-else><slot name="footer"></slot></template>
6+
<view wx:if="{{footer}}" class="weui-cells__tips">{{footer}}</view>
7+
<slot name="footer" wx:else></slot>
88
</view>

Diff for: src/checkbox-group/checkbox-group.ts

+7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Component({
5454
if (!this.data.parentCell) {
5555
this.data.parentCell = target
5656
}
57+
this.setParentCellsClass()
5758
},
5859
unlinked(target) {
5960
this.data.parentCell = null; // 方便内存回收
@@ -85,6 +86,12 @@ Component({
8586
this.triggerEvent('change', {value: val}, {})
8687
}
8788
},
89+
setParentCellsClass() {
90+
const className = this.data.multi ? 'weui-cells_checkbox' : ''
91+
if (this.data.parentCell) {
92+
this.data.parentCell.setCellsClass(className)
93+
}
94+
},
8895
_multiChange(multi) {
8996
this.data.targetList.forEach(target => {
9097
target.setMulti(multi)

Diff for: src/checkbox/checkbox.wxml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<mp-cell bindtap="checkedChange" footer-class="{{!multi ? 'weui-check__ft_in-radio' : ''}}" icon-class="{{multi ? 'weui-check__hd_in-checkbox' : ''}}" ext-class="weui-check__label {{outerClass}} {{extClass}}">
1+
<mp-cell has-footer="{{!multi}}" has-header="{{multi}}" bindtap="checkedChange" footer-class="{{!multi ? 'weui-check__ft_in-radio' : ''}}" icon-class="{{multi ? 'weui-check__hd_in-checkbox' : ''}}" ext-class="weui-check__label {{outerClass}} {{extClass}} {{!multi ? 'weui-cell_radio' : 'weui-cell_checkbox'}}">
22

33
<view slot="icon" wx:if="{{multi}}">
44
<checkbox value="{{value}}" checked="{{checked}}" disabled="{{disabled}}" color="{{color}}" class="weui-check"></checkbox>

Diff for: src/form-page/form-page.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"component": true,
3+
"usingComponents": {}
4+
}

Diff for: src/form-page/form-page.less

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import "../weui-wxss/src/style/widget/weui-page/weui-form.wxss";
2+
3+

Diff for: src/form-page/form-page.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Component({
2+
options: {
3+
addGlobalClass: true,
4+
multipleSlots: true,
5+
},
6+
properties: {
7+
title: { // Msg 标题
8+
type: String,
9+
value: '',
10+
},
11+
subtitle: { // icon 的 type
12+
type: String,
13+
value: ''
14+
},
15+
},
16+
relations: {
17+
'../cells/cells': {
18+
type: 'descendant',
19+
linked(target) {
20+
if (!this.data.firstItem) {
21+
this.data.firstItem = target
22+
}
23+
if (target !== this.data.firstItem) {
24+
target.setOuterClass('weui-cells__group_wxss')
25+
}
26+
},
27+
},
28+
},
29+
data: {
30+
firstItem: null
31+
},
32+
})

Diff for: src/form-page/form-page.wxml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<view class="weui-form">
2+
<block wx:if="{{title || subtitle}}">
3+
<view class="weui-form__text-area">
4+
<view class="weui-form__title">{{title}}</view>
5+
<view class="weui-form__desc">{{subtitle}}</view>
6+
</view>
7+
</block>
8+
<block wx:else>
9+
<view class="weui-form__text-area">
10+
<slot name="title"></slot>
11+
</view>
12+
</block>
13+
<view class="weui-form__control-area">
14+
<view class="weui-cells__group weui-cells__group_form">
15+
<slot></slot>
16+
</view>
17+
</view>
18+
<view class="weui-form__tips-area">
19+
<slot name="tips"></slot>
20+
</view>
21+
<view class="weui-form__opr-area">
22+
<slot name="button"></slot>
23+
</view>
24+
<view class="weui-form__tips-area">
25+
<slot name="suffixtips"></slot>
26+
</view>
27+
<view class="weui-form__extra-area">
28+
<view class="weui-footer">
29+
<slot name="footer"></slot>
30+
</view>
31+
</view>
32+
</view>
33+

Diff for: src/form/form-validator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const toString = Object.prototype.toString
55
const validateSingleRule = (rule: any, value:any, param:any = null, models = null) => {
66
let message = ''
77
for (const ruleKey in rule) {
8-
if (ruleKey === 'validator' || ruleKey === 'name' || ruleKey === 'message') continue
8+
if (ruleKey === 'name' || ruleKey === 'message') continue
99
const validateMethod = typeof rule.validator !== 'undefined' ? rule.validator : Validator[ruleKey]
1010
if (typeof validateMethod === 'function') {
1111
message = validateMethod(rule, value, param, models)

0 commit comments

Comments
 (0)