码迷,mamicode.com
首页 > 微信 > 详细

微信分享JS函数

时间:2014-11-05 18:49:36      阅读:442      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   color   ar   sp   div   

 1 //微信内置浏览器分享事件
 2 //来自:http://www.cnblogs.com/cielwater
 3 //分享朋友圈事件
 4 //UpdateWeixinJSBridge(CircleModel[Json格式,分享朋友圈事件参数])
 5 //Json{, img_url:封面图片地址, img_width:图片宽度, img_height:图片高度, link:跳转地址, desc:正文, title:标题}
 6 function Circle(CircleModel) {
 7     WeixinJSBridge.on(‘menu:share:timeline‘, function (argv) {
 8         WeixinJSBridge.invoke(‘shareTimeline‘, {
 9             "img_url": CircleModel.img_url,
10             "img_width": CircleModel.img_width,
11             "img_height": CircleModel.img_height,
12             "link": CircleModel.link,
13             "desc": CircleModel.desc,
14             "title": CircleModel.title
15         }, function (res) {
16             if (‘share_timeline:cancel‘ != res.err_msg) {
17                 //如果用户没有取消
18                 weimobAfterShare("", WeixinModel.link, ‘timeline‘);
19             }
20             _report(‘timeline‘, res.err_msg);
21         });
22     });
23 }
24 //分享好友事件
25 //FriendsModel[Json格式,分享给朋友事件参数]
26 //Json{img_url:封面图片地址, img_width:图片宽度, img_height:图片高度, link:跳转地址, desc:正文, title:标题}
27 function Friends(FriendsModel) {
28     WeixinJSBridge.on(‘menu:share:appmessage‘, function (argv) {
29         WeixinJSBridge.invoke(‘sendAppMessage‘, {
30             "img_url": FriendsModel.img_url,
31             "img_width": FriendsModel.img_width,
32             "img_height": FriendsModel.img_height,
33             "link": FriendsModel.link,
34             "desc": FriendsModel.desc,
35             "title": FriendsModel.title
36         }, function (res) {
37             if (‘send_app_msg:cancel‘ != res.err_msg) {
38                 weimobAfterShare("", window.shareData.link, ‘appmessage‘);
39             }
40             _report(‘send_msg‘, res.err_msg);
41         })
42     });
43 }
44 //分享微博事件
45 //WeiboModel[Json格式,分享微博事件参数]
46 //Json{content:正文, url:跳转地址}
47 function Weibo(WeiboModel) {
48     WeixinJSBridge.on(‘menu:share:weibo‘, function (argv) {
49         WeixinJSBridge.invoke(‘shareWeibo‘, {
50             "content": WeiboModel.content,
51             "url": WeiboModel.url
52         }, function (res) {
53             if (‘share_weibo:cancel‘ != res.err_msg) {
54                 weimobAfterShare("", WeiboModel.url, ‘weibo‘);
55             }
56             _report(‘weibo‘, res.err_msg);
57         });
58     });
59 }
60 //绑定微信分享事件
61 function WeiXinBind(CircleModel, FriendsModel, WeiboModel) {
62     document.addEventListener(‘WeixinJSBridgeReady‘, function onBridgeReady() {
63         Circle(InitializeCircleModel);
64         Friends(InitializeFriendsModel);
65         Weibo(InitializeWeiboModel);
66     }, false);
67 }

 

微信分享JS函数

标签:des   style   blog   http   io   color   ar   sp   div   

原文地址:http://www.cnblogs.com/CielWater/p/4076701.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!