zoukankan      html  css  js  c++  java
  • 微信分享JS函数(原创)[已失效]

     1 //微信内置浏览器分享事件
     2 //来自:http://www.cnblogs.com/cielwater
     3 //分享朋友圈事件
     4 //UpdateWeixinJSBridge(CircleModel[Json格式,分享朋友圈事件参数])
     5 //Json{, img_url:封面图片地址, img_图片宽度, 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_图片宽度, 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 }

     已失效。请至微信官方文档查看微信官方API文档http://mp.weixin.qq.com/wiki

  • 相关阅读:
    mysql常用操作语句
    开启端口命令
    在linux终端远程登陆linux服务器
    CentOS个人目录下中文路径转英文路径
    安装MariaDB和简单配置
    centos 7.1 apache 源码编译安装
    PHP页面跳转
    一亿个不重复的随机数算法
    HTML中添加背景
    SQL语法
  • 原文地址:https://www.cnblogs.com/CielWater/p/4076701.html
Copyright © 2011-2022 走看看