Files
peko-h5/view/peko/shortLink/index.html

147 lines
5.1 KiB
HTML
Raw Permalink Normal View History

2023-09-21 10:22:36 +08:00
<!DOCTYPE html>
<html lang="en">
2023-09-21 15:13:01 +08:00
<head> 
2023-09-21 10:22:36 +08:00
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2023-09-21 15:13:01 +08:00
    <title>下載</title>
    <style>
2023-09-21 10:22:36 +08:00
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
background: #0f273d;
}
</style>
</head>
<body>
</body>
</html>
2023-09-21 14:36:41 +08:00
<script>
2023-09-21 15:13:01 +08:00
var productUrl = 'https://api.pekolive.com'; // 正式环境
var testUrl = 'http://beta.api.pekolive.com'; // 测试环境
2023-09-21 14:36:41 +08:00
var urlData = getQueryString();
2023-09-21 10:22:36 +08:00
var browser = checkVersion();
var time = dateFormat(new Date().getTime(), 'yyyy-MM-dd hh:mm:ss');
let urlPrefix = getUrlPrefix()
2023-09-21 15:13:01 +08:00
var httpRequest = new XMLHttpRequest();
2023-09-21 16:29:57 +08:00
httpRequest.open('GET', `${urlPrefix}/short/link/click?code=${urlData.code}&clientTime=${time}`, true);
2023-09-21 15:13:01 +08:00
httpRequest.send();
/**
* 获取数据后的处理程序
*/
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
var json = httpRequest.responseText;//获取到json字符串还需解析
2023-09-21 16:29:57 +08:00
var res = JSON.parse(json);
2023-09-21 15:13:01 +08:00
if (JSON.parse(json).code == 200) {
2023-09-21 16:29:57 +08:00
if (res.data.type == 1) {
window.location.replace(res.data.customValue);
2023-09-21 10:22:36 +08:00
} else {
2023-09-21 16:29:57 +08:00
if (browser.ios) {
2023-09-21 17:13:24 +08:00
window.location.replace('https://apps.apple.com/cn/app/id6446155565')
2023-09-21 16:29:57 +08:00
} else if (browser.android) {
2023-12-25 14:22:54 +08:00
window.location.replace('https://play.google.com/store/apps/details?id=app.hiyoo.fun')
2023-09-21 16:29:57 +08:00
} else {
window.location.replace('http://www.pekolive.com/')
}
2023-09-21 10:22:36 +08:00
}
2023-09-21 15:13:01 +08:00
}
}
};
// 根据域名判断 正式环境(含www)/测试环境(含beta), 并返回所需url前缀
// written by zxfxiong
function getUrlPrefix () {
if (!EnvCheck()) return undefined;
return EnvCheck() === 'live' ? productUrl : testUrl;
}
// 根据域名适配环境
function EnvCheck () {
if (window.location.href) {
var _url = window.location.href;
var res = _url.match(/uat/);
var res1 = _url.match(/120.79.211.243/);
var res2 = _url.match(/192.168./)
var res3 = _url.match(/127.0/)
var res4 = _url.match(/beta/)
if (res || res1 || res2 || res3 || res4) {
return 'test';
} else {
return 'live';
}
}
}
// 获取地址栏参数
function getQueryString () {
var _url = location.search;
var theRequest = new Object();
if (_url.indexOf('?') != -1) {
var str = _url.substr(1);
strs = str.split('&');
for (var i in strs) {
theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
}
}
return theRequest;
}
// 判断浏览器内核,手机类型
function checkVersion () {
var u = navigator.userAgent,
app = navigator.appVersion;
return {
trident: u.indexOf('Trident') > -1, //IE内核
presto: u.indexOf('Presto') > -1, //opera内核
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') > -1, //是否web应该程序没有头部与底部
weixin: u.indexOf('MicroMessenger') > -1, //是否微信
qq: u.match(/\sQQ/i) == " qq", //是否QQ
pekoApp: u.match('pekoApp'),
app: u.match('pekoApp') //是否在app内
};
}
function dateFormat (date, fmt) {
date = new Date(date);
var o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds()
};
// 补全0
function padLeftZero (str) {
return ('00' + str).substr(str.length);
}
// 年份
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
}
// 月日时分秒
for (var k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
var str = o[k] + '';
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str));
2023-09-21 10:22:36 +08:00
}
2023-09-21 15:13:01 +08:00
}
2023-09-21 10:22:36 +08:00
2023-09-21 15:13:01 +08:00
date = o = padLeftZero = null;
return fmt;
}
2023-09-21 10:22:36 +08:00
</script>