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

23 篇文章 4 订阅
15 篇文章 0 订阅

到这个 入门 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>
效果如下




你可以参考上面的代码,放到服务器上,然后生成对应的二维码,如下图



评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值