313 lines
14 KiB
HTML
313 lines
14 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title></title>
|
||
<!-- <script type="text/javascript" src="https://saas.eshangtech.com/goaliPay/wanmeiyizhan.js"></script> -->
|
||
<!-- <script type="text/javascript" src="https://saas.eshangtech.com/goaliPay/wanmeiyizhan.js"></script> -->
|
||
<!-- <script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
|
||
<script type="text/javascript" src="https://eshangtech.com/goaliPay/wanmeiyizhanwx.js"></script>
|
||
|
||
<script>
|
||
// var url = window.location.href.split('#')[0]
|
||
// console.log('url',url);
|
||
// let noncestr = Math.random().toString(36).substr(2, 15);
|
||
// let time = Math.floor(Date.now() / 1000);
|
||
// let currentUrl = url
|
||
// fetch(`https://api.eshangtech.com/EShangApiMain/WeChat/GetJsapiTicket?appId=wxcf4dbe1815d5d872&sourcePlatform=publicprogram`,{
|
||
// method:"GET",
|
||
// headers:{
|
||
// "Content-Type":"application/json; charset=utf-8"
|
||
// }
|
||
// }).then(response => response.json()).then(config => {
|
||
// console.log('config',config);
|
||
// fetch(`https://api.eshangtech.com/EShangApiMain/WeChat/GetConfigSignature`,{
|
||
// method:"POST",
|
||
// body:JSON.stringify({
|
||
// jsapi_ticket: config.Result_Data,
|
||
// timestamp: time,
|
||
// noncestr: noncestr,
|
||
// url:currentUrl,
|
||
// jsApiList: ["getLocation","scanQRCode","openLocation"],
|
||
// // "openLocation", "getLocation",
|
||
// }),
|
||
// headers:{
|
||
// "Content-Type":"application/json; charset=utf-8"
|
||
// }
|
||
// }).then(response2 => response2.json()).then(config2 => {
|
||
// console.log('config2',config2);
|
||
// console.log('config3',JSON.stringify({
|
||
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||
// appId: 'wxcf4dbe1815d5d872', // 必填,公众号的唯一标识
|
||
// timestamp: time, // 必填,生成签名的时间戳
|
||
// nonceStr: noncestr, // 必填,生成签名的随机串
|
||
// signature: config2.Result_Data,// 必填,签名
|
||
// jsApiList: ["scanQRCode"]// 必填,需要使用的JS接口列表
|
||
// // "openLocation", "getLocation",
|
||
// }));
|
||
|
||
|
||
// wx.config({
|
||
// url:currentUrl,
|
||
// // debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||
// appId: 'wxcf4dbe1815d5d872', // 必填,公众号的唯一标识
|
||
// timestamp: time, // 必填,生成签名的时间戳
|
||
// nonceStr: noncestr, // 必填,生成签名的随机串
|
||
// signature: config2.Result_Data,// 必填,签名
|
||
// jsApiList: ["getLocation","scanQRCode","openLocation"]// 必填,需要使用的JS接口列表
|
||
// // "openLocation", "getLocation",
|
||
// })
|
||
|
||
// wx.ready(function(){
|
||
// // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
|
||
// });
|
||
|
||
// wx.error(function(res){
|
||
// // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
|
||
// });
|
||
// })
|
||
// })
|
||
|
||
|
||
|
||
|
||
// ----------------------------------------小程序端测试开始-----------------------------------------------
|
||
window.onload = function() {
|
||
|
||
|
||
|
||
|
||
// console.log('window.location',window.location);
|
||
// let str = window.location.hash.replace('#', "")
|
||
// let url = window.location.href.split('#')[0]
|
||
// console.log('str', str);
|
||
// let res = decodeURIComponent(str)
|
||
// if (res) {
|
||
// res = JSON.parse(res)
|
||
// }
|
||
// console.log('res',res);
|
||
// console.log('config',
|
||
// {
|
||
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||
// appId: res.appId, // 必填,公众号的唯一标识
|
||
// timestamp: res.timestamp, // 必填,生成签名的时间戳
|
||
// nonceStr: res.nonceStr, // 必填,生成签名的随机串
|
||
// signature: res.result,// 必填,签名
|
||
// url:res.url,
|
||
// jsApiList: ["openLocation", "getLocation", "scanQRCode"]// 必填,需要使用的JS接口列表
|
||
// });
|
||
// wx.config({
|
||
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||
// appId: 'wxcf4dbe1815d5d872', // 必填,公众号的唯一标识
|
||
// timestamp: res.timestamp, // 必填,生成签名的时间戳
|
||
// nonceStr: res.nonceStr, // 必填,生成签名的随机串
|
||
// signature: res.result,// 必填,签名
|
||
// url:res.url,
|
||
// jsApiList: ["openLocation", "getLocation", "scanQRCode"]// 必填,需要使用的JS接口列表
|
||
// });
|
||
|
||
|
||
|
||
// let noncestr = Math.random().toString(36).substr(2, 15);
|
||
// let time = Math.floor(Date.now() / 1000);
|
||
|
||
// fetch(`https://api.eshangtech.com/EShangApiMain/WeChat/GetJsapiTicket?appId=wx4c497eddcec4a0e7&sourcePlatform=minprogram`,{
|
||
// method:"GET",
|
||
// headers:{
|
||
// "Content-Type":"application/json; charset=utf-8"
|
||
// }
|
||
// }).then(response => response.json()).then(config => {
|
||
// console.log('config',config);
|
||
// fetch(`https://api.eshangtech.com/EShangApiMain/WeChat/GetConfigSignature`,{
|
||
// method:"POST",
|
||
// body:JSON.stringify({
|
||
// jsapi_ticket: config.Result_Data,
|
||
// timestamp: time,
|
||
// noncestr: noncestr,
|
||
// url:"https://saas.eshangtech.com/goaliPay/testwx.html"
|
||
// }),
|
||
// headers:{
|
||
// "Content-Type":"application/json; charset=utf-8"
|
||
// }
|
||
// }).then(response => response.json()).then(config => {
|
||
// console.log('config2',config);
|
||
// wx.config({
|
||
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||
// appId: 'wx4c497eddcec4a0e7', // 必填,公众号的唯一标识
|
||
// timestamp: time, // 必填,生成签名的时间戳
|
||
// nonceStr: noncestr, // 必填,生成签名的随机串
|
||
// signature: config.Result_Data,// 必填,签名
|
||
// url:url,
|
||
// // jsApiList: ["openLocation", "getLocation", "scanQRCode"]// 必填,需要使用的JS接口列表
|
||
// });
|
||
// })
|
||
// })
|
||
|
||
|
||
|
||
|
||
|
||
const userInfoWXButton = document.getElementById('userInfoWX');
|
||
const getLocationWXButton = document.getElementById('getLocationWX');
|
||
const scanQRCodeWXButton = document.getElementById('scanQRCodeWX');
|
||
const openLocationWXButton = document.getElementById('openLocationWX');
|
||
const openNewPageWXButton = document.getElementById('openNewPageWX');
|
||
const navigateBackWXButton = document.getElementById('navigateBackWX');
|
||
|
||
// 获取用户信息
|
||
userInfoWXButton.addEventListener('click', function() {
|
||
wmyz_app.uniApi({
|
||
apiName: 'getStorageSync',
|
||
params: 'userInfo',
|
||
success: (res) => {
|
||
document.getElementById("getStorageSync").innerText = JSON.stringify(res)
|
||
}
|
||
})
|
||
})
|
||
|
||
|
||
// 获取经纬度位置
|
||
getLocationWXButton.addEventListener('click', function() {
|
||
// wx.getLocation({
|
||
// type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
|
||
// success: function (res) {
|
||
// console.log('res',res);
|
||
// document.getElementById("getLocationText").innerText = JSON.stringify(res)
|
||
// }
|
||
// })
|
||
console.log('获取经纬度位置');
|
||
wmyz_app.uniApi({
|
||
apiName: 'getLocation',
|
||
params: {
|
||
type: 'gcj02',
|
||
success: (res) => {
|
||
console.log('当前位置的经度:' + res.longitude);
|
||
console.log('当前位置的纬度:' + res.latitude);
|
||
document.getElementById("getLocationText").innerText = JSON.stringify(res)
|
||
}
|
||
}
|
||
})
|
||
})
|
||
|
||
// 扫一扫
|
||
scanQRCodeWXButton.addEventListener('click', function() {
|
||
wmyz_app.uniApi({
|
||
apiName: 'scanCode',
|
||
params: {
|
||
success: (res) => {
|
||
console.log('条码类型:' + res.scanType);
|
||
console.log('条码内容:' + res.result);
|
||
document.getElementById("scanQRCodeText").innerText = JSON.stringify(res)
|
||
}
|
||
}
|
||
})
|
||
// wx.scanQRCode({
|
||
// needResult: 0, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
|
||
// scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码,默认二者都有
|
||
// success: function (res) {
|
||
// console.log('res',res);
|
||
// var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
|
||
// document.getElementById("scanQRCodeText").innerText = JSON.stringify(res)
|
||
// }
|
||
// })
|
||
})
|
||
|
||
// 打开第三方位置
|
||
openLocationWXButton.addEventListener('click', function() {
|
||
document.getElementById("openLocationText").innerText = JSON.stringify({
|
||
latitude:'31.920213',
|
||
longitude:'116.894166',
|
||
name:"新桥服务区",
|
||
})
|
||
wmyz_app.uniApi({
|
||
apiName: 'openLocation',
|
||
params: {
|
||
latitude:31.920213,
|
||
longitude:116.894166,
|
||
name:"新桥服务区",
|
||
}
|
||
})
|
||
|
||
|
||
|
||
// wx.openLocation({
|
||
// latitude: '31.920213', // 纬度,浮点数,范围为90 ~ -90
|
||
// longitude: '116.894166', // 经度,浮点数,范围为180 ~ -180。
|
||
// name: "新桥服务区", // 位置名
|
||
// address: '', // 地址详情说明
|
||
// scale: 16, // 地图缩放级别,整型值,范围从1~28。默认为最大
|
||
// infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
|
||
// })
|
||
})
|
||
|
||
// 打开新页面
|
||
openNewPageWXButton.addEventListener('click', function() {
|
||
wmyz_app.uniApi({
|
||
apiName: 'openNewPage',
|
||
params: {
|
||
url:"https://ahyd.eshangtech.com/robot/",
|
||
title:'新页面'
|
||
}
|
||
})
|
||
|
||
// wx.miniProgram.navigateTo({
|
||
// url:`/pages/thirdParty/newPage?url=https://ahyd.eshangtech.com/robot/&title=新页面`
|
||
// // url:"",
|
||
// // title:''
|
||
// })
|
||
})
|
||
|
||
// 返回上一页面
|
||
|
||
navigateBackWXButton.addEventListener('click', function() {
|
||
wmyz_app.uniApi({
|
||
apiName: 'navigateBack',
|
||
})
|
||
// wx.miniProgram.navigateBack({
|
||
// delta:1
|
||
// })
|
||
})
|
||
|
||
|
||
|
||
// wx.miniProgram.navigateTo({url: '/pages/home/index'})
|
||
// wx.getLocation({
|
||
// type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
|
||
// success: function (res) {
|
||
// console.log('r大萨达手打es',res);
|
||
// document.getElementById("content").innerText = res
|
||
// }
|
||
// });
|
||
// });
|
||
|
||
}
|
||
|
||
// ----------------------------------------小程序端测试结束-----------------------------------------------
|
||
</script>
|
||
</head>
|
||
<body>
|
||
|
||
<button id="userInfoWX">获取用户信息</button>
|
||
<button id="getLocationWX">获取经纬度位置</button>
|
||
<button id="scanQRCodeWX">扫一扫</button>
|
||
<button id="openLocationWX">打开第三方位置</button>
|
||
<button id="openNewPageWX">打开新页面</button>
|
||
<button id="navigateBackWX">返回上一页面</button>
|
||
|
||
|
||
<div id="content">
|
||
<div id="getStorageSync"></div>
|
||
<div id="getLocationText"></div>
|
||
<div id="scanQRCodeText"></div>
|
||
<div id="openLocationText"></div>
|
||
</div>
|
||
|
||
<!-- <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
|
||
<!-- <script type="text/javascript" src="https://saas.eshangtech.com/goaliPay/wanmeiyizhanwx.js"></script> -->
|
||
<!-- <script type="text/javascript" src="https://saas.eshangtech.com/goaliPay/uniapp.js"></script> -->
|
||
</body>
|
||
<style>
|
||
</style>
|
||
</html>
|