HBuiler 真机调试可以分享,使用 DCloud 云端打包后就不能分享了(微信好友)
var sharewx = null;
function share() {
plus.share.getServices(function(s) {
// console.log(JSON.stringify(shares))
for(var i in s) {
if('weixin' == s[i].id) {
sharewx = s[i]
break
}
}
mui.toast(sharewx.authenticated)
if(sharewx.authenticated) {
shareWeixinMessage()
} else {
sharewx.authorize(function() {
shareWeixinMessage()
}, function(e) {
mui.toast("认证授权失败:" + e.code + " - " + e.message)
})
}
}, function(e) {
mui.toast("获取分享服务列表失败:" + e.message)
});
}
function shareWeixinMessage() {
sharewx.send({ title: "好友为你推荐。。。!", content: "最近发现一款 APP。。。", pictures: ["images/bg_qipei.png"], thumbs: ["images/icon_share.png"], href: "http://www.dcould.com/", extra: { scene: "WXSceneSession" } }, function() {
mui.toast("分享成功!")
}, function(e) {
mui.toast("分享失败。")
})
}
1 个回复
骁骑
检查HBuider里配置的 微信分享用的appkey和你打包用的证书和包名是否匹配,如果不匹配会导致分享失败,
注意:
打包后检查生成包的签名是否和你在微信平台上申请时填写的应用签名是否一致,如果不一致必然出错