您的位置:首页 > 移动开发 > 微信开发

phonegap(cordova) 入门 15----微信中屏蔽apk下载间接解决办法

2014-12-29 11:13 429 查看
到这个 入门 15 ,有可能你的app基本上该有的都有了,可以发布了,App Store 这个你只能听Apple 的,如果是android 的,虽然这个是一个间接避免的方式,但仍然不建议,因为国内的几个应用商城都不严格的,添加吧,方便,别跟他们斗气了

由于微信中打开如果是apk的地址,则无法下载,必须是应用宝内的apk,绕过微信实在是太费劲,再说,人家的用户量多,强势!任性!

参考网络一种相对聪明的做法,引导客户去下载,只是多一个步骤而已

代码如下

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title id="title">下载</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="img/jquery-1.10.2.min.htm"></script>
<style type="text/css">
* {
margin: 0;
padding: 0;
}

img {
max-width: 100%;
height: auto;
}

.test {
height: 600px;
max-width: 600px;
font-size: 40px;
}
</style>
</head>
<body>

</body>
<script>
function is_weixin() {
var ua = navigator.userAgent.toLowerCase();
//alert(ua);
if (ua.match(/MicroMessenger/i) == "micromessenger") {
if (ua.match(/iphone/i) == "iphone" || ua.match(/ipad/i) == "ipad") {
window.location.href = "https://appstore对应app的地址";
return false;
}
else {
return true;
}
} else {
if (ua.match(/iphone/i) == "iphone" || ua.match(/ipad/i) == "ipad") {
window.location.href = "https://appstore对应app的地址";
return false;
}
else {
window.location.href = "http://apk下载地址";
return false;
}

}
}

var isWeixin = is_weixin();
var winHeight = typeof window.innerHeight != 'undefined' ? window.innerHeight : document.documentElement.clientHeight;
var weixinTip = $('<div id="weixinTip"><p><img src="img/live_weixin.png" alt="微信打开"/></p></div>');

if (isWeixin) {
$("#title").html("请按下方指示操作");
$("body").append(weixinTip);

}
$("#weixinTip").css({
"position": "fixed",
"left": "0",
"top": "0",
"height": winHeight,
"width": "100%",
"z-index": "1000",
"background-color": "rgba(0,0,0,0.8)",
"filter": "alpha(opacity=80)",
});
$("#weixinTip p").css({
"text-align": "center",
"margin-top": "10%",
"padding-left": "5%",
"padding-right": "5%"
});
</script>

</html>
效果如下



你可以参考上面的代码,放到服务器上,然后生成对应的二维码,如下图
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  微信 apk 二维码