//分享链接点击事件
function share(shares, object) {
console.log(3);
var ids = [{
id: "weixin",
ex: "WXSceneSession"
}, {
id: "weixin",
ex: "WXSceneTimeline"
}, {
id: "sinaweibo"
}, {
id: "tencentweibo"
}, {
id: "qq"
}],
bts = [{
title: "发送给微信好友"
}, {
title: "分享到微信朋友圈"
}, {
title: "分享到新浪微博"
}, {
title: "分享到腾讯微博"
}, {
title: "分享到QQ"
}];
plus.nativeUI.actionSheet({
cancel: "取消",
buttons: bts
}, function(e) {
var i = e.index;
if (i > 0) {
var s_id = ids[i - 1].id;
var share = shares[s_id];
if (share.authenticated) {
shareMessage(share, ids[i - 1].ex, object);
} else {
share.authorize(function() {
shareMessage(share, ids[i - 1].ex, object);
}, function(e) {
console.log("认证授权失败:" + e.code + " - " + e.message);
});
}
}
});
}
// 分享执行动作
function shareMessage(share, ex, object) {
var msg = {
extra: {
scene: ex
}
};
console.log(JSON.stringify(object));
msg.href = "http://www.lzrsh.com/app/shareindex/shareindex.php?id=" + object.id;
msg.title = object.title;
msg.type="web";
msg.content = "每天一篇励志文章,每晚一个励志故事,让你的人生从这里与以前不同!";
if (~share.id.indexOf('weibo')) {
msg.content += ";体验地址:http://mip.lzrsh.com";
}
msg.thumbs = ["_www/img/logo.png"];
share.send(msg, function() {
console.log("分享到\"" + share.description + "\"成功! ");
}, function(e) {
console.log("分享到\"" + share.description + "\"失败: " + e.code + " - " + e.message);
});
}
0 个回复