column-goods.js 1.17 KB
/**
 * kids,lifestyle商品模块JS
 * @author: liuyue(yue.liu@yoho.cn)
 * @date: 2015/9/23
 */
/*
var $ = require('yoho.zepto'),
    Mustache = require('yoho.mustache'),
    lazyLoad = require('yoho.lazyload');


var tpl,
    res,
    $firstColumnNav = $('.column-nav').find('li').eq(0),
    $goodList = $('.two-column-goods').find('.goods-list');

if ($('.two-column-goods').size() <= 0) {
    return;
}

//read good-info template
$.get('/common/goodinfo', function (data) {
    tpl = '{{# goods}}' + data + '{{/ goods}}';
    Mustache.parse(tpl);
});


function goodsAjax(url) {
    $.ajax({
        type: 'GET',
        url: url
    }).then(function (data) {
        if (data.code === 200) {
            res = data.data;

            $goodList.html(Mustache.render(tpl, {
                goods: res.goods
            }));

            //lazyLoad
            lazyLoad($goodList.children('.good-info').find('img.lazy'));
        }
    });
}

$firstColumnNav.addClass('current');
goodsAjax($('.column-nav').find('.current').data('url'));

$('.column-nav').on('click', 'li', function () {
    $(this).addClass('current').siblings().removeClass('current');
    goodsAjax($(this).data('url'));
});*/