data传入参数
正确写法: data: {"requestUrl":url}
错误写法: data: "requestUrl="+url}
部分代码:
function onLoadShareConf() {
var url = window.location.href;
alert(url);
$.ajax({
type: "POST",
url: "**********/xph/shareConf.do",
dataType : "json",
contentType : "application/x-www-form-urlencoded; charset=utf-8",
data: {"requestUrl":url},
success: function(data){
console.log(data);
wx.config({
debug : true,
appId : data.appId,
timestamp : data.timestamp,
nonceStr : data.nonceStr,
signature : data.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" ]
});
}
});
}
function share(){
wx.ready(function(){
wx.onMenuShareTimeline({
title: "测试分享朋友圈功能", // 分享标题
link: "*************/myshare/beforeshare.do",// 分享链接
imgUrl: "**************/img/myshare.jpg", // 分享图标
success: function () { // 用户确认分享后执行的回调函数 记录分享的次数
alert("123");
},
cancel: function () { // 用户取消分享后执行的回调函数
alert('取消分享成功!');
}
});
//分享给朋友
wx.onMenuShareAppMessage({
title: "",
desc: "",
link: "********/myshare/beforeshare.do",
imgUrl: "*************/img/myshare.jpg",
success: function () {
alert("123321");
},
cancel: function () {
// 用户取消分享后执行的回调函数
}
});
});
}