H5+微信分享

shareToNews (id) {

var shares = null;

var sweixin = null;

var pic = '';

var extra = [

{ title: "我的好友", extra: { scene: "WXSceneSession" } },

{ title: "朋友圈", extra: { scene: "WXSceneTimeline" } }

];

var msg = {};

msg.type = "image";

msg.content = "快讯分享";

msg.href = "http://www.coinun.co/";

this.saveCanvas()

msg.pictures = [plus.io.convertLocalFileSystemURL('_doc/news_picture.png')];

msg.extra = extra[id].extra;

console.log(msg);

plus.share.getServices(

function(s) {

shares = {};

for (var i in s) {

var t = s[i];

shares[t.id] = t;

}

sweixin = shares["weixin"];

sweixin.send(

msg,

function() {

/* Toast({

message: "sweixin.description: 已分享",

position: "bottom",

duration: 1000

}); */

alert('分享到"' + sweixin.description + '"成功!'+ msg);

},

function(e) {

alert(

'分享到"' + sweixin.description + '"失败: ' + JSON.stringify(e)

);

/* Toast({

message: "sweixin.description: 分享失败" + JSON.stringify(e),

position: "bottom",

duration: 1000

}); */

}

);

},

function(e) {

outSet("获取分享服务列表失败:" + e.message);

}

);

猜你喜欢

转载自blog.csdn.net/qq_42306443/article/details/85322543