You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
3.1 KiB
64 lines
3.1 KiB
11 months ago
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||
|
<title>扫一扫</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
|
||
|
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.min.js"></script>
|
||
|
<script src="https://cdn.bootcdn.net/ajax/libs/Base64/1.1.0/base64.min.js"></script>
|
||
|
<script>
|
||
|
// var wxUrl = location.protocol + "//" + location.host + "/scan/ele-myinvoice/wx/getJsSdk?reqUrl=" + 'https://bxsdk-pre.ele-cloud.com';
|
||
|
var wxUrl=location.protocol + "//" + location.host +'/scan/ele-myinvoice/wx/getJsSdk?reqUrl='+ window.location.href;//window.location.href.split('toPath=')[1]
|
||
|
//alert('鉴权接口'+wxUrl)
|
||
|
axios.get(wxUrl).then((res) => {
|
||
|
console.log("getWXconfig" + JSON.stringify(res));//请求的返回体
|
||
|
var result;
|
||
|
if (typeof res === 'string') {
|
||
|
result = JSON.parse(res);
|
||
|
} else {
|
||
|
result = res;
|
||
|
}
|
||
|
//alert('扫一扫获取鉴权信息'+JSON.stringify(result.data))
|
||
|
// window.location.href=window.location.href.split('toPath=')[1]+'?qrData='+ JSON.stringify(result.data);
|
||
|
var wxConfig = {
|
||
|
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||
|
appId: result.data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
|
||
|
timestamp: result.data.timestamp, // 必填,生成签名的时间戳
|
||
|
nonceStr: result.data.nonceStr, // 必填,生成签名的随机串
|
||
|
signature: result.data.signature, // 必填,签名
|
||
|
jsApiList: ['scanQRCode'] // 必填,需要使用的JS接口列表
|
||
|
};
|
||
|
// console.log("wxConfig" + JSON.stringify(wxConfig))
|
||
|
wx.config(wxConfig);
|
||
|
wx.ready(function () {
|
||
|
console.log('wx ready')
|
||
|
wx.scanQRCode({
|
||
|
debug: true,
|
||
|
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
|
||
|
scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
|
||
|
success: function (res) {
|
||
|
console.log("qrCode-Result" + JSON.stringify(res));
|
||
|
window.location.href=window.location.href.split('toPath=')[1]+'?qrData='+ JSON.stringify(res);
|
||
|
},
|
||
|
error: function (res) {
|
||
|
alert("scanQRCode-error" + res)
|
||
|
},
|
||
|
cancel: function(res){
|
||
|
// 用户取消操作
|
||
|
window.location.href=window.location.href.split('toPath=')[1];
|
||
|
}
|
||
|
})
|
||
|
});
|
||
|
wx.error(function (res) {
|
||
|
console.log('错误信息',res)
|
||
|
})
|
||
|
}).catch((error) => {
|
||
|
console.log(error);//异常
|
||
|
});
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|