analysis.hbs 1.64 KB
<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.1.0/yas.js', '_yas'));

    (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() || queryString().uid;

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