Code
share:function(t){
var _this=this;
var strUrl = location.href.split('#')[0];
var img=_this.$(".weixinimg").attr("src");
var WXDate={
timestamp:'1497234052',
nonceStr:'e40ac141-7338-49e6-b49c-c255041abe6a',
jsapi_ticket:'',//寫(xiě)死了
signature:'', //寫(xiě)死了
url:'http://www.bjiponline.com'
};
wxconifg(WXDate);
/*$.ajax({
type: "Post",
url: "config.aspx/GetKey",
//方法傳參的寫(xiě)法一定要對(duì),strUrl為形參的名字
data: "{'str':'" + strUrl + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
//返回的數(shù)據(jù)用data.d獲取內(nèi)容
$("#wx-share-sign").val(data.d.signature);
wxconifg(data.d);
},
error: function (err) {
alert('55');
}
});*/
function wxconifg(WXDate) {
wx.config({
debug: true,
appId: 'wxfb42c31ca406c63f',
timestamp: WXDate.timestamp,
nonceStr: WXDate.nonceStr,
signature: WXDate.signature,
jsApiList: ["checkJsApi", "onMenuShareTimeline", "onMenuShareAppMessage"]
});
wx.ready(function () {
wx.checkJsApi({
jsApiList: [
'getLocation',
'onMenuShareTimeline',
'onMenuShareAppMessage'
],
success: function (res) {
console.log(res);
}
});
_this.$("#onMenuShareTimeline").click(function(){
alert(11)
wx.onMenuShareAppMessage({
title: t,
desc: t,
link: WXDate.url,
imgUrl: img,
trigger: function (res) {
},
success: function (res) {
alert('成功')
},
cancel: function (res) {
},
fail: function (res) {
alert(JSON.stringify(res));
}
});
});
_this.$("#onMenuShareAppMessage").click(function(){
//分享到朋友圈
wx.onMenuShareTimeline({
title: t,
desc: t,
link: WXDate.url,
imgUrl: img,
type: 'link',
dataUrl: strUrl,
trigger: function (res) {
},
success: function (res) {
alert('成功')
},
cancel: function (res) {
},
fail: function (res) {
alert(JSON.stringify(res));
}
});
});
wx.error(function(res){
alert('驗(yàn)證失敗')
});
});
}
},
I am testing now. So the signatures and other things used are all generated by myself and hard-coded in js, but now they are executed when all my functions are executed, but what is particularly strange is that there is no indication of success or failure, but this ## is displayed in the browser.
Make it clear that the essence of jssdk is that it only configures information such as titles, descriptions, pictures, etc. for you, rather than doing all the actions for you like a plug-in