微信分享功能实现
使用微信插件
cordova plugin add cordova-plugin-wechat --variable wechatappid=YOUR_WECHAT_APPID;
$scope.sharechat=function(scene,title, desc, url, thumb){
// console.log(scene);
Wechat.share({
message: {
title: "你所不知道的",
description: "This is description",
thumb: "http://pic6.huitu.com/res/20130116/84481_20130116142820494200_1.jpg",
// url: url ?url : "http://baidu.com"
media: {
type: Wechat.Type.WEBPAGE,
webpageUrl: "http://www.cnblogs.com/gongdy/"
}
},
scene:scene // share to Timeline
}, function () {
alert("Success");
}, function (reason) {
alert("Failed: " + reason);
});
};
$scope.shareLink = function(title, desc, url, thumb){
var hideSheet = $ionicActionSheet.show({
buttons:[{
'text':'分享给好友'},
{'text':'分享到朋友圈'}],
cancelText: '取消',
buttonClicked: function(index) {
if(index == 0) {
$scope.sharechat(0,title, desc, url, thumb);
} else if(index == 1) {
$scope.sharechat(1,title, desc, url, thumb);
}
// return true;
}
});
$timeout(function() {
hideSheet();
}, 2000);
};