app-downloads.html 13.2 KB
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Yoho!Buy有货|年轻人潮流购物中心,中国潮流购物风向标</title>
    <meta name="keywords"
          content="Yoho!Buy有货 有货官网,潮流志,潮流男装,潮牌,美国潮牌,日本潮牌,香港潮牌,潮牌店,新品首发,欧美潮流,全球购,代购,时尚,流行,特卖,B2C,正品,购物网站,网上购物,货到付款">
    <meta name="description" content="Yoho!Buy有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <meta http-equiv="cleartype" content="on">
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta content="telephone=no" name="format-detection"/>
    <meta content="email=no" name="format-detection"/>
    <link rel="dns-prefetch" href="//cdn.yoho.cn">
    <link rel="dns-prefetch" href="//static.yohobuy.com">
    <link rel="dns-prefetch" href="//img10.static.yhbimg.com">
    <link rel="dns-prefetch" href="//img11.static.yhbimg.com">
    <link rel="dns-prefetch" href="//img12.static.yhbimg.com">
    <link rel="dns-prefetch" href="//img13.static.yhbimg.com">
    <link rel="dns-prefetch" href="//analytics.m.yohobuy.com">
    <link rel="dns-prefetch" href="//search.m.yohobuy.com">
    <link rel="dns-prefetch" href="//list.m.yohobuy.com">
    <link rel="dns-prefetch" href="//guang.m.yohobuy.com">

    <script type="text/javascript">
        (function (d, c) {
            var e = d.documentElement, a = "orientationchange" in window ? "orientationchange" : "resize", b = function () {
                var f = e.clientWidth;
                if (!f) {
                    return
                }
                if (f >= 640) {
                    e.style.fontSize = "40px"
                } else {
                    e.style.fontSize = 40 * (f / 640) + "px"
                }
            };
            if (!d.addEventListener) {
                return
            }
            b();
            c.addEventListener(a, b, false);
            d.addEventListener("DOMContentLoaded", b, false)
        })(document, window);
    </script>


    <link rel="stylesheet" media="all" href="//cdn.yoho.cn/m-yohobuy-node/5.3.20/common.css">
    <link rel="stylesheet" media="all" href="//cdn.yoho.cn/m-yohobuy-node/5.3.20/activity.app-downloads.css">
    <link rel="apple-touch-icon-precomposed"
          href="//static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png">
    <link rel="apple-touch-startup-image" sizes="640x920"
          href="//static.yohobuy.com/m/v1/img/startup/startup-retina.png"
          media="screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2)">
    <link rel="apple-touch-startup-image" sizes="320x460" href="//static.yohobuy.com/m/v1/img/startup/startup.png"
          media="screen and (max-device-width: 320)">
</head>
<body class="      ">
<div class="main-wrap" id="main-wrap">


    <div class="container">
        <div id="no-download"></div>
        <div class="banner"></div>
        <div class="main">
            <div class="slide-box">
                <div class="swiper-wrapper clearfix">
                    <div class="yohobuy" tag="0">
                        <div class="swiper-yohobuy bg"></div>
                        <div class="ewm-area">
                            <img src="//cdn.yoho.cn/yohocn/160315/images/ewm-yohobuy.png"/>
                            <div class="ewm-info"></div>
                        </div>
                        <span id="download" class="download-btn" onclick="downloadApp();">点击下载 · Yoho!Buy有货</span>
                    </div>
                </div>
            </div>
            <div class="slide-pagination clearfix">
            </div>
        </div>
        <div class="footer">
            CopyRight © 2007-2017 YOHO!新力传媒
        </div>
        <div class="mask">
            <div class="wx-img1"></div>
            <div class="wx-img2"></div>
            <div class="wx-img3"></div>
        </div>
    </div>


</div>

<script>var STATIC_RESOURCE_PATH = '//cdn.yoho.cn/m-yohobuy-node/assets';</script>
<script src="//cdn.yoho.cn/m-yohobuy-node/5.3.20/libs.js"></script>
<!--<script src="//cdn.yoho.cn/m-yohobuy-node/5.3.20/activity.app-downloads.js"></script>-->
<script type="text/javascript">
    function cookie(name) {
        var cookies = document.cookie,
            cookieVal;

        if (cookies) {
            cookies = cookies.split(';');
            cookies.forEach(function (c) {
                if (c.indexOf(name) > -1) {
                    cookieVal = decodeURIComponent($.trim(c.replace(name + '=', '')));
                    return;
                }
            });
        }

        return cookieVal;
    }

    function queryString() {
        var vars = {},
            hash,
            i;
        var hashes = window.location.search.slice(1).split('&');

        for (i = 0; i < hashes.length; i++) {
            hash = hashes[i].split('=');
            vars[hash[0]] = hash[1];
        }
        return vars;
    }


    function xhrGet(url, cb) {
        var conn = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
        conn.onreadystatechange = function () {
            if (conn.readyState == 4 && conn.status == 200) {
                cb(conn.responseText)
            }
        };
        conn.open("GET", url, true);
        conn.send();
    }

    window.cookie = cookie;

    var url = 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.home","params":{"gender":"1","channel":"2"}}';
    var u = navigator.userAgent.toLowerCase();
    var isiOS = u.indexOf('os') > -1 || u.indexOf('iphone') > -1 || u.indexOf('mac') > -1 || u.indexOf('ipad') > -1;
    var isWechat = /micromessenger/i.test(navigator.userAgent || '');
    var version, type, appid, td, params;

    params = queryString();

    if (isiOS) {
        var regStr_saf = /os [\d._]*/gi;
        var verinfo = u.match(regStr_saf);

        version = (verinfo + '').replace(/[^0-9|_.]/ig, '').replace(/_/ig, '.');
        type = 'ios';
        appid = '490655927';
        td = window.screen.width + '_' + window.screen.height + '_' + type + '_' + version;

    } else if (u.indexOf('android') > -1 || u.indexOf('linux') > -1) {
        type = 'android';
        appid = 'com.yoho';
        try {
            var indextd = u.indexOf('_td');
            var index = u.indexOf(' build');
            var preString = '';

            if (indextd > -1) {
                preString = u.substr(0, indextd);
                preString = preString.substr(preString.lastIndexOf(";") + 1);
                preString = preString.replace(/\s+/g, '').replace(/_/ig, '');

                var sansungIndex = preString.indexOf('samsung-');
                if (sansungIndex > -1) {
                    preString = preString.substr(8);
                }
            } else if (index > -1) {
                preString = u.substr(0, index);
                preString = preString.substr(preString.lastIndexOf(";") + 1);
                preString = preString.replace(/\s+/g, '').replace(/_/ig, '');
                //alert(preString);
            }
            deviceType = preString;
            version = u.substr(u.indexOf('android') + 8, 3);
            td = deviceType + '_' + type + '_' + version;
        } catch (e) {

        }
    }


    var appPath = url;
    var ifr;

    setTimeout(function () {
        //记录唤醒时间
        var openTime = +new Date();

        window.setTimeout(function () {
            if (ifr) {
                document.body.removeChild(ifr);
            }

            //如果setTimeout 回调超过2500ms,则弹出下载
            if ((+new Date()) - openTime > 500) {
                if (isiOS) {
                    url = '//itunes.apple.com/us/app/id490655927?ls=1&mt=8';
                } else {
                    url = '//yoho-apps.qiniudn.com/YohoBuy_YOHO.apk';
                }

                unionClick();

                location.href = url;
                // window.open(url);
            }
        }, 1000);

        if (isiOS) {
            window.location.href = appPath;
        } else {
            ifr = document.createElement('iframe');
            ifr.src = appPath;
            ifr.style.display = 'none';
            document.body.appendChild(ifr);
        }
    }, 500);

    //1: 男生,2-女生,3-潮童,4-创意生活
    var CHANNELS = {
        boys: 1,
        girls: 2,
        kids: 3,
        lifestyle: 4
    };

    function downloadApp() {
        var url;
        var channel = window.cookie('_Channel');

        if(isWechat){
            url = 'http://union.yoho.cn/union/downapp.html';
        }else{
            if (isiOS) {
                url = '//itunes.apple.com/us/app/id490655927?ls=1&mt=8';
            } else {
                url = '//yoho-apps.qiniudn.com/YohoBuy_YOHO.apk';
            }
        }

        // 上报 nginx 数据
        xhrGet('//m.yohobuy.com/activitylog.json?download2', function () {
        });

        // 上报 yas 数据
        if (typeof _yas !== 'undefined') {
            _yas.sendCustomInfo && _yas.sendCustomInfo({
                op: 'YB_DOWNLOAD_C',
                param: JSON.stringify({
                    C_ID: CHANNELS[channel],
                    TO_URL: encodeURIComponent(url)
                })
            }, true);
        }

        // 联盟点击
        unionClick();

        location.href = url;
    }

    function unionClick() {
        var unionUrl = 'http://union.yoho.cn/union/ClickUnionRest/addUnion?client_type=' + type;
//        var unionUrl = 'http://127.0.0.1:8088/union/ClickUnionRest/addUnion?client_type=' + type;
        if (params.union_type) {
            unionUrl += '&union_type=' + params.union_type;
        }
        if (params.identify_id) {
            unionUrl += '&identify_id=' + params.identify_id;
        }
        if (params.callbackurl) {
            unionUrl += '&callbackurl=' + params.callbackurl;
        }
        if (params.td) {
            unionUrl += '&td=' + params.td;
        } else {
            unionUrl += '&td=' + td;
        }
        if (params.appid) {
            unionUrl += '&appid=' + params.appid;
        } else {
            unionUrl += '&appid=' + appid;
        }
        if (params.idfa) {
            unionUrl += '&idfa=' + params.idfa;
        } else if (params.IDFA) {
            unionUrl += '&idfa=' + params.IDFA;
        }
        if (params.imei) {
            unionUrl += '&imei=' + params.imei;
        } else if (params.IMEI) {
            unionUrl += '&imei=' + params.IMEI;
        }
        xhrGet(unionUrl, function () {
        });
    }
</script>
<script>
    (function (w, d, s, j, f) {
        var a = d.createElement(s);
        var m = d.getElementsByTagName(s)[0];

        w.YohoAcquisitionObject = f;

        w[f] = function () {
            w[f].p = arguments;
        };

        a.async = 1;
        a.src = j;
        m.parentNode.insertBefore(a, m);
    }(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.2.1/yas.js', '_yas'));

    var _hmt = _hmt || [];

    (function () {
        function getUid() {
            var uid,
                name = '_UID',
                cookies = (document.cookie && document.cookie.split(';')) || [];

            cookies.forEach(function (c) {
                if (c.indexOf(name) > -1) {
                    uid = decodeURIComponent(c.replace(name + '=', '').trim());
                    return;
                }
            });

            if (!uid) return 0;

            uid = uid.split('::');
            if (!uid || uid.length < 4) {
                return 0;
            }
            return uid[1];
        }

//        function queryString() {
//            var vars = {},
//                hash,
//                i;
//            var hashes = window.location.search.slice(1).split('&');
//
//            for (i = 0; i < hashes.length; i++) {
//                hash = hashes[i].split('=');
//                vars[hash[0]] = hash[1];
//            }
//            return vars;
//        }

        var uid = getUid() || params.uid;

        uid = uid === 0 ? '' : uid;
        window._ozuid = uid; // 暴露ozuid
        if (window._yas) {
            window._yas(1 * new Date(), '2.2.1', 'yohobuy_m', uid, '', '');
        }

        // 非登录状态,加载百度统计
        if (!uid) {
            setTimeout(function () {
                (function () {
                    var hm = document.createElement("script");
                    hm.src = "https://hm.baidu.com/hm.js?65dd99e0435a55177ffda862198ce841";
                    var s = document.getElementsByTagName("script")[0];
                    s.parentNode.insertBefore(hm, s);
                })();
                (function () {
                    var hm = document.createElement("script");
                    hm.src = "https://hm.baidu.com/hm.js?e5b83a487a4458aa5abca43f5779b764";
                    var s = document.getElementsByTagName("script")[0];
                    s.parentNode.insertBefore(hm, s);
                })();
            }, 1000);
        }
    }());
</script>

</body>
</html>