download.html 4.43 KB
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>潮流商品 | YOHO!有货</title>
    <meta name="description" content="">
    <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
        var agent = navigator.userAgent.toLowerCase() ;
        var version, type, appid, td, queryString, downUrl;

        var jumpTypes = [110];

        function isInJump(unionType) {
            for (var i = 0 ;i < jumpTypes.length; i++) {
                if (unionType == jumpTypes[i]) {
                    return true;
                }
            }
            return false;
        }

        function getQueryString() {
            var vars = [],
                    hash,
                    i;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

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

        queryString = getQueryString();
        downUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
        //downUrl = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
        var appkey = queryString.appkey;

        if (appkey == "yoho") {
            //yohonow
            downUrl = "http://a.app.qq.com/o/simple.jsp?pkgname=cn.yoho.magazine#opened";
        } else if (appkey == "mars") {
            //mars
            downUrl = "https://itunes.apple.com/cn/app/mars-xin-xian-hao-qu-chu-yu/id1056487123?l=en&mt=8";
            //downUrl = "http://yoho-apps.qiniudn.com/YohoMars.apk";
        }

        if (agent.indexOf("like mac os x") > 0) {
            var regStr_saf = /os [\d._]*/gi ;
            var verinfo = agent.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 (agent.indexOf('android') > -1 || agent.indexOf('linux') > -1) {
            var indextd = agent.indexOf('_td');
            var index = agent.indexOf(' build');
            var preString = '';
            var deviceType = '';

            //alert(agent);
            if (indextd > -1) {
                preString = agent.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 = agent.substr(0, index);
                preString = preString.substr(preString.lastIndexOf(";") + 1);
                preString = preString.replace(/\s+/g,'').replace(/_/ig, '');
                //alert(preString);
            }
            deviceType = preString;
            version = agent.substr(agent.indexOf('android') + 8, 3);
            type = 'android';
            appid = 'com.yoho';

            td =  deviceType + '_' + type + '_' + version;
            //downUrl = 'http://cdn.yoho.cn/app-downfiles/yohoBuy_YOHO_2953.apk';
        }



        $.ajax({
            method: 'POST',
            url: 'http://union.yoho.cn/union/ClickUnionRest/addCommonUnion',
//            url: 'http://192.168.102.205:8088/union/ClickUnionRest/addUnion',
            data: {
                union_type: queryString.union_type,
                identify_id: queryString.identify_id,
                callbackurl: queryString.callbackurl,
                client_type: type,
                td: queryString.td ? queryString.td : td,
                appid: queryString.appid ? queryString.appid : appid,
                appkey: queryString.appkey
            },
            complete: function() {

                /* if (!downUrl) {
                 window.location.href = "http://m.yohobuy.com";
                 } else {
                 window.location.href = downUrl;
                 } */
                window.location.href = downUrl;

                window.setTimeout(function() {
                    window.location.href = "http://m.yohobuy.com";
                }, 2000);
            }
        });


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