File tree Expand file tree Collapse file tree 9 files changed +108
-6
lines changed Expand file tree Collapse file tree 9 files changed +108
-6
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 2
2
"component" : true ,
3
3
"usingComponents" : {},
4
4
"componentGenerics" : {
5
- "l-water-flow-item" : true
5
+ "l-water-flow-item" : " true"
6
6
}
7
7
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
{
2
- "component" : true ,
3
- "componentGenerics" : {
4
- "l-water-flow-item" : true
5
- }
6
- }
2
+ "component" : true ,
3
+ "usingComponents" : {},
4
+ "componentGenerics" : {
5
+ "l-water-flow-item" : " true"
6
+ }
7
+ }
Original file line number Diff line number Diff line change
1
+ // pages/components/water/index.js
2
+ Component ( {
3
+ /**
4
+ * 组件的属性列表
5
+ */
6
+ properties : {
7
+ columnGap : {
8
+ type : String ,
9
+ value : '20rpx'
10
+ }
11
+ } ,
12
+
13
+ /**
14
+ * 组件的初始数据
15
+ */
16
+ data : {
17
+ data : [ ] ,
18
+ leftData : [ ] ,
19
+ rightData : [ ]
20
+ } ,
21
+
22
+ attached ( ) {
23
+ this . _init ( )
24
+ } ,
25
+
26
+ /**
27
+ * 组件的方法列表
28
+ */
29
+ methods : {
30
+ _init ( ) {
31
+ wx . lin = wx . lin || { }
32
+ wx . lin . renderWaterFlow = ( data = [ ] , success ) => {
33
+ if ( Object . prototype . toString . call ( data ) !== '[object Array]' ) {
34
+ console . error ( "[data]参数类型错误,渲染失败" ) ;
35
+ return false ;
36
+ }
37
+ this . _select ( data ) . then ( ( ) => {
38
+ success && success ( )
39
+ } )
40
+ }
41
+ } ,
42
+ _select ( data ) {
43
+ const query = wx . createSelectorQuery ( ) . in ( this )
44
+ this . columnNodes = query . selectAll ( '#left, #right' )
45
+
46
+ return new Promise ( ( resolve , reject ) => {
47
+ this . _render ( data , 0 , ( ) => {
48
+ resolve ( )
49
+ } )
50
+ } )
51
+ } ,
52
+ _render ( data , i , success ) {
53
+ if ( data . length > i ) {
54
+ this . columnNodes . boundingClientRect ( ) . exec ( res => {
55
+ const rects = res [ 0 ]
56
+ const leftHeight = rects [ 0 ] . height
57
+ const rightHeight = rects [ 1 ] . height
58
+
59
+ if ( leftHeight <= rightHeight ) {
60
+ this . data . leftData . push ( data [ i ] )
61
+ } else {
62
+ this . data . rightData . push ( data [ i ] )
63
+ }
64
+
65
+ this . setData ( {
66
+ leftData : this . data . leftData ,
67
+ rightData : this . data . rightData
68
+ } , _ => {
69
+ this . _render ( data , ++ i , success )
70
+ } )
71
+ } )
72
+ } else {
73
+ success && success ( )
74
+ }
75
+ }
76
+ }
77
+ } )
Original file line number Diff line number Diff line change
1
+ {
2
+ "component" : true ,
3
+ "usingComponents" : {},
4
+ "componentGenerics" : {
5
+ "l-water-flow-item" : " true"
6
+ }
7
+ }
Original file line number Diff line number Diff line change
1
+ .water-flow-container {display :flex ;width :100% ;box-sizing :border-box }.water-column {flex :1 }
Original file line number Diff line number Diff line change
1
+ <view class="l-class water-flow-container">
2
+ <view class="water-column" style="margin-right:{{columnGap}}">
3
+ <view id="left">
4
+ <block wx:for="{{leftData}}" wx:key="{{index}}">
5
+ <l-water-flow-item data="{{item}}" />
6
+ </block>
7
+ </view>
8
+ </view>
9
+ <view class="water-column">
10
+ <view id="right">
11
+ <block wx:for="{{rightData}}" wx:key="{{index}}">
12
+ <l-water-flow-item data="{{item}}" />
13
+ </block>
14
+ </view>
15
+ </view>
16
+ </view>
You can’t perform that action at this time.
0 commit comments