Files
peko-h5/view/peko/shortLink/index.html
2023-12-25 14:22:54 +08:00

147 lines
5.1 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>下載</title>
    <style>
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
background: #0f273d;
}
</style>
</head>
<body>
</body>
</html>
<script>
var productUrl = 'https://api.pekolive.com'; // 正式环境
var testUrl = 'http://beta.api.pekolive.com'; // 测试环境
var urlData = getQueryString();
var browser = checkVersion();
var time = dateFormat(new Date().getTime(), 'yyyy-MM-dd hh:mm:ss');
let urlPrefix = getUrlPrefix()
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', `${urlPrefix}/short/link/click?code=${urlData.code}&clientTime=${time}`, true);
httpRequest.send();
/**
* 获取数据后的处理程序
*/
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
var json = httpRequest.responseText;//获取到json字符串还需解析
var res = JSON.parse(json);
if (JSON.parse(json).code == 200) {
if (res.data.type == 1) {
window.location.replace(res.data.customValue);
} else {
if (browser.ios) {
window.location.replace('https://apps.apple.com/cn/app/id6446155565')
} else if (browser.android) {
window.location.replace('https://play.google.com/store/apps/details?id=app.hiyoo.fun')
} else {
window.location.replace('http://www.pekolive.com/')
}
}
}
}
};
// 根据域名判断 正式环境(含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));
}
}
date = o = padLeftZero = null;
return fmt;
}
</script>