good-slide.js
2.19 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* 你可能喜欢
* @author: gxh<xuhui.ge@yoho.cn>
* @date: 2017/03/03
*/
'use strict';
var lazyLoad = require('yoho-jquery-lazyload');
var dataLazyLoad = require('../plugins/lazy-load')(document);
var $ = require('yoho-jquery');
var recommendTpl = require('hbs/product/good-slide.hbs');
var $recommendSlide = $('[data-role="recommend-slide"]');
require('../plugins/slider');
require('../common/center-slider');
function getSearchRecommend() {
console.log(112222211118888888);
$.ajax({
url: 'http://search.yohobuy.com/product/search/less/recommend',
dataType: 'json',
data: {
// limit: num || 15
},
success: function(data) {
var recommendGood = [],
res, i, cur;
if (data.code === 200) {
res = data.data.item;
console.log(res);
// 若无最近浏览,请隐藏容器
if (res.length === 0) {
$('.bottom-tab-line').hide();
$('[data-role="recommend-slide"]').hide();
return;
}
// for (i = 0; i < res.length; i++) {
// cur = res[i];
//
// recommendGood.push({
// href: cur.url,
// img: cur.pic_url,
// title: cur.product_name,
// price: cur.price,
// marketPrice: cur.market_price
// });
// }
$recommendSlide.html(recommendTpl({
item: res,
hasNext: res && res.length > 5,
hasPrev: res && res.length > 5
}));
lazyLoad($recommendSlide.find('.lazy'));
console.log('aaaaa');
$recommendSlide.find('.goods-slide-item').slider2({
shownum: 5,
isCircle: true
});
console.log('bbbb');
}
}
});
}
window.getSearchRecommend = getSearchRecommend;
// 数据懒加载
dataLazyLoad.init({cls: '.lazy-load-object-2', threshold: 700});