footer.js 1.75 KB
/**
 * 底部JS
 * @author: liangzhifeng<zhifeng.liang@yoho.cn>
 * @date: 2015/10/26
 */

var $ = require('jquery'),
    Hammer = require('yoho.hammer');

var floatLayerCloseHammer, floatLayerBtnHammer;

function downLoadApp() {
    var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
    var clickedAt = new Date();

    setTimeout(function () {
        if ((new Date()) - clickedAt < 2000) {
            window.location = appUrl;
        }
    }, 500);
}

// $('#float-layer-close').bind('tap', function () {
//     $('#float-layer-app').hide();
//     window.setCookie('_float-layer-app', 'id490655927',
//         {
//             domain: '.yohobuy.com'
//         });
//     window.setCookie('_float-layer-app-close', 1,
//         {
//             domain: '.yohobuy.com',
//             expires: 1
//         });
// });

if ($('#float-layer-close') && $('#float-layer-close')[0]) {
    floatLayerCloseHammer = new Hammer($('#float-layer-close')[0]);
    floatLayerCloseHammer.on('tap', function(e) {
        $('#float-layer-app').hide();
        window.setCookie('_float-layer-app', 'id490655927',
            {
                domain: '.yohobuy.com'
            });
        window.setCookie('_float-layer-app-close', 1,
            {
                domain: '.yohobuy.com',
                expires: 1
            });
    });
}

// $('#float-layer-btn').tap(function () {
//     downLoadApp('bottom');
// });

if ($('#float-layer-btn') && $('#float-layer-btn')[0]) {
    floatLayerBtnHammer = new Hammer($('#float-layer-btn')[0]);
    floatLayerBtnHammer.on('tap', function(e) {
        downLoadApp('bottom');
    });

    if (!window.cookie('_float-layer-app')) {
        $('#float-layer-app').show();
    } else {
        $('#float-layer-app').hide();
    }
}