_WXShare()微信分享通用组件

_WXShare('分享显示的LOGO','LOGO宽度','LOGO高度','分享标题','分享描述','分享连接','微信APPID(通常不用填)');浏览器

微信分享通用组件,用于微信浏览器内浏览网页的分享信息定义。
1、可定义的信息
一、分享时显示的LOGO;
二、分享LOGO的宽度;
三、分享LOGO的高度;
四、分享出去显示的标题(默认调用网页标题);
五、分享出去显示的描述(默认调用网页标题);
六、分享连接(默认为当前页面的URL)。
七、分享微信的APPID(通常为空)。微信

 

function _WXShare(img,width,height,title,desc,url,appid){app

//初始化参数url

img=img||'http://a.zhixun.in/plug/img/ico-share.png';code

width=width||100;事件

height=height||100;string

title=title||document.title;it

desc=desc||document.title;io

url=url||document.location.href;微博

appid=appid||'';

//微信内置方法

function _ShareFriend() {

WeixinJSBridge.invoke('sendAppMessage',{

'appid': appid,

'img_url': img,

'img_width': width,

'img_height': height,

'link': url,

'desc': desc,

'title': title

}, function(res){

_report('send_msg', res.err_msg);

})

}

function _ShareTL() {

WeixinJSBridge.invoke('shareTimeline',{

'img_url': img,

'img_width': width,

'img_height': height,

'link': url,

'desc': desc,

'title': title

}, function(res) {

_report('timeline', res.err_msg);

});

}

function _ShareWB() {

WeixinJSBridge.invoke('shareWeibo',{

'content': desc,

'url': url,

}, 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){

_ShareTL();

});

 

// 分享到微博

WeixinJSBridge.on('menu:share:weibo', function(argv){

_ShareWB();

});

}, false);

}

相关文章
相关标签/搜索