downapp.html 2.04 KB


<!DOCTYPE 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;

       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;
        }

        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';            
        } else if (agent.indexOf('android') > -1 || agent.indexOf('linux') > -1) {
            version = agent.substr(agent.indexOf('android') + 8, 5);
            type = 'android';
            appid = 'com.yoho';
        }

        td = window.screen.width + '_' + window.screen.height + '_' + type + '_' + version;
        queryString = getQueryString();

        $.ajax({
            method: 'POST',
            url: '/union/ClickUnionRest/addUnion',
            data: {
                union_type: queryString.union_type,
                identify_id: queryString.identify_id,
                callbackurl: queryString.callbackurl,
                client_type: type,
                td: td,
                appid: appid
            },
            complete: function() {
                var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
                window.location = appUrl;
            }
        });

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