pay.page.js 1.26 KB
var $ = require('yoho-jquery'),
    lazyLoad = require('yoho-jquery-lazyload');

var prompt = $('.fraud-prompt'),
    tipContent = $('.tip-content'),
    tip = $('.tip'),
    fraudTip = $('.fraud-tip');

var tipConWidth = tipContent.width(),
    tipWidth = tip.width(),
    promptWidth = prompt.width();

var scrollVal,
    onePageW,
    diff;

require('../common');

lazyLoad($('img.lazy'));

function getGender() {
    return window.cookie('_Channel') || 'boys';
}

require('../channel/maybe-like')(getGender());

// 你可能喜欢没有数据就隐藏
setTimeout(function() {
    if ($('#goods-list').find('.good-info').length === 0) {
        $('.maybe-like').hide();
    }
}, 200);

// 防诈骗提示滚动
if (tipConWidth > promptWidth - tipWidth) {
    var speed = 30;

    tipContent.width(tipConWidth + (promptWidth / 2));

    fraudTip.append('<div class="tip-content">' + tipContent.html() + '</div>').css({
        width: 2 * tipContent.width()
    });

    function Marquee() {
        prompt.scrollLeft(prompt.scrollLeft() + 1);

        scrollVal = prompt.scrollLeft();
        onePageW = tipContent.eq(0).width();
        diff = scrollVal - onePageW;

        if (diff > 0) {
            prompt.scrollLeft(Math.abs(diff));
        }
    }

    setInterval(Marquee, speed);
}