channel.js
4.83 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
define('channel',function(require, exports)
{
var swipe = require("plugins/swipe");
var $ = require("jquery");
var freetile = require("lib/ui/jquery.freetile");
require("plugins/pagination");
function setLayout()
{
$('.fluid-list-inner').freetile({ animate: false, elementDelay: 0 });
}
function getTopProduct(gender)
{
$.ajax
({
type:"post",
url:'/default/getTopProduct',
data:{gender:gender},
dataType:"json",
success:function(data)
{
if(data.code == 200)
{
var html = '';
var pos = 1;
var number_class = '';
var number = '';
$.each(data.data, function(key, val)
{
if(pos == 1)
{
number_class = 'number_1';
number = '';
}
else
{
number = pos;
number_class = 'number_2';
}
html += '<li><div class="goods-image">'+
'<img src="'+val.product_img+'" alt=""/>'+
'<span class="'+number_class+'">'+number+'</span></div>'+
'<h3><a target="_blank" href="'+val.product_url+'">'+val.product_name+'</a></h3><p>人气: '+val.sale_sum+'</p></li>';
pos++;
});
$(".show-goods-list").html('<ul>'+html+'</ul>');
}
}
});
}
//yohood展会页面
exports.exhibition=function(){
swipe.init
({
slideBox: '.slide-box-exhibition',
prev: '.slide-prev-exhibition',
next: '.slide-next-exhibition',
pagination: '.dib a',
activeClass: 'on',
auto:3000,
continuous:true
});
}
//首页
exports.index = function()
{
var sortPos = 0;
var productGenders = [];
var currentGenderPos = 0;
var productListNames = [];
if($(".show-goods").size() > 0)
{
productGenders = $(".show-goods").attr("product_genders").split(',');
currentGenderPos = $(".show-goods").attr("current_gender_pos");
productListNames = $(".show-goods").attr("product_list_names").split(',');
getTopProduct(productGenders[currentGenderPos]);
}
swipe.init
({
slideBox: '.slide-box',
prev: '.slide-prev',
next: '.slide-next',
pagination: '.dib a',
activeClass: 'on',
auto:3000,
continuous:true
});
$(".goods_prev, .goods_next").bind("click", function()
{
currentGenderPos = parseInt($(".show-goods").attr("current_gender_pos"));
if($(this).attr("class") == 'goods_prev')
{
genderPos = parseInt(currentGenderPos - 1 >= 0 ? currentGenderPos-1 : 0);
}
else
{
genderPos = parseInt(currentGenderPos + 1 < productGenders.length ? currentGenderPos + 1 : currentGenderPos);
}
if(genderPos != currentGenderPos)
{
$(".show-goods").attr("current_gender_pos", genderPos);
getTopProduct(productGenders[genderPos]);
$(".show-goods").find("span").remove();
$(".show-goods").find("h2").prepend("<span>"+productListNames[genderPos]+"</span>");
}
});
setLayout();
};
//资讯
exports.news = function()
{
setLayout();
}
//show页面
exports.show = function()
{
$(".look_big_image").bind("click",function(event)
{
var divName = '#mask';
var sourceImage = $(this).attr("source");
var imageWidth = parseInt($(divName).children().attr("width"));
var imageHeight = parseInt($(divName).children().attr("height"));
$(divName).html('<img src="'+sourceImage+'" width="'+imageWidth+'" height="'+imageHeight+'" />').attr("current_class",$(this).parent().attr("class"));
var top = ($(window).height() - imageHeight)/2;
var left = ($(window).width() - imageWidth)/2;
var scrollTop = 0;//$(document).scrollTop();
var scrollLeft = 0;//$(document).scrollLeft();
$(divName).css( { position : 'absolute', 'top' : top + scrollTop, left : left + scrollLeft });
$(".model").show();
if(left-75 > 10)
{
$(".image-prev").css("left", left-75);
$(".image-next").css("right", left-75);
}
$.each($(this).parents("span").children("span"), function(index, dom)
{
var style_top = parseInt($(dom).attr("x"))/10000 * imageHeight;
var style_left = parseInt($(dom).attr("y"))/10000 * imageWidth;
$(divName).append('<a class="pic-tip" style="left:'+style_left+'px;top:'+style_top+'px;">'+$(dom).attr("label")+'</a>')
});
event.stopPropagation();
});
$(".image-next, .image-prev").bind("click",function()
{
var current_class = $("#mask").attr("current_class");
var pos = parseInt(current_class.replace('single_',''));
if($(this).attr("class").indexOf("image-next") != -1)
{
pos = pos + 1;
}
else
{
pos = pos - 1;
}
if($(".single_"+pos).size() > 0)
{
$(".single_"+pos).find(".look_big_image").click();
}
});
$(".ui-dialog-close").bind("click",function(event)
{
$(".model").hide();
event.stopPropagation();
});
}
});