column-goods.js
1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* 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'));
});*/