2025-01-15 18:39:05 +08:00

338 lines
10 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>
// ----------------------------------------小程序端测试开始-----------------------------------------------
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)
// }
// 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:url
// }),
// 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 openNewPageWXButton = document.getElementById('openNewPageWX');
// // 获取位置
// openNewPageWXButton.addEventListener('click', function() {
// wx.getLocation({
// type: 'wgs84', // 默认为wgs84的gps坐标如果要返回直接给openLocation用的火星坐标可传入'gcj02'
// success: function (res) {
// console.log('r大萨达手打es',res);
// document.getElementById("content").innerText = res
// }
// });
// });
}
// ----------------------------------------小程序端测试结束-----------------------------------------------
// -----------------------------------APP端测试开始---------------------------------------
window.onload = function() {
let str = window.location.hash.replace('#', "")
console.log('str', str);
let res = decodeURIComponent(str)
if (res) {
res = JSON.parse(res)
}
console.log('res323123', res);
console.log('res323123', JSON.stringify(res));
// 获取按钮元素
const userInfoButton = document.getElementById('userInfo');
const positionButton = document.getElementById('position');
const scanButton = document.getElementById('scanCode');
const openLocationButton = document.getElementById('openLocation');
const openNewPageButton = document.getElementById('openNewPage');
const openNewPageWXButton = document.getElementById('openNewPageWX');
const backPageButton = document.getElementById('backPage');
userInfoButton.addEventListener('click', function() {
// 获取用户信息
// wmyz_app.handleGetPosition().then(result=>{
// // {
// // "latitude":30.301017,
// // "longitude":120.222985
// // }
// })
wmyz_app.uniApi({
apiName: 'getStorageSync',
params: 'userInfo',
success: (res) => {
console.log('USER_INFO', JSON.stringify(res) )
const contentBox = document.getElementById('content')
contentBox.innerText = res
// {
// ....,
// MEMBERSHIP_MOBILEPHONE:*****
// }
}
})
});
positionButton.addEventListener('click', function() {
// 获取位置
// wmyz_app.handleGetPosition().then(result=>{
// // {
// // "latitude":30.301017,
// // "longitude":120.222985
// // }
// })
wmyz_app.uniApi({
apiName: 'getLocation',
params: {
type: 'wgs84',
success: (res) => {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
}
}
})
});
scanButton.addEventListener('click', function() {
// 扫一扫
// wmyz_app.handleScanCode().then(res=>{
// // {
// // "scanType":"QR_CODE",
// // "path":"",
// // "charSet":"ISO8859_1",
// // "result":"21487001748451870946074",
// // "errMsg":"scanCode:ok"
// // }
// })
wmyz_app.uniApi({
apiName: 'scanCode',
params: {
success: (res) => {
// {
// scanType:'',
// result:''
// }
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
}
}
})
});
openLocationButton.addEventListener('click', function() {
// 打开第三方导航
// wmyz_app.handleOpenLocation({
// latitude:'31.920213',
// longitude:'116.894166',
// name:"新桥服务区",
// })
wmyz_app.uniApi({
apiName: 'openLocation',
params: {
latitude:'31.920213',
longitude:'116.894166',
name:"新桥服务区",
}
})
});
openNewPageButton.addEventListener('click', function() {
// 打开新页面 原页面有标题 会被顶掉title的值
// wmyz_app.handleOpenNewPage({
// title:'新页面',
// url:'https://ahyd.eshangtech.com/robot/',
// })
wmyz_app.uniApi({
apiName: 'openNewPage',
params: {
url:"https://ahyd.eshangtech.com/robot/",
title:'新页面'
}
})
});
backPageButton.addEventListener('click', function() {
// 返回上一页面
// wmyz_app.handleBackPage()
wmyz_app.uniApi({
apiName: 'navigateBack',
})
});
// // 小程序的打开新页面
// openNewPageWXButton.addEventListener('click', function() {
// wx.miniProgram.navigateTo({url: '/pages/home/index'})
// });
};
// -----------------------------------APP端测试截止------------------------------------------
// window.addEventListener('popstate', function() {
// console.log('URL 改变,当前路径:', window.location.href);
// // 处理变化
// });
// window.addEventListener('hashchange', function() {
// console.log('Hash 值已改变:', window.location.hash);
// // 处理变化
// });
// document.addEventListener('UniAppJSBridgeReady', function() {
// uni.postMessage({
// data:{
// action: 'scanCode'
// }
// });
// console.log('当前环境:')
// console.log('页面加载时,当前 URL:', window.location.href);
// // uni.webView.getEnv(function(res) {
// // });
// });
// window.addEventListener('message', function(event) {
// const data = event.data;
// console.log('收到来自 Vue 页面的数据:', data);
// // 处理接收到的数据
// });
// window.addEventListener('message', (event) => {
// if (event.data.type === 'fromUniApp') {
// console.log('Received message from uni-app:', event.data.message);
// }
// });
// window.parent.postMessage({
// type: 'fromH5Page',
// message: 'Hello from H5!',
// }, '*');
// window.onload = function () {
// WeixinJSBridge.on('onPageStateChange', function(res) {
// console.log('res is active', res.active)
// })
// console.log('window',window);
// window.parent.postMessage({
// type: 'messageFromH5',
// content: 'Hello from H5'
// }, '*');
// };
// window.onload = function () {
// const iframe = document.createElement('iframe');
// iframe.style.display = 'none';
// iframe.src = 'alipays://platformapi/startapp?appId=20000056'; // 支付宝的 URL Scheme
// document.body.appendChild(iframe);
// // 如果支付宝未安装,跳转到支付宝下载页面
// setTimeout(function () {
// window.location.href = 'https://d.alipay.com'; // 跳转到支付宝下载页
// }, 2000); // 等待2秒后跳转
// };
</script>
</head>
<body>
<button id="userInfo">获取用户信息</button>
<button id="position">获取经纬度</button>
<button id="scanCode">扫码</button>
<button id="openLocation">打开第三方导航</button>
<button id="openNewPage">打开新页面</button>
<button id="backPage">返回上一页面</button>
<button id="openNewPageWX">小程序跳转</button>
<!-- <button id="openNewPageWX">小程序获取经纬度</button> -->
<div id="content"></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>