问题:
1、使用微信JSSDK的分享接口,已打开调试模式,debug:true,执行wx.config()时,弹出提示config:ok,但是执行到wx.ready()里面的接口代码时,提示system:permission denied,本人是服务号,而且是交费认证过的,在开发者中心的权限列表也显示分享接口已获得。
2、关注本人的公众号后,点击本人的自定义菜单进入本人本人开发的网页时,点击微信浏览器右上角的按钮,弹出菜单中只有一个收藏菜单项,本人进入其他公众号的网页,点击这个按钮弹出的菜单都有发送给朋友、分享到朋友圈、分享到手机QQ等等很多菜单项的,很郁闷,不知道什么原因,大家有碰到过这个问题吗。
下面是本人调用分享接口的主要代码:
1、使用微信JSSDK的分享接口,已打开调试模式,debug:true,执行wx.config()时,弹出提示config:ok,但是执行到wx.ready()里面的接口代码时,提示system:permission denied,本人是服务号,而且是交费认证过的,在开发者中心的权限列表也显示分享接口已获得。
2、关注本人的公众号后,点击本人的自定义菜单进入本人本人开发的网页时,点击微信浏览器右上角的按钮,弹出菜单中只有一个收藏菜单项,本人进入其他公众号的网页,点击这个按钮弹出的菜单都有发送给朋友、分享到朋友圈、分享到手机QQ等等很多菜单项的,很郁闷,不知道什么原因,大家有碰到过这个问题吗。
下面是本人调用分享接口的主要代码:
<section data-role="page" id="pageSeeHouseTeamList">
<script>
wx.config({
debug: true,
appId: $("input[id$="hdfAppId"]").val(),
timestamp: $("input[id$="hdfTimestamp"]").val(),
nonceStr: $("input[id$="hdfNonce"]").val(),
signature: $("input[id$="hdfSignature"]").val(),
jsApiList: ["checkJsApi", "onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ", "onMenuShareWeibo"]
});
wx.error(function (res) {
alert(res);
});
wx.ready(function () {
$("img[src$="share_03.gif"]").on("click", function () {
var isOk = true;
wx.checkJsApi({
jsApiList: ["onMenuShareQQ"],
fail: function (res) {
alert("微信版本太低,不支持分享给朋友的功能!");
isOk = false;
},
success: function (res) {
alert("支持QQ分享。");
}
});
if (!isOk)
return;
var $div = $(this).closest("li").children("div");
wx.onMenuShareQQ({
title: $div.eq(0).children("a").text(), // 分享标题
desc: $div.eq(1).find("dt").text() + "," + $div.eq(1).find("dd").text(), // 分享描述
link: $div.eq(0).children("a").attr("href"), // 分享链接
imgUrl: $div.eq(1).children("a").css("background").replace("url(", "").replace(")", ""), // 分享图标
success: function (res) {
alert("分享给QQ好友成功");// 用户确认分享后执行的回调函数
},
cancel: function () {
// 用户取消分享后执行的回调函数
},
fail: function (res) {
alert(res);//$.parseJSON(res).errMsg
}
});
});
$("img[src$="share_05.gif"]").on("click", function () {
var $div = $(this).closest("li").children("div");
wx.onMenuShareTimeline({
title: $div.eq(0).children("a").text(), // 分享标题
link: $div.eq(0).children("a").attr("href"), // 分享链接
imgUrl: $div.eq(1).children("a").css("background").replace("url(", "").replace(")", ""), // 分享图标
success: function (res) {
alert("分享到朋友圈成功");// 用户确认分享后执行的回调函数
},
cancel: function () {
// 用户取消分享后执行的回调函数
},
fail: function (res) {
alert(res);
}
});
});
$("img[src$="share_07.gif"]").on("click", function () {
var $div = $(this).closest("li").children("div");
wx.onMenuShareWeibo({
title: $div.eq(0).children("a").text(), // 分享标题
link: $div.eq(0).children("a").attr("href"), // 分享链接
imgUrl: $div.eq(1).children("a").css("background").replace("url(", "").replace(")", ""), // 分享图标
success: function (res) {
alert("分享到腾讯微博成功");// 用户确认分享后执行的回调函数
},
cancel: function () {
// 用户取消分享后执行的回调函数
},
fail: function (res) {
alert(res);
}
});
});
$("img[src$="share_16.gif"]").on("click", function () {
var $div = $(this).closest("li").children("div");
wx.onMenuShareAppMessage({
title: $div.eq(0).children("a").text(), // 分享标题
desc: $div.eq(1).find("dt").text() + "," + $div.eq(1).find("dd").text(), // 分享描述
link: $div.eq(0).children("a").attr("href"), // 分享链接
imgUrl: $div.eq(1).children("a").css("background").replace("url(", "").replace(")", ""), // 分享图标
type: "link", // 分享类型,music、video或link,不填默认为link
dataUrl: "", // 假如type是music或video,则要提供数据链接,默认为空
success: function (res) {
alert("分享给微信朋友成功");// 用户确认分享后执行的回调函数
},
cancel: function () {
// 用户取消分享后执行的回调函数
},
fail: function (res) {
alert(res);
}
});
});
});
</script>
<div data-role="content" style="padding:0px;background:#FFF;">
<input id="hdfAppId" type="hidden" runat="server" />
<input id="hdfTimestamp" type="hidden" runat="server" />
<input id="hdfNonce" type="hidden" runat="server" />
<input id="hdfSignature" type="hidden" runat="server" />
<input id="temp" type="hidden" runat="server" />
<ul class="ul-seeHouseTeamList">
<FC:RepeaterPlusNone ID="rptSeeHouseTeam" runat="server">
<ItemTemplate>
<li>
<div>
<a id="lnkTeamTitle" runat="server" href="/teamBuy/seeHouseTeamView-{0}.aspx" data-transition="slide"></a>
</div>
<div>
<a id="lnkHouse" runat="server" href="/teamBuy/seeHouseTeamView-{0}.aspx" data-transition="slide"></a>
<dl><dt><asp:Literal ID="ltlPrice" runat="server"></asp:Literal>元/平米</dt><dd><asp:Literal ID="ltlTeamInfo" runat="server"></asp:Literal></dd></dl>
</div>
<div>
<p>已报名<span style="color:#ff6600;"><asp:Literal ID="ltlJoinCount" runat="server"></asp:Literal></span>人</p>
<p>
分享
<img src="/themes/default/images/share_03.gif" />
<img src="/themes/default/images/share_05.gif" />
<img src="/themes/default/images/share_07.gif" />
<img src="/themes/default/images/share_16.gif" />
</p>
</div>
<div>
<a id="lnkJoin" runat="server" href="/userCenter/teamBuyJoin.aspx?tbid={0}" data-transition="slide">报 名</a>
</div>
</li>
</ItemTemplate>
<NoneTemplate><li style="text-align:center;height:100px;line-height:100px;">对不起,没找到数据!</li></NoneTemplate>
</FC:RepeaterPlusNone>
</ul>
</div>
</section>
解决方案
20
1.是全部接口都报permission denied错误吗?
2.你调用一下wx.showAllNonBaseMenuItem(); 这个接口试试
2.你调用一下wx.showAllNonBaseMenuItem(); 这个接口试试
20
加载官方的JS,后
wx.config({
debug: false,
appId: share_cfg.appid,
timestamp: share_cfg.timestamp,
nonceStr: share_cfg.nonceStr,
signature: share_cfg.signature,
jsApiList: ["onMenuShareTimeline","onMenuShareAppMessage","scanQRCode"]
});
wx.ready(function(){
//share to timeline
wx.onMenuShareTimeline({
title: share_cfg.title,
link: share_cfg.link,
imgUrl: share_cfg.img,
success: function () {
shareLog();
},
cancel: function () {
}
});
wx.onMenuShareAppMessage({
desc: share_cfg.desc,
title: share_cfg.title,
link: share_cfg.link,
imgUrl: share_cfg.img,
type: "link",
dataUrl: "",
success: function () {
shareLog()
},
cancel: function () {
}
});
});
wx.error(function(res){
});
本人这边是正常使用的。