WeChat隠し共有js
8773 ワード
<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>