From 54e9367f71e2ecbe253cbbd805410f29131e730f Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 29 Jul 2016 10:52:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E4=BA=AB=E6=A0=87=E9=A2=98=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wechat/controllers/invite_code.js | 85 +++++++++++++++---- 1 file changed, 70 insertions(+), 15 deletions(-) diff --git a/public/javascripts/wechat/controllers/invite_code.js b/public/javascripts/wechat/controllers/invite_code.js index 0c8bbe09e..14bdbba35 100644 --- a/public/javascripts/wechat/controllers/invite_code.js +++ b/public/javascripts/wechat/controllers/invite_code.js @@ -12,23 +12,78 @@ app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config function(response){ console.log(response.data); vm.course = response.data.data; + wxinit(); } ); - vm.share = function(){ - window.WeixinJSBridge.invoke('sendAppMessage',{ - 'appid': 'wxf694495398c7d470', // 公众号appID - 'type': 'link', // 非必填,music,vido或link,默认为link。 - 'data_url': '', // 非必填,连接地址,如音乐的mp3数据地址,供内置播放器使用 - 'img_url': 'http://pnewsapp.tc.qq.com/newsapp_bt/0/9963967/640', // 缩略图地址 - 'img_height':370, // 缩略图高度 - 'img_width':550, // 缩略图宽度 - 'link':'http://view.inews.qq.com/a/WXN2013101101385701', // 链接地址 - 'desc':'desc', // 描述 - 'title':'title' // 标题 - },function(res){ - //alert(res.err_msg); - }); - } +// vm.share = function(){ +// window.WeixinJSBridge.invoke('sendAppMessage',{ +// 'appid': 'wxf694495398c7d470', // 公众号appID +// 'type': 'link', // 非必填,music,vido或link,默认为link。 +// 'data_url': '', // 非必填,连接地址,如音乐的mp3数据地址,供内置播放器使用 +// 'img_url': 'http://pnewsapp.tc.qq.com/newsapp_bt/0/9963967/640', // 缩略图地址 +// 'img_height':370, // 缩略图高度 +// 'img_width':550, // 缩略图宽度 +// 'link':'http://view.inews.qq.com/a/WXN2013101101385701', // 链接地址 +// 'desc':'desc', // 描述 +// 'title':'title' // 标题 +// },function(res){ +// //alert(res.err_msg); +// }); +// } + + wxinit = function(){ + var descContent = '班级邀请:'+vm.course.name+'班级'; //分享给朋友或朋友圈时的文字简介 + var shareTitle = 'Trustie创新实践平台'; //分享title + var appid = 'wxc09454f171153c2d'; //apiID,可留空 + var linelink = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='+vm.course.qrcode; + + function shareFriend() { + WeixinJSBridge.invoke('sendAppMessage',{ + "appid": appid, + "img_width": "200", + "img_height": "200", + "link": linelink, + "desc": descContent, + "title": shareTitle + }, function(res) { + //_report('send_msg', res.err_msg); + }) + } + function shareTimeline() { + WeixinJSBridge.invoke('shareTimeline',{ + "img_width": "200", + "img_height": "200", + "link": linelink, + "desc": descContent, + "title": shareTitle + }, function(res) { + //_report('timeline', res.err_msg); + }); + } + function shareWeibo() { + WeixinJSBridge.invoke('shareWeibo',{ + "content": descContent, + "url": linelink + }, function(res) { + //_report('weibo', res.err_msg); + }); + } + // 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。 + document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() { + // 发送给好友 + WeixinJSBridge.on('menu:share:appmessage', function(argv){ + shareFriend(); + }); + // 分享到朋友圈 + WeixinJSBridge.on('menu:share:timeline', function(argv){ + shareTimeline(); + }); + // 分享到微博 + WeixinJSBridge.on('menu:share:weibo', function(argv){ + shareWeibo(); + }); + }, false); + }; }]);