我前端调用扫一扫接口,莫得反应是怎么回事,,获取签名什么的都成功了,,debug 也没用弹出信息
url: '请求签名的后台地址',
method: "post",
xhrFields: {
withCredentials: true
},
data: pageUrl,//获取当前页面路径
dataType: "json",
cache: false,//第一次请求完毕之后,如果再次去请求,可以直接从缓存里面读取而不是再到服务器端读取
success: function(data) {
console.log(data)
console.log(pageUrl.url)
console.log(data.nonceStr)
// //alert(data.member.nickName);
wx.config({
debug:true,
// 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出, 仅在pc端时才会打印。
appId: data.appID,
// 必填,公众号的唯一标识
timestamp: data.timestamp,
// 必填,生成签名的时间戳
nonceStr: data.nonceStr,
// 必填,生成签名的随机串
signature: data.signature,
// 必填,签名,见附录1
jsApiList: ["scanQRCode"] // 必填,需要使用的JS接口列表,
});
console.log(wx);
wx.error(function(res){
alert("错误信息== " + res.errMsg);
});
wx.ready(function(){
console.log("----------------------")
wx.scanQRCode({
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码,默认二者都有
success: function (res) {
var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
alert(result);
}
});
});
}
});