@@ -2,12 +2,15 @@ import computeOffset from '../behaviors/computeOffset';
22import zIndex from '../behaviors/zIndex' ;
33import hover from '../behaviors/hover' ;
44import validator from '../behaviors/validator' ;
5+
56Component ( {
67 /**
78 * 组件的属性列表
89 */
910 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+ ] ,
1114 properties : {
1215 // 显示与隐藏
1316 show : {
@@ -97,43 +100,15 @@ Component({
97100 initDialog ( ) {
98101 wx . lin = wx . lin || { } ;
99102 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 ) ;
130105 } ;
131106 } ,
132107
133108 // 确定按钮
134109 onConfirmTap ( ) {
135110 let detail = 'confirm' ;
136- let option = { bubbles : true , composed : true } ;
111+ let option = { bubbles : true , composed : true } ;
137112
138113 const {
139114 success
@@ -154,7 +129,7 @@ Component({
154129 onCancelTap ( ) {
155130
156131 let detail = 'cancel' ;
157- let option = { bubbles : true , composed : true } ;
132+ let option = { bubbles : true , composed : true } ;
158133
159134 const {
160135 success
@@ -174,7 +149,7 @@ Component({
174149 // 背景点击事件
175150 onDialogTap ( ) {
176151 let detail = true ;
177- let option = { bubbles : true , composed : true } ;
152+ let option = { bubbles : true , composed : true } ;
178153
179154 if ( this . data . locked !== true ) {
180155 this . setData ( {
@@ -183,6 +158,53 @@ Component({
183158 }
184159
185160 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+ } ) ;
186208 }
187209 }
188210} ) ;
0 commit comments