@@ -2,12 +2,15 @@ import computeOffset from '../behaviors/computeOffset';
2
2
import zIndex from '../behaviors/zIndex' ;
3
3
import hover from '../behaviors/hover' ;
4
4
import validator from '../behaviors/validator' ;
5
+
5
6
Component ( {
6
7
/**
7
8
* 组件的属性列表
8
9
*/
9
10
behaviors : [ computeOffset , zIndex , hover , validator ] ,
10
- externalClasses : [ 'l-class' , 'l-title-class' , 'l-content-class' , 'l-confirm-class' , 'l-cancel-class' , 'l-bg-class' ] ,
11
+ externalClasses : [
12
+ 'l-class' , 'l-title-class' , 'l-content-class' , 'l-confirm-class' , 'l-cancel-class' , 'l-bg-class'
13
+ ] ,
11
14
properties : {
12
15
// 显示与隐藏
13
16
show : {
@@ -97,43 +100,15 @@ Component({
97
100
initDialog ( ) {
98
101
wx . lin = wx . lin || { } ;
99
102
wx . lin . showDialog = ( options ) => {
100
- const {
101
- type = 'alert' ,
102
- title = '提示' ,
103
- showTitle = true ,
104
- content = '' ,
105
- locked = true ,
106
- confirmText = '确定' ,
107
- contentColor = 'rgba(89,108,142,1)' ,
108
- cancelColor = '#45526b' ,
109
- cancelText = '取消' ,
110
- confirmColor = '#3683d6' ,
111
- success = null ,
112
- fail = null ,
113
- } = options ;
114
- this . setData ( {
115
- type,
116
- title,
117
- showTitle,
118
- content,
119
- locked,
120
- confirmText,
121
- cancelColor,
122
- cancelText,
123
- confirmColor,
124
- contentColor,
125
- show : true ,
126
- fail,
127
- success
128
- } ) ;
129
- return this ;
103
+ console . warn ( 'wx.lin 方法已废弃,请使用开放函数代替 https://doc.mini.talelin.com/start/open-function.html' ) ;
104
+ this . linShow ( options ) ;
130
105
} ;
131
106
} ,
132
107
133
108
// 确定按钮
134
109
onConfirmTap ( ) {
135
110
let detail = 'confirm' ;
136
- let option = { bubbles : true , composed : true } ;
111
+ let option = { bubbles : true , composed : true } ;
137
112
138
113
const {
139
114
success
@@ -154,7 +129,7 @@ Component({
154
129
onCancelTap ( ) {
155
130
156
131
let detail = 'cancel' ;
157
- let option = { bubbles : true , composed : true } ;
132
+ let option = { bubbles : true , composed : true } ;
158
133
159
134
const {
160
135
success
@@ -174,7 +149,7 @@ Component({
174
149
// 背景点击事件
175
150
onDialogTap ( ) {
176
151
let detail = true ;
177
- let option = { bubbles : true , composed : true } ;
152
+ let option = { bubbles : true , composed : true } ;
178
153
179
154
if ( this . data . locked !== true ) {
180
155
this . setData ( {
@@ -183,6 +158,53 @@ Component({
183
158
}
184
159
185
160
this . triggerEvent ( 'lintap' , detail , option ) ;
161
+ } ,
162
+
163
+ // ====================== 开放函数 ========================
164
+
165
+ /**
166
+ * 显示 Dialog
167
+ * @param options Dialog 所有属性
168
+ */
169
+ linShow ( options ) {
170
+ const {
171
+ type = 'alert' ,
172
+ title = '提示' ,
173
+ showTitle = true ,
174
+ content = '' ,
175
+ locked = true ,
176
+ confirmText = '确定' ,
177
+ contentColor = 'rgba(89,108,142,1)' ,
178
+ cancelColor = '#45526b' ,
179
+ cancelText = '取消' ,
180
+ confirmColor = '#3683d6' ,
181
+ success = null ,
182
+ fail = null ,
183
+ } = options ;
184
+ this . setData ( {
185
+ type,
186
+ title,
187
+ showTitle,
188
+ content,
189
+ locked,
190
+ confirmText,
191
+ cancelColor,
192
+ cancelText,
193
+ confirmColor,
194
+ contentColor,
195
+ show : true ,
196
+ fail,
197
+ success
198
+ } ) ;
199
+ } ,
200
+
201
+ /**
202
+ * 隐藏 Dialog
203
+ */
204
+ linHide ( ) {
205
+ this . setData ( {
206
+ show : true
207
+ } ) ;
186
208
}
187
209
}
188
210
} ) ;
0 commit comments