<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>微信登录</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script type="text/javascript" src="js/hotime.js"></script>
    <script type="text/javascript" src="js/qrcode.min.js"></script>
    <style>
        body{margin:0;}
        .box{width:100%;height: 100vh;display:flex;align-items:center;justify-content: center;position: relative;}
        .logo{position: absolute;top:7px;left: 17px;z-index: 2;width: 62px;height:22px;}
        .logo img{width:100%;background-size: contain;}
        .bg-img{position: absolute;top:0;left:0;width:100%;background-size: contain;}
        .title{font-size: 14px;font-weight: bold;color: #FFF;letter-spacing: 6px;margin-bottom:50px;text-align: center;}
        #qrcode{width:117px; height:117px; margin:23px auto 40px;}
        .content{background: #D0ECF9;border: 1px solid rgba(255, 255, 255, 0.6);box-shadow: 0px 4px 12px rgba(25, 105, 146, 0.24);border-radius: 8px;padding:34px 0;font-size: 18px;color: #0674AE;margin:0 auto;width:65%;text-align: center;}
        .footer{position: fixed;bottom:14px;width: 100%;font-size: 12px;
color: rgba(0, 0, 0, 0.7);text-align: center;line-height: 16px;}
    </style>
</head>
<body>
    <div class="box">
        <div class="logo">
            <img src="./img/logo_2@2x.png" alt="">
        </div>
        <img class="bg-img" src="./img/bg_up@2x.png">
        <div style="flex:1;">
            <div class="title">
                欢迎使用政策狩猎精灵
            </div>
            <div class="content">
                <div>初次使用需要绑定您的信息</div>
                <div>请打开微信扫描下方二维码</div>
                <div id="qrcode"></div>
            </div>
        </div>
        <div class="footer">
            <div>成都市创新创业服务平台</div>
            <div>国家级双创示范平台</div>
        </div>
    </div>
<script>
    var qrcode = new QRCode(document.getElementById("qrcode"), {
        width: 117,
        height: 117
    })
    function run() {
        var data={"timestamp": window.H.getParam("timestamp"),"sn":window.H.getParam("sn")}
        // if(data.code==null){
        //     location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4d97696b9ecb49fc&redirect_uri='+location.href+'&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect'
        //     return
        // }
        
        //定时器,3s刷新登录
        window.H.post("/app/upan/login", data, function (res) {
            if (res.status != 0) {
                //展示二维码,链接扫码到一个页面传参timestamp&sn,页面内容:app/upan/create?timestamp&sn&phone&company_name&code,成功后跳转到首页
                 
                let url = 'https://'+location.host+'/#/qrcode?timestamp='+ window.H.getParam("timestamp")+"&sn="+ encodeURIComponent(window.H.getParam("sn"))
                qrcode.makeCode(url)
                setTimeout(function(){
                    run()
                },3000)
                return
            }
        // let res = { "result": { "acttoken": "56_ogEfWa4mglG-Ilf2kD50FfekZWimJXUouZ4gMKmkVP2CwcLwv2lHO35LOn5NSLOQ-yEAZcIs3FvgIBhk2uF9CA", "appid": "wx4d97696b9ecb49fc", "avatar": "https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLNj0yKXe77H8C60ic2lUFIx5hkibf0FluNCRfTkiazrBfuqclqRhm4nDug9Hx3nsXQhtzNdfchAvJTQ/132", "nickname": "候鸟半夏", "openid": "oPoZT6juCkF6fvnMHrCFI6SK_vK8", "retoken": "56_tjuJPobvbLVvOPtqPRZjTzQHR7i3Vmx_aGXOy9j0WsNTFS_JRnb4ArmUGhWtq6e7eCpUnPNKulIQ44CPiBnYEA", "unionid": "ofKK36PEkbIt0xMMUgch4H-bVaFI" }, "status": 0 }
            location.href="/#/home"

        })
    }

    run()


</script>
</body>
</html>