searchResult.js
3.92 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
define(function(require, exports, module) {
/*
引入包
*/
var _Mcity = require('mcity'); //城市信息
$(function() {
/*
筛选&排序
*/
// 筛选切换
$('.m-tab li').on('click', function() {
$(this).addClass('on').siblings().removeClass('on');
});
/*
商品产地数据读取
*/
$('.m-city').on('click', function() {
new _Mcity(this, {});
});
// 价格排序
$('#sort-price').on('click', function() {
var _icon = $(this).find('.m-icon');
if (_icon.length > 0) {
if (_icon.hasClass('icon-up')) {
_icon.removeClass('icon-up').addClass('icon-down');
} else {
_icon.removeClass('icon-down').addClass('icon-up');
}
} else {
$(this).find('a').append('<i class="m-icon icon-up"></i>');
}
});
/*
加载更多
*/
var loadmore = function(target, options) {
this.target = target;
this.isRequestData = false;
this.opt = {
loadwrap: '#list-loading',
loading: function(target) {}
};
$.extend(this.opt, options);
this.bind();
}
loadmore.prototype = {
//绑定浏览器滚动事件
bind: function() {
var _this = this,
_target = _this.target;
$('.m-page').scroll(function() {
var scrollBottom = $('.m-page-content').height() - $('.m-page').height() - $('.m-page').scrollTop();
if (scrollBottom <= 20 && !_this.isRequestData) {
_this.isRequestData = true;
$(_this.opt.loadwrap).css('display', 'block');
setTimeout(function() {
_this.opt.loading(_target);
$(_this.opt.loadwrap).css('display', 'none');
_this.isRequestData = false;
}, 1000);
}
});
}
}
var num = 0;
// 商品列表加载更多
if ($('#goods-list-view').length > 0) {
new loadmore($('#goods-list-view'), {
loading: function(target) {
var _html = '<li class="cell cell-extend-pic">\
<a href="product_detail.html">\
<img src="../images/user-home.png" width="80" height="80" alt="" class="pic">\
<h3 class="title">标题' + num + '</h3>\
<p class="btm"><em>0.9元/斤</em><span class="source">地利自营</span></p>\
</a>\
</li>';
$(target).append(_html);
num++;
}
});
}
// 店铺列表加载更多
if ($('#shop-list-view').length > 0) {
new loadmore($('#shop-list-view'), {
loading: function(target) {
var _html = '<li class="cell cell-extend-pic acc-icon">\
<a href="shop_detail.html">\
<img src="../images/user-home.png" width="80" height="80" alt="" class="pic">\
<h3 class="title">店铺' + num + '</h3>\
<p class="detail">经营类目:青丝茄子\
<br>经营品类:萝卜\
<br>经营区域:四川成都\
</p>\
</a>\
</li>';
$(target).append(_html);
num++;
}
});
}
});
});