锘縱ar appIdstr = ''; var timestampstr; var nonceStrstr = ''; var signaturestr = ''; var cururl = window.location.href; //alert(cururl) //$("#wx-share-link").val(cururl); function getWeiXin() { $.ajax({ url: '/data/getdata.ashx?op=4&cururl=' + escape(cururl) + '×temp=' + new Date().getTime(), type: 'GET', dataType: "json", async: false, error: function () { }, success: function (data) { if (data.msg == 1) { appIdstr = data.appId; timestampstr = data.timestamp; nonceStrstr = data.nonceStr; signaturestr = data.signature; wx.config({ debug: false, appId: appIdstr, timestamp: timestampstr, nonceStr: nonceStrstr, signature: signaturestr, jsApiList: [ 'checkJsApi', 'updateTimelineShareData', 'updateAppMessageShareData', //'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' ] }); doWeixin(); } } }); } wx.checkJsApi({ jsApiList: ['updateTimelineShareData','updateAppMessageShareData'], // 闇€瑕佹娴嬬殑JS鎺ュ彛鍒楄〃锛屾墍鏈塉S鎺ュ彛鍒楄〃瑙侀檮褰?, success: function (res) { //alert(res.checkResult) //alert(res.errMsg) // 浠ラ敭鍊煎鐨勫舰寮忚繑鍥烇紝鍙敤鐨刟pi鍊紅rue锛屼笉鍙敤涓篺alse // 濡傦細{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"} } }) function doWeixin() { wx.ready(function () { wx.updateAppMessageShareData({ title: document.getElementById('wx-share-title').value, // 鍒嗕韩鏍囬 desc: document.getElementById('wx-share-title').value, // 鍒嗕韩鎻忚堪 link: window.location.href + '&v=11', // 鍒嗕韩閾炬帴锛岃閾炬帴鍩熷悕鎴栬矾寰勫繀椤讳笌褰撳墠椤甸潰瀵瑰簲鐨勫叕浼楀彿JS瀹夊叏鍩熷悕涓€鑷 imgUrl: ''+document.getElementById('wx-share-img').value, // 鍒嗕韩鍥炬爣 success: function () { //alert('鍙戦€佹湅鍙嬭缃垚鍔?) } }) wx.updateTimelineShareData({ title: document.getElementById('wx-share-title').value, link: window.location.href +'&v=11', imgUrl: ''+document.getElementById('wx-share-img').value, success: function () { //alert('鍒嗕韩璁剧疆鎴愬姛') } }) wx.onMenuShareWeibo({ title: document.getElementById('wx-share-title').value, link: window.location.href, imgUrl: '' +document.getElementById('wx-share-img').value, desc: document.getElementById('wx-share-title').value, // 鍒嗕韩鎻忚堪 success: function () { // 鐢ㄦ埛纭鍒嗕韩鍚庢墽琛岀殑鍥炶皟鍑芥暟 }, cancel: function () { // 鐢ㄦ埛鍙栨秷鍒嗕韩鍚庢墽琛岀殑鍥炶皟鍑芥暟 } }); }); } //function doWeixin() { // wx.ready(function () { // var sharebackurl =document.getElementById('sharebackurl').value; // // 2. 鍒嗕韩鎺ュ彛 // // 2.1 鐩戝惉"鍒嗕韩缁欐湅鍙?锛屾寜閽偣鍑汇€佽嚜瀹氫箟鍒嗕韩鍐呭鍙婂垎浜粨鏋滄帴鍙 // // document.querySelector('#onMenuShareAppMessage').onclick = function () { // wx.onMenuShareAppMessage({ // title: document.getElementById('wx-share-title').value, // desc: document.getElementById('wx-share-desc').value, // link: document.getElementById("wx-share-link").value, // imgUrl: document.getElementById('wx-share-img').value, // trigger: function (res) { // // alert('鐢ㄦ埛鐐瑰嚮鍙戦€佺粰鏈嬪弸'); // }, // success: function (res) { // // alert('宸插垎浜?); // var image=new Image(); // image.src=sharebackurl; // }, // cancel: function (res) { // //alert('宸插彇娑?); // }, // fail: function (res) { // //alert(JSON.stringify(res)); // } // }); // // }; // // 2.2 鐩戝惉"鍒嗕韩鍒版湅鍙嬪湀"鎸夐挳鐐瑰嚮銆佽嚜瀹氫箟鍒嗕韩鍐呭鍙婂垎浜粨鏋滄帴鍙 // //document.querySelector('#onMenuShareTimeline').onclick = function () { // wx.updateTimelineShareData({ // title: document.getElementById('wx-share-title').value, // link: document.getElementById("wx-share-link").value, // imgUrl: document.getElementById('wx-share-img').value, // trigger: function (res) { // alert('鐢ㄦ埛鐐瑰嚮鍒嗕韩鍒版湅鍙嬪湀'); // }, // success: function (res) { // alert('ok'); // // var image=new Image(); // //image.src=sharebackurl; // }, // cancel: function (res) { // alert('宸插彇娑?); // }, // fail: function (res) { // alert(JSON.stringify(res)); // } // }); // // alert('宸叉敞鍐岃幏鍙?鍒嗕韩鍒版湅鍙嬪湀"鐘舵€佷簨浠?); // //}; // // 2.3 鐩戝惉"鍒嗕韩鍒癚Q"鎸夐挳鐐瑰嚮銆佽嚜瀹氫箟鍒嗕韩鍐呭鍙婂垎浜粨鏋滄帴鍙 // //document.querySelector('#onMenuShareQQ').onclick = function () { // wx.onMenuShareQQ({ // title: document.getElementById('wx-share-title').value, // desc: document.getElementById('wx-share-desc').value, // link: document.getElementById("wx-share-link").value, // imgUrl: document.getElementById('wx-share-img').value, // trigger: function (res) { // // alert('鐢ㄦ埛鐐瑰嚮鍒嗕韩鍒癚Q'); // }, // complete: function (res) { // //alert(JSON.stringify(res)); // }, // success: function (res) { // var image=new Image(); // image.src=sharebackurl; // }, // cancel: function (res) { // // alert('宸插彇娑?); // }, // fail: function (res) { // //alert(JSON.stringify(res)); // } // }); // // alert('宸叉敞鍐岃幏鍙?鍒嗕韩鍒 QQ"鐘舵€佷簨浠?); // // }; // // 2.4 鐩戝惉"鍒嗕韩鍒板井鍗?鎸夐挳鐐瑰嚮銆佽嚜瀹氫箟鍒嗕韩鍐呭鍙婂垎浜粨鏋滄帴鍙 // // document.querySelector('#onMenuShareWeibo').onclick = function () { // wx.onMenuShareWeibo({ // title: document.getElementById('wx-share-title').value, // desc: document.getElementById('wx-share-desc').value, // link: document.getElementById("wx-share-link").value, // imgUrl: document.getElementById('wx-share-img').value, // trigger: function (res) { // //alert('鐢ㄦ埛鐐瑰嚮鍒嗕韩鍒板井鍗?); // }, // complete: function (res) { // // alert(JSON.stringify(res)); // }, // success: function (res) { // var image=new Image(); // image.src=sharebackurl; // }, // cancel: function (res) { // //alert('宸插彇娑?); // }, // fail: function (res) { // // alert(JSON.stringify(res)); // } // }); //}); //} //doWeixin();