微信隐藏分享js

<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript"> wx.config({ debug: false, appId: 'wxfc2df8df104e1555', timestamp: 1452308713, nonceStr: '522738', signature: '399edba928508a6f7736af5a970c2f070253026c', jsApiList: [ 'checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'openLocation', 'getLocation', 'addCard', 'chooseCard', 'openCard', 'hideMenuItems', 'hideOptionMenu', 'hideAllNonBaseMenuItem' ] }); </script>

<script type="text/javascript"> window.shareData = { "moduleName":"Index", "moduleID": "0", "imgUrl": "", "timeLineLink": "http://www.37wei.cn/index.php?g=Wap&m=Index&a=index&token=xdgkiy1444014268", "sendFriendLink": "http://www.37wei.cn/index.php?g=Wap&m=Index&a=index&token=xdgkiy1444014268", "weiboLink": "http://www.37wei.cn/index.php?g=Wap&m=Index&a=index&token=xdgkiy1444014268", "tTitle": "", "tContent": "", "timeline_hide": "1" }; </script>



<script type="text/javascript"> wx.ready(function () { // 1 判断当前版本是否支持指定 JS 接口,支持批量判断 /*document.querySelector('#checkJsApi').onclick = function () { wx.checkJsApi({ jsApiList: [ 'getNetworkType', 'previewImage' ], success: function (res) { //alert(JSON.stringify(res)); } }); };*/ // 2. 分享接口 // 2.1 监听“分享给朋友”,按钮点击、自定义分享内容及分享结果接口 wx.onMenuShareAppMessage({ title: window.shareData.tTitle, desc: window.shareData.tContent, link: window.shareData.sendFriendLink, imgUrl: window.shareData.imgUrl, type: '', // 分享类型,music、video或link,不填默认为link dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 success: function () { shareHandle('frined'); }, cancel: function () { //alert('分享朋友失败'); } }); // 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口 wx.onMenuShareTimeline({ title: window.shareData.fTitle?window.shareData.fTitle:window.shareData.tTitle, link: window.shareData.sendFriendLink, imgUrl: window.shareData.imgUrl, success: function () { shareHandle('frineds'); //alert('分享朋友圈成功'); }, cancel: function () { //alert('分享朋友圈失败'); } }); // 2.4 监听“分享到微博”按钮点击、自定义分享内容及分享结果接口 wx.onMenuShareWeibo({ title: window.shareData.tTitle, desc: window.shareData.tContent, link: window.shareData.sendFriendLink, imgUrl: window.shareData.imgUrl, success: function () { shareHandle('weibo'); //alert('分享微博成功'); }, cancel: function () { //alert('分享微博失败'); } }); if(window.shareData.timeline_hide == '1'){ //隐藏分享到朋友圈 wx.hideMenuItems({ menuList: [ 'menuItem:share:timeline', 'menuItem:favorite' ], }); wx.hideOptionMenu(); wx.hideAllNonBaseMenuItem(); //wx.showOptionMenu(); } }); // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。 wx.error(function (res) { /*if(res.errMsg == 'config:invalid signature'){ wx.hideOptionMenu(); }else if(res.errMsg == 'config:invalid url domain'){ wx.hideOptionMenu(); }else{ wx.hideOptionMenu(); //alert(res.errMsg); }*/ if(res.errMsg){ wx.hideOptionMenu(); } alert(res+'打开失败,请联系管理员!'); }); function shareHandle(to) { var submitData = { module: window.shareData.moduleName, moduleid: window.shareData.moduleID, token:'xdgkiy1444014268', wecha_id:'', url: window.shareData.sendFriendLink, to:to }; $.post('index.php?g=Wap&m=Share&a=shareData&token=xdgkiy1444014268&wecha_id=',submitData,function (data) {},'json'); if(window.shareData.isShareNum == 1){ var ShareNum = { token:'xdgkiy1444014268', ShareNumData:window.shareData.ShareNumData } $.post('index.php?g=Wap&m=Share&a=ShareNum&token=xdgkiy1444014268&wecha_id=',ShareNum,function (data) {},'json'); } } </script>

你可能感兴趣的:(JavaScript,微信,调试)