pay.page.js 1.14 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());

if ($('#goods-list').length === 0) {
    $('.maybe-like').hide();
}

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