wechatshare.js
1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function setShare(url, imgurl, descript, gourl) {
setShareNew(document.title, url, imgurl, descript, gourl);
}
function setShareNew(title, url, imgurl, descript, gourl) {
wx.ready(function () {
wx.onMenuShareAppMessage({
title: title,
desc: descript,
link: url,
imgUrl: imgurl,
trigger: function (res) {
//alert('用户点击发送给朋友');
},
success: function (res) {
if (gourl) window.location.href = gourl;
},
cancel: function (res) {
//alert('已取消');
},
fail: function (res) {
//alert(JSON.stringify(res));
}
});
//注册分享到朋友圈
wx.onMenuShareTimeline({
title: title,
desc: descript,
link: url,
imgUrl: imgurl,
trigger: function (res) {
//alert('用户点击发送给朋友');
},
success: function (res) {
if (gourl) window.location.href = gourl;
},
cancel: function (res) {
//alert('已取消');
},
fail: function (res) {
//alert(JSON.stringify(res));
}
});
});
}
//隐藏复制按钮
function HideCopyMenu() {
wx.ready(function() {
wx.hideMenuItems({
menuList: ["menuItem:copyUrl", "menuItem:openWithQQBrowser", "menuItem:openWithSafari"]
});
});
}