<script type="text/javascript">
// 获取当前用户扫描的设备
window.onload = function () {
checkPhone();
}
/* 判断用户手机为安卓还是iphone */
var checkPhone = function () {
var _this = this
/* 判断是否为微信环境 */
this.isWeiXin = navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1 ? true : false;
if (_this.isWeiXin) {
$(".mask").css("display", "block");
return
}
var agent = (navigator.userAgent || navigator.vendor || window.opera)
if (agent != null) {
var agentName = agent.toLowerCase()
if (/android/i.test(agentName)) {
_this.isAndroid = true
} else if (/iphone/i.test(agentName)) {
_this.isIOS = true
}
}
}
var apkUrl = "";
// 获取下载app地址
$(document).delegate(".downloadApp", "click", function (e) {
var versionType = $(this).attr("versionType");
var ajaxobj = {
type: "get",
ajaxName: ajaxUrl.getAppListErWeiMa,
};
var params = {
"versionType": versionType,
};
getdata(ajaxobj, params, function (data) {
console.log(data);
if (data.resultnum === "0000") {
apkUrl = data.resultdata[0].apkURL;
downloadApp();
} else {
console.log("获取数据错误")
}
});
});
/* 点击下载按钮 */
var downloadApp = function () {
// 微信环境
let _this = this
checkPhone()
let agent = (navigator.userAgent || navigator.vendor || window.opera)
if (agent != null) {
if (_this.isAndroid) {
// alert(apkUrl);
// 安卓包下载地址
window.location.href = apkUrl;
} else {
alert("暂不支持此设备,敬请期待~");
}
}
}
</script>
H5判断当前手机使用的是安卓还是ios,并检测是否是微信登陆,给予app下载地址
最新推荐文章于 2024-07-03 02:27:14 发布
本文介绍了一种通过JavaScript实现的移动端设备类型检测方法,并提供了根据不同设备类型触发APP下载的功能。文章详细解释了如何判断用户使用的设备是Android还是iPhone,并在确认设备类型后提供相应的APP下载链接。
543

被折叠的 条评论
为什么被折叠?



