File tree Expand file tree Collapse file tree 2 files changed +74
-58
lines changed Expand file tree Collapse file tree 2 files changed +74
-58
lines changed Original file line number Diff line number Diff line change 1
1
// pages/home/home.js
2
2
Page ( {
3
-
4
- /**
5
- * 页面的初始数据
6
- */
7
- data : {
8
-
9
- } ,
10
-
11
- /**
12
- * 生命周期函数--监听页面加载
13
- */
14
- onLoad : function ( options ) {
15
-
16
- } ,
17
-
18
- /**
19
- * 生命周期函数--监听页面初次渲染完成
20
- */
21
- onReady : function ( ) {
22
-
23
- } ,
24
-
25
- /**
26
- * 生命周期函数--监听页面显示
27
- */
28
- onShow : function ( ) {
29
-
3
+ handleShowToast ( ) {
4
+ wx . showToast ( {
5
+ title : '加载中ing' ,
6
+ duration : 3000 ,
7
+ icon : 'loading' ,
8
+ // image: "/assets/icon/icon.png"
9
+ mask : true ,
10
+ success : function ( ) {
11
+ console . log ( '展示弹窗成功' )
12
+ } ,
13
+ fail : function ( ) {
14
+ console . log ( '展示弹窗失败' )
15
+ } ,
16
+ complete : function ( ) {
17
+ console . log ( '完成函数的调用' )
18
+ }
19
+ } )
30
20
} ,
31
-
32
- /**
33
- * 生命周期函数--监听页面隐藏
34
- */
35
- onHide : function ( ) {
36
-
21
+ handleShowModal ( ) {
22
+ wx . showModal ( {
23
+ title : '我是标题' ,
24
+ content : '我是内容,哈哈哈' ,
25
+ // showCancel: false,
26
+ cancelText : '退出' ,
27
+ cancelColor : 'red' ,
28
+ success : function ( res ) {
29
+ console . log ( res )
30
+ if ( res . cancel ) {
31
+ console . log ( '用户点击了取消按钮' )
32
+ }
33
+ if ( res . confirm ) {
34
+ console . log ( '用户点击了确定按钮' )
35
+ }
36
+ }
37
+ } )
37
38
} ,
38
-
39
- /**
40
- * 生命周期函数--监听页面卸载
41
- */
42
- onUnload : function ( ) {
43
-
39
+ handleShowLoading ( ) {
40
+ wx . showLoading ( {
41
+ title : '加载ing' ,
42
+ mask : true
43
+ } )
44
+
45
+ setTimeout ( ( ) => {
46
+ // 必须手动hideLoading才会让loading消失
47
+ wx . hideLoading ( )
48
+ } , 1000 )
44
49
} ,
45
-
46
- /**
47
- * 页面相关事件处理函数--监听用户下拉动作
48
- */
49
- onPullDownRefresh : function ( ) {
50
-
50
+ handleShowAction ( ) {
51
+ wx . showActionSheet ( {
52
+ itemList : [ '相册' , '拍照' ] ,
53
+ itemColor : 'red' ,
54
+ success : function ( res ) {
55
+ console . log ( res )
56
+ }
57
+ } )
51
58
} ,
52
-
53
- /**
54
- * 页面上拉触底事件的处理函数
55
- */
56
- onReachBottom : function ( ) {
57
-
58
- } ,
59
-
60
- /**
61
- * 用户点击右上角分享
62
- */
63
- onShareAppMessage : function ( ) {
64
-
59
+ onShareAppMessage : function ( options ) {
60
+ return {
61
+ title : '你好啊,李银河' ,
62
+ path : '/pages/about/about' ,
63
+ imageUrl : 'http://s3.mogucdn.com/mlcdn/c45406/170915_0a93207ci28kelh617k4hh62l65lb_640x960.jpg'
64
+ }
65
65
}
66
66
} )
Original file line number Diff line number Diff line change 1
1
<!--pages/home/home.wxml-->
2
2
<text class='title'>Hello World</text>
3
3
<button size='mini'>按钮</button>
4
+
5
+ <!-- 1.Toast -->
6
+ <button size='mini' bind:tap="handleShowToast">showToast</button>
7
+
8
+ <!-- 2.Modal -->
9
+ <button size='mini' bind:tap="handleShowModal">showModal</button>
10
+
11
+ <!-- 3.Loading -->
12
+ <button size='mini' bind:tap="handleShowLoading">showLoading</button>
13
+
14
+ <!-- 4.actionSheet -->
15
+ <button size='mini' bind:tap="handleShowAction">showAction</button>
16
+
17
+ <!-- 5.分享按钮 -->
18
+ <button size='mini' open-type='share'>分享</button>
19
+
You can’t perform that action at this time.
0 commit comments