MUI Android分享功能
来源:互联网 发布:学网络编程 编辑:程序博客网 时间:2024/06/05 16:36
/** 更新分享服务 */
/* 更新分享服务需要在 mui.plusReady里执行
*/
function updateSerivces() {
plus.share.getServices(
function(data) {
shares = {};
for (var i in data) {
var t = data[i];
shares[t.id] = t;
}
},
function(data) {
mui.toast("获取分享服务列表失败:" + data.message);
}
);
}
plus.share.getServices(
function(data) {
shares = {};
for (var i in data) {
var t = data[i];
shares[t.id] = t;
}
},
function(data) {
mui.toast("获取分享服务列表失败:" + data.message);
}
);
}
/** 分享事件 */
/*两个参数
index 要分享的下标
msg 分享信息
href: msg.url, 连接地址
title: msg.title, 标题名称
content: msg.content, 内容名称thumbs: [msg.image], 图标
pictures: [msg.image] 图标
*/
function share(index,msg) {
var ids =
[{id: "qq"}, /*QQ好友*/
{id: "weixin",ex: "WXSceneSession"}, /*微信好友*/
{id: "weixin",ex: "WXSceneTimeline"}, /*微信朋友圈*/
{id: "sinaweibo"} /*新浪微博*/
];
shareAction(ids[index].id, ids[index].ex,msg);
}
var ids =
[{id: "qq"}, /*QQ好友*/
{id: "weixin",ex: "WXSceneSession"}, /*微信好友*/
{id: "weixin",ex: "WXSceneTimeline"}, /*微信朋友圈*/
{id: "sinaweibo"} /*新浪微博*/
];
shareAction(ids[index].id, ids[index].ex,msg);
}
/** 分享操作 */
function shareAction(id, ex, msg) {
var sharedServices = null;
if (!id || !(sharedServices = shares[id])) {
mui.toast("无效的分享服务!");
return;
}
if (sharedServices.authenticated) {
sendShare(sharedServices, ex,msg);
} else {
sharedServices.authorize(
function() {
sendShare(sharedServices, ex,msg);
},
function(e) {
mui.toast("认证授权失败");
}
);
}
}
var sharedServices = null;
if (!id || !(sharedServices = shares[id])) {
mui.toast("无效的分享服务!");
return;
}
if (sharedServices.authenticated) {
sendShare(sharedServices, ex,msg);
} else {
sharedServices.authorize(
function() {
sendShare(sharedServices, ex,msg);
},
function(e) {
mui.toast("认证授权失败");
}
);
}
}
/** 发送分享消息 */
function sendShare(sharedServices, ex,msg) {
/*信息*/
var message= {
href: msg.url,
thumbs: [msg.image],
pictures: [msg.image],
extra: {
scene: ex
}
};
sharedServices.send(
message,
function() {
mui.toast("分享成功!");
},
function(e) {
}
);
}
/*信息*/
var message= {
href: msg.url,
title: msg.title,
content: msg.content,thumbs: [msg.image],
pictures: [msg.image],
extra: {
scene: ex
}
};
sharedServices.send(
message,
function() {
mui.toast("分享成功!");
},
function(e) {
}
);
}
阅读全文
0 0
- MUI Android分享功能
- Android 分享功能
- android 使用分享功能
- Android分享功能
- android 分享功能
- Android分享功能
- Android分享功能
- android分享功能开发!!!
- Android分享功能
- Android使用分享功能
- Android 分享功能
- android 分享功能
- android 实现分享功能
- Android分享功能源码
- android 分享功能开发
- android 分享功能
- android分享功能开发
- android分享功能
- A
- JAVA类集(2)简单操作
- leetcode--Sqrt(x)
- SpringMVC返回Json失败,请检查是否配置了Jackson
- 【php中的curl】php中curl的详细解说
- MUI Android分享功能
- windows 查看端口占用
- 正则化方法:L1和L2 regularization、数据集扩增、dropout
- 整数中1出现的次数
- 打通微信通信第一步
- 数串
- 【SpringCloud】(二):服务发现和服务注册
- vi/vim实用操作记录
- UVA.10325 The Lottery (组合数学 容斥原理 二进制枚举)