天天看點

微信掃描二維碼下載下傳軟體

1.引用qrcode.js前,去如下位址下載下傳或學習使用

QRCode.js教程位址可參考:http://www.runoob.com/w3cnote/javascript-qrcodejs-library.html

Github 位址:

https://github.com/davidshimjs/qrcodejs

2.scanner.html(生成二維碼)

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta name="description" content="">

<meta name="keywords" content="">

<meta name="author" content="webthemez">

<!-- Title -->

<title>test</title>

<script type="text/javascript">

function test(){

// 設定參數方式

var qrcode = new QRCode('qrcode', {

text: 'test.html',

width: 238,//設定二維碼的寬

height: 210,//設定二維碼的高

colorDark : '#000000',

colorLight : '#ffffff',

correctLevel : QRCode.CorrectLevel.H

});

$("#qrcode").show();

}

</script>

</head>

<body class="index" id="to-top" onload="test()">

<footer class="footer-section" role="contentinfo">

<div class="container">

<div class="row">

<p><a name="test">手機APP使用者請掃描下方二維碼</a></p>

<div id="qrcode" style="display:none;">

</div>

</div>

</div>

</footer>

<script src="js/jquery-2.1.0.min.js"></script>

<script src="js/qrcode.js"></script>

</body>

</html>

3.test.html(微信掃描時,判斷是否是微信,根據核心判斷,如果是微信跳轉到如下weixin.png圖,同時也是個html頁面,會提示使用在浏覽器中打開,然後點選打開浏覽器直接下載下傳,非微信浏覽器使用者可直接掃描下載下傳)

<!DOCTYPE html>
<html>
 
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <title>APP下載下傳</title>
        <script src="js/jquery-2.1.0.min.js" type="text/javascript" charset="utf-8"></script>
        <script language="javascript">
            window.onload = function() {
                var u = navigator.userAgent;
                if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) { //安卓手機
                    //                    alert("安卓手機");
                    window.location.href = "apk目錄";
                } else if (u.indexOf('iPhone') > -1) { //蘋果手機
                    //                    alert("蘋果手機");
                    window.location.href = "apk目錄";
                } else if (u.indexOf('Windows Phone') > -1) { //winphone手機
                    alert("WindowsPhone暫未推出。");
                    // window.location.href = "apk目錄";
                }else{
                
                    window.location.href = "apk目錄";
                }
                //                var vU=JSON.stringify(u);
                //                alert(vU);
            }
            $(window).on("load", function() {
                var winHeight = $(window).height();
 
                function is_weixin() {
                    var ua = navigator.userAgent.toLowerCase();
                    if (ua.match(/MicroMessenger/i) == "micromessenger") {
                        return true;
                    } else {
                        return false;
                    }
                }
                var isWeixin = is_weixin();
                if (isWeixin) {
                    $(".weixin-tip").css("height", winHeight);
                    $(".weixin-tip").show();
                }
            })
        </script>
        <style type="text/css">
            * {
                margin: 0;
                padding: 0;
            }
            
            a {
                text-decoration: none;
            }
            
            img {
                max-width: 100%;
                height: auto;
            }
            
            .weixin-tip {
  
                position: fixed;
                left: 0;
                top: 0;
                bottom: 0;
                background: rgba(0, 0, 0, 0.8);
                filter: alpha(opacity=80);
                height: 100%;
                width: 100%;
                z-index: 100;
            }
            
            .weixin-tip p {
                text-align: center;
                margin-top: 10%;
                padding: 0 5%;
            }
        </style>
    </head>
 
    <body>
        <div class="weixin-tip">
            <p>
                <img src="images/weixin.png" alt="微信打開" />
            </p>
        </div>
    </body>
 
</html>      

4.圖檔

weixin.png      
微信掃描二維碼下載下傳軟體

繼續閱讀