<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=750,user-scalable=no,target-densitydpi=device-dpi">
    <meta name="format-detection" content="telephone=no">
    <title>首页</title>
    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/push/css/main.css?<?php echo bonus_version(); ?>">
    <script src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>
    <script type="text/javascript">
        if ('addEventListener' in document) {
            document.addEventListener('DOMContentLoaded', function() {
                FastClick.attach(document.body);
            }, false);
        }
    </script>
</head>
<body>
<div class="container">
    <?php echo $output['tpl']->show(); ?>
    <span class="close_btn"><img src="<?php echo RESOURCE_SITE_URL; ?>/mobile/push/fcode/close.png" class="img"></span>
</div>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/new_bridge.js?<?php echo bonus_version(); ?>"></script>
<script type="text/javascript">
    window.onload = function ()
    {
        var bridge = new Bridge();

        (function(){
            if(document.getElementsByClassName('updata_focus').length > 0) {
                document.getElementsByClassName('schema_link')[0].setAttribute('href','javascript:void(0)');
                if(bridge.isMobile.Android()) {
                    document.getElementsByClassName('schema_link')[0].setAttribute('href','xmmz://p.lrlz.com/app/update?url=http://p.lrlz.com/data/upload/package/xmmz_release.apk');
                }
                else if(bridge.isMobile.iOS()) {
                    document.getElementsByClassName('schema_link')[0].setAttribute('href','itms-apps://itunes.apple.com/app/id945609424');
                }
                else {

                }
            }
        })();

        var ImgLoad = function (images, callback) {
            this.images = images;
            this.img_len = this.images.length;
            this.load_img = 1;
            this.imgLoad = function (img, callback) {
                var timer = setInterval(function () {
                    if (img.complete) {
                        callback(img);
                        clearInterval(timer)
                    }
                }, 50)
            };
            this.load = function () {
                var that = this;
                for (var i = 0; i < this.img_len; i++) {
                    (function (i) {
                        var j = i;
                        that.imgLoad(that.images[j], function () {
                            that.load_img++;
                            if (that.img_len == that.load_img) {
                                var jsonobject = {
                                    action: "resource_ready"
                                };
                                bridge.call_native_handler('on_native_click', JSON.stringify(jsonobject));
                                callback();
                            }
                        })
                    })(i)
                }
            }
        };
        var img_load = new ImgLoad(document.getElementsByClassName('img'), animate);
        img_load.load();

        function animate() {
            setTimeout(function () {
                document.getElementsByClassName('push_content')[0].setAttribute('style', '-webkit-transform:scale(1)');
            }, 300);
        };


        document.getElementsByClassName('close_btn')[0].addEventListener('click', function () {
            var jsonobject = {
                action: "back"
            };
            bridge.call_native_handler('on_native_click', JSON.stringify(jsonobject));
        });

        document.getElementsByClassName('close_btn')[0].addEventListener('touchstart', function () {
            this.setAttribute('style', 'background:rgba(255,255,255,0.6);');
        });

        document.getElementsByClassName('close_btn')[0].addEventListener('touchend', function () {
            this.setAttribute('style', 'background:rgba(255,255,255,0);');
        });

        document.getElementsByClassName('look_btn')[0].addEventListener('touchstart', function () {
            this.setAttribute('style', 'background:rgba(220,194,126,0.6);');
        });

        document.getElementsByClassName('look_btn')[0].addEventListener('touchend', function () {
            this.setAttribute('style', 'background:rgba(220,194,126,1);');
        });

        document.getElementsByClassName('schema_link')[0].addEventListener('touchstart',function(){
            var jsonobject = {
                action: "back"
            };
            bridge.call_native_handler('on_native_click', JSON.stringify(jsonobject));
        });
    }
</script>
</body>
</html>
