javascript - 微信jssdk ios微信内部自定义分享失效,安卓正常
本文介绍了javascript - 微信jssdk ios微信内部自定义分享失效,安卓正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
微信内部分享onMenuShareTimeline、onMenuShareAppMessage在ios系统中自定义内容出不来,安卓分享是没有问题的,这是怎么回事儿?
代码如下:
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
wx.config({
debug: false,
appId: '<?php echo $signPackage["appid"];?>',
timestamp: '<?php echo $signPackage["timestamp"];?>',
nonceStr: '<?php echo $signPackage["noncestr"];?>',
signature: '<?php echo $signPackage["signature"];?>',
jsApiList: [
'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'hideAllNonBaseMenuItem'
]
});
</script>
<script>
{if !empty($share_data)}
wx.ready(function () {
// 在这里调用 API
wx.onMenuShareTimeline({
title: '<?php echo $share_data["title"];?>', // 分享标题
desc: '<?php echo $share_data["desc"];?>', // 分享描述
link: '<?php echo $share_data["url"];?>', // 分享链接
imgUrl: '<?php echo $share_data["imgurl"];?>', // 分享图标
success: function () {
// if (share_success != undefined) {
share_success();
// }
},
cancel: function () {
// if (share_cancel != undefined) {
share_cancel();
// }
}
});
wx.onMenuShareAppMessage({
title: '<?php echo $share_data["title"];?>', // 分享标题
desc: '<?php echo $share_data["desc"];?>', // 分享描述
link: '<?php echo $share_data["url"];?>', // 分享链接
imgUrl: '<?php echo $share_data["imgurl"];?>', // 分享图标
type: 'link', // 分享类型,music、video或link,不填默认为link
dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
success: function () {
// if (share_success != undefined) {
share_success();
// }
},
cancel: function () {
// if (share_cancel != undefined) {
share_cancel();
// }
}
});
wx.onMenuShareQQ({
title: '<?php echo $share_data["title"];?>', // 分享标题
desc: '<?php echo $share_data["desc"];?>', // 分享描述
link: '<?php echo $share_data["url"];?>', // 分享链接
imgUrl: '<?php echo $share_data["imgurl"];?>', // 分享图标
type: 'link', // 分享类型,music、video或link,不填默认为link
dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
success: function () {
// if (share_success != undefined) {
share_success();
// }
},
cancel: function () {
// if (share_cancel != undefined) {
share_cancel();
// }
}
});
});
wx.error(function (res) {
// alert(res.errMsg);
});
{else}
wx.ready(function () {
wx.hideAllNonBaseMenuItem();
});
{/if}
</script>
解决方案
解决了,link带的url是要带http的地址,现在我改成window.location.href,ios正常了
这篇关于javascript - 微信jssdk ios微信内部自定义分享失效,安卓正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文