公众号有分享权限,配置也配置了。打包的时候安装报“解析错误”是怎么回事?急急急!!!!!
- 发布:2016-12-12 15:16
- 更新:2016-12-12 16:14
- 阅读:1121
我也是刚做完一个分享功能,你可以把方法贴出来 我给你参考参考
-
丿白开水 (作者)
function DianZanShare( object ){//点击"点赞",“转发”图标
var dataNum = object.getAttribute( "data-type" );
shareId = object.parentNode.parentNode.getAttribute( "data-txtId" );
shareTxt = object.parentNode.parentNode.querySelector(".friend-content-text").innerText;
if( dataNum == "1" ){//点击“点赞”功能
like( object,shareId );
event.stopPropagation();
} else if( dataNum == "2" ){//点击“转发”功能
plus.share.getServices( shareSuccess, function(){ mui.toast("你的手机暂不支持转发功能") } );
event.stopPropagation();
}
}
function shareSuccess( services ){
var shareBts=[], serArray = {};
for( var i in services ){
var power = services[i];
serArray[power.id] = power;
}
//更新分享列表
shareBts.push({title:'微信朋友圈',name:serArray['weixin'],limit:'WXSceneTimeline'});
shareBts.push({title:'微信好友',name:serArray['weixin'],limit:'WXSceneSession'});
//shareBts.push({title:'QQ',name:serArray['qq']});
// 弹出分享列表
if( shareBts.length > 0 ){
plus.nativeUI.actionSheet(
{title:'分享链接',cancel:'取消',buttons:shareBts},
function(e){
if( e.index > 0 ){
shareAction(shareBts[e.index-1]);
}
})
} else {
plus.nativeUI.alert('当前环境无法支持分享链接操作!');
}
}
function shareAction( Array ) {
var msg={
title : "UDS快递APP",
content : shareTxt,
thumbs : "image/logo.png",
href : mainUrl + "forum/share?cardId=" + shareId,
extra : { scene : Array.limit }
};
if ( Array.name.authenticated ) {
shareMessage(msg,Array.name);
} else {
Array.name.authorize( function(){
shareMessage(msg,Array.name);
},function(e){
mui.toast( "认证授权失败:"+e.code+" - "+e.message );
});
}
}
function shareMessage(msg,s){
s.send( msg, function(){
mui.toast( "分享到" + s.description + "成功! " );
}, function(e){
mui.toast( "分享到" + s.description + "失败!" );
} );
}2016-12-12 15:46
你这个后面的方法写的不对
function shareAction( Array ) {
var msg={
title : "UDS快递APP",
content : shareTxt,
thumbs : "image/logo.png",
href : mainUrl + "forum/share?cardId=" + shareId,
extra : { scene : Array.limit }
};
if ( Array.name.authenticated ) {
shareMessage(msg,Array.name);
} else {
Array.name.authorize( function(){
shareMessage(msg,Array.name);
},function(e){
mui.toast( "认证授权失败:"+e.code+" - "+e.message );
});
}
}
function shareMessage(msg,s){
s.send( msg, function(){
mui.toast( "分享到" + s.description + "成功! " );
}, function(e){
mui.toast( "分享到" + s.description + "失败!" );
} );
}
上面的msg是一个局部变量,你下面shareMessage的msg调用不到
丿白开水 (作者)
肯定添加了的,没有添加我截图的地方是没有数据的。
2016-12-12 15:33
g***@126.com
调用的方法是咋写的 你贴出来看看
2016-12-12 15:36