hn-hlw-pc/public/hnhlw.html

73 lines
2.1 KiB
HTML
Raw Normal View History

2026-07-31 18:26:54 +08:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>海宁互联网医院</title>
</head>
<body>
<script>
function getQueryParam(url, paramName) {
// 方案1使用原生 API现代浏览器
if (typeof URLSearchParams !== 'undefined') {
try {
const urlObj = new URL(url);
return urlObj.searchParams.get(paramName);
} catch (e) {
// URL 构造失败,继续降级
}
}
// 方案2正则匹配兼容性好
const pattern = new RegExp('[?&]' + paramName + '=([^&#]*)', 'i');
const match = url.match(pattern);
if (match) {
return decodeURIComponent(match[1]);
}
// 方案3手动解析最兼容
const queryStart = url.indexOf('?');
if (queryStart === -1) return null;
const queryString = url.substring(queryStart + 1);
const params = queryString.split('&');
for (let param of params) {
const [key, value] = param.split('=');
if (key === paramName) {
return decodeURIComponent(value || '');
}
}
return null;
}
2026-08-12 15:20:29 +08:00
function getPageQuery() {
const type = getQueryParam(location.href, 'type') || '';
if (type === 'ybAuth') {
const id = getQueryParam(location.href, 'id') || ''
return encodeURIComponent(`pages/consult/self-auth/auth-action?id=${id}`);
} else if (type === 'store') {
const storeId = getQueryParam(location.href, 'storeId') || '';
return encodeURIComponent(`pages/home/home?storeId=${storeId}`);
}
return ''
}
2026-07-31 18:26:54 +08:00
window.onload = function () {
2026-08-12 15:20:29 +08:00
const query = getPageQuery()
const scheme = `alipays://platformapi/startapp?appId=2021004129669493${query ? '&page=' : ''}${query}`;
2026-07-31 18:26:54 +08:00
const href = `https://ds.alipay.com/?scheme=${encodeURIComponent(scheme)}`;
location.href = href;
// console.log(href);
// window.open(href, '_blank');
}
</script>
</body>
</html>