1
1
Component ( {
2
- externalClasses : [ 'l-class-title' , 'l-class-item' , 'l-class-cancel' ] ,
3
- properties : {
4
- locked : Boolean ,
5
- showCancel : Boolean ,
6
- show : Boolean ,
7
- itemList : Array ,
8
- cancelText : {
9
- type : String ,
10
- value : '取消'
11
- } ,
12
- title : String ,
13
- openApi : {
14
- type : Boolean ,
15
- value : true ,
16
- }
17
- } ,
18
- data : {
19
- success : '' ,
20
- fail : '' ,
21
- isIphoneX : false
22
- } ,
23
- attached ( ) {
24
- if ( this . data . openApi ) {
25
- this . initActionSheet ( ) ;
26
- }
27
- this . initUIAdapter ( ) ;
2
+ externalClasses : [ 'l-class-title' , 'l-class-item' , 'l-class-cancel' ] ,
3
+ properties : {
4
+ locked : Boolean ,
5
+ showCancel : Boolean ,
6
+ show : Boolean ,
7
+ itemList : Array ,
8
+ cancelText : {
9
+ type : String ,
10
+ value : '取消'
28
11
} ,
12
+ title : String ,
13
+ openApi : {
14
+ type : Boolean ,
15
+ value : true ,
16
+ }
17
+ } ,
18
+ data : {
19
+ success : '' ,
20
+ fail : '' ,
21
+ isIphoneX : false
22
+ } ,
23
+ attached ( ) {
24
+ if ( this . data . openApi ) {
25
+ this . initActionSheet ( ) ;
26
+ }
27
+ this . initUIAdapter ( ) ;
28
+ } ,
29
29
30
- lifetimes : {
31
- show ( ) {
32
- if ( this . data . openApi ) {
33
- this . initActionSheet ( ) ;
34
- }
30
+ lifetimes : {
31
+ show ( ) {
32
+ if ( this . data . openApi ) {
33
+ this . initActionSheet ( ) ;
34
+ }
35
35
36
- } ,
37
36
} ,
38
- methods : {
39
- /**
37
+ } ,
38
+ methods : {
39
+ /**
40
40
* 区分UI尺寸
41
41
*/
42
- initUIAdapter ( ) {
43
- wx . getSystemInfo ( {
44
- success : ( res ) => {
45
- this . setData ( {
46
- isIphoneX : res . model == " iPhone X" ? true : false ,
47
- } )
48
- }
49
- } )
50
- } ,
51
- initActionSheet ( ) {
52
- const config = {
53
- itemList : [ ] ,
54
- success : null ,
55
- fail : null ,
56
- title : '' ,
57
- locked : true ,
58
- cancelText : '取消' ,
59
- showCancel : false
60
- }
61
- wx . lin = wx . lin || { } ;
62
- wx . lin . showActionSheet = ( options = { } ) => {
63
- const {
64
- itemList = config . itemList ,
65
- success = config . success ,
66
- fail = config . fail ,
67
- title = config . title ,
68
- locked = config . locked ,
69
- cancelText = config . cancelText ,
70
- showCancel = config . showCancel ,
71
- } = options ;
72
- this . setData ( {
73
- itemList : itemList . slice ( 0 , 10 ) ,
74
- success,
75
- fail,
76
- title,
77
- locked,
78
- cancelText,
79
- showCancel,
80
- show : true ,
81
- } ) ;
82
- return this ;
83
- } ;
84
- } ,
85
- handleClickItem ( e ) {
86
- const {
87
- success
88
- } = this . data ;
89
- success && success ( { ...e . currentTarget . dataset } ) ;
90
- this . triggerEvent ( 'linitemtap' , { ...e . currentTarget . dataset } ) ;
91
- this . _hideActionSheet ( ) ;
92
- } ,
42
+ initUIAdapter ( ) {
43
+ wx . getSystemInfo ( {
44
+ success : ( res ) => {
45
+ this . setData ( {
46
+ isIphoneX : res . model == ' iPhone X' ? true : false ,
47
+ } ) ;
48
+ }
49
+ } ) ;
50
+ } ,
51
+ initActionSheet ( ) {
52
+ const config = {
53
+ itemList : [ ] ,
54
+ success : null ,
55
+ fail : null ,
56
+ title : '' ,
57
+ locked : true ,
58
+ cancelText : '取消' ,
59
+ showCancel : false
60
+ } ;
61
+ wx . lin = wx . lin || { } ;
62
+ wx . lin . showActionSheet = ( options = { } ) => {
63
+ const {
64
+ itemList = config . itemList ,
65
+ success = config . success ,
66
+ fail = config . fail ,
67
+ title = config . title ,
68
+ locked = config . locked ,
69
+ cancelText = config . cancelText ,
70
+ showCancel = config . showCancel ,
71
+ } = options ;
72
+ this . setData ( {
73
+ itemList : itemList . slice ( 0 , 10 ) ,
74
+ success,
75
+ fail,
76
+ title,
77
+ locked,
78
+ cancelText,
79
+ showCancel,
80
+ show : true ,
81
+ } ) ;
82
+ return this ;
83
+ } ;
84
+ } ,
85
+ handleClickItem ( e ) {
86
+ const {
87
+ success
88
+ } = this . data ;
89
+ success && success ( { ...e . currentTarget . dataset } ) ;
90
+ this . triggerEvent ( 'linitemtap' , { ...e . currentTarget . dataset } ) ;
91
+ this . _hideActionSheet ( ) ;
92
+ } ,
93
93
94
- _showActionSheet ( ) {
95
- this . setData ( {
96
- show : true
97
- } )
98
- } ,
94
+ _showActionSheet ( ) {
95
+ this . setData ( {
96
+ show : true
97
+ } ) ;
98
+ } ,
99
99
100
- _hideActionSheet ( ) {
101
- this . setData ( {
102
- show : false
103
- } )
104
- } ,
100
+ _hideActionSheet ( ) {
101
+ this . setData ( {
102
+ show : false
103
+ } ) ;
104
+ } ,
105
105
106
- handleClickCancel ( ) {
107
- const {
108
- fail
109
- } = this . data ;
110
- fail && fail ( {
111
- errMsg : 'showactionsheet:fail cancel'
112
- } ) ;
113
- this . triggerEvent ( 'lincancel' , {
114
- errMsg : 'showactionsheet:fail cancel'
115
- } )
116
- this . _hideActionSheet ( ) ;
117
- } ,
106
+ handleClickCancel ( ) {
107
+ const {
108
+ fail
109
+ } = this . data ;
110
+ fail && fail ( {
111
+ errMsg : 'showactionsheet:fail cancel'
112
+ } ) ;
113
+ this . triggerEvent ( 'lincancel' , {
114
+ errMsg : 'showactionsheet:fail cancel'
115
+ } ) ;
116
+ this . _hideActionSheet ( ) ;
117
+ } ,
118
118
119
- handleClickPopUp ( ) {
120
- if ( ! this . data . locked ) {
121
- this . handleClickCancel ( ) ;
122
- }
123
- } ,
124
- }
119
+ handleClickPopUp ( ) {
120
+ if ( ! this . data . locked ) {
121
+ this . handleClickCancel ( ) ;
122
+ }
123
+ } ,
124
+ }
125
125
} ) ;
0 commit comments