Skip to content

Commit 3c0913c

Browse files
committed
弹窗和分享
1 parent 51f8b15 commit 3c0913c

File tree

2 files changed

+74
-58
lines changed

2 files changed

+74
-58
lines changed

pages/home/home.js

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
11
// pages/home/home.js
22
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+
})
3020
},
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+
})
3738
},
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)
4449
},
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+
})
5158
},
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+
}
6565
}
6666
})

pages/home/home.wxml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
<!--pages/home/home.wxml-->
22
<text class='title'>Hello World</text>
33
<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+

0 commit comments

Comments
 (0)