锘?function ($) { var appId, timeStamp, nonceStr, signature, imgUrl, title, desc; if (isWeiXinBrowser() && checkWeixinShareEnable()) { getWeixinShareParameters(); } function setImgUrl() { imgUrl = $('meta[name="Image"]').attr("content"); } function setTitle() { title = $('meta[name="ArticleTitle"]').attr('content'); } function setDesc() { title = $('meta[name="description"]').attr('content'); } function getWeixinShareParameters() { setImgUrl(); setTitle(); setDesc(); if (imgUrl || title || desc) { $.ajax({ type: "get", url: "/weixin/home/AjaxGetWeixinShareParameters", dataType: 'json', async: false, data: { currentUrl: getSharedUrl() }, success: function (data) { if (data !== false) { appId = data.appId; timeStamp = data.timestamp; nonceStr = data.nonceStr; signature = data.signature; setWxConfig(); } } }); } } function setWxConfig() { wx.config({ debug: false, // 寮€鍚皟璇曟ā寮?璋冪敤鐨勬墍鏈塧pi鐨勮繑鍥炲€间細鍦ㄥ鎴风alert鍑烘潵锛岃嫢瑕佹煡鐪嬩紶鍏ョ殑鍙傛暟锛屽彲浠ュ湪pc绔墦寮€锛屽弬鏁颁俊鎭細閫氳繃log鎵撳嚭锛屼粎鍦╬c绔椂鎵嶄細鎵撳嵃銆 appId: appId, // 蹇呭~锛屽叕浼楀彿鐨勫敮涓€鏍囪瘑 timestamp: timeStamp, // 蹇呭~锛岀敓鎴愮鍚嶇殑鏃堕棿鎴 nonceStr: nonceStr, // 蹇呭~锛岀敓鎴愮鍚嶇殑闅忔満涓 signature: signature, // 蹇呭~锛岀鍚 jsApiList: [ "checkJsApi", 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem', 'translateVoice', 'startRecord', 'stopRecord', 'onRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'uploadVoice', 'downloadVoice', 'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'getNetworkType', 'openLocation', 'getLocation', 'hideOptionMenu', 'showOptionMenu', 'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard' ] }); wx.error(function (res) { console.log(res); console.warn('寰俊楠岃瘉澶辫触锛屽垎浜姛鑳芥棤娉曟甯镐娇鐢紒'); }); wx.ready(function () { wx.onMenuShareTimeline({ title: title, desc: desc, imgUrl: imgUrl }); wx.onMenuShareAppMessage({ title: title, desc: desc, imgUrl: imgUrl }); }); } function isWeiXinBrowser() { var userAgent = window.navigator.userAgent.toLowerCase(); if (userAgent.match(/MicroMessenger/i) == 'micromessenger') { return true; } else { return false; } } function checkWeixinShareEnable() { var siteId = $("meta[name=SiteId]").attr("content"); var weixinShareItem = window.POWER_WEIXINSHARE_CONFIG && window.POWER_WEIXINSHARE_CONFIG.WeixinShareItems && window.POWER_WEIXINSHARE_CONFIG.WeixinShareItems[siteId]; return weixinShareItem; } function getSharedUrl() { var hrefUrl = location.href; var query = location.search; if (query) { if (query.indexOf('SessionVerify=') > -1) { return location.origin + location.pathname; } } return hrefUrl; } })(jQuery);