Skip to content

Commit d192be0

Browse files
authored
update
1 parent b134171 commit d192be0

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

index.html

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,62 @@ <h1>Hello World!</h1>
1515
<p><a href="go://login">biubiubiu~</a></p>
1616

1717
<p onclick="window.location.href='go://login'">登录</p>
18+
19+
<script>
20+
var imgUrl = 'https://s2.mogucdn.com/mlcdn/c45406/170401_0caaa1d6g0731699i5h9cb9g1jl97_750x360.jpg_200x200.jpg'; // 分享后展示的一张图片
21+
var lineLink = 'http://www.baidu.com'; // 点击分享后跳转的页面地址
22+
var descContent = "小灰博客,敬请访问!"; // 分享后的描述信息
23+
var shareTitle = '小灰博客'; // 分享后的标题
24+
var appid = ''; // 应用id,如果有可以填,没有就留空
25+
function shareFriend() {
26+
WeixinJSBridge.invoke('sendAppMessage',{
27+
"appid": appid,
28+
"img_url": imgUrl,
29+
"img_width": "200",
30+
"img_height": "200",
31+
"link": lineLink,
32+
"desc": descContent,
33+
"title": shareTitle
34+
}, function(res) {
35+
//_report('send_msg', res.err_msg); // 这是回调函数,必须注释掉
36+
})
37+
}
38+
function shareTimeline() {
39+
WeixinJSBridge.invoke('shareTimeline',{
40+
"img_url": imgUrl,
41+
"img_width": "200",
42+
"img_height": "200",
43+
"link": lineLink,
44+
"desc": descContent,
45+
"title": shareTitle
46+
}, function(res) {
47+
//_report('timeline', res.err_msg); // 这是回调函数,必须注释掉
48+
});
49+
}
50+
function shareWeibo() {
51+
WeixinJSBridge.invoke('shareWeibo',{
52+
"content": descContent,
53+
"url": lineLink,
54+
}, function(res) {
55+
//_report('weibo', res.err_msg);
56+
});
57+
}
58+
// 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
59+
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
60+
// 发送给好友
61+
WeixinJSBridge.on('menu:share:appmessage', function(argv){
62+
shareFriend();
63+
});
64+
// 分享到朋友圈
65+
WeixinJSBridge.on('menu:share:timeline', function(argv){
66+
shareTimeline();
67+
});
68+
// 分享到微博
69+
WeixinJSBridge.on('menu:share:weibo', function(argv){
70+
shareWeibo();
71+
});
72+
}, false);
73+
74+
</script>
1875
</body>
1976
</html>

0 commit comments

Comments
 (0)