(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-144200070-1', 'auto'); ga('set', 'displayFeaturesTask', null); ga('send', 'pageview');
WX_Custom_Share = function(){ var xhr = null; var url = 'http://www.zhoufuweb.com/wp-admin/admin-ajax.php'; var signature_url = window.location.href.split('#')[0]; var formData = { action: 'wxcs_get_share_info', type: 'post', id: '1719', signature_url: signature_url }; this.init = function(){ if( window.XMLHttpRequest ){ xhr = new XMLHttpRequest(); } else if( window.ActiveXObject ){ xhr = new ActiveXObject('Microsoft.XMLHTTP'); } get_share_info(); } function formatPostData( obj ){ var arr = new Array(); for (var attr in obj ){ arr.push( encodeURIComponent( attr ) + '=' + encodeURIComponent( obj[attr] ) ); } return arr.join( '&' ); } function get_share_info(){ if( xhr == null ) return; xhr.onreadystatechange = function(){ if( xhr.readyState == 4 && xhr.status == 200 ){ var data = eval('(' + xhr.responseText + ')'); if( data == null ){ return; } var info = { title: data.title, summary: data.desc, pic: data.img, url: data.url }; if( formData.type == 'other' ){ info.title = document.title; info.summary = location.href; info.url = location.href; } if( data.use_actual_url == true ){ info.url = location.href; } if( data.error ){ console.error( '自定义微信分享: ', data.error ); } else if( data.appid ){ info.WXconfig = { swapTitleInWX: data.swapTitleInWX, appId: data.appid, timestamp: data.timestamp, nonceStr: data.nonceStr, signature: data.signature }; } setShareInfo( info ); } }; xhr.open( 'POST', url, true); xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); xhr.send( formatPostData( formData ) ); } } new WX_Custom_Share().init();