|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>开心0元购</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
width: 7.5rem;
}
.container {
position: relative;
}
.conbg {
width: 100%;
display: block;
}
.btn {
position: absolute;
top: 11.3rem;
left: calc(50% + 0.15rem);
transform: translateX(-50%);
width: 3.1rem;
height: 0.85rem;
}
#adr-mask {
background-color: rgba(0, 0, 0, .8);
width: 100%;
height: 100%;
z-index: 99999;
left: 0px;
top: 0px;
position: fixed;
overflow: hidden;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<div id="adr-mask" style="display: none;">
<img src="/img/arrow.png" style="margin: 1rem 0 0 2.5rem;">
<p style="color: #ffffff;font-size: 23px;margin:.5rem 0 .9rem 0;">请在浏览器中打开</p>
<img src="/img/know.png" onclick="closeMask()" style="CURSOR: pointer">
</div>
<img class="conbg" src="/img/bg-img.png" alt="">
<!-- <a href="https://s3.cn-northwest-1.amazonaws.com.cn/s3.jianos.com/Zero.apk" download=""> -->
<div class="btn" onclick="download()"></div>
<!-- </a> -->
</div>
<script>
var downUrl = "https://s3.cn-northwest-1.amazonaws.com.cn/s3.jianos.com/Zero.apk";
function requestApi(callback) {
var url = 'https://apifreego.jianos.com/app_update';
var xhr = new XMLHttpRequest();
xhr.open('get', url, true);
xhr.setRequestHeader("content-type", "application/json");
xhr.onload = () => {
// console.log('xhr.response = ', xhr.response)
if (xhr.status == 200) {
var result = JSON.parse(xhr.response);
// console.log(222,result)
if (result && result.data && result.data.src) {
downUrl = result.data.src;
//if(callback)callback(result.src);
// console.log('得到的下载地址是 = ' + downUrl)
}
}
}
xhr.onerror = () => {
console.log('xhr.onerror = ', xhr)
}
xhr.send();
}
requestApi();
document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
function download() {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
//是微信环境,弹出遮罩
document.getElementById('adr-mask').style.display = 'block';
return true;
} else {
// TODO 这里弱网环境会有问题
//不是微信环境,直接下载,
window.location.href = downUrl;
return false;
}
}
function closeMask() {
document.getElementById('adr-mask').style.display = 'none';
}
</script>
</body>
</html>
|