installment.page.js 1.31 KB
var $ = require('yoho-jquery'),
    ellipsis = require('yoho-mlellipsis'),
    ListData = require('./installment-goods'),
    lazyLoad = require('yoho-jquery-lazyload');

require('../common');

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

new ListData({
    url: '/home/installment/get-goods',
    page: 1,
    boxArea: $('#goods-list')
});

function setDetailText() {
    var $this, $title;

    $('.good-detail-text .name').each(function() {
        $this = $(this);
        $title = $this.find('a');

        $title[0].mlellipsis(2);
    });
}

function setDefaultHeight() {
    var $detailImg = $('.good-detail-img');

    $detailImg.css({
        height: $detailImg.find('img').height() - 1,
        background: '#c3c3c3'
    });
}

setDetailText();

$('.detail-tab span').on('click', function() {
    $(this).addClass('on').siblings().removeClass('on');
    $('.installment-cont').hide().eq($(this).index()).show();

    if ($(this).index() === 1) {
        setDetailText();
        lazyLoad($('img.lazy'));

        setTimeout(function() {
            setDefaultHeight();
        }, 2000);
    }
});

setTimeout(function() {
    setDefaultHeight();
}, 2500);


window.setCookie('installmentUid', window.queryString.uid);
window.setCookie('udid', window.queryString.udid);
window.setCookie('clientType', window.queryString.client_type);