do gulp ge to gzip css js
Showing
4 changed files
with
3427 additions
and
0 deletions
Too many changes to show.
To preserve performance only 4 of 4+ files are displayed.
static/dist/myohobuy/0.0.2/index-debug.js
0 → 100644
1 | +define("index", ["zepto","lazyload","swiper","mlellipsis","iscroll-probe","index"], function(require, exports, module){ | ||
2 | +var yohobuy; | ||
3 | + | ||
4 | +require("js/common"); | ||
5 | + | ||
6 | +require("js/passport/index"); | ||
7 | +require("js/guang/index"); | ||
8 | +require("js/home/index"); | ||
9 | +require("js/product/index"); | ||
10 | +require("js/index/index"); | ||
11 | + | ||
12 | +module.exports = yohobuy; | ||
13 | + | ||
14 | +}); | ||
15 | +define("js/common", ["zepto"], function(require, exports, module){ | ||
16 | +/** | ||
17 | + * 页面公共逻辑 | ||
18 | + * @author: xuqi<qi.xu@yoho.cn> | ||
19 | + * @date: 2015/10/21 | ||
20 | + */ | ||
21 | +var $ = require("zepto"); | ||
22 | + | ||
23 | +function cookie(name) { | ||
24 | + var cookies = document.cookie, | ||
25 | + cookieVal, | ||
26 | + offset; | ||
27 | + | ||
28 | + if (document.cookie && document.cookie !== '') { | ||
29 | + offset = cookies.indexOf(name + '='); | ||
30 | + if (offset > -1) { | ||
31 | + offset += name.length + 1; | ||
32 | + | ||
33 | + cookieVal = decodeURIComponent($.trim(cookies.substring(offset, cookies.indexOf(';', offset)))); | ||
34 | + } | ||
35 | + } | ||
36 | + | ||
37 | + return cookieVal; | ||
38 | +} | ||
39 | + | ||
40 | +function setCookie(name, value, options) { | ||
41 | + var expires = '', | ||
42 | + path, | ||
43 | + domain, | ||
44 | + secure, | ||
45 | + date; | ||
46 | + | ||
47 | + if (typeof value !== 'undefined') { | ||
48 | + options = options || {}; | ||
49 | + if (value === null) { | ||
50 | + value = ''; | ||
51 | + options.expires = -1; | ||
52 | + } | ||
53 | + | ||
54 | + if (options.expires && | ||
55 | + (typeof options.expires === 'number' || options.expires.toUTCString)) { | ||
56 | + if (typeof options.expires === 'number') { | ||
57 | + date = new Date(); | ||
58 | + date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); | ||
59 | + } else { | ||
60 | + date = options.expires; | ||
61 | + } | ||
62 | + expires = '; expires=' + date.toUTCString(); | ||
63 | + } | ||
64 | + path = options.path ? '; path=' + options.path : ''; | ||
65 | + domain = options.domain ? '; domain=' + options.domain : ''; | ||
66 | + secure = options.secure ? '; secure' : ''; | ||
67 | + document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); | ||
68 | + } | ||
69 | +} | ||
70 | + | ||
71 | +function getUser() { | ||
72 | + var c = cookie('_UID'), | ||
73 | + user; | ||
74 | + | ||
75 | + if (typeof c === 'undefined') { | ||
76 | + return 0; | ||
77 | + } | ||
78 | + | ||
79 | + user = c.split('::'); | ||
80 | + | ||
81 | + if (typeof user === 'undefined' || user.length < 4) { | ||
82 | + return 0; | ||
83 | + } | ||
84 | + | ||
85 | + return user; | ||
86 | +} | ||
87 | + | ||
88 | +function getUid() { | ||
89 | + var user = getUser(); | ||
90 | + | ||
91 | + if (user === 0) { | ||
92 | + return 0; | ||
93 | + } | ||
94 | + | ||
95 | + return user[1]; | ||
96 | +} | ||
97 | + | ||
98 | +function getShoppingKey() { | ||
99 | + var c = cookie('_g'); | ||
100 | + | ||
101 | + if (typeof c === 'undefined') { | ||
102 | + return ''; | ||
103 | + } | ||
104 | + | ||
105 | + return JSON.parse(c).k; | ||
106 | +} | ||
107 | + | ||
108 | +//页面通用底部位置及status设置 | ||
109 | +(function () { | ||
110 | + var $footer = $('#yoho-footer'), | ||
111 | + $op = $footer.children('.op-row'); | ||
112 | + | ||
113 | + var user = getUser(); | ||
114 | + | ||
115 | + if ($('body').height() < $(window).height()) { | ||
116 | + $footer.addClass('bottom'); | ||
117 | + } | ||
118 | + | ||
119 | + if (user === 0) { | ||
120 | + | ||
121 | + //未登录 | ||
122 | + $op.prepend( | ||
123 | + '<a href="http://m.yohobuy.com/signin.html">登录</a>' + | ||
124 | + '<span class="sep-line">|</span>' + | ||
125 | + '<a href="http://m.yohobuy.com/reg.html">注册</a>' | ||
126 | + ); | ||
127 | + } else { | ||
128 | + | ||
129 | + //已登录 | ||
130 | + $op.prepend( | ||
131 | + 'Hi,' + | ||
132 | + '<a class="user-name" href="http://m.yohobuy.com/home?tmp=' + Math.random() + '">' + user[0] + '</a>' + | ||
133 | + '<a href="http://m.yohobuy.com/passport/signout/index?token=' + user[3] + '">退出</a>' | ||
134 | + ); | ||
135 | + } | ||
136 | + | ||
137 | + $footer.removeClass('hide'); | ||
138 | +}()); | ||
139 | + | ||
140 | +//暴露公共接口 | ||
141 | +window.cookie = cookie; | ||
142 | + | ||
143 | +window.setCookie = setCookie; | ||
144 | + | ||
145 | +window.getUser = getUser; | ||
146 | + | ||
147 | +window.getUid = getUid; | ||
148 | + | ||
149 | +window.getShoppingKey = getShoppingKey; | ||
150 | + | ||
151 | +}); | ||
152 | +define("js/passport/index", ["zepto"], function(require, exports, module){ | ||
153 | +/** | ||
154 | + * 注册、登录、密码找回打包入口 | ||
155 | + * @author: xuqi<qi.xu@yoho.cn> | ||
156 | + * @date: 2015/10/8 | ||
157 | + */ | ||
158 | + | ||
159 | +//注册 | ||
160 | +require("js/passport/register/register"); | ||
161 | +require("js/passport/register/code"); | ||
162 | +require("js/passport/register/password"); | ||
163 | + | ||
164 | +//登录 | ||
165 | +require("js/passport/login/login"); | ||
166 | +require("js/passport/login/international"); | ||
167 | + | ||
168 | +//密码找回 | ||
169 | +require("js/passport/back/mobile"); | ||
170 | +require("js/passport/back/code"); | ||
171 | +require("js/passport/back/email"); | ||
172 | +require("js/passport/back/email-success"); | ||
173 | +require("js/passport/back/new-password"); | ||
174 | +}); | ||
175 | +define("js/passport/register/register", ["zepto"], function(require, exports, module){ | ||
176 | +/** | ||
177 | + * 注册 | ||
178 | + * @author: xuqi<qi.xu@yoho.cn> | ||
179 | + * @date: 2015/10/8 | ||
180 | + */ | ||
181 | +var $ = require("zepto"); | ||
182 | + | ||
183 | +var $phoneNum = $('#phone-num'), | ||
184 | + $countrySelect = $('#country-select'), | ||
185 | + $areaCode = $('#area-code'), | ||
186 | + $btnNext = $('#btn-next'); | ||
187 | + | ||
188 | +var api = require("js/passport/api"); | ||
189 | +var tip = require("js/plugin/tip"); | ||
190 | + | ||
191 | +var trim = $.trim; | ||
192 | +var showErrTip = tip.show; | ||
193 | + | ||
194 | +api.selectCssHack($('#country-select')); | ||
195 | + | ||
196 | +api.bindClearEvt(); | ||
197 | + | ||
198 | +$phoneNum.bind('input', function() { | ||
199 | + if (trim($phoneNum.val()) === '') { | ||
200 | + $btnNext.addClass('disable'); | ||
201 | + } else { | ||
202 | + $btnNext.removeClass('disable'); | ||
203 | + } | ||
204 | +}); | ||
205 | + | ||
206 | +$countrySelect.change(function() { | ||
207 | + $areaCode.text($countrySelect.val()); | ||
208 | +}); | ||
209 | + | ||
210 | +$btnNext.on('tap', function() { | ||
211 | + var pn = trim($phoneNum.val()), | ||
212 | + areaCode = $countrySelect.val(); | ||
213 | + | ||
214 | + if ($btnNext.hasClass('disable')) { | ||
215 | + return; | ||
216 | + } | ||
217 | + | ||
218 | + if (api.phoneRegx[areaCode].test(pn)) { | ||
219 | + $.ajax({ | ||
220 | + url: '/passport/reg/verifymobile', | ||
221 | + type: 'POST', | ||
222 | + data: { | ||
223 | + areaCode: areaCode.replace('+', ''), | ||
224 | + phoneNum: pn | ||
225 | + }, | ||
226 | + success: function(data) { | ||
227 | + if (data.code === 200) { | ||
228 | + location.href = data.data; | ||
229 | + } else { | ||
230 | + showErrTip(data.message); | ||
231 | + } | ||
232 | + } | ||
233 | + }); | ||
234 | + } else { | ||
235 | + showErrTip('手机号格式不正确,请重新输入'); | ||
236 | + } | ||
237 | +}); | ||
238 | +}); | ||
239 | +define("js/passport/api", ["zepto"], function(require, exports, module){ | ||
240 | +/** | ||
241 | + * 登录注册公用API | ||
242 | + * @author: xuqi<qi.xu@yoho.cn> | ||
243 | + * @date: 2015/10/8 | ||
244 | + */ | ||
245 | +var $ = require("zepto"); | ||
246 | + | ||
247 | +var trim = $.trim; | ||
248 | + | ||
249 | +//邮箱验证规则 | ||
250 | +var emailRegx = /^([a-zA-Z0-9]+[_|\_|\.|-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.|-]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; | ||
251 | + | ||
252 | +//手机号码验证规则 | ||
253 | +var phoneRegx = { | ||
254 | + '+86': /^1[35847]{1}[0-9]{9}$/, | ||
255 | + '+852': /^[965]{1}[0-9]{7}$/, | ||
256 | + '+853': /^[0-9]{8}$/, | ||
257 | + '+886': /^[0-9]{10}$/, | ||
258 | + '+65': /^[98]{1}[0-9]{7}$/, | ||
259 | + '+60': /^1[1234679]{1}[0-9]{8}$/, | ||
260 | + '+1': /^[0-9]{10}$/, | ||
261 | + '+82': /^01[0-9]{9}$/, | ||
262 | + '+44': /^7[789][0-9]{8}$/, | ||
263 | + '+81': /^0[9|8|7][0-9]{9}$/, | ||
264 | + '+61': /^[0-9]{11}$/ | ||
265 | +}; | ||
266 | + | ||
267 | +/** | ||
268 | + * 密码显示隐藏 | ||
269 | + * @params opt 初始化参数 | ||
270 | + */ | ||
271 | +function bindEyesEvt(opt) { | ||
272 | + var $hasEye = $('.has-eye'), | ||
273 | + $eye; | ||
274 | + | ||
275 | + if (opt && opt.status === 'open') { | ||
276 | + $hasEye.append('<div class="eye"></div>'); | ||
277 | + } else { | ||
278 | + $hasEye.append('<div class="eye close"></div>'); | ||
279 | + } | ||
280 | + $eye = $hasEye.children('.eye'); | ||
281 | + | ||
282 | + $eye.on('tap', function(e) { | ||
283 | + var $this = $(this), | ||
284 | + $pwd = $this.siblings('.pwd'); | ||
285 | + | ||
286 | + e.preventDefault(); | ||
287 | + $this.toggleClass('close'); | ||
288 | + | ||
289 | + //切换密码显示和文本显示 | ||
290 | + if ($this.hasClass('close')) { | ||
291 | + $pwd.attr('type', 'password'); | ||
292 | + } else { | ||
293 | + $pwd.attr('type', 'text'); | ||
294 | + } | ||
295 | + $pwd.focus(); | ||
296 | + }); | ||
297 | +} | ||
298 | + | ||
299 | +// 清空账号显示 | ||
300 | +function bindClearEvt() { | ||
301 | + var $hasClear = $('.has-clear'), | ||
302 | + $clear; | ||
303 | + | ||
304 | + $hasClear.append('<div class="clear-input"></div>'); | ||
305 | + $clear = $hasClear.children('.clear-input'); | ||
306 | + | ||
307 | + $clear.on('tap', function(e) { | ||
308 | + var $input = $clear.siblings('.input'); | ||
309 | + | ||
310 | + $input.val('').trigger('input').focus(); | ||
311 | + e.preventDefault(); | ||
312 | + }); | ||
313 | + | ||
314 | + //反向逻辑 | ||
315 | + $hasClear.children('.input').bind('input', function() { | ||
316 | + var $this = $(this), | ||
317 | + $thisClear = $this.siblings('.clear-input'), | ||
318 | + val = trim($this.val()); | ||
319 | + | ||
320 | + if (val === '') { | ||
321 | + $thisClear.hide(); | ||
322 | + } else { | ||
323 | + $thisClear.show(); | ||
324 | + } | ||
325 | + }); | ||
326 | +} | ||
327 | + | ||
328 | +// 密码长度验证 | ||
329 | +function pwdValidate(pwd) { | ||
330 | + if (pwd.length >= 6 && pwd.length <= 20) { | ||
331 | + return true; | ||
332 | + } | ||
333 | + return false; | ||
334 | +} | ||
335 | + | ||
336 | +// hack for resolving direction:rtl didn't work in android uc | ||
337 | +function selectCssHack($countrySelect) { | ||
338 | + var u = navigator.userAgent; | ||
339 | + | ||
340 | + function autoSelectWidth() { | ||
341 | + var wordCount = $countrySelect.find('option:selected').text().length; | ||
342 | + | ||
343 | + switch (wordCount) { | ||
344 | + | ||
345 | + //分别有2,3,4个汉字的情况 | ||
346 | + case 2: | ||
347 | + $countrySelect.outerWidth(90); | ||
348 | + break; | ||
349 | + case 3: | ||
350 | + $countrySelect.outerWidth(110); | ||
351 | + break; | ||
352 | + default: | ||
353 | + $countrySelect.outerWidth(130); | ||
354 | + } | ||
355 | + } | ||
356 | + | ||
357 | + if (u.match(/uc/i) && u.match(/android/i)) { | ||
358 | + $countrySelect.change(function() { | ||
359 | + autoSelectWidth(); | ||
360 | + }); | ||
361 | + } else { | ||
362 | + $countrySelect.removeClass('in-android-uc'); | ||
363 | + } | ||
364 | +} | ||
365 | + | ||
366 | +//Exports APIs | ||
367 | +module.exports = { | ||
368 | + emailRegx: emailRegx, | ||
369 | + phoneRegx: phoneRegx, | ||
370 | + bindEyesEvt: bindEyesEvt, | ||
371 | + bindClearEvt: bindClearEvt, | ||
372 | + pwdValidate: pwdValidate, | ||
373 | + selectCssHack: selectCssHack | ||
374 | +}; | ||
375 | +}); | ||
376 | +define("js/plugin/tip", ["zepto"], function(require, exports, module){ | ||
377 | +/** | ||
378 | + * 弹框提示 | ||
379 | + * @author: xuqi<qi.xu@yoho.cn> | ||
380 | + * @date: 2015/10/10 | ||
381 | + */ | ||
382 | +var $ = require("zepto"); | ||
383 | + | ||
384 | +var $tip, tipItime; | ||
385 | + | ||
386 | +/** | ||
387 | + * 初始化提示框 | ||
388 | + */ | ||
389 | +(function() { | ||
390 | + var tipHtml = '<div id="yoho-tip" class="yoho-tip"></div>'; | ||
391 | + | ||
392 | + //插入提示HTML | ||
393 | + $('.yoho-page').append(tipHtml); | ||
394 | + | ||
395 | + $tip = $('#yoho-tip'); | ||
396 | + $tip.on('tap', function() { | ||
397 | + $tip.hide(); | ||
398 | + | ||
399 | + //清除Timeout | ||
400 | + clearTimeout(tipItime); | ||
401 | + }); | ||
402 | +}()); | ||
403 | + | ||
404 | +/** | ||
405 | + * 显示提示 | ||
406 | + */ | ||
407 | +function show(con, dur) { | ||
408 | + var content, duration; | ||
409 | + | ||
410 | + if (typeof con === 'undefined') { | ||
411 | + return; | ||
412 | + } | ||
413 | + | ||
414 | + content = con.toString(); | ||
415 | + duration = (dur && dur > 0) ? dur : 2000; | ||
416 | + | ||
417 | + $tip.text(content).show(); | ||
418 | + | ||
419 | + tipItime = setTimeout(function() { | ||
420 | + if ($tip.css('display') === 'block') { | ||
421 | + $tip.hide(); | ||
422 | + } | ||
423 | + }, duration); | ||
424 | +} | ||
425 | + | ||
426 | +exports.show = show; | ||
427 | +}); | ||
428 | +define("js/passport/register/code", ["zepto"], function(require, exports, module){ | ||
429 | +/** | ||
430 | + * 注册-验证码 | ||
431 | + * @author: xuqi<qi.xu@yoho.cn> | ||
432 | + * @date: 2015/10/8 | ||
433 | + */ | ||
434 | + | ||
435 | +require("js/passport/code")(true); | ||
436 | +}); | ||
437 | +define("js/passport/code", ["zepto"], function(require, exports, module){ | ||
438 | +/** | ||
439 | + * 注册/找回密码-验证码 | ||
440 | + * @author: xuqi<qi.xu@yoho.cn> | ||
441 | + * @date: 2015/10/8 | ||
442 | + */ | ||
443 | +var $ = require("zepto"); | ||
444 | + | ||
445 | +module.exports = function(useInRegister) { | ||
446 | + var $captcha = $('#captcha'), | ||
447 | + $btnNext = $('#btn-next'), | ||
448 | + $captchaTip = $('#captcha-tip'), | ||
449 | + phoneNum = $('#phone-num').val(), | ||
450 | + areaCode = $('#area-code').val().replace('+', ''); | ||
451 | + | ||
452 | + var api = require("js/passport/api"); | ||
453 | + var tip = require("js/plugin/tip"); | ||
454 | + | ||
455 | + var trim = $.trim; | ||
456 | + var showErrTip = tip.show; | ||
457 | + | ||
458 | + var urlMid = useInRegister ? 'reg' : 'back'; | ||
459 | + | ||
460 | + function countDown() { | ||
461 | + var count = 59, | ||
462 | + itime; | ||
463 | + | ||
464 | + itime = setInterval(function() { | ||
465 | + if (count === 0) { | ||
466 | + $captchaTip.text('重发验证码').removeClass('disable'); | ||
467 | + clearInterval(itime); | ||
468 | + } else { | ||
469 | + $captchaTip.text('重发验证码 (' + count-- + '秒)'); | ||
470 | + } | ||
471 | + }, 1000); | ||
472 | + } | ||
473 | + | ||
474 | + api.bindClearEvt(); | ||
475 | + | ||
476 | + $captcha.bind('input', function() { | ||
477 | + if (trim($captcha.val()) !== '') { | ||
478 | + $btnNext.removeClass('disable'); | ||
479 | + } else { | ||
480 | + $btnNext.addClass('disable'); | ||
481 | + } | ||
482 | + }); | ||
483 | + | ||
484 | + //重新发送验证码 | ||
485 | + $captchaTip.on('tap', function() { | ||
486 | + if ($captchaTip.hasClass('disable')) { | ||
487 | + return; | ||
488 | + } | ||
489 | + | ||
490 | + $.ajax({ | ||
491 | + type: 'POST', | ||
492 | + url: '/passport/' + urlMid + '/sendcode', | ||
493 | + data: { | ||
494 | + phoneNum: phoneNum, | ||
495 | + areaCode: areaCode | ||
496 | + }, | ||
497 | + success: function(data) { | ||
498 | + if (data.code === 200) { | ||
499 | + $captchaTip.text('重发验证码 (60秒)').addClass('disable'); | ||
500 | + countDown(); | ||
501 | + } else { | ||
502 | + | ||
503 | + //验证码不正确,显示提示 | ||
504 | + showErrTip(data.message); | ||
505 | + } | ||
506 | + } | ||
507 | + }); | ||
508 | + }); | ||
509 | + | ||
510 | + $btnNext.on('tap', function() { | ||
511 | + if ($btnNext.hasClass('disable')) { | ||
512 | + return; | ||
513 | + } | ||
514 | + | ||
515 | + $.ajax({ | ||
516 | + type: 'POST', | ||
517 | + url: '/passport/' + urlMid + '/verifycode', | ||
518 | + data: { | ||
519 | + phoneNum: phoneNum, | ||
520 | + areaCode: areaCode, | ||
521 | + code: trim($captcha.val()), | ||
522 | + token: $('#token').val() | ||
523 | + }, | ||
524 | + success: function(data) { | ||
525 | + if (data.code === 200) { | ||
526 | + location.href = data.data; | ||
527 | + } else { | ||
528 | + | ||
529 | + //验证码不正确,显示提示 | ||
530 | + showErrTip(data.message); | ||
531 | + } | ||
532 | + } | ||
533 | + }); | ||
534 | + }); | ||
535 | + | ||
536 | + countDown(); | ||
537 | +}; | ||
538 | +}); | ||
539 | +define("js/passport/register/password", ["zepto"], function(require, exports, module){ | ||
540 | +/** | ||
541 | + * 注册-密码 | ||
542 | + * @author: xuqi<qi.xu@yoho.cn> | ||
543 | + * @date: 2015/10/8 | ||
544 | + */ | ||
545 | +var $ = require("zepto"); | ||
546 | + | ||
547 | +var $pwd = $('#pwd'), | ||
548 | + $btnSure = $('#btn-sure'); | ||
549 | + | ||
550 | +var api = require("js/passport/api"); | ||
551 | +var tip = require("js/plugin/tip"); | ||
552 | + | ||
553 | +var trim = $.trim; | ||
554 | +var showErrTip = tip.show; | ||
555 | + | ||
556 | +api.bindEyesEvt({ | ||
557 | + status: 'open' //默认眼睛打开 | ||
558 | +}); | ||
559 | + | ||
560 | +$pwd.bind('input', function() { | ||
561 | + if (trim($pwd.val()) === '') { | ||
562 | + $btnSure.addClass('disable'); | ||
563 | + } else { | ||
564 | + $btnSure.removeClass('disable'); | ||
565 | + } | ||
566 | +}); | ||
567 | + | ||
568 | +$btnSure.on('tap', function() { | ||
569 | + var pwd = trim($pwd.val()); | ||
570 | + | ||
571 | + if ($btnSure.hasClass('disable')) { | ||
572 | + return; | ||
573 | + } | ||
574 | + | ||
575 | + if (api.pwdValidate(pwd) === false) { | ||
576 | + showErrTip('密码6-20位,请重新输入'); | ||
577 | + } else { | ||
578 | + $.ajax({ | ||
579 | + type: 'POST', | ||
580 | + url: '/passport/reg/setpassword', | ||
581 | + data: { | ||
582 | + password: pwd, | ||
583 | + phoneNum: $('#phone-num').val(), | ||
584 | + areaCode: $('#area-code').val(), | ||
585 | + token: $('#token').val() | ||
586 | + }, | ||
587 | + success: function(data) { | ||
588 | + if (data.code === 200) { | ||
589 | + showErrTip('注册成功'); | ||
590 | + | ||
591 | + //1000ms后跳转页面 | ||
592 | + setTimeout(function() { | ||
593 | + location.href = data.data; | ||
594 | + }, 1000); | ||
595 | + } else { | ||
596 | + if (data.code === 401 || data.code === 404 || data.code === 505) { | ||
597 | + showErrTip(data.message); | ||
598 | + } else { | ||
599 | + showErrTip(data.message); | ||
600 | + setTimeout(function() { | ||
601 | + location.href = data.data; | ||
602 | + }, 1000); | ||
603 | + } | ||
604 | + } | ||
605 | + } | ||
606 | + }); | ||
607 | + } | ||
608 | +}); | ||
609 | +}); | ||
610 | +define("js/passport/login/login", ["zepto"], function(require, exports, module){ | ||
611 | +/** | ||
612 | + * 登录 | ||
613 | + * @author: xuqi<qi.xu@yoho.cn> | ||
614 | + * @date: 2015/9/30 | ||
615 | + */ | ||
616 | +var $ = require("zepto"); | ||
617 | + | ||
618 | +var $account = $('#account'), | ||
619 | + $pwd = $('#pwd'), | ||
620 | + $loginBtn = $('#btn-login'), | ||
621 | + | ||
622 | + $mask = $('#retrive-pwd-mask'), | ||
623 | + $ways = $('#retrive-pwd-ways'), | ||
624 | + | ||
625 | + accPass = false, | ||
626 | + pwdPass = false; | ||
627 | + | ||
628 | +var api = require("js/passport/api"); | ||
629 | +var tip = require("js/plugin/tip"); | ||
630 | + | ||
631 | +var trim = $.trim; | ||
632 | +var showErrTip = tip.show; | ||
633 | + | ||
634 | +//登录按钮状态切换 | ||
635 | +function switchLoginBtnStatus() { | ||
636 | + if (accPass && pwdPass) { | ||
637 | + $loginBtn.removeClass('disable'); | ||
638 | + } else { | ||
639 | + $loginBtn.addClass('disable'); | ||
640 | + } | ||
641 | +} | ||
642 | + | ||
643 | +//显示找回密码面板 | ||
644 | +function showRetrivePanel() { | ||
645 | + $mask.show(); | ||
646 | + $ways.show(); | ||
647 | +} | ||
648 | + | ||
649 | +//隐藏找回密码面板 | ||
650 | +function hideRetrivePanel() { | ||
651 | + $mask.hide(); | ||
652 | + $ways.hide(); | ||
653 | +} | ||
654 | + | ||
655 | +//密码显示与隐藏 | ||
656 | +api.bindEyesEvt(); | ||
657 | + | ||
658 | +//清空账号输入框 | ||
659 | +api.bindClearEvt(); | ||
660 | + | ||
661 | +$account.bind('input', function() { | ||
662 | + if (trim($account.val()) !== '') { | ||
663 | + accPass = true; | ||
664 | + } else { | ||
665 | + accPass = false; | ||
666 | + } | ||
667 | + switchLoginBtnStatus(); | ||
668 | +}); | ||
669 | + | ||
670 | +$pwd.bind('input', function() { | ||
671 | + if (trim($pwd.val()) === '') { | ||
672 | + pwdPass = false; | ||
673 | + } else { | ||
674 | + pwdPass = true; | ||
675 | + } | ||
676 | + switchLoginBtnStatus(); | ||
677 | +}); | ||
678 | + | ||
679 | + | ||
680 | +// Login | ||
681 | +$loginBtn.on('tap', function() { | ||
682 | + var acc = trim($account.val()), | ||
683 | + pwd = trim($pwd.val()); | ||
684 | + | ||
685 | + if ($loginBtn.hasClass('disable')) { | ||
686 | + return; | ||
687 | + } | ||
688 | + | ||
689 | + //验证账号(数字或者邮箱)和密码合理性 | ||
690 | + if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) { | ||
691 | + $.ajax({ | ||
692 | + type: 'POST', | ||
693 | + url: '/passport/login/auth', | ||
694 | + data: { | ||
695 | + account: acc, | ||
696 | + password: pwd | ||
697 | + }, | ||
698 | + success: function(data) { | ||
699 | + if (data.code === 200) { | ||
700 | + showErrTip('登录成功'); | ||
701 | + | ||
702 | + //1s后跳转页面 | ||
703 | + setTimeout(function() { | ||
704 | + location.href = data.data; | ||
705 | + }, 1000); | ||
706 | + } else { | ||
707 | + showErrTip(data.message); | ||
708 | + } | ||
709 | + }, | ||
710 | + error: function() { | ||
711 | + showErrTip('网络断开连接啦~'); | ||
712 | + } | ||
713 | + }); | ||
714 | + } else { | ||
715 | + showErrTip('账号或密码有错误,请重新输入'); | ||
716 | + } | ||
717 | +}); | ||
718 | + | ||
719 | + | ||
720 | +$('#forget-pwd').on('tap', function() { | ||
721 | + showRetrivePanel(); | ||
722 | +}); | ||
723 | + | ||
724 | +$mask.on('tap', function() { | ||
725 | + hideRetrivePanel(); | ||
726 | +}); | ||
727 | + | ||
728 | +$('#cancel-retrive').on('tap', function(e) { | ||
729 | + e.preventDefault(); | ||
730 | + hideRetrivePanel(); | ||
731 | +}); | ||
732 | + | ||
733 | +//对初始有默认值的情况去初始化登录按钮状态 | ||
734 | +$account.trigger('input'); | ||
735 | +$pwd.trigger('input'); | ||
736 | +}); | ||
737 | +define("js/passport/login/international", ["zepto"], function(require, exports, module){ | ||
738 | +/** | ||
739 | + * 国际账号登录 | ||
740 | + * @author: xuqi<qi.xu@yoho.cn> | ||
741 | + * @date: 2015/10/8 | ||
742 | + */ | ||
743 | +var $ = require("zepto"); | ||
744 | + | ||
745 | +var $phoneNum = $('#phone-num'), | ||
746 | + $countrySelect = $('#country-select'), | ||
747 | + $areaCode = $('#area-code'), | ||
748 | + $pwd = $('#pwd'), | ||
749 | + $loginBtn = $('#btn-login'), | ||
750 | + | ||
751 | + pnPass = false, | ||
752 | + pwdPass = false; | ||
753 | + | ||
754 | +var api = require("js/passport/api"); | ||
755 | +var tip = require("js/plugin/tip"); | ||
756 | + | ||
757 | +var trim = $.trim; | ||
758 | +var showErrTip = tip.show; | ||
759 | + | ||
760 | +//登录按钮状态切换 | ||
761 | +function switchLoginBtnStatus() { | ||
762 | + if (pnPass && pwdPass) { | ||
763 | + $loginBtn.removeClass('disable'); | ||
764 | + } else { | ||
765 | + $loginBtn.addClass('disable'); | ||
766 | + } | ||
767 | +} | ||
768 | + | ||
769 | +//Android-UC下显示select的direction:rtl无效的临时解决办法 | ||
770 | +api.selectCssHack($countrySelect); | ||
771 | + | ||
772 | +//显示隐藏密码 | ||
773 | +api.bindEyesEvt(); | ||
774 | + | ||
775 | +//清空手机号码 | ||
776 | +api.bindClearEvt(); | ||
777 | + | ||
778 | +$phoneNum.bind('input', function() { | ||
779 | + if (trim($phoneNum.val()) === '') { | ||
780 | + pnPass = false; | ||
781 | + } else { | ||
782 | + pnPass = true; | ||
783 | + } | ||
784 | + | ||
785 | + switchLoginBtnStatus(); | ||
786 | +}); | ||
787 | + | ||
788 | +$pwd.bind('input', function() { | ||
789 | + var pwd = trim($pwd.val()); | ||
790 | + | ||
791 | + if (pwd === '') { | ||
792 | + pwdPass = false; | ||
793 | + } else { | ||
794 | + pwdPass = true; | ||
795 | + } | ||
796 | + | ||
797 | + switchLoginBtnStatus(); | ||
798 | +}); | ||
799 | + | ||
800 | +$countrySelect.change(function() { | ||
801 | + $areaCode.text($countrySelect.val()); | ||
802 | +}); | ||
803 | + | ||
804 | +$loginBtn.on('tap', function() { | ||
805 | + var pn = trim($phoneNum.val()), | ||
806 | + areaCode = $countrySelect.val(), | ||
807 | + pwd = trim($pwd.val()); | ||
808 | + | ||
809 | + if ($loginBtn.hasClass('disable')) { | ||
810 | + return; | ||
811 | + } | ||
812 | + | ||
813 | + if (api.phoneRegx[areaCode].test(pn) && api.pwdValidate(pwd)) { | ||
814 | + $.ajax({ | ||
815 | + type: 'POST', | ||
816 | + url: '/passport/login/auth', | ||
817 | + data: { | ||
818 | + areaCode: areaCode.replace('+', ''), | ||
819 | + account: pn, | ||
820 | + password: pwd | ||
821 | + }, | ||
822 | + success: function(data) { | ||
823 | + if (data.code === 200) { | ||
824 | + showErrTip('登录成功'); | ||
825 | + | ||
826 | + //1000ms后跳转页面 | ||
827 | + setTimeout(function() { | ||
828 | + location.href = data.data; | ||
829 | + }, 1000); | ||
830 | + } else { | ||
831 | + showErrTip(data.message); | ||
832 | + } | ||
833 | + }, | ||
834 | + error: function() { | ||
835 | + showErrTip('网络断开连接啦~'); | ||
836 | + } | ||
837 | + }); | ||
838 | + } else { | ||
839 | + showErrTip('账号或密码有错误,请重新输入'); | ||
840 | + } | ||
841 | +}); | ||
842 | + | ||
843 | +//对初始有默认值的情况去初始化登录按钮状态 | ||
844 | +$phoneNum.trigger('input'); | ||
845 | +$pwd.trigger('input'); | ||
846 | +}); | ||
847 | +define("js/passport/back/mobile", ["zepto"], function(require, exports, module){ | ||
848 | +/** | ||
849 | + * 找回密码-手机 | ||
850 | + * @author: xuqi<qi.xu@yoho.cn> | ||
851 | + * @date: 2015/10/8 | ||
852 | + */ | ||
853 | +var $ = require("zepto"); | ||
854 | + | ||
855 | +var $phoneNum = $('#phone-num'), | ||
856 | + $countrySelect = $('#country-select'), | ||
857 | + $areaCode = $('#area-code'), | ||
858 | + $btnNext = $('#btn-next'); | ||
859 | + | ||
860 | +var api = require("js/passport/api"); | ||
861 | +var tip = require("js/plugin/tip"); | ||
862 | + | ||
863 | +var trim = $.trim; | ||
864 | +var showErrTip = tip.show; | ||
865 | + | ||
866 | +api.selectCssHack($('#country-select')); | ||
867 | + | ||
868 | +api.bindClearEvt(); | ||
869 | + | ||
870 | +$phoneNum.bind('input', function() { | ||
871 | + if (trim($phoneNum.val()) === '') { | ||
872 | + $btnNext.addClass('disable'); | ||
873 | + } else { | ||
874 | + $btnNext.removeClass('disable'); | ||
875 | + } | ||
876 | +}); | ||
877 | + | ||
878 | +$countrySelect.change(function() { | ||
879 | + $areaCode.text($countrySelect.val()); | ||
880 | +}); | ||
881 | + | ||
882 | +$btnNext.on('tap', function() { | ||
883 | + var pn = trim($phoneNum.val()), | ||
884 | + area = $countrySelect.val(); | ||
885 | + | ||
886 | + if ($btnNext.hasClass('disable')) { | ||
887 | + return; | ||
888 | + } | ||
889 | + | ||
890 | + if (api.phoneRegx[area].test(pn)) { | ||
891 | + $.ajax({ | ||
892 | + url: '/passport/back/sendcode', | ||
893 | + type: 'POST', | ||
894 | + data: { | ||
895 | + areaCode: area.replace('+', ''), | ||
896 | + phoneNum: pn | ||
897 | + }, | ||
898 | + success: function(data) { | ||
899 | + if (data.code === 200) { | ||
900 | + location.href = data.data; | ||
901 | + } else { | ||
902 | + showErrTip(data.message); | ||
903 | + } | ||
904 | + } | ||
905 | + }); | ||
906 | + } else { | ||
907 | + showErrTip('手机号格式不正确,请重新输入'); | ||
908 | + } | ||
909 | +}); | ||
910 | +}); | ||
911 | +define("js/passport/back/code", ["zepto"], function(require, exports, module){ | ||
912 | +/** | ||
913 | + * 找回密码-验证码 | ||
914 | + * @author: xuqi<qi.xu@yoho.cn> | ||
915 | + * @date: 2015/10/8 | ||
916 | + */ | ||
917 | + | ||
918 | +require("js/passport/code")(false); | ||
919 | +}); | ||
920 | +define("js/passport/back/email", ["zepto"], function(require, exports, module){ | ||
921 | +/** | ||
922 | + * 找回密码-邮箱找回 | ||
923 | + * @author: xuqi<qi.xu@yoho.cn> | ||
924 | + * @date: 2015/10/8 | ||
925 | + */ | ||
926 | +var $ = require("zepto"); | ||
927 | + | ||
928 | +var $email = $('#email'), | ||
929 | + $btnSure = $('#btn-sure'); | ||
930 | + | ||
931 | +var api = require("js/passport/api"); | ||
932 | +var tip = require("js/plugin/tip"); | ||
933 | + | ||
934 | +var trim = $.trim; | ||
935 | +var showErrTip = tip.show; | ||
936 | + | ||
937 | +api.bindClearEvt(); | ||
938 | + | ||
939 | +$email.bind('input', function() { | ||
940 | + if (trim($email.val()) === '') { | ||
941 | + $btnSure.addClass('disable'); | ||
942 | + } else { | ||
943 | + $btnSure.removeClass('disable'); | ||
944 | + } | ||
945 | +}); | ||
946 | + | ||
947 | +$btnSure.on('tap', function() { | ||
948 | + var email = trim($email.val()); | ||
949 | + | ||
950 | + if ($btnSure.hasClass('disable')) { | ||
951 | + return; | ||
952 | + } | ||
953 | + | ||
954 | + if (api.emailRegx.test(email)) { | ||
955 | + $.ajax({ | ||
956 | + url: '/passport/back/sendemail', | ||
957 | + type: 'POST', | ||
958 | + data: { | ||
959 | + email: email | ||
960 | + }, | ||
961 | + success: function(data) { | ||
962 | + if (data.code === 200) { | ||
963 | + location.href = data.data; | ||
964 | + } else { | ||
965 | + showErrTip(data.message); | ||
966 | + } | ||
967 | + } | ||
968 | + }); | ||
969 | + } else { | ||
970 | + showErrTip('邮箱格式不正确,请重新输入'); | ||
971 | + } | ||
972 | +}); | ||
973 | +}); | ||
974 | +define("js/passport/back/email-success", ["zepto"], function(require, exports, module){ | ||
975 | +/** | ||
976 | + * 找回密码-邮箱找回成功 | ||
977 | + * @author: xuqi<qi.xu@yoho.cn> | ||
978 | + * @date: 2015/10/8 | ||
979 | + */ | ||
980 | + | ||
981 | +var $ = require("zepto"); | ||
982 | + | ||
983 | +var $resend = $('#resend'); | ||
984 | + | ||
985 | +var tip = require("js/plugin/tip"), | ||
986 | + showErrTip = tip.show; | ||
987 | + | ||
988 | +$resend.on('tap', function(e) { | ||
989 | + e.preventDefault(); | ||
990 | + | ||
991 | + $.ajax({ | ||
992 | + url: $resend.data('url'), | ||
993 | + type: 'GET', | ||
994 | + success: function(data) { | ||
995 | + if (data.code === 200) { | ||
996 | + showErrTip(data.message); | ||
997 | + } else { | ||
998 | + showErrTip(data.message); | ||
999 | + } | ||
1000 | + } | ||
1001 | + }); | ||
1002 | +}); | ||
1003 | +}); | ||
1004 | +define("js/passport/back/new-password", ["zepto"], function(require, exports, module){ | ||
1005 | +/** | ||
1006 | + * 密码找回-新密码 | ||
1007 | + * @author: xuqi<qi.xu@yoho.cn> | ||
1008 | + * @date: 2015/10/8 | ||
1009 | + */ | ||
1010 | +var $ = require("zepto"); | ||
1011 | + | ||
1012 | +var $pwd = $('#pwd'), | ||
1013 | + $btnOk = $('#btn-ok'); | ||
1014 | + | ||
1015 | +var api = require("js/passport/api"); | ||
1016 | +var tip = require("js/plugin/tip"); | ||
1017 | + | ||
1018 | +var trim = $.trim; | ||
1019 | +var showErrTip = tip.show; | ||
1020 | + | ||
1021 | +var $phoneNum = $('#phone-num'); | ||
1022 | + | ||
1023 | +api.bindEyesEvt(); | ||
1024 | + | ||
1025 | +$pwd.bind('input', function() { | ||
1026 | + if (trim($pwd.val()) === '') { | ||
1027 | + $btnOk.addClass('disable'); | ||
1028 | + } else { | ||
1029 | + $btnOk.removeClass('disable'); | ||
1030 | + } | ||
1031 | +}); | ||
1032 | + | ||
1033 | +$btnOk.on('tap', function() { | ||
1034 | + var pwd = trim($pwd.val()), | ||
1035 | + mobileBack = true, | ||
1036 | + setting, | ||
1037 | + url; | ||
1038 | + | ||
1039 | + if ($btnOk.hasClass('disable')) { | ||
1040 | + return; | ||
1041 | + } | ||
1042 | + | ||
1043 | + setting = { | ||
1044 | + password: pwd | ||
1045 | + }; | ||
1046 | + | ||
1047 | + if ($phoneNum.length === 0) { | ||
1048 | + mobileBack = false; | ||
1049 | + } | ||
1050 | + | ||
1051 | + if (mobileBack) { | ||
1052 | + $.extend(setting, { | ||
1053 | + phoneNum: $phoneNum.val(), | ||
1054 | + areaCode: $('#areaCode').val(), | ||
1055 | + token: $('#token').val() | ||
1056 | + }); | ||
1057 | + | ||
1058 | + url = '/passport/back/passwordByMobile'; | ||
1059 | + } else { | ||
1060 | + $.extend(setting, { | ||
1061 | + code: $('#email-code').val() | ||
1062 | + }); | ||
1063 | + | ||
1064 | + url = '/passport/back/passwordByEmail'; | ||
1065 | + } | ||
1066 | + | ||
1067 | + | ||
1068 | + if (api.pwdValidate(pwd)) { | ||
1069 | + $.ajax({ | ||
1070 | + type: 'POST', | ||
1071 | + url: url, | ||
1072 | + data: setting, | ||
1073 | + success: function(data) { | ||
1074 | + if (data.code === 200) { | ||
1075 | + showErrTip('密码修改成功'); | ||
1076 | + | ||
1077 | + //1000ms后跳转页面 | ||
1078 | + setTimeout(function() { | ||
1079 | + location.href = data.data; | ||
1080 | + }, 1000); | ||
1081 | + } else { | ||
1082 | + showErrTip(data.message); | ||
1083 | + } | ||
1084 | + } | ||
1085 | + }); | ||
1086 | + } else { | ||
1087 | + showErrTip('密码6-20位,请重新输入'); | ||
1088 | + } | ||
1089 | +}); | ||
1090 | +}); | ||
1091 | +define("js/guang/index", ["zepto","lazyload","swiper","mlellipsis","iscroll-probe","index"], function(require, exports, module){ | ||
1092 | +/** | ||
1093 | + * 逛打包入口 | ||
1094 | + * @author: xuqi<qi.xu@yoho.cn> | ||
1095 | + * @date: 2015/10/9 | ||
1096 | + */ | ||
1097 | + | ||
1098 | +require("js/guang/plus-star/list"); | ||
1099 | +require("js/guang/plus-star/detail"); | ||
1100 | + | ||
1101 | +require("js/guang/home"); | ||
1102 | +require("js/guang/list"); | ||
1103 | +require("js/guang/detail"); | ||
1104 | +}); | ||
1105 | +define("js/guang/plus-star/list", ["zepto","lazyload","swiper","index"], function(require, exports, module){ | ||
1106 | +/** | ||
1107 | + * PLUS+STAR列表页 | ||
1108 | + * @author: xuqi<qi.xu@yoho.cn> | ||
1109 | + * @date: 2015/10/10 | ||
1110 | + */ | ||
1111 | + | ||
1112 | +var $ = require("zepto"), | ||
1113 | + lazyLoad = require("lazyload"), | ||
1114 | + Swiper = require("swiper"); | ||
1115 | + | ||
1116 | +var $navs = $('#nav-tab > li'), | ||
1117 | + $contents = $('#ps-content > .content'); | ||
1118 | + | ||
1119 | +var mySwiper; | ||
1120 | + | ||
1121 | +lazyLoad($('img.lazy')); | ||
1122 | + | ||
1123 | +mySwiper = new Swiper('.swiper-container', { | ||
1124 | + lazyLoading: true, | ||
1125 | + pagination: '.swiper-pagination' | ||
1126 | +}); | ||
1127 | + | ||
1128 | +$('#nav-tab').delegate('li', 'tap', function() { | ||
1129 | + if ($(this).hasClass('focus')) { | ||
1130 | + return; | ||
1131 | + } | ||
1132 | + | ||
1133 | + $navs.toggleClass('focus'); | ||
1134 | + $contents.toggleClass('hide'); | ||
1135 | + | ||
1136 | + $(document).trigger('scroll'); //Trigger lazyLoad | ||
1137 | +}); | ||
1138 | +}); | ||
1139 | +define("js/guang/plus-star/detail", ["zepto","mlellipsis","lazyload"], function(require, exports, module){ | ||
1140 | +/** | ||
1141 | + * PLUS+STAR详情页 | ||
1142 | + * @author: xuqi<qi.xu@yoho.cn> | ||
1143 | + * @date: 2015/10/10 | ||
1144 | + */ | ||
1145 | + | ||
1146 | +var $ = require("zepto"), | ||
1147 | + ellipsis = require("mlellipsis"), | ||
1148 | + lazyLoad = require("lazyload"); | ||
1149 | + | ||
1150 | +var $intro = $('#intro'), | ||
1151 | + $imt = $('#intro-more-txt'), | ||
1152 | + $infosContainer = $('#related-infos-container'); | ||
1153 | + | ||
1154 | +var info = require("js/guang/info"); | ||
1155 | + | ||
1156 | +var tip = require("js/plugin/tip"); | ||
1157 | + | ||
1158 | +var brandId = $('#brand-info').data('id'); | ||
1159 | + | ||
1160 | +var mIntro, aIntro; | ||
1161 | + | ||
1162 | +ellipsis.init(); | ||
1163 | + | ||
1164 | +//Init LazyLoad | ||
1165 | +lazyLoad($('img.lazy')); | ||
1166 | + | ||
1167 | +//文字介绍文字截取 | ||
1168 | +$intro[0].mlellipsis(3); | ||
1169 | + | ||
1170 | +//获取截取文字和完整文字 | ||
1171 | +setTimeout(function() { | ||
1172 | + mIntro = $intro.text(); | ||
1173 | + aIntro = $intro.attr('title'); | ||
1174 | +}); | ||
1175 | + | ||
1176 | +info.initInfosEvt($infosContainer); | ||
1177 | + | ||
1178 | +//文字介绍收起与展开 | ||
1179 | +$('#more-intro').bind('tap', function() { | ||
1180 | + var $this = $(this); | ||
1181 | + | ||
1182 | + $this.toggleClass('spread'); | ||
1183 | + | ||
1184 | + if ($this.hasClass('spread')) { | ||
1185 | + | ||
1186 | + //显示 | ||
1187 | + $intro.text(aIntro); | ||
1188 | + $imt.text('收起'); | ||
1189 | + } else { | ||
1190 | + | ||
1191 | + //隐藏 | ||
1192 | + $intro.text(mIntro); | ||
1193 | + $imt.text('more'); | ||
1194 | + } | ||
1195 | +}); | ||
1196 | + | ||
1197 | +//品牌收藏 | ||
1198 | +$('#brand-like').bind('tap', function(e) { | ||
1199 | + var opt = 'ok', | ||
1200 | + $this = $(this); | ||
1201 | + | ||
1202 | + e.preventDefault(); | ||
1203 | + | ||
1204 | + if ($this.hasClass('like')) { | ||
1205 | + opt = 'cancel'; | ||
1206 | + } | ||
1207 | + | ||
1208 | + $.ajax({ | ||
1209 | + type: 'POST', | ||
1210 | + url: '/product/opt/favoriteBrand', | ||
1211 | + data: { | ||
1212 | + id: brandId, | ||
1213 | + opt: opt | ||
1214 | + }, | ||
1215 | + success: function(data) { | ||
1216 | + if (data.code === 200) { | ||
1217 | + $this.toggleClass('like'); | ||
1218 | + } else if (data.code === 400) { | ||
1219 | + tip.show('未登录'); | ||
1220 | + } | ||
1221 | + }, | ||
1222 | + error: function() { | ||
1223 | + tip.show('网络断开连接了~'); | ||
1224 | + } | ||
1225 | + }); | ||
1226 | +}); | ||
1227 | +}); | ||
1228 | +define("js/guang/info", ["zepto","mlellipsis","lazyload"], function(require, exports, module){ | ||
1229 | +/** | ||
1230 | + * 资讯相关API | ||
1231 | + * @author: xuqi<qi.xu@yoho.cn> | ||
1232 | + * @date: 2015/10/10 | ||
1233 | + */ | ||
1234 | + | ||
1235 | +var $ = require("zepto"), | ||
1236 | + ellipsis = require("mlellipsis"), | ||
1237 | + lazyLoad = require("lazyload"); | ||
1238 | + | ||
1239 | +var tip = require("js/plugin/tip"); | ||
1240 | + | ||
1241 | +var $loadMoreInfo = $('#load-more-info'); | ||
1242 | +var $loading = $(''), | ||
1243 | + $noMore = $(''); | ||
1244 | + | ||
1245 | +var loading = false; | ||
1246 | + | ||
1247 | +ellipsis.init(); | ||
1248 | + | ||
1249 | +if ($loadMoreInfo.length > 0) { | ||
1250 | + $loading = $loadMoreInfo.children('.loading'); | ||
1251 | + $noMore = $loadMoreInfo.children('.no-more'); | ||
1252 | +} | ||
1253 | + | ||
1254 | +/** | ||
1255 | + * 设置指定资讯项的Lazyload和文字截取 | ||
1256 | + * @params $infos 资讯项 | ||
1257 | + */ | ||
1258 | +function setLazyLoadAndMellipsis($infos) { | ||
1259 | + lazyLoad($infos.find('img.lazy')); | ||
1260 | + | ||
1261 | + $infos.each(function() { | ||
1262 | + var $this = $(this), | ||
1263 | + $title = $this.find('.info-title'), | ||
1264 | + $text = $this.find('.info-text'); | ||
1265 | + | ||
1266 | + $title[0].mlellipsis(2); | ||
1267 | + $text[0].mlellipsis(2); | ||
1268 | + }); | ||
1269 | +} | ||
1270 | + | ||
1271 | +/** | ||
1272 | + * 初始化资讯列表事件绑定 | ||
1273 | + * @params $container 逛资讯列表容器 | ||
1274 | + */ | ||
1275 | +function initInfosEvt($container) { | ||
1276 | + $container.delegate('.like-btn', 'tap', function(e) { | ||
1277 | + var $likeBtn = $(e.currentTarget), | ||
1278 | + $info = $likeBtn.closest('.guang-info'), | ||
1279 | + opt = 'ok'; | ||
1280 | + | ||
1281 | + if ($likeBtn.hasClass('like')) { | ||
1282 | + opt = 'cancel'; | ||
1283 | + } | ||
1284 | + | ||
1285 | + $.ajax({ | ||
1286 | + type: 'POST', | ||
1287 | + url: '/guang/opt/praiseArticle', | ||
1288 | + data: { | ||
1289 | + id: $info.data('id'), | ||
1290 | + opt: opt | ||
1291 | + }, | ||
1292 | + success: function(data) { | ||
1293 | + var code = data.code; | ||
1294 | + | ||
1295 | + if (code === 200) { | ||
1296 | + $likeBtn.next('.like-count').text(data.data); | ||
1297 | + | ||
1298 | + //切换点赞状态 | ||
1299 | + $likeBtn.toggleClass('like'); | ||
1300 | + } | ||
1301 | + }, | ||
1302 | + error: function() { | ||
1303 | + tip.show('网络断开连接了~'); | ||
1304 | + } | ||
1305 | + }); | ||
1306 | + }); | ||
1307 | + | ||
1308 | + setLazyLoadAndMellipsis($container.find('.guang-info')); | ||
1309 | +} | ||
1310 | + | ||
1311 | +/** | ||
1312 | + * 资讯LoadMore | ||
1313 | + */ | ||
1314 | +function loadMore($container, opt) { | ||
1315 | + if (loading) { | ||
1316 | + return; | ||
1317 | + } | ||
1318 | + | ||
1319 | + if (opt.end) { | ||
1320 | + return; | ||
1321 | + } | ||
1322 | + | ||
1323 | + loading = true; | ||
1324 | + $.ajax({ | ||
1325 | + type: 'GET', | ||
1326 | + url: ' /guang/index/page', | ||
1327 | + data: opt, | ||
1328 | + success: function(data) { | ||
1329 | + if (data === ' ') { | ||
1330 | + opt.end = true; | ||
1331 | + loading = false; | ||
1332 | + | ||
1333 | + // | ||
1334 | + $loading.addClass('hide'); | ||
1335 | + $noMore.removeClass('hide'); | ||
1336 | + | ||
1337 | + return; | ||
1338 | + } | ||
1339 | + $container.append(data); | ||
1340 | + | ||
1341 | + setLazyLoadAndMellipsis($container.find('.guang-info')); | ||
1342 | + | ||
1343 | + opt.page++; | ||
1344 | + | ||
1345 | + loading = false; | ||
1346 | + }, | ||
1347 | + error: function() { | ||
1348 | + tip.show('网络断开连接了~'); | ||
1349 | + loading = false; | ||
1350 | + } | ||
1351 | + }); | ||
1352 | +} | ||
1353 | + | ||
1354 | +exports.initInfosEvt = initInfosEvt; | ||
1355 | +exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis; | ||
1356 | +exports.loadMore = loadMore; | ||
1357 | +}); | ||
1358 | +define("js/guang/home", ["zepto","swiper","mlellipsis","lazyload","index"], function(require, exports, module){ | ||
1359 | +/** | ||
1360 | + * 逛首页 | ||
1361 | + * @author: xuqi<qi.xu@yoho.cn> | ||
1362 | + * @date: 2015/10/10 | ||
1363 | + */ | ||
1364 | + | ||
1365 | +var $ = require("zepto"), | ||
1366 | + Swiper = require("swiper"); | ||
1367 | + | ||
1368 | +var info = require("js/guang/info"), | ||
1369 | + setLazyLoadAndMellipsis = info.setLazyLoadAndMellipsis, | ||
1370 | + loadMore = info.loadMore; | ||
1371 | + | ||
1372 | +var $loadMoreInfo = $('#load-more-info'); | ||
1373 | +var $loading = $(''), | ||
1374 | + $noMore = $(''); | ||
1375 | + | ||
1376 | +var winH = $(window).height(), | ||
1377 | + loadMoreH = $loadMoreInfo.height(); | ||
1378 | + | ||
1379 | +var $infoList = $('#info-list'), | ||
1380 | + $infos = $infoList.children('.info-list'), | ||
1381 | + $nav = $('#guang-nav'), | ||
1382 | + $curNav = $nav.children('.focus'), | ||
1383 | + curType = $curNav.data('type'); | ||
1384 | + | ||
1385 | +var state = {}; | ||
1386 | + | ||
1387 | +var mySwiper; | ||
1388 | + | ||
1389 | +if ($loadMoreInfo.length > 0) { | ||
1390 | + $loading = $loadMoreInfo.children('.loading'); | ||
1391 | + $noMore = $loadMoreInfo.children('.no-more'); | ||
1392 | +} | ||
1393 | + | ||
1394 | +mySwiper = new Swiper('.swiper-container', { | ||
1395 | + lazyLoading: true, | ||
1396 | + pagination: '.swiper-pagination' | ||
1397 | +}); | ||
1398 | + | ||
1399 | +info.initInfosEvt($infoList); | ||
1400 | + | ||
1401 | +//初始化各Nav下资讯加载的状态 | ||
1402 | +(function() { | ||
1403 | + var gender = $('#gender').val(); | ||
1404 | + | ||
1405 | + $nav.children('.guang-nav-item').each(function() { | ||
1406 | + var type = $(this).data('type'); | ||
1407 | + | ||
1408 | + state[type] = { | ||
1409 | + page: 1, | ||
1410 | + gender: gender, | ||
1411 | + type: type, | ||
1412 | + end: false | ||
1413 | + }; | ||
1414 | + }); | ||
1415 | +}()); | ||
1416 | + | ||
1417 | +$nav.delegate('.guang-nav-item', 'tap', function() { | ||
1418 | + var $this = $(this), | ||
1419 | + $content, | ||
1420 | + index; | ||
1421 | + | ||
1422 | + if ($this.hasClass('focus')) { | ||
1423 | + return; | ||
1424 | + } | ||
1425 | + | ||
1426 | + index = $this.index(); | ||
1427 | + | ||
1428 | + $this.addClass('focus'); | ||
1429 | + $curNav.removeClass('focus'); | ||
1430 | + | ||
1431 | + $infos.not('.hide').addClass('hide'); | ||
1432 | + | ||
1433 | + $content = $infos.eq(index); | ||
1434 | + $content.removeClass('hide'); | ||
1435 | + | ||
1436 | + //lazyload & mellipsis | ||
1437 | + setLazyLoadAndMellipsis($content.children('.guang-info')); | ||
1438 | + | ||
1439 | + $curNav = $this; | ||
1440 | + curType = $this.data('type'); | ||
1441 | + | ||
1442 | + //重置当前Tab的load-more | ||
1443 | + if (state[curType].end) { | ||
1444 | + $loading.addClass('hide'); | ||
1445 | + $noMore.removeClass('hide'); | ||
1446 | + } else { | ||
1447 | + $loading.removeClass('hide'); | ||
1448 | + $noMore.addClass('hide'); | ||
1449 | + } | ||
1450 | +}); | ||
1451 | + | ||
1452 | +$(document).scroll(function() { | ||
1453 | + if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) { | ||
1454 | + loadMore($infos, state[curType]); | ||
1455 | + } | ||
1456 | +}); | ||
1457 | +}); | ||
1458 | +define("js/guang/list", ["zepto","mlellipsis","lazyload"], function(require, exports, module){ | ||
1459 | +/** | ||
1460 | + * 列表页,编辑页 | ||
1461 | + * @author: xuqi<qi.xu@yoho.cn> | ||
1462 | + * @date: 2015/10/10 | ||
1463 | + */ | ||
1464 | + | ||
1465 | +var $ = require("zepto"); | ||
1466 | + | ||
1467 | +var info = require("js/guang/info"), | ||
1468 | + loadMore = info.loadMore; | ||
1469 | + | ||
1470 | +var winH = $(window).height(), | ||
1471 | + loadMoreH = $('#load-more').height(); | ||
1472 | + | ||
1473 | +var $author = $('#author-infos'); | ||
1474 | +var $tag = $('#tag'); | ||
1475 | + | ||
1476 | +var setting = { | ||
1477 | + page: 1, | ||
1478 | + end: false | ||
1479 | +}; | ||
1480 | + | ||
1481 | +var $infos = $('#info-list'); | ||
1482 | + | ||
1483 | +info.initInfosEvt($infos); | ||
1484 | + | ||
1485 | +if ($author.length > 0) { | ||
1486 | + $.extend(setting, { | ||
1487 | + authorId: $author.data('id') | ||
1488 | + }); | ||
1489 | +} | ||
1490 | + | ||
1491 | +if ($tag.length > 0) { | ||
1492 | + $.extend(setting, { | ||
1493 | + tag: $tag.val() | ||
1494 | + }); | ||
1495 | +} | ||
1496 | + | ||
1497 | +$(document).scroll(function() { | ||
1498 | + if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) { | ||
1499 | + loadMore($infos, setting); | ||
1500 | + } | ||
1501 | +}); | ||
1502 | +}); | ||
1503 | +define("js/guang/detail", ["zepto","mlellipsis","lazyload","iscroll-probe"], function(require, exports, module){ | ||
1504 | +/** | ||
1505 | + * 逛详情页 | ||
1506 | + * @author: xuqi<qi.xu@yoho.cn> | ||
1507 | + * @date: 2015/10/13 | ||
1508 | + */ | ||
1509 | + | ||
1510 | +var $ = require("zepto"), | ||
1511 | + ellipsis = require("mlellipsis"), | ||
1512 | + lazyLoad = require("lazyload"), | ||
1513 | + IScroll = require("iscroll-probe"); | ||
1514 | + | ||
1515 | +var $authorIntro = $('.author .intro'); | ||
1516 | + | ||
1517 | +var isIphone = navigator.userAgent.indexOf('iPhone') > 0 ? true : false; | ||
1518 | + | ||
1519 | +var hasCollocationBlock = $('.collocation-block').length > 0 ? true : false; | ||
1520 | + | ||
1521 | +//collocation block variable | ||
1522 | +var thumbWidth = 0, | ||
1523 | + $fixedThumbContainer = $(''), | ||
1524 | + $coBlock, $thumbContainer, $thumbs, $prods, | ||
1525 | + scrollToEl; | ||
1526 | + | ||
1527 | +var scrollToEl = document.querySelector('#wrapper .collocation-block'); | ||
1528 | + | ||
1529 | +var winW = $(window).width(); | ||
1530 | + | ||
1531 | +var myScroll; | ||
1532 | + | ||
1533 | +/** | ||
1534 | + * 计算搭配的箭头的位置 | ||
1535 | + * @param $curPos 当前focus的搭配项 | ||
1536 | + */ | ||
1537 | +function posCollocationArrow($curCo) { | ||
1538 | + var left = $curCo.offset().left, | ||
1539 | + bgPos = -winW + left + (thumbWidth / 2) + 'px'; | ||
1540 | + | ||
1541 | + $thumbContainer.css({ | ||
1542 | + backgroundPosition: bgPos + ' bottom' | ||
1543 | + }); | ||
1544 | + | ||
1545 | + if (isIphone) { | ||
1546 | + $fixedThumbContainer.css({ | ||
1547 | + backgroundPosition: bgPos + ' bottom' | ||
1548 | + }); | ||
1549 | + } | ||
1550 | +} | ||
1551 | + | ||
1552 | +//搭配thumb的touch事件句柄 | ||
1553 | +function thumbTouchEvt(e) { | ||
1554 | + var $curCo = $(e.currentTarget), | ||
1555 | + index = $curCo.index(), | ||
1556 | + $brother, $brotherCo, | ||
1557 | + $curProds; | ||
1558 | + | ||
1559 | + if ($curCo.hasClass('focus')) { | ||
1560 | + return; | ||
1561 | + } | ||
1562 | + | ||
1563 | + $thumbs.filter('.focus').removeClass('focus'); | ||
1564 | + | ||
1565 | + if (isIphone) { | ||
1566 | + if ($curCo.closest('.fixed-thumb-container').length > 0) { | ||
1567 | + $brother = $thumbContainer; | ||
1568 | + } else { | ||
1569 | + $brother = $fixedThumbContainer; | ||
1570 | + } | ||
1571 | + | ||
1572 | + $brotherCo = $brother.find('.thumb').eq(index); | ||
1573 | + $fixedThumbContainer.find('.thumb.focus').removeClass('focus'); | ||
1574 | + $brotherCo.addClass('focus'); | ||
1575 | + } | ||
1576 | + | ||
1577 | + $curCo.addClass('focus'); | ||
1578 | + | ||
1579 | + //定位arrow | ||
1580 | + posCollocationArrow($curCo); | ||
1581 | + | ||
1582 | + $prods.not('.hide').addClass('hide'); | ||
1583 | + $curProds = $prods.eq(index); | ||
1584 | + $curProds.removeClass('hide'); | ||
1585 | + | ||
1586 | + // | ||
1587 | + lazyLoad($curProds.find('.lazy')); | ||
1588 | + | ||
1589 | + if (isIphone) { | ||
1590 | + if (myScroll) { | ||
1591 | + myScroll.scrollToElement(scrollToEl, 400); | ||
1592 | + } | ||
1593 | + } else { | ||
1594 | + $('body').animate({ | ||
1595 | + scrollTop: $coBlock.offset().top | ||
1596 | + }, 400); | ||
1597 | + } | ||
1598 | +} | ||
1599 | + | ||
1600 | +if (isIphone) { | ||
1601 | + $('#wrapper').addClass('ios'); | ||
1602 | +} | ||
1603 | + | ||
1604 | +ellipsis.init(); | ||
1605 | + | ||
1606 | +lazyLoad($('.lazy')); | ||
1607 | + | ||
1608 | +//title mlellipsis | ||
1609 | +$('.info-list .title, .one-good .reco-name').each(function() { | ||
1610 | + this.mlellipsis(2); | ||
1611 | +}); | ||
1612 | + | ||
1613 | +//offset.left约等于marginLeft的值则表示介绍被换行,则清除intro的paddingTop让其更靠近头像和作者名 | ||
1614 | +if (parseInt($authorIntro.offset().left, 10) === parseInt($authorIntro.css('margin-left'), 10)) { | ||
1615 | + $authorIntro.css('padding-top', 0); | ||
1616 | +} | ||
1617 | + | ||
1618 | +//有搭配模块,iphone使用iscroll初始化滚动并有固定的搭配栏,其他的没有 | ||
1619 | +if (hasCollocationBlock) { | ||
1620 | + $coBlock = $('.collocation-block'); | ||
1621 | + $thumbContainer = $coBlock.children('.thumb-container'); | ||
1622 | + $thumbs = $thumbContainer.find('li'); | ||
1623 | + $prods = $coBlock.find('.prod'); | ||
1624 | + | ||
1625 | + thumbWidth = $thumbs.width(); | ||
1626 | + | ||
1627 | + if (isIphone) { | ||
1628 | + $fixedThumbContainer = $('#wrapper') | ||
1629 | + .after($thumbContainer.clone().addClass('fixed-thumb-container fixed-bottom')) | ||
1630 | + .next('.thumb-container'); | ||
1631 | + | ||
1632 | + //load img of fixed thumb container | ||
1633 | + lazyLoad($fixedThumbContainer.find('.lazy'), { | ||
1634 | + event: 'sporty' | ||
1635 | + }); | ||
1636 | + } | ||
1637 | + | ||
1638 | + //Init Arrow Position | ||
1639 | + posCollocationArrow($thumbs.filter('.focus')); | ||
1640 | + | ||
1641 | + $thumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt); | ||
1642 | + | ||
1643 | + if (isIphone) { | ||
1644 | + $fixedThumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt); | ||
1645 | + } | ||
1646 | +} | ||
1647 | + | ||
1648 | +// 初始化iscroll | ||
1649 | +window.onload = function() { | ||
1650 | + var $scroller = $('#scroller'); | ||
1651 | + | ||
1652 | + var winH, tcH, cbH, cbTop, fixedThumbDom; | ||
1653 | + | ||
1654 | + if (!isIphone) { | ||
1655 | + return; | ||
1656 | + } | ||
1657 | + | ||
1658 | + myScroll = new IScroll('#wrapper', { | ||
1659 | + probeType: 3, | ||
1660 | + mouseWheel: true, | ||
1661 | + click: true | ||
1662 | + }); | ||
1663 | + | ||
1664 | + document.addEventListener('touchmove', function (e) { | ||
1665 | + e.preventDefault(); | ||
1666 | + }, false); | ||
1667 | + | ||
1668 | + if (!hasCollocationBlock) { | ||
1669 | + myScroll.on('scroll', function() { | ||
1670 | + $scroller.trigger('scroll'); | ||
1671 | + }); | ||
1672 | + return; | ||
1673 | + } | ||
1674 | + | ||
1675 | + winH = $(window).height(); | ||
1676 | + fixedThumbDom = $fixedThumbContainer[0]; | ||
1677 | + | ||
1678 | + tcH = $thumbContainer.height(); | ||
1679 | + cbH = $coBlock.height(); | ||
1680 | + cbTop = $coBlock.offset().top; | ||
1681 | + | ||
1682 | + myScroll.on('scroll', function() { | ||
1683 | + var sTop = -this.y; | ||
1684 | + var classList = fixedThumbDom.className; | ||
1685 | + | ||
1686 | + if (sTop <= cbTop - winH + tcH) { | ||
1687 | + if (classList.indexOf('fixed-bottom') === -1) { | ||
1688 | + $fixedThumbContainer | ||
1689 | + .addClass('fixed-bottom') | ||
1690 | + .removeClass('hide'); | ||
1691 | + } | ||
1692 | + } else if (sTop <= cbTop) { | ||
1693 | + if (classList.indexOf('hide') === -1) { | ||
1694 | + $fixedThumbContainer | ||
1695 | + .addClass('hide') | ||
1696 | + .removeClass('fixed-bottom fixed-top'); | ||
1697 | + } | ||
1698 | + } else if (sTop <= cbTop + cbH - tcH) { | ||
1699 | + if (classList.indexOf('fixed-top') === -1) { | ||
1700 | + $fixedThumbContainer | ||
1701 | + .addClass('fixed-top') | ||
1702 | + .removeClass('hide absolute') | ||
1703 | + .css('top', ''); | ||
1704 | + } | ||
1705 | + } else if (sTop <= cbTop + cbH) { | ||
1706 | + if (classList.indexOf('absolute') === -1) { | ||
1707 | + $fixedThumbContainer | ||
1708 | + .addClass('absolute') | ||
1709 | + .removeClass('fixed-top hide'); | ||
1710 | + } | ||
1711 | + fixedThumbDom.style.top = cbTop + cbH - tcH - sTop + 'px'; | ||
1712 | + } else if (sTop > cbTop + cbH) { | ||
1713 | + if (classList.indexOf('hide') === -1) { | ||
1714 | + $fixedThumbContainer | ||
1715 | + .addClass('hide') | ||
1716 | + .removeClass('absolute'); | ||
1717 | + } | ||
1718 | + } | ||
1719 | + $scroller.trigger('scroll'); | ||
1720 | + }); | ||
1721 | +}; | ||
1722 | +}); | ||
1723 | +define("js/home/index", ["zepto","swiper","lazyload","index"], function(require, exports, module){ | ||
1724 | +/** | ||
1725 | + * 首页打包入口 | ||
1726 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
1727 | + * @date: 2015/10/12 | ||
1728 | + */ | ||
1729 | + | ||
1730 | +require("js/home/home"); | ||
1731 | +require("js/home/maybe-like"); | ||
1732 | +}); | ||
1733 | +define("js/home/home", ["zepto","swiper","lazyload","index"], function(require, exports, module){ | ||
1734 | +/** | ||
1735 | + * 首页 | ||
1736 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
1737 | + * @date: 2015/10/12 | ||
1738 | + */ | ||
1739 | +var $ = require("zepto"), | ||
1740 | + Swiper = require("swiper"), | ||
1741 | + lazyLoad = require("lazyload"), | ||
1742 | + bannerSwiper, | ||
1743 | + recommendSwiper, | ||
1744 | + hotBrandsSwiper, | ||
1745 | + trendTopicSwiper, | ||
1746 | + goodsSwiper; | ||
1747 | + | ||
1748 | +var requestFrame, | ||
1749 | + thisFunc, | ||
1750 | + start = 0, | ||
1751 | + i, | ||
1752 | + swiperClass, | ||
1753 | + supportCss3, | ||
1754 | + $logotrans = $('.home-header .logo'), | ||
1755 | + isen = true; | ||
1756 | + | ||
1757 | +require("js/home/maybe-like"); | ||
1758 | + | ||
1759 | +lazyLoad($('img.lazy')); | ||
1760 | + | ||
1761 | +//$('img:in-viewport').trigger('appear'); | ||
1762 | + | ||
1763 | +//点击首页汉堡menu图标,滑出侧栏导航 | ||
1764 | +$('.nav-btn').on('tap', function (event) { | ||
1765 | + if (!$(this).hasClass('menu-open')) { | ||
1766 | + $('.mobile-wrap').addClass('menu-open'); | ||
1767 | + $('.overlay').addClass('show'); | ||
1768 | + $('.side-nav').addClass('on'); | ||
1769 | + | ||
1770 | + //设置boy高宽,页面不能上下滑动 | ||
1771 | + $('body').css({ | ||
1772 | + height: $(window).height(), | ||
1773 | + width: '100%', | ||
1774 | + overflow: 'hidden' | ||
1775 | + }); | ||
1776 | + } | ||
1777 | + event.stopPropagation(); | ||
1778 | +}); | ||
1779 | + | ||
1780 | +//点击页面主体,收起侧栏导航及二级导航 | ||
1781 | +$('.mobile-wrap').on('tap', function () { | ||
1782 | + if ($(this).hasClass('menu-open')) { | ||
1783 | + $('.mobile-wrap').removeClass('menu-open'); | ||
1784 | + $('.overlay').removeClass('show'); | ||
1785 | + $('.sub-nav').removeClass('show'); | ||
1786 | + $('.side-nav').removeClass('on'); | ||
1787 | + $('body').css({ | ||
1788 | + height: 'auto', | ||
1789 | + overflow: 'auto' | ||
1790 | + }); | ||
1791 | + } | ||
1792 | +}); | ||
1793 | + | ||
1794 | +//点击一级导航,弹出二级导航 | ||
1795 | +$('.side-nav').on('tap', 'li', function () { | ||
1796 | + if ($(this).find('.sub-nav').size() > 0) { | ||
1797 | + $('.sub-nav').removeClass('show'); | ||
1798 | + $(this).find('.sub-nav').addClass('show'); | ||
1799 | + } | ||
1800 | +}); | ||
1801 | + | ||
1802 | +//返回一级导航,收起二级导航 | ||
1803 | +$('.sub-nav').each(function () { | ||
1804 | + $(this).find('li').eq(0).on('tap', function (e) { | ||
1805 | + $('.sub-nav').removeClass('show'); | ||
1806 | + e.stopPropagation(); | ||
1807 | + }); | ||
1808 | +}); | ||
1809 | + | ||
1810 | +//二级导航样式控制 | ||
1811 | +$('.sub-nav').on('mouseenter', 'li', function () { | ||
1812 | + if ($(this).index() !== 0) { | ||
1813 | + $(this).addClass('current').siblings().removeClass('current'); | ||
1814 | + } | ||
1815 | +}); | ||
1816 | + | ||
1817 | +//头部banner轮播 | ||
1818 | +if ($('.banner-swiper').find('li').size() > 1) { | ||
1819 | + bannerSwiper = new Swiper('.banner-swiper', { | ||
1820 | + lazyLoading: true, | ||
1821 | + lazyLoadingInPrevNext: true, | ||
1822 | + loop: true, | ||
1823 | + autoplay: 3000, | ||
1824 | + autoplayDisableOnInteraction: false, | ||
1825 | + paginationClickable: true, | ||
1826 | + slideElement: 'li', | ||
1827 | + pagination: '.banner-top .pagination-inner' | ||
1828 | + }); | ||
1829 | +} | ||
1830 | + | ||
1831 | +//热门品牌滑动 | ||
1832 | +hotBrandsSwiper = new Swiper('.brands-swiper', { | ||
1833 | + grabCursor: true, | ||
1834 | + slidesPerView: 'auto', | ||
1835 | + wrapperClass: 'brands-list', | ||
1836 | + slideElement: 'li' | ||
1837 | +}); | ||
1838 | + | ||
1839 | +//推荐搭配滑动 | ||
1840 | +recommendSwiper = new Swiper('.recommend-swiper', { | ||
1841 | + grabCursor: true, | ||
1842 | + slidesPerView: 'auto', | ||
1843 | + wrapperClass: 'recommend-list', | ||
1844 | + slideElement: 'li' | ||
1845 | +}); | ||
1846 | + | ||
1847 | +//潮品话题轮播 | ||
1848 | +if ($('.trend-topic-swiper').find('li').size() > 1) { | ||
1849 | + trendTopicSwiper = new Swiper('.trend-topic-swiper', { | ||
1850 | + loop: true, | ||
1851 | + autoplay: 3000, | ||
1852 | + autoplayDisableOnInteraction: false, | ||
1853 | + paginationClickable: true, | ||
1854 | + slideElement: 'li', | ||
1855 | + pagination: '.trend-topic-content .pagination-inner' | ||
1856 | + }); | ||
1857 | +} | ||
1858 | + | ||
1859 | +//潮流上装/经典裤装等轮播 | ||
1860 | +$('.category-swiper').each(function (i, index) { | ||
1861 | + swiperClass = 'category-swiper' + i; | ||
1862 | + $(this).addClass(swiperClass); | ||
1863 | + if ($('.' + swiperClass).find('.swiper-slide').size() > 1) { | ||
1864 | + goodsSwiper = new Swiper('.' + swiperClass, { | ||
1865 | + loop: true, | ||
1866 | + autoplay: 3000, | ||
1867 | + autoplayDisableOnInteraction: false, | ||
1868 | + paginationClickable: true, | ||
1869 | + slideElement: 'li', | ||
1870 | + pagination: '.' + swiperClass + ' .pagination-inner' | ||
1871 | + }); | ||
1872 | + } | ||
1873 | +}); | ||
1874 | + | ||
1875 | +//关闭头部下载浮层 | ||
1876 | +$('.header-download').on('tap', '.close-btn', function () { | ||
1877 | + $(this).parent().remove(); | ||
1878 | +}); | ||
1879 | + | ||
1880 | + | ||
1881 | +//logo动画 | ||
1882 | +requestFrame = (function () { | ||
1883 | + var tempFunc = null, | ||
1884 | + prefixList = ['webkit', 'moz', 'ms']; | ||
1885 | + | ||
1886 | + for (i = 0; i < prefixList.length; i++) { | ||
1887 | + thisFunc = prefixList[i] + 'RequestAnimationFrame'; | ||
1888 | + if (window[thisFunc]) { | ||
1889 | + supportCss3 = true; | ||
1890 | + tempFunc = thisFunc; | ||
1891 | + } | ||
1892 | + } | ||
1893 | + | ||
1894 | + if (supportCss3) { | ||
1895 | + return function (callback) { | ||
1896 | + window[tempFunc](callback); | ||
1897 | + }; | ||
1898 | + } | ||
1899 | + return function (callback) { | ||
1900 | + window.setTimeout(callback, 67); | ||
1901 | + }; | ||
1902 | +})(); | ||
1903 | + | ||
1904 | +function tsAnimate() { | ||
1905 | + start = start + 10; | ||
1906 | + $logotrans.css({ | ||
1907 | + transform: 'rotateX(' + start + 'deg)', | ||
1908 | + '-webkit-transform': 'rotateX(' + start + 'deg)', | ||
1909 | + '-moz-transform': 'rotateX(' + start + 'deg)' | ||
1910 | + }); | ||
1911 | + if (start / 90 % 2 === 1) { | ||
1912 | + if (isen) { | ||
1913 | + $logotrans.addClass('animate'); | ||
1914 | + isen = false; | ||
1915 | + } else { | ||
1916 | + $logotrans.removeClass('animate'); | ||
1917 | + isen = true; | ||
1918 | + } | ||
1919 | + } | ||
1920 | + if (start / 90 % 2 === 0 && start % 360 !== 0) { | ||
1921 | + window.setTimeout(tsAnimate, 3000); | ||
1922 | + } else { | ||
1923 | + if (start % 360 === 0) { | ||
1924 | + window.setTimeout(tsAnimate, 3 * 60 * 1000); | ||
1925 | + } else { | ||
1926 | + requestFrame(function () { | ||
1927 | + tsAnimate(); | ||
1928 | + }); | ||
1929 | + } | ||
1930 | + } | ||
1931 | +} | ||
1932 | + | ||
1933 | +tsAnimate(); | ||
1934 | + | ||
1935 | + | ||
1936 | +}); | ||
1937 | +define("js/home/maybe-like", ["zepto","lazyload"], function(require, exports, module){ | ||
1938 | +/** | ||
1939 | + * “你可能喜欢”模块JS | ||
1940 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
1941 | + * @date: 2015/10/12 | ||
1942 | + */ | ||
1943 | + | ||
1944 | +var $ = require("zepto"), | ||
1945 | + tip = require("js/plugin/tip"), | ||
1946 | + lazyLoad = require("lazyload"); | ||
1947 | + | ||
1948 | +var winH = $(window).height(), | ||
1949 | + loadMoreH = $('#load-more').height(), | ||
1950 | + $goodList = $('#goods-list'), | ||
1951 | + loading = false, | ||
1952 | + page = 0, | ||
1953 | + gender = $('.mobile-wrap').hasClass('boys-wrap') ? '1,3' : '2,3', | ||
1954 | + kidsType = $('.mobile-wrap').hasClass('kids-wrap') ? true : false, | ||
1955 | + lifestyleType = $('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false, | ||
1956 | + num, | ||
1957 | + url; | ||
1958 | + | ||
1959 | +var $curNav, | ||
1960 | + index, | ||
1961 | + $navList = $('#maybe-like-nav'); | ||
1962 | + | ||
1963 | +//ajax url | ||
1964 | +if (kidsType) { | ||
1965 | + url = '/product/recom/maylikekids'; | ||
1966 | +} else if (lifestyleType) { | ||
1967 | + url = '/product/recom/maylikelife'; | ||
1968 | +} else { | ||
1969 | + url = '/product/recom/maylike?gender=' + gender; | ||
1970 | +} | ||
1971 | + | ||
1972 | +$curNav = $navList.children('.focus'); | ||
1973 | + | ||
1974 | +$('#maybe-like-nav').delegate('li', 'tap', function() { | ||
1975 | + var $this = $(this), | ||
1976 | + $goods = $('.goods-list'), | ||
1977 | + $content; | ||
1978 | + | ||
1979 | + | ||
1980 | + if ($this.hasClass('focus')) { | ||
1981 | + return; | ||
1982 | + } | ||
1983 | + | ||
1984 | + index = $this.index(); | ||
1985 | + | ||
1986 | + $this.addClass('focus'); | ||
1987 | + $curNav.removeClass('focus'); | ||
1988 | + | ||
1989 | + $goods.not('.hide').addClass('hide'); | ||
1990 | + $content = $goods.eq(index); | ||
1991 | + $content.removeClass('hide'); | ||
1992 | + | ||
1993 | + $curNav = $this; | ||
1994 | + | ||
1995 | + $(document).trigger('scroll'); //Trigger lazyLoad | ||
1996 | +}); | ||
1997 | + | ||
1998 | +//srcoll to load more | ||
1999 | +$(window).scroll(function () { | ||
2000 | + if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) { | ||
2001 | + if (loading) { | ||
2002 | + return; | ||
2003 | + } | ||
2004 | + loading = true; | ||
2005 | + num = $goodList.children('.good-info').length; | ||
2006 | + $.ajax({ | ||
2007 | + type: 'GET', | ||
2008 | + url: url, | ||
2009 | + data: { | ||
2010 | + page: page + 1 | ||
2011 | + }, | ||
2012 | + success: function(data) { | ||
2013 | + if (data === ' ') { | ||
2014 | + loading = true; | ||
2015 | + return; | ||
2016 | + } | ||
2017 | + $goodList.append(data); | ||
2018 | + | ||
2019 | + //lazyLoad | ||
2020 | + //lazyLoad($goodList.children('.good-info:gt(' + (num - 1) + ')').find('img.lazy')); | ||
2021 | + lazyLoad($('.good-info').find('img.lazy')); | ||
2022 | + | ||
2023 | + loading = false; | ||
2024 | + page++; | ||
2025 | + }, | ||
2026 | + error: function() { | ||
2027 | + tip.show('网络断开连接了~'); | ||
2028 | + loading = false; | ||
2029 | + } | ||
2030 | + }); | ||
2031 | + } | ||
2032 | + | ||
2033 | +}); | ||
2034 | +}); | ||
2035 | +define("js/product/index", ["zepto","swiper","lazyload","index"], function(require, exports, module){ | ||
2036 | +/** | ||
2037 | + * 产品打包入口 | ||
2038 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
2039 | + * @date: 2015/10/12 | ||
2040 | + */ | ||
2041 | + | ||
2042 | +require("js/product/newsale/newarrival"); | ||
2043 | +require("js/product/newsale/discount"); | ||
2044 | +require("js/product/list"); | ||
2045 | +require("js/product/detail/detail"); | ||
2046 | +}); | ||
2047 | +define("js/product/newsale/newarrival", ["zepto","swiper","lazyload","index"], function(require, exports, module){ | ||
2048 | +/** | ||
2049 | + * 新品到着 | ||
2050 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
2051 | + * @date: 2015/10/24 | ||
2052 | + */ | ||
2053 | + | ||
2054 | +var $ = require("zepto"), | ||
2055 | + Swiper = require("swiper"), | ||
2056 | + lazyLoad = require("lazyload"); | ||
2057 | + | ||
2058 | +var swiper; | ||
2059 | + | ||
2060 | +var filter = require("js/plugin/filter"); | ||
2061 | + | ||
2062 | +var $goodsContainer = $('#goods-container'), | ||
2063 | + $ngc = $($goodsContainer.children().get(0)), | ||
2064 | + $pgc = $($goodsContainer.children().get(1)), | ||
2065 | + $dgc = $($goodsContainer.children().get(2)); | ||
2066 | + | ||
2067 | +var winH = $(window).height(); | ||
2068 | + | ||
2069 | +//默认筛选条件 | ||
2070 | +var defaultOpt = { | ||
2071 | + gender: $('#gender').val(), | ||
2072 | + brand: $('#brand').val(), | ||
2073 | + msort: $('#msort').val(), | ||
2074 | + color: $('#color').val(), | ||
2075 | + size: $('#size').val(), | ||
2076 | + price: $('#price').val(), | ||
2077 | + discount: $('#discount').val(), | ||
2078 | + limit: $('#limit').val(), | ||
2079 | + channel: $('#channel').val(), | ||
2080 | + p_d: $('#p_d').val() | ||
2081 | +}; | ||
2082 | + | ||
2083 | +var now = new Date(), | ||
2084 | + month = now.getMonth() + 1, | ||
2085 | + date = now.getDate(); | ||
2086 | + | ||
2087 | +var $listNav = $('#list-nav'), | ||
2088 | + | ||
2089 | + //导航数据信息 | ||
2090 | + navInfo = { | ||
2091 | + today: { | ||
2092 | + reload: true, | ||
2093 | + page: 0, | ||
2094 | + end: false | ||
2095 | + }, | ||
2096 | + week: { | ||
2097 | + reload: true, | ||
2098 | + page: 0, | ||
2099 | + end: false | ||
2100 | + }, | ||
2101 | + sale: { | ||
2102 | + reload: true, | ||
2103 | + page: 0, | ||
2104 | + end: false | ||
2105 | + } | ||
2106 | + }, | ||
2107 | + $pre, //纪录进入筛选前的active项 | ||
2108 | + searching; | ||
2109 | + | ||
2110 | +$pgc.addClass('hide'); | ||
2111 | +$dgc.addClass('hide'); | ||
2112 | + | ||
2113 | +$('#today a').text(month + '月' + date + '号'); | ||
2114 | + | ||
2115 | +if ($('.swiper-container .swiper-slide').length > 1) { | ||
2116 | + swiper = new Swiper('.swiper-container', { | ||
2117 | + lazyLoading: true, | ||
2118 | + loop: true, | ||
2119 | + autoplay: 3000, | ||
2120 | + autoplayDisableOnInteraction: false, | ||
2121 | + paginationClickable: true, | ||
2122 | + pagination: '.swiper-pagination' | ||
2123 | + }); | ||
2124 | +} | ||
2125 | + | ||
2126 | +/** | ||
2127 | + * 筛选注册的回调,筛选子项点击后逻辑 | ||
2128 | + * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载 | ||
2129 | + * @param opt {type, id} | ||
2130 | + */ | ||
2131 | +function search(opt) { | ||
2132 | + var setting = {}, | ||
2133 | + ext, | ||
2134 | + att, | ||
2135 | + nav, navType, | ||
2136 | + dayLimit, | ||
2137 | + page; | ||
2138 | + | ||
2139 | + if (opt) { | ||
2140 | + | ||
2141 | + //筛选项变更则重置reload为true | ||
2142 | + for (att in navInfo) { | ||
2143 | + if (navInfo.hasOwnProperty(att)) { | ||
2144 | + navInfo[att].reload = true; | ||
2145 | + } | ||
2146 | + } | ||
2147 | + | ||
2148 | + //处理active状态 | ||
2149 | + $listNav.children('.active').removeClass('active'); | ||
2150 | + $pre.addClass('active'); | ||
2151 | + | ||
2152 | + switch (opt.type) { | ||
2153 | + case 'gender': | ||
2154 | + ext = { | ||
2155 | + gender: opt.id | ||
2156 | + }; | ||
2157 | + break; | ||
2158 | + case 'brand': | ||
2159 | + ext = { | ||
2160 | + brand: opt.id | ||
2161 | + }; | ||
2162 | + break; | ||
2163 | + case 'msort': | ||
2164 | + ext = { | ||
2165 | + msort: opt.id | ||
2166 | + }; | ||
2167 | + break; | ||
2168 | + case 'color': | ||
2169 | + ext = { | ||
2170 | + color: opt.id | ||
2171 | + }; | ||
2172 | + break; | ||
2173 | + case 'size': | ||
2174 | + ext = { | ||
2175 | + size: opt.id | ||
2176 | + }; | ||
2177 | + break; | ||
2178 | + case 'price': | ||
2179 | + ext = { | ||
2180 | + price: opt.id | ||
2181 | + }; | ||
2182 | + break; | ||
2183 | + case 'discount': | ||
2184 | + ext = { | ||
2185 | + discount: opt.id | ||
2186 | + }; | ||
2187 | + break; | ||
2188 | + case 'limit': | ||
2189 | + ext = { | ||
2190 | + limit: opt.id | ||
2191 | + }; | ||
2192 | + break; | ||
2193 | + case 'channel': | ||
2194 | + ext = { | ||
2195 | + channel: opt.id | ||
2196 | + }; | ||
2197 | + break; | ||
2198 | + case 'p_d': | ||
2199 | + ext = { | ||
2200 | + p_d: opt.id | ||
2201 | + }; | ||
2202 | + break; | ||
2203 | + } | ||
2204 | + | ||
2205 | + $.extend(defaultOpt, ext); //扩展筛选项 | ||
2206 | + } | ||
2207 | + | ||
2208 | + if (searching) { | ||
2209 | + return; | ||
2210 | + } | ||
2211 | + | ||
2212 | + //导航类别 | ||
2213 | + if ($pre.hasClass('today')) { | ||
2214 | + navType = 'today'; | ||
2215 | + dayLimit = 1; | ||
2216 | + } else if ($pre.hasClass('week')) { | ||
2217 | + navType = 'week'; | ||
2218 | + dayLimit = 2; | ||
2219 | + } else if ($pre.hasClass('sale')) { | ||
2220 | + navType = 'sale'; | ||
2221 | + dayLimit = 3; | ||
2222 | + } | ||
2223 | + | ||
2224 | + nav = navInfo[navType]; | ||
2225 | + | ||
2226 | + page = nav.page + 1; | ||
2227 | + if (nav.reload) { | ||
2228 | + page = 1; | ||
2229 | + } else if (nav.end) { | ||
2230 | + | ||
2231 | + //不需要重新加载并且数据请求结束 | ||
2232 | + return; | ||
2233 | + } | ||
2234 | + | ||
2235 | + $.extend(setting, defaultOpt, { | ||
2236 | + dayLimit: dayLimit, | ||
2237 | + page: page | ||
2238 | + }); | ||
2239 | + | ||
2240 | + searching = true; | ||
2241 | + | ||
2242 | + $.ajax({ | ||
2243 | + type: 'GET', | ||
2244 | + url: '/product/newsale/selectNewSale', | ||
2245 | + data: setting, | ||
2246 | + success: function(data) { | ||
2247 | + var noResult = '<p class="no-result">未找到相关搜索结果</p>', | ||
2248 | + $container; | ||
2249 | + | ||
2250 | + switch (navType) { | ||
2251 | + case 'today': | ||
2252 | + $container = $ngc; | ||
2253 | + break; | ||
2254 | + case 'week': | ||
2255 | + $container = $pgc; | ||
2256 | + break; | ||
2257 | + case 'sale': | ||
2258 | + $container = $dgc; | ||
2259 | + break; | ||
2260 | + } | ||
2261 | + | ||
2262 | + if (data === ' ') { | ||
2263 | + nav.end = true; | ||
2264 | + | ||
2265 | + if (nav.reload) { | ||
2266 | + $container.html(noResult); | ||
2267 | + } | ||
2268 | + } else { | ||
2269 | + if (nav.reload) { | ||
2270 | + $container.html(data); | ||
2271 | + } else { | ||
2272 | + $container.append(data); | ||
2273 | + } | ||
2274 | + | ||
2275 | + lazyLoad($container.find('.lazy')); | ||
2276 | + } | ||
2277 | + | ||
2278 | + nav.reload = false; | ||
2279 | + nav.page = page; | ||
2280 | + | ||
2281 | + searching = false; | ||
2282 | + } | ||
2283 | + }); | ||
2284 | + | ||
2285 | +} | ||
2286 | + | ||
2287 | +lazyLoad($('.lazy')); | ||
2288 | + | ||
2289 | +filter.registerCbFn(search); | ||
2290 | + | ||
2291 | +//导航栏点击逻辑说明: | ||
2292 | +//1.点击非active项时切换active状态 | ||
2293 | +//2.价格和折扣active状态时继续点击切换排序 | ||
2294 | +//3.筛选无active时点击展开筛选面板 | ||
2295 | +//4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态 | ||
2296 | +//5.当前active为筛选并且点击其他项时,隐藏筛选面板 | ||
2297 | +$listNav.delegate('li', 'tap', function() { | ||
2298 | + var $this = $(this), | ||
2299 | + nav, | ||
2300 | + navType, | ||
2301 | + $active; | ||
2302 | + | ||
2303 | + if ($this.hasClass('filter')) { | ||
2304 | + | ||
2305 | + //筛选面板切换状态 | ||
2306 | + if ($this.hasClass('active')) { | ||
2307 | + filter.hideFilter(); | ||
2308 | + | ||
2309 | + //点击筛选钱的active项回复active | ||
2310 | + $pre.addClass('active'); | ||
2311 | + $this.removeClass('active'); | ||
2312 | + } else { | ||
2313 | + $pre = $this.siblings('.active'); | ||
2314 | + | ||
2315 | + $pre.removeClass('active'); | ||
2316 | + $this.addClass('active'); | ||
2317 | + | ||
2318 | + filter.showFilter(); | ||
2319 | + } | ||
2320 | + } else { | ||
2321 | + | ||
2322 | + if ($this.hasClass('today')) { | ||
2323 | + navType = 'today'; | ||
2324 | + } else if ($this.hasClass('week')) { | ||
2325 | + navType = 'week'; | ||
2326 | + } else if ($this.hasClass('sale')) { | ||
2327 | + navType = 'sale'; | ||
2328 | + } | ||
2329 | + | ||
2330 | + nav = navInfo[navType]; | ||
2331 | + | ||
2332 | + if (!($this.hasClass('active'))) { | ||
2333 | + | ||
2334 | + $active = $this.siblings('.active'); | ||
2335 | + | ||
2336 | + $pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项 | ||
2337 | + | ||
2338 | + if ($active.hasClass('filter')) { | ||
2339 | + | ||
2340 | + //若之前active项为筛选,则隐藏筛选面板 | ||
2341 | + filter.hideFilter(); | ||
2342 | + } else { | ||
2343 | + | ||
2344 | + //切换container显示 | ||
2345 | + $goodsContainer.children('.container:not(.hide)').addClass('hide'); | ||
2346 | + | ||
2347 | + switch (navType) { | ||
2348 | + case 'today': | ||
2349 | + $ngc.removeClass('hide'); | ||
2350 | + break; | ||
2351 | + | ||
2352 | + case 'week': | ||
2353 | + $pgc.removeClass('hide'); | ||
2354 | + break; | ||
2355 | + | ||
2356 | + case 'sale': | ||
2357 | + $dgc.removeClass('hide'); | ||
2358 | + break; | ||
2359 | + } | ||
2360 | + } | ||
2361 | + | ||
2362 | + $active.removeClass('active'); | ||
2363 | + $this.addClass('active'); | ||
2364 | + } | ||
2365 | + | ||
2366 | + if (nav.reload) { | ||
2367 | + search(); | ||
2368 | + } | ||
2369 | + } | ||
2370 | +}); | ||
2371 | + | ||
2372 | +$(window).scroll(function() { | ||
2373 | + | ||
2374 | + //当scroll到1/4$goodsContainer高度后继续请求下一页数据 | ||
2375 | + if ($(window).scrollTop() + winH > | ||
2376 | + $(document).height() - 0.25 * $goodsContainer.height()) { | ||
2377 | + if ($pre !== undefined) { | ||
2378 | + search(); | ||
2379 | + } | ||
2380 | + } | ||
2381 | +}); | ||
2382 | +}); | ||
2383 | +define("js/plugin/filter", ["zepto"], function(require, exports, module){ | ||
2384 | +/** | ||
2385 | + * 筛选JS | ||
2386 | + * 暴露三个接口:注册回调、显示filter、隐藏filter | ||
2387 | + * @author: xuqi<qi.xu@yoho.cn> | ||
2388 | + * @date: 2015/10/19 | ||
2389 | + */ | ||
2390 | + | ||
2391 | +var $ = require("zepto"); | ||
2392 | + | ||
2393 | +var $filter = $('.filter-mask, .filter-body'); | ||
2394 | + | ||
2395 | +var $classify = $filter.find('.classify'), | ||
2396 | + $subClassify = $filter.find('.sub-classify'); | ||
2397 | + | ||
2398 | +var cbFn; | ||
2399 | + | ||
2400 | +//隐藏筛选界面 | ||
2401 | +function hideFilter() { | ||
2402 | + $filter.addClass('hide'); | ||
2403 | +} | ||
2404 | + | ||
2405 | +//显示筛选界面 | ||
2406 | +function showFilter() { | ||
2407 | + $filter.removeClass('hide'); | ||
2408 | +} | ||
2409 | + | ||
2410 | +//注册sub-classify点击后的回调 | ||
2411 | +function registerCbFn(cb) { | ||
2412 | + cbFn = cb; | ||
2413 | +} | ||
2414 | + | ||
2415 | +//设置完高度后显示sub并设置选中 | ||
2416 | +$classify.children(':first-child').addClass('active'); //T:不在HTML中使用{{#if @first}}active{{/if}}来初始化active为避免sub设置高度时的闪烁 | ||
2417 | + | ||
2418 | +//classify switch | ||
2419 | +$classify.delegate('.classify-item', 'tap', function() { | ||
2420 | + var $this = $(this); | ||
2421 | + | ||
2422 | + if ($this.hasClass('active')) { | ||
2423 | + return; | ||
2424 | + } | ||
2425 | + | ||
2426 | + $this.siblings('.active').removeClass('active'); | ||
2427 | + | ||
2428 | + $this.addClass('active'); | ||
2429 | +}); | ||
2430 | + | ||
2431 | +//点击Mask隐藏筛选界面 | ||
2432 | +$filter.filter('.filter-mask').tap(function() { | ||
2433 | + hideFilter(); | ||
2434 | +}); | ||
2435 | + | ||
2436 | +$subClassify.delegate('li', 'tap', function(e) { | ||
2437 | + var $this = $(this), | ||
2438 | + id = $this.data('id'); | ||
2439 | + | ||
2440 | + var $sub = $this.closest('.sub-classify'); | ||
2441 | + | ||
2442 | + var $shower = $sub.siblings('.shower'); | ||
2443 | + | ||
2444 | + var html, shower; | ||
2445 | + | ||
2446 | + e.stopPropagation(); | ||
2447 | + | ||
2448 | + if ($this.hasClass('chosed')) { | ||
2449 | + return; | ||
2450 | + } | ||
2451 | + | ||
2452 | + $sub.children('.chosed').removeClass('chosed'); | ||
2453 | + $this.addClass('chosed'); | ||
2454 | + | ||
2455 | + html = $.trim($this.html()); | ||
2456 | + | ||
2457 | + shower = $.trim($shower.html()); | ||
2458 | + | ||
2459 | + $shower.html( | ||
2460 | + shower.substring(0, shower.indexOf('</span>') + 7) + //拆分出shower的title | ||
2461 | + html.substring(0, html.indexOf('<i')) //拆分选中筛选值 | ||
2462 | + ); | ||
2463 | + | ||
2464 | + if ($this.index() === 0) { | ||
2465 | + $shower.addClass('default'); | ||
2466 | + } else { | ||
2467 | + $shower.removeClass('default'); | ||
2468 | + } | ||
2469 | + | ||
2470 | + if (cbFn) { | ||
2471 | + cbFn({ | ||
2472 | + type: $sub.data('type'), | ||
2473 | + id: id | ||
2474 | + }); | ||
2475 | + } | ||
2476 | + | ||
2477 | + hideFilter(); | ||
2478 | +}); | ||
2479 | + | ||
2480 | + | ||
2481 | +exports.showFilter = showFilter; | ||
2482 | + | ||
2483 | +exports.hideFilter = hideFilter; | ||
2484 | + | ||
2485 | +exports.registerCbFn = registerCbFn; | ||
2486 | +}); | ||
2487 | +define("js/product/newsale/discount", ["zepto","swiper","lazyload","index"], function(require, exports, module){ | ||
2488 | +/** | ||
2489 | + * 商品列表页 | ||
2490 | + * @author: xuqi<qi.xu@yoho.cn> | ||
2491 | + * @date: 2015/10/20 | ||
2492 | + */ | ||
2493 | + | ||
2494 | +var $ = require("zepto"), | ||
2495 | + Swiper = require("swiper"), | ||
2496 | + lazyLoad = require("lazyload"); | ||
2497 | + | ||
2498 | +var swiper; | ||
2499 | + | ||
2500 | +var filter = require("js/plugin/filter"); | ||
2501 | + | ||
2502 | +var $goodsContainer = $('#goods-container'), | ||
2503 | + $ngc = $($goodsContainer.children().get(0)), | ||
2504 | + $pgc = $($goodsContainer.children().get(1)), | ||
2505 | + $dgc = $($goodsContainer.children().get(2)); | ||
2506 | + | ||
2507 | +var winH = $(window).height(); | ||
2508 | + | ||
2509 | +//默认筛选条件 | ||
2510 | +var defaultOpt = { | ||
2511 | + gender: $('#gender').val(), | ||
2512 | + brand: $('#brand').val(), | ||
2513 | + msort: $('#msort').val(), | ||
2514 | + color: $('#color').val(), | ||
2515 | + size: $('#size').val(), | ||
2516 | + price: $('#price').val(), | ||
2517 | + discount: $('#discount').val() | ||
2518 | +}; | ||
2519 | + | ||
2520 | +var $listNav = $('#list-nav'), | ||
2521 | + | ||
2522 | + //导航数据信息 | ||
2523 | + navInfo = { | ||
2524 | + newest: { | ||
2525 | + order: 1, | ||
2526 | + reload: true, | ||
2527 | + page: 0, | ||
2528 | + end: false | ||
2529 | + }, | ||
2530 | + price: { | ||
2531 | + order: 0, | ||
2532 | + reload: true, | ||
2533 | + page: 0, | ||
2534 | + end: false | ||
2535 | + }, | ||
2536 | + discount: { | ||
2537 | + order: 0, | ||
2538 | + reload: true, | ||
2539 | + page: 0, | ||
2540 | + end: false | ||
2541 | + } | ||
2542 | + }, | ||
2543 | + $pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项 | ||
2544 | + searching; | ||
2545 | + | ||
2546 | +if ($('.swiper-container .swiper-slide').length > 1) { | ||
2547 | + swiper = new Swiper('.swiper-container', { | ||
2548 | + lazyLoading: true, | ||
2549 | + loop: true, | ||
2550 | + autoplay: 3000, | ||
2551 | + autoplayDisableOnInteraction: false, | ||
2552 | + paginationClickable: true, | ||
2553 | + pagination: '.swiper-pagination' | ||
2554 | + }); | ||
2555 | +} | ||
2556 | + | ||
2557 | +/** | ||
2558 | + * 筛选注册的回调,筛选子项点击后逻辑 | ||
2559 | + * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载 | ||
2560 | + * @param opt {type, id} | ||
2561 | + */ | ||
2562 | +function search(opt) { | ||
2563 | + var setting = {}, | ||
2564 | + ext, | ||
2565 | + att, | ||
2566 | + nav, navType, | ||
2567 | + page; | ||
2568 | + | ||
2569 | + if (opt) { | ||
2570 | + | ||
2571 | + //筛选项变更则重置reload为true | ||
2572 | + for (att in navInfo) { | ||
2573 | + if (navInfo.hasOwnProperty(att)) { | ||
2574 | + navInfo[att].reload = true; | ||
2575 | + } | ||
2576 | + } | ||
2577 | + | ||
2578 | + //处理active状态 | ||
2579 | + $listNav.children('.active').removeClass('active'); | ||
2580 | + $pre.addClass('active'); | ||
2581 | + | ||
2582 | + switch (opt.type) { | ||
2583 | + case 'gender': | ||
2584 | + ext = { | ||
2585 | + gender: opt.id | ||
2586 | + }; | ||
2587 | + break; | ||
2588 | + case 'brand': | ||
2589 | + ext = { | ||
2590 | + brand: opt.id | ||
2591 | + }; | ||
2592 | + break; | ||
2593 | + case 'msort': | ||
2594 | + ext = { | ||
2595 | + msort: opt.id | ||
2596 | + }; | ||
2597 | + break; | ||
2598 | + case 'color': | ||
2599 | + ext = { | ||
2600 | + color: opt.id | ||
2601 | + }; | ||
2602 | + break; | ||
2603 | + case 'size': | ||
2604 | + ext = { | ||
2605 | + size: opt.id | ||
2606 | + }; | ||
2607 | + break; | ||
2608 | + case 'price': | ||
2609 | + ext = { | ||
2610 | + price: opt.id | ||
2611 | + }; | ||
2612 | + break; | ||
2613 | + case 'discount': | ||
2614 | + ext = { | ||
2615 | + discount: opt.id | ||
2616 | + }; | ||
2617 | + break; | ||
2618 | + } | ||
2619 | + | ||
2620 | + $.extend(defaultOpt, ext); //扩展筛选项 | ||
2621 | + } | ||
2622 | + | ||
2623 | + if (searching) { | ||
2624 | + return; | ||
2625 | + } | ||
2626 | + | ||
2627 | + //导航类别 | ||
2628 | + if ($pre.hasClass('new')) { | ||
2629 | + navType = 'newest'; | ||
2630 | + } else if ($pre.hasClass('price')) { | ||
2631 | + navType = 'price'; | ||
2632 | + } else if ($pre.hasClass('discount')) { | ||
2633 | + navType = 'discount'; | ||
2634 | + } | ||
2635 | + | ||
2636 | + nav = navInfo[navType]; | ||
2637 | + | ||
2638 | + page = nav.page + 1; | ||
2639 | + if (nav.reload) { | ||
2640 | + page = 1; | ||
2641 | + } else if (nav.end) { | ||
2642 | + | ||
2643 | + //不需要重新加载并且数据请求结束 | ||
2644 | + return; | ||
2645 | + } | ||
2646 | + | ||
2647 | + $.extend(setting, defaultOpt, { | ||
2648 | + type: navType, | ||
2649 | + order: nav.order, | ||
2650 | + page: page | ||
2651 | + }); | ||
2652 | + | ||
2653 | + searching = true; | ||
2654 | + | ||
2655 | + $.ajax({ | ||
2656 | + type: 'GET', | ||
2657 | + url: '/product/newsale/selectNewSale', | ||
2658 | + data: setting, | ||
2659 | + success: function(data) { | ||
2660 | + var noResult = '<p class="no-result">未找到相关搜索结果</p>', | ||
2661 | + $container; | ||
2662 | + | ||
2663 | + switch (navType) { | ||
2664 | + case 'newest': | ||
2665 | + $container = $ngc; | ||
2666 | + break; | ||
2667 | + case 'price': | ||
2668 | + $container = $pgc; | ||
2669 | + break; | ||
2670 | + case 'discount': | ||
2671 | + $container = $dgc; | ||
2672 | + break; | ||
2673 | + } | ||
2674 | + | ||
2675 | + if (data === ' ') { | ||
2676 | + nav.end = true; | ||
2677 | + | ||
2678 | + if (nav.reload) { | ||
2679 | + $container.html(noResult); | ||
2680 | + } | ||
2681 | + } else { | ||
2682 | + if (nav.reload) { | ||
2683 | + $container.html(data); | ||
2684 | + } else { | ||
2685 | + $container.append(data); | ||
2686 | + } | ||
2687 | + | ||
2688 | + lazyLoad($container.find('.lazy')); | ||
2689 | + } | ||
2690 | + | ||
2691 | + nav.reload = false; | ||
2692 | + nav.page = page; | ||
2693 | + | ||
2694 | + searching = false; | ||
2695 | + } | ||
2696 | + }); | ||
2697 | + | ||
2698 | +} | ||
2699 | + | ||
2700 | +lazyLoad($('.lazy')); | ||
2701 | + | ||
2702 | +filter.registerCbFn(search); | ||
2703 | + | ||
2704 | +//导航栏点击逻辑说明: | ||
2705 | +//1.点击非active项时切换active状态 | ||
2706 | +//2.价格和折扣active状态时继续点击切换排序 | ||
2707 | +//3.筛选无active时点击展开筛选面板 | ||
2708 | +//4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态 | ||
2709 | +//5.当前active为筛选并且点击其他项时,隐藏筛选面板 | ||
2710 | +$listNav.delegate('li', 'tap', function() { | ||
2711 | + var $this = $(this), | ||
2712 | + nav, | ||
2713 | + navType, | ||
2714 | + $active; | ||
2715 | + | ||
2716 | + if ($this.hasClass('filter')) { | ||
2717 | + | ||
2718 | + //筛选面板切换状态 | ||
2719 | + if ($this.hasClass('active')) { | ||
2720 | + filter.hideFilter(); | ||
2721 | + | ||
2722 | + //点击筛选钱的active项回复active | ||
2723 | + $pre.addClass('active'); | ||
2724 | + $this.removeClass('active'); | ||
2725 | + } else { | ||
2726 | + $pre = $this.siblings('.active'); | ||
2727 | + | ||
2728 | + $pre.removeClass('active'); | ||
2729 | + $this.addClass('active'); | ||
2730 | + | ||
2731 | + filter.showFilter(); | ||
2732 | + } | ||
2733 | + } else { | ||
2734 | + | ||
2735 | + if ($this.hasClass('new')) { | ||
2736 | + navType = 'newest'; | ||
2737 | + } else if ($this.hasClass('price')) { | ||
2738 | + navType = 'price'; | ||
2739 | + } else if ($this.hasClass('discount')) { | ||
2740 | + navType = 'discount'; | ||
2741 | + } | ||
2742 | + | ||
2743 | + nav = navInfo[navType]; | ||
2744 | + | ||
2745 | + if ($this.hasClass('active')) { | ||
2746 | + | ||
2747 | + //最新无排序切换 | ||
2748 | + if ($this.hasClass('new')) { | ||
2749 | + return; | ||
2750 | + } | ||
2751 | + | ||
2752 | + if ($this.hasClass('price') || $this.hasClass('discount')) { | ||
2753 | + | ||
2754 | + // 价格/折扣切换排序状态 | ||
2755 | + $this.find('.icon > .iconfont').toggleClass('cur'); | ||
2756 | + $pre = $this; //更新pre为当前项 | ||
2757 | + nav.reload = true; //重置reload,HTML会被替换为逆序的HTML | ||
2758 | + nav.order = nav.order === 0 ? 1 : 0; //切换排序 | ||
2759 | + } | ||
2760 | + } else { | ||
2761 | + $active = $this.siblings('.active'); | ||
2762 | + | ||
2763 | + $pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项 | ||
2764 | + | ||
2765 | + if ($active.hasClass('filter')) { | ||
2766 | + | ||
2767 | + //若之前active项为筛选,则隐藏筛选面板 | ||
2768 | + filter.hideFilter(); | ||
2769 | + } else { | ||
2770 | + | ||
2771 | + //切换container显示 | ||
2772 | + $goodsContainer.children('.container:not(.hide)').addClass('hide'); | ||
2773 | + | ||
2774 | + switch (navType) { | ||
2775 | + case 'newest': | ||
2776 | + $ngc.removeClass('hide'); | ||
2777 | + break; | ||
2778 | + | ||
2779 | + case 'price': | ||
2780 | + $pgc.removeClass('hide'); | ||
2781 | + break; | ||
2782 | + | ||
2783 | + case 'discount': | ||
2784 | + $dgc.removeClass('hide'); | ||
2785 | + break; | ||
2786 | + } | ||
2787 | + } | ||
2788 | + | ||
2789 | + $active.removeClass('active'); | ||
2790 | + $this.addClass('active'); | ||
2791 | + } | ||
2792 | + | ||
2793 | + if (nav.reload) { | ||
2794 | + search(); | ||
2795 | + } | ||
2796 | + } | ||
2797 | +}); | ||
2798 | + | ||
2799 | +$(window).scroll(function() { | ||
2800 | + | ||
2801 | + //当scroll到1/4$goodsContainer高度后继续请求下一页数据 | ||
2802 | + if ($(window).scrollTop() + winH > | ||
2803 | + $(document).height() - 0.25 * $goodsContainer.height()) { | ||
2804 | + if ($pre !== undefined) { | ||
2805 | + search(); | ||
2806 | + } | ||
2807 | + } | ||
2808 | +}); | ||
2809 | +}); | ||
2810 | +define("js/product/list", ["zepto","lazyload"], function(require, exports, module){ | ||
2811 | +/** | ||
2812 | + * 商品列表页 | ||
2813 | + * @author: xuqi<qi.xu@yoho.cn> | ||
2814 | + * @date: 2015/10/20 | ||
2815 | + */ | ||
2816 | + | ||
2817 | +var $ = require("zepto"), | ||
2818 | + lazyLoad = require("lazyload"); | ||
2819 | + | ||
2820 | +//品牌页参数 | ||
2821 | +var $brandHeader = $('#brand-header'), | ||
2822 | + $introBox = $('#intro-box'); | ||
2823 | + | ||
2824 | +var filter = require("js/plugin/filter"); | ||
2825 | + | ||
2826 | +var tip = require("js/plugin/tip"); | ||
2827 | + | ||
2828 | +var $goodsContainer = $('#goods-container'), | ||
2829 | + $ngc = $goodsContainer.children('.new-goods'), | ||
2830 | + $pgc = $goodsContainer.children('.price-goods'), | ||
2831 | + $dgc = $goodsContainer.children('.discount-goods'); | ||
2832 | + | ||
2833 | +var winH = $(window).height(); | ||
2834 | + | ||
2835 | +//默认筛选条件 | ||
2836 | +var defaultOpt = { | ||
2837 | + gender: $('#gender').val(), | ||
2838 | + brand: $('#brand').val(), | ||
2839 | + msort: $('#msort').val(), | ||
2840 | + color: $('#color').val(), | ||
2841 | + size: $('#size').val(), | ||
2842 | + price: $('#price').val(), | ||
2843 | + discount: $('#discount').val() | ||
2844 | +}; | ||
2845 | + | ||
2846 | +var $listNav = $('#list-nav'), | ||
2847 | + | ||
2848 | + //导航数据信息 | ||
2849 | + navInfo = { | ||
2850 | + newest: { | ||
2851 | + order: 1, | ||
2852 | + reload: true, | ||
2853 | + page: 0, | ||
2854 | + end: false | ||
2855 | + }, | ||
2856 | + price: { | ||
2857 | + order: 0, | ||
2858 | + reload: true, | ||
2859 | + page: 0, | ||
2860 | + end: false | ||
2861 | + }, | ||
2862 | + discount: { | ||
2863 | + order: 0, | ||
2864 | + reload: true, | ||
2865 | + page: 0, | ||
2866 | + end: false | ||
2867 | + } | ||
2868 | + }, | ||
2869 | + $pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项 | ||
2870 | + searching; | ||
2871 | + | ||
2872 | +/** | ||
2873 | + * 筛选注册的回调,筛选子项点击后逻辑 | ||
2874 | + * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载 | ||
2875 | + * @param opt {type, id} | ||
2876 | + */ | ||
2877 | +function search(opt) { | ||
2878 | + var setting = {}, | ||
2879 | + ext, | ||
2880 | + att, | ||
2881 | + nav, navType, | ||
2882 | + page; | ||
2883 | + | ||
2884 | + if (opt) { | ||
2885 | + | ||
2886 | + //筛选项变更则重置reload为true | ||
2887 | + for (att in navInfo) { | ||
2888 | + if (navInfo.hasOwnProperty(att)) { | ||
2889 | + navInfo[att].reload = true; | ||
2890 | + } | ||
2891 | + } | ||
2892 | + | ||
2893 | + //处理active状态 | ||
2894 | + $listNav.children('.active').removeClass('active'); | ||
2895 | + $pre.addClass('active'); | ||
2896 | + | ||
2897 | + switch (opt.type) { | ||
2898 | + case 'gender': | ||
2899 | + ext = { | ||
2900 | + gender: opt.id | ||
2901 | + }; | ||
2902 | + break; | ||
2903 | + case 'brand': | ||
2904 | + ext = { | ||
2905 | + brand: opt.id | ||
2906 | + }; | ||
2907 | + break; | ||
2908 | + case 'msort': | ||
2909 | + ext = { | ||
2910 | + msort: opt.id | ||
2911 | + }; | ||
2912 | + break; | ||
2913 | + case 'color': | ||
2914 | + ext = { | ||
2915 | + color: opt.id | ||
2916 | + }; | ||
2917 | + break; | ||
2918 | + case 'size': | ||
2919 | + ext = { | ||
2920 | + size: opt.id | ||
2921 | + }; | ||
2922 | + break; | ||
2923 | + case 'price': | ||
2924 | + ext = { | ||
2925 | + price: opt.id | ||
2926 | + }; | ||
2927 | + break; | ||
2928 | + case 'discount': | ||
2929 | + ext = { | ||
2930 | + discount: opt.id | ||
2931 | + }; | ||
2932 | + break; | ||
2933 | + } | ||
2934 | + | ||
2935 | + $.extend(defaultOpt, ext); //扩展筛选项 | ||
2936 | + } | ||
2937 | + | ||
2938 | + if (searching) { | ||
2939 | + return; | ||
2940 | + } | ||
2941 | + | ||
2942 | + //导航类别 | ||
2943 | + if ($pre.hasClass('new')) { | ||
2944 | + navType = 'newest'; | ||
2945 | + } else if ($pre.hasClass('price')) { | ||
2946 | + navType = 'price'; | ||
2947 | + } else if ($pre.hasClass('discount')) { | ||
2948 | + navType = 'discount'; | ||
2949 | + } | ||
2950 | + | ||
2951 | + nav = navInfo[navType]; | ||
2952 | + | ||
2953 | + page = nav.page + 1; | ||
2954 | + if (nav.reload) { | ||
2955 | + page = 1; | ||
2956 | + } else if (nav.end) { | ||
2957 | + | ||
2958 | + //不需要重新加载并且数据请求结束 | ||
2959 | + return; | ||
2960 | + } | ||
2961 | + | ||
2962 | + $.extend(setting, defaultOpt, { | ||
2963 | + type: navType, | ||
2964 | + order: nav.order, | ||
2965 | + page: page | ||
2966 | + }); | ||
2967 | + | ||
2968 | + searching = true; | ||
2969 | + | ||
2970 | + $.ajax({ | ||
2971 | + type: 'GET', | ||
2972 | + url: '/index/search/search', | ||
2973 | + data: setting, | ||
2974 | + success: function(data) { | ||
2975 | + var noResult = '<p class="no-result">未找到相关搜索结果</p>', | ||
2976 | + $container; | ||
2977 | + | ||
2978 | + switch (navType) { | ||
2979 | + case 'newest': | ||
2980 | + $container = $ngc; | ||
2981 | + break; | ||
2982 | + case 'price': | ||
2983 | + $container = $pgc; | ||
2984 | + break; | ||
2985 | + case 'discount': | ||
2986 | + $container = $dgc; | ||
2987 | + break; | ||
2988 | + } | ||
2989 | + | ||
2990 | + if (data === ' ') { | ||
2991 | + nav.end = true; | ||
2992 | + | ||
2993 | + if (nav.reload) { | ||
2994 | + $container.html(noResult); | ||
2995 | + } | ||
2996 | + } else { | ||
2997 | + if (nav.reload) { | ||
2998 | + $container.html(data); | ||
2999 | + } else { | ||
3000 | + $container.append(data); | ||
3001 | + } | ||
3002 | + | ||
3003 | + lazyLoad($container.find('.lazy')); | ||
3004 | + } | ||
3005 | + | ||
3006 | + nav.reload = false; | ||
3007 | + nav.page = page; | ||
3008 | + | ||
3009 | + searching = false; | ||
3010 | + } | ||
3011 | + }); | ||
3012 | + | ||
3013 | +} | ||
3014 | + | ||
3015 | +lazyLoad($('.lazy')); | ||
3016 | + | ||
3017 | +filter.registerCbFn(search); | ||
3018 | + | ||
3019 | +//导航栏点击逻辑说明: | ||
3020 | +//1.点击非active项时切换active状态 | ||
3021 | +//2.价格和折扣active状态时继续点击切换排序 | ||
3022 | +//3.筛选无active时点击展开筛选面板 | ||
3023 | +//4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态 | ||
3024 | +//5.当前active为筛选并且点击其他项时,隐藏筛选面板 | ||
3025 | +$listNav.delegate('li', 'tap', function() { | ||
3026 | + var $this = $(this), | ||
3027 | + nav, | ||
3028 | + navType, | ||
3029 | + $active; | ||
3030 | + | ||
3031 | + if ($this.hasClass('filter')) { | ||
3032 | + | ||
3033 | + //筛选面板切换状态 | ||
3034 | + if ($this.hasClass('active')) { | ||
3035 | + filter.hideFilter(); | ||
3036 | + | ||
3037 | + //点击筛选钱的active项回复active | ||
3038 | + $pre.addClass('active'); | ||
3039 | + $this.removeClass('active'); | ||
3040 | + } else { | ||
3041 | + $pre = $this.siblings('.active'); | ||
3042 | + | ||
3043 | + $pre.removeClass('active'); | ||
3044 | + $this.addClass('active'); | ||
3045 | + | ||
3046 | + filter.showFilter(); | ||
3047 | + } | ||
3048 | + } else { | ||
3049 | + | ||
3050 | + if ($this.hasClass('new')) { | ||
3051 | + navType = 'newest'; | ||
3052 | + } else if ($this.hasClass('price')) { | ||
3053 | + navType = 'price'; | ||
3054 | + } else if ($this.hasClass('discount')) { | ||
3055 | + navType = 'discount'; | ||
3056 | + } | ||
3057 | + | ||
3058 | + nav = navInfo[navType]; | ||
3059 | + | ||
3060 | + if ($this.hasClass('active')) { | ||
3061 | + | ||
3062 | + //最新无排序切换 | ||
3063 | + if ($this.hasClass('new')) { | ||
3064 | + return; | ||
3065 | + } | ||
3066 | + | ||
3067 | + if ($this.hasClass('price') || $this.hasClass('discount')) { | ||
3068 | + | ||
3069 | + // 价格/折扣切换排序状态 | ||
3070 | + $this.find('.icon > .iconfont').toggleClass('cur'); | ||
3071 | + $pre = $this; //更新pre为当前项 | ||
3072 | + nav.reload = true; //重置reload,HTML会被替换为逆序的HTML | ||
3073 | + nav.order = nav.order === 0 ? 1 : 0; //切换排序 | ||
3074 | + } | ||
3075 | + } else { | ||
3076 | + $active = $this.siblings('.active'); | ||
3077 | + | ||
3078 | + $pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项 | ||
3079 | + | ||
3080 | + if ($active.hasClass('filter')) { | ||
3081 | + | ||
3082 | + //若之前active项为筛选,则隐藏筛选面板 | ||
3083 | + filter.hideFilter(); | ||
3084 | + } else { | ||
3085 | + | ||
3086 | + //切换container显示 | ||
3087 | + $goodsContainer.children('.container:not(.hide)').addClass('hide'); | ||
3088 | + | ||
3089 | + switch (navType) { | ||
3090 | + case 'newest': | ||
3091 | + $ngc.removeClass('hide'); | ||
3092 | + break; | ||
3093 | + | ||
3094 | + case 'price': | ||
3095 | + $pgc.removeClass('hide'); | ||
3096 | + break; | ||
3097 | + | ||
3098 | + case 'discount': | ||
3099 | + $dgc.removeClass('hide'); | ||
3100 | + break; | ||
3101 | + } | ||
3102 | + } | ||
3103 | + | ||
3104 | + $active.removeClass('active'); | ||
3105 | + $this.addClass('active'); | ||
3106 | + } | ||
3107 | + | ||
3108 | + if (nav.reload) { | ||
3109 | + search(); | ||
3110 | + } | ||
3111 | + } | ||
3112 | +}); | ||
3113 | + | ||
3114 | +$(window).scroll(function() { | ||
3115 | + | ||
3116 | + //当scroll到1/4$goodsContainer高度后继续请求下一页数据 | ||
3117 | + if ($(window).scrollTop() + winH > | ||
3118 | + $(document).height() - 0.25 * $goodsContainer.height()) { | ||
3119 | + search(); | ||
3120 | + } | ||
3121 | +}); | ||
3122 | + | ||
3123 | +//品牌介绍 | ||
3124 | +$brandHeader.children('.btn-intro').bind('tap', function() { | ||
3125 | + $introBox.removeClass('hide'); | ||
3126 | +}); | ||
3127 | + | ||
3128 | +$('.close-intro, .brand-intro-box').tap(function() { | ||
3129 | + $introBox.addClass('hide'); | ||
3130 | +}); | ||
3131 | + | ||
3132 | +$('#brand-intro').tap(function(e) { | ||
3133 | + e.stopPropagation(); | ||
3134 | +}); | ||
3135 | + | ||
3136 | +//品牌收藏 | ||
3137 | +$brandHeader.children('.btn-col').bind('tap', function() { | ||
3138 | + var $this = $(this); | ||
3139 | + | ||
3140 | + var id = $brandHeader.data('id'), | ||
3141 | + opt; | ||
3142 | + | ||
3143 | + if ($this.hasClass('coled')) { | ||
3144 | + opt = 'cancel'; | ||
3145 | + } else { | ||
3146 | + opt = 'ok'; | ||
3147 | + } | ||
3148 | + | ||
3149 | + $.ajax({ | ||
3150 | + type: 'POST', | ||
3151 | + url: '/product/opt/favoriteBrand', | ||
3152 | + data: { | ||
3153 | + id: id, | ||
3154 | + opt: opt | ||
3155 | + }, | ||
3156 | + success: function(data) { | ||
3157 | + if (data.code === 200) { | ||
3158 | + $this.toggleClass('coled'); | ||
3159 | + } else if (data.code === 400) { | ||
3160 | + tip.show('未登录'); | ||
3161 | + } | ||
3162 | + }, | ||
3163 | + error: function() { | ||
3164 | + tip.show('网络断开连接了~'); | ||
3165 | + } | ||
3166 | + }); | ||
3167 | +}); | ||
3168 | +}); | ||
3169 | +define("js/product/detail/detail", ["zepto","swiper","lazyload","index"], function(require, exports, module){ | ||
3170 | +/** | ||
3171 | + * 产品打包入口 | ||
3172 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
3173 | + * @date: 2015/10/20 | ||
3174 | + */ | ||
3175 | + var $ = require("zepto"), | ||
3176 | + Swiper = require("swiper"), | ||
3177 | + lazyLoad = require("lazyload"), | ||
3178 | + goodsSwiper; | ||
3179 | + | ||
3180 | +lazyLoad($('img.lazy')); | ||
3181 | + | ||
3182 | +goodsSwiper = new Swiper('.banner-swiper', { | ||
3183 | + loop: true, | ||
3184 | + pagination: '.banner-top .pagination-inner', | ||
3185 | + slideElement: 'div', | ||
3186 | + nextButton: '.swiper-button-next', | ||
3187 | + prevButton: '.swiper-button-prev' | ||
3188 | +}); | ||
3189 | +}); | ||
3190 | +define("js/index/index", ["zepto"], function(require, exports, module){ | ||
3191 | +/** | ||
3192 | + * Index打包入口 | ||
3193 | + * @author: xuqi<qi.xu@yoho.cn> | ||
3194 | + * @date: 2015/10/19 | ||
3195 | + */ | ||
3196 | + | ||
3197 | +require("js/index/search"); | ||
3198 | +require("js/index/channel"); | ||
3199 | +require("js/index/footer"); | ||
3200 | +}); | ||
3201 | +define("js/index/search", ["zepto"], function(require, exports, module){ | ||
3202 | +/** | ||
3203 | + * 搜索JS | ||
3204 | + * @author: xuqi<qi.xu@yoho.cn> | ||
3205 | + * @date: 2015/10/19 | ||
3206 | + */ | ||
3207 | + | ||
3208 | +var $ = require("zepto"); | ||
3209 | + | ||
3210 | +var $input = $('#search-input input'); | ||
3211 | + | ||
3212 | +var $clear = $('#search-input .clear-input'); | ||
3213 | + | ||
3214 | +var $history = $('.history'); | ||
3215 | + | ||
3216 | +$('#clear-history').bind('tap', function() { | ||
3217 | + $.ajax({ | ||
3218 | + type: 'POST', | ||
3219 | + url: '/search/clearHistory', | ||
3220 | + success: function(data) { | ||
3221 | + if (data.code === 200) { | ||
3222 | + $history.html(''); //clear search history items | ||
3223 | + } | ||
3224 | + } | ||
3225 | + }); | ||
3226 | +}); | ||
3227 | + | ||
3228 | +$input.bind('input', function() { | ||
3229 | + if ($input.val() === '') { | ||
3230 | + $clear.addClass('hide'); | ||
3231 | + } else { | ||
3232 | + $clear.removeClass('hide'); | ||
3233 | + } | ||
3234 | +}); | ||
3235 | + | ||
3236 | +$clear.bind('tap', function() { | ||
3237 | + $input.val('').trigger('input'); | ||
3238 | +}); | ||
3239 | +}); | ||
3240 | +define("js/index/channel", [], function(require, exports, module){ | ||
3241 | +/** | ||
3242 | + * 频道选择 | ||
3243 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
3244 | + * @date: 2015/10/12 | ||
3245 | + */ | ||
3246 | + | ||
3247 | +}); | ||
3248 | +define("js/index/footer", ["zepto"], function(require, exports, module){ | ||
3249 | +/** | ||
3250 | + * 底部JS | ||
3251 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
3252 | + * @date: 2015/10/26 | ||
3253 | + */ | ||
3254 | + | ||
3255 | +var $ = require("zepto"); | ||
3256 | + | ||
3257 | +var $searchBox = $('.search-box'), | ||
3258 | + $indexSearch = $('.index-search'), | ||
3259 | + $indexLogo = $('.index-logo'); | ||
3260 | + | ||
3261 | +function downLoadApp() { | ||
3262 | + var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445'; | ||
3263 | + var clickedAt = new Date(); | ||
3264 | + | ||
3265 | + setTimeout(function () { | ||
3266 | + if ((new Date()) - clickedAt < 2000) { | ||
3267 | + window.location = appUrl; | ||
3268 | + } | ||
3269 | + }, 500); | ||
3270 | +} | ||
3271 | + | ||
3272 | +$('#float-layer-close').bind('tap', function () { | ||
3273 | + $('#float-layer-app').hide(); | ||
3274 | + window.setCookie('_float-layer-app', 'id490655927', | ||
3275 | + { | ||
3276 | + domain: '.yohobuy.com' | ||
3277 | + }); | ||
3278 | + window.setCookie('_float-layer-app-close', 1, | ||
3279 | + { | ||
3280 | + domain: '.yohobuy.com', | ||
3281 | + expires: 1 | ||
3282 | + }); | ||
3283 | +}); | ||
3284 | + | ||
3285 | +$('#float-layer-btn').tap(function () { | ||
3286 | + downLoadApp('bottom'); | ||
3287 | +}); | ||
3288 | + | ||
3289 | +if (!window.cookie('_float-layer-app')) { | ||
3290 | + $('#float-layer-app').show(); | ||
3291 | +} else { | ||
3292 | + $('#float-layer-app').hide(); | ||
3293 | +} | ||
3294 | + | ||
3295 | +/** | ||
3296 | + * 频道选择页面顶部搜索 | ||
3297 | + * @author: bikai<kai.bi@yoho.cn> | ||
3298 | + * @date: 2015/10/28 | ||
3299 | + */ | ||
3300 | + | ||
3301 | +$searchBox.find('input').on('focus', function () { | ||
3302 | + $indexLogo.css({ | ||
3303 | + width: 0, | ||
3304 | + display: 'none' | ||
3305 | + }); | ||
3306 | + $searchBox.css({ | ||
3307 | + width: '12.8rem' | ||
3308 | + }); | ||
3309 | + $indexSearch.css({ | ||
3310 | + width: '15.5rem' | ||
3311 | + }); | ||
3312 | + $('.clear-text, .no-search').show(); | ||
3313 | +}).on('blur', function () { | ||
3314 | + $indexLogo.css({ | ||
3315 | + width: '5.4rem', | ||
3316 | + display: 'block' | ||
3317 | + }); | ||
3318 | + $searchBox.css({ | ||
3319 | + width: '8.8rem' | ||
3320 | + }); | ||
3321 | + $indexSearch.css({ | ||
3322 | + width: '9.6rem' | ||
3323 | + }); | ||
3324 | + $('.clear-text, .no-search').hide(); | ||
3325 | +}); | ||
3326 | + | ||
3327 | +$searchBox.find('.clear-text').tap(function () { | ||
3328 | + $searchBox.find('input').val('').trigger('focus'); | ||
3329 | +}); | ||
3330 | + | ||
3331 | +$searchBox.find('.search-icon').tap(function () { | ||
3332 | + $indexSearch.submit(); | ||
3333 | +}); | ||
3334 | +}); |
static/dist/myohobuy/0.0.2/index.css
0 → 100644
1 | +/* | ||
2 | +Error: No files were found in the load path matching "guang/clothes/*.png". Your current load paths are: D:/workspace/yohobuy.git.dev.yoho.cn/static/dist/myohobuy/assets/img | ||
3 | + on line 1 of D:/workspace/yohobuy.git.dev.yoho.cn/static/sass/guang/_detail.scss | ||
4 | + from line 1 of D:/workspace/yohobuy.git.dev.yoho.cn/static/sass/guang/_index.scss | ||
5 | + from line 96 of D:/workspace/yohobuy.git.dev.yoho.cn/static/sass/index.scss | ||
6 | + | ||
7 | +1: @import "compass", "compass/reset"; | ||
8 | +2: $pxConvertRem: 40; | ||
9 | +3: | ||
10 | +4: * { | ||
11 | +5: -webkit-tap-highlight-color: rgba(0,0,0,0); | ||
12 | +6: -moz-tap-highlight-color: rgba(0,0,0,0); | ||
13 | + | ||
14 | +Backtrace: | ||
15 | +D:/workspace/yohobuy.git.dev.yoho.cn/static/sass/guang/_detail.scss:1 | ||
16 | +D:/workspace/yohobuy.git.dev.yoho.cn/static/sass/guang/_index.scss:1 | ||
17 | +D:/workspace/yohobuy.git.dev.yoho.cn/static/sass/index.scss:96 | ||
18 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/import_node.rb:67:in `rescue in import' | ||
19 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/import_node.rb:45:in `import' | ||
20 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/import_node.rb:28:in `imported_file' | ||
21 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/import_node.rb:37:in `css_import?' | ||
22 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:311:in `visit_import' | ||
23 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/base.rb:36:in `visit' | ||
24 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:158:in `block in visit' | ||
25 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:79:in `block in with_base' | ||
26 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:115:in `with_frame' | ||
27 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:79:in `with_base' | ||
28 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:158:in `visit' | ||
29 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:326:in `block (2 levels) in visit_import' | ||
30 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:326:in `map' | ||
31 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:326:in `block in visit_import' | ||
32 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:88:in `block in with_import' | ||
33 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:115:in `with_frame' | ||
34 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:88:in `with_import' | ||
35 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:323:in `visit_import' | ||
36 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/base.rb:36:in `visit' | ||
37 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:158:in `block in visit' | ||
38 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:79:in `block in with_base' | ||
39 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:115:in `with_frame' | ||
40 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:79:in `with_base' | ||
41 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:158:in `visit' | ||
42 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:326:in `block (2 levels) in visit_import' | ||
43 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:326:in `map' | ||
44 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:326:in `block in visit_import' | ||
45 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:88:in `block in with_import' | ||
46 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:115:in `with_frame' | ||
47 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:88:in `with_import' | ||
48 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:323:in `visit_import' | ||
49 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/base.rb:36:in `visit' | ||
50 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:158:in `block in visit' | ||
51 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:79:in `block in with_base' | ||
52 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:115:in `with_frame' | ||
53 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/stack.rb:79:in `with_base' | ||
54 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:158:in `visit' | ||
55 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/base.rb:52:in `block in visit_children' | ||
56 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/base.rb:52:in `map' | ||
57 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/base.rb:52:in `visit_children' | ||
58 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:167:in `block in visit_children' | ||
59 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:179:in `with_environment' | ||
60 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:166:in `visit_children' | ||
61 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/base.rb:36:in `block in visit' | ||
62 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:186:in `visit_root' | ||
63 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/base.rb:36:in `visit' | ||
64 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:157:in `visit' | ||
65 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/visitors/perform.rb:8:in `visit' | ||
66 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/root_node.rb:36:in `css_tree' | ||
67 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/tree/root_node.rb:20:in `render' | ||
68 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/engine.rb:278:in `render' | ||
69 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-import-once-1.0.5/lib/compass/import-once/engine.rb:17:in `block in render' | ||
70 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-import-once-1.0.5/lib/compass/import-once/engine.rb:29:in `with_import_scope' | ||
71 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-import-once-1.0.5/lib/compass/import-once/engine.rb:16:in `render' | ||
72 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/plugin/compiler.rb:492:in `update_stylesheet' | ||
73 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/plugin/compiler.rb:215:in `block in update_stylesheets' | ||
74 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/plugin/compiler.rb:209:in `each' | ||
75 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/sass-3.4.19/lib/sass/plugin/compiler.rb:209:in `update_stylesheets' | ||
76 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-1.0.3/lib/compass/sass_compiler.rb:40:in `compile!' | ||
77 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-1.0.3/lib/compass/commands/update_project.rb:49:in `perform' | ||
78 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-1.0.3/lib/compass/commands/base.rb:18:in `execute' | ||
79 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-1.0.3/lib/compass/commands/project_base.rb:19:in `execute' | ||
80 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:43:in `perform!' | ||
81 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:15:in `run!' | ||
82 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-1.0.3/bin/compass:30:in `block in <top (required)>' | ||
83 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-1.0.3/bin/compass:44:in `call' | ||
84 | +D:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-1.0.3/bin/compass:44:in `<top (required)>' | ||
85 | +D:/Ruby22/bin/compass:23:in `load' | ||
86 | +D:/Ruby22/bin/compass:23:in `<main>' | ||
87 | +*/ | ||
88 | +body:before { | ||
89 | + white-space: pre; | ||
90 | + font-family: monospace; | ||
91 | + content: "Error: No files were found in the load path matching \"guang/clothes/*.png\". Your current load paths are: D:/workspace/yohobuy.git.dev.yoho.cn/static/dist/myohobuy/assets/img\A on line 1 of D:/workspace/yohobuy.git.dev.yoho.cn/static/sass/guang/_detail.scss\A from line 1 of D:/workspace/yohobuy.git.dev.yoho.cn/static/sass/guang/_index.scss\A from line 96 of D:/workspace/yohobuy.git.dev.yoho.cn/static/sass/index.scss\A \A 1: @import \"compass\", \"compass/reset\";\A 2: $pxConvertRem: 40;\A 3: \A 4: * {\A 5: -webkit-tap-highlight-color: rgba(0,0,0,0);\A 6: -moz-tap-highlight-color: rgba(0,0,0,0);"; } |
static/dist/myohobuy/0.0.2/index.js
0 → 100644
1 | +define("index",["zepto","lazyload","swiper","mlellipsis","iscroll-probe","index"],function(e,a,s){var i;e("js/common"),e("js/passport/index"),e("js/guang/index"),e("js/home/index"),e("js/product/index"),e("js/index/index"),s.exports=i}),define("js/common",["zepto"],function(e,a,s){function i(e){var a,s,i=document.cookie;return document.cookie&&""!==document.cookie&&(s=i.indexOf(e+"="),s>-1&&(s+=e.length+1,a=decodeURIComponent(r.trim(i.substring(s,i.indexOf(";",s)))))),a}function t(e,a,s){var i,t,n,o,l="";"undefined"!=typeof a&&(s=s||{},null===a&&(a="",s.expires=-1),s.expires&&("number"==typeof s.expires||s.expires.toUTCString)&&("number"==typeof s.expires?(o=new Date,o.setTime(o.getTime()+24*s.expires*60*60*1e3)):o=s.expires,l="; expires="+o.toUTCString()),i=s.path?"; path="+s.path:"",t=s.domain?"; domain="+s.domain:"",n=s.secure?"; secure":"",document.cookie=[e,"=",encodeURIComponent(a),l,i,t,n].join(""))}function n(){var e,a=i("_UID");return"undefined"==typeof a?0:(e=a.split("::"),"undefined"==typeof e||e.length<4?0:e)}function o(){var e=n();return 0===e?0:e[1]}function l(){var e=i("_g");return"undefined"==typeof e?"":JSON.parse(e).k}var r=e("zepto");!function(){var e=r("#yoho-footer"),a=e.children(".op-row"),s=n();r("body").height()<r(window).height()&&e.addClass("bottom"),0===s?a.prepend('<a href="http://m.yohobuy.com/signin.html">登录</a><span class="sep-line">|</span><a href="http://m.yohobuy.com/reg.html">注册</a>'):a.prepend('Hi,<a class="user-name" href="http://m.yohobuy.com/home?tmp='+Math.random()+'">'+s[0]+'</a><a href="http://m.yohobuy.com/passport/signout/index?token='+s[3]+'">退出</a>'),e.removeClass("hide")}(),window.cookie=i,window.setCookie=t,window.getUser=n,window.getUid=o,window.getShoppingKey=l}),define("js/passport/index",["zepto"],function(e,a,s){e("js/passport/register/register"),e("js/passport/register/code"),e("js/passport/register/password"),e("js/passport/login/login"),e("js/passport/login/international"),e("js/passport/back/mobile"),e("js/passport/back/code"),e("js/passport/back/email"),e("js/passport/back/email-success"),e("js/passport/back/new-password")}),define("js/passport/register/register",["zepto"],function(e,a,s){var i=e("zepto"),t=i("#phone-num"),n=i("#country-select"),o=i("#area-code"),l=i("#btn-next"),r=e("js/passport/api"),d=e("js/plugin/tip"),c=i.trim,p=d.show;r.selectCssHack(i("#country-select")),r.bindClearEvt(),t.bind("input",function(){""===c(t.val())?l.addClass("disable"):l.removeClass("disable")}),n.change(function(){o.text(n.val())}),l.on("tap",function(){var e=c(t.val()),a=n.val();l.hasClass("disable")||(r.phoneRegx[a].test(e)?i.ajax({url:"/passport/reg/verifymobile",type:"POST",data:{areaCode:a.replace("+",""),phoneNum:e},success:function(e){200===e.code?location.href=e.data:p(e.message)}}):p("手机号格式不正确,请重新输入"))})}),define("js/passport/api",["zepto"],function(e,a,s){function i(e){var a,s=l(".has-eye");e&&"open"===e.status?s.append('<div class="eye"></div>'):s.append('<div class="eye close"></div>'),a=s.children(".eye"),a.on("tap",function(e){var a=l(this),s=a.siblings(".pwd");e.preventDefault(),a.toggleClass("close"),a.hasClass("close")?s.attr("type","password"):s.attr("type","text"),s.focus()})}function t(){var e,a=l(".has-clear");a.append('<div class="clear-input"></div>'),e=a.children(".clear-input"),e.on("tap",function(a){var s=e.siblings(".input");s.val("").trigger("input").focus(),a.preventDefault()}),a.children(".input").bind("input",function(){var e=l(this),a=e.siblings(".clear-input"),s=r(e.val());""===s?a.hide():a.show()})}function n(e){return e.length>=6&&e.length<=20?!0:!1}function o(e){function a(){var a=e.find("option:selected").text().length;switch(a){case 2:e.outerWidth(90);break;case 3:e.outerWidth(110);break;default:e.outerWidth(130)}}var s=navigator.userAgent;s.match(/uc/i)&&s.match(/android/i)?e.change(function(){a()}):e.removeClass("in-android-uc")}var l=e("zepto"),r=l.trim,d=/^([a-zA-Z0-9]+[_|\_|\.|-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.|-]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/,c={"+86":/^1[35847]{1}[0-9]{9}$/,"+852":/^[965]{1}[0-9]{7}$/,"+853":/^[0-9]{8}$/,"+886":/^[0-9]{10}$/,"+65":/^[98]{1}[0-9]{7}$/,"+60":/^1[1234679]{1}[0-9]{8}$/,"+1":/^[0-9]{10}$/,"+82":/^01[0-9]{9}$/,"+44":/^7[789][0-9]{8}$/,"+81":/^0[9|8|7][0-9]{9}$/,"+61":/^[0-9]{11}$/};s.exports={emailRegx:d,phoneRegx:c,bindEyesEvt:i,bindClearEvt:t,pwdValidate:n,selectCssHack:o}}),define("js/plugin/tip",["zepto"],function(e,a,s){function i(e,a){var s,i;"undefined"!=typeof e&&(s=e.toString(),i=a&&a>0?a:2e3,t.text(s).show(),n=setTimeout(function(){"block"===t.css("display")&&t.hide()},i))}var t,n,o=e("zepto");!function(){var e='<div id="yoho-tip" class="yoho-tip"></div>';o(".yoho-page").append(e),t=o("#yoho-tip"),t.on("tap",function(){t.hide(),clearTimeout(n)})}(),a.show=i}),define("js/passport/register/code",["zepto"],function(e,a,s){e("js/passport/code")(!0)}),define("js/passport/code",["zepto"],function(e,a,s){var i=e("zepto");s.exports=function(a){function s(){var e,a=59;e=setInterval(function(){0===a?(o.text("重发验证码").removeClass("disable"),clearInterval(e)):o.text("重发验证码 ("+a--+"秒)")},1e3)}var t=i("#captcha"),n=i("#btn-next"),o=i("#captcha-tip"),l=i("#phone-num").val(),r=i("#area-code").val().replace("+",""),d=e("js/passport/api"),c=e("js/plugin/tip"),p=i.trim,u=c.show,h=a?"reg":"back";d.bindClearEvt(),t.bind("input",function(){""!==p(t.val())?n.removeClass("disable"):n.addClass("disable")}),o.on("tap",function(){o.hasClass("disable")||i.ajax({type:"POST",url:"/passport/"+h+"/sendcode",data:{phoneNum:l,areaCode:r},success:function(e){200===e.code?(o.text("重发验证码 (60秒)").addClass("disable"),s()):u(e.message)}})}),n.on("tap",function(){n.hasClass("disable")||i.ajax({type:"POST",url:"/passport/"+h+"/verifycode",data:{phoneNum:l,areaCode:r,code:p(t.val()),token:i("#token").val()},success:function(e){200===e.code?location.href=e.data:u(e.message)}})}),s()}}),define("js/passport/register/password",["zepto"],function(e,a,s){var i=e("zepto"),t=i("#pwd"),n=i("#btn-sure"),o=e("js/passport/api"),l=e("js/plugin/tip"),r=i.trim,d=l.show;o.bindEyesEvt({status:"open"}),t.bind("input",function(){""===r(t.val())?n.addClass("disable"):n.removeClass("disable")}),n.on("tap",function(){var e=r(t.val());n.hasClass("disable")||(o.pwdValidate(e)===!1?d("密码6-20位,请重新输入"):i.ajax({type:"POST",url:"/passport/reg/setpassword",data:{password:e,phoneNum:i("#phone-num").val(),areaCode:i("#area-code").val(),token:i("#token").val()},success:function(e){200===e.code?(d("注册成功"),setTimeout(function(){location.href=e.data},1e3)):401===e.code||404===e.code||505===e.code?d(e.message):(d(e.message),setTimeout(function(){location.href=e.data},1e3))}}))})}),define("js/passport/login/login",["zepto"],function(e,a,s){function i(){u&&h?d.removeClass("disable"):d.addClass("disable")}function t(){c.show(),p.show()}function n(){c.hide(),p.hide()}var o=e("zepto"),l=o("#account"),r=o("#pwd"),d=o("#btn-login"),c=o("#retrive-pwd-mask"),p=o("#retrive-pwd-ways"),u=!1,h=!1,f=e("js/passport/api"),g=e("js/plugin/tip"),v=o.trim,m=g.show;f.bindEyesEvt(),f.bindClearEvt(),l.bind("input",function(){u=""!==v(l.val())?!0:!1,i()}),r.bind("input",function(){h=""===v(r.val())?!1:!0,i()}),d.on("tap",function(){var e=v(l.val()),a=v(r.val());d.hasClass("disable")||((/^[0-9]+$/.test(e)||f.emailRegx.test(e))&&f.pwdValidate(a)?o.ajax({type:"POST",url:"/passport/login/auth",data:{account:e,password:a},success:function(e){200===e.code?(m("登录成功"),setTimeout(function(){location.href=e.data},1e3)):m(e.message)},error:function(){m("网络断开连接啦~")}}):m("账号或密码有错误,请重新输入"))}),o("#forget-pwd").on("tap",function(){t()}),c.on("tap",function(){n()}),o("#cancel-retrive").on("tap",function(e){e.preventDefault(),n()}),l.trigger("input"),r.trigger("input")}),define("js/passport/login/international",["zepto"],function(e,a,s){function i(){c&&p?d.removeClass("disable"):d.addClass("disable")}var t=e("zepto"),n=t("#phone-num"),o=t("#country-select"),l=t("#area-code"),r=t("#pwd"),d=t("#btn-login"),c=!1,p=!1,u=e("js/passport/api"),h=e("js/plugin/tip"),f=t.trim,g=h.show;u.selectCssHack(o),u.bindEyesEvt(),u.bindClearEvt(),n.bind("input",function(){c=""===f(n.val())?!1:!0,i()}),r.bind("input",function(){var e=f(r.val());p=""===e?!1:!0,i()}),o.change(function(){l.text(o.val())}),d.on("tap",function(){var e=f(n.val()),a=o.val(),s=f(r.val());d.hasClass("disable")||(u.phoneRegx[a].test(e)&&u.pwdValidate(s)?t.ajax({type:"POST",url:"/passport/login/auth",data:{areaCode:a.replace("+",""),account:e,password:s},success:function(e){200===e.code?(g("登录成功"),setTimeout(function(){location.href=e.data},1e3)):g(e.message)},error:function(){g("网络断开连接啦~")}}):g("账号或密码有错误,请重新输入"))}),n.trigger("input"),r.trigger("input")}),define("js/passport/back/mobile",["zepto"],function(e,a,s){var i=e("zepto"),t=i("#phone-num"),n=i("#country-select"),o=i("#area-code"),l=i("#btn-next"),r=e("js/passport/api"),d=e("js/plugin/tip"),c=i.trim,p=d.show;r.selectCssHack(i("#country-select")),r.bindClearEvt(),t.bind("input",function(){""===c(t.val())?l.addClass("disable"):l.removeClass("disable")}),n.change(function(){o.text(n.val())}),l.on("tap",function(){var e=c(t.val()),a=n.val();l.hasClass("disable")||(r.phoneRegx[a].test(e)?i.ajax({url:"/passport/back/sendcode",type:"POST",data:{areaCode:a.replace("+",""),phoneNum:e},success:function(e){200===e.code?location.href=e.data:p(e.message)}}):p("手机号格式不正确,请重新输入"))})}),define("js/passport/back/code",["zepto"],function(e,a,s){e("js/passport/code")(!1)}),define("js/passport/back/email",["zepto"],function(e,a,s){var i=e("zepto"),t=i("#email"),n=i("#btn-sure"),o=e("js/passport/api"),l=e("js/plugin/tip"),r=i.trim,d=l.show;o.bindClearEvt(),t.bind("input",function(){""===r(t.val())?n.addClass("disable"):n.removeClass("disable")}),n.on("tap",function(){var e=r(t.val());n.hasClass("disable")||(o.emailRegx.test(e)?i.ajax({url:"/passport/back/sendemail",type:"POST",data:{email:e},success:function(e){200===e.code?location.href=e.data:d(e.message)}}):d("邮箱格式不正确,请重新输入"))})}),define("js/passport/back/email-success",["zepto"],function(e,a,s){var i=e("zepto"),t=i("#resend"),n=e("js/plugin/tip"),o=n.show;t.on("tap",function(e){e.preventDefault(),i.ajax({url:t.data("url"),type:"GET",success:function(e){o(200===e.code?e.message:e.message)}})})}),define("js/passport/back/new-password",["zepto"],function(e,a,s){var i=e("zepto"),t=i("#pwd"),n=i("#btn-ok"),o=e("js/passport/api"),l=e("js/plugin/tip"),r=i.trim,d=l.show,c=i("#phone-num");o.bindEyesEvt(),t.bind("input",function(){""===r(t.val())?n.addClass("disable"):n.removeClass("disable")}),n.on("tap",function(){var e,a,s=r(t.val()),l=!0;n.hasClass("disable")||(e={password:s},0===c.length&&(l=!1),l?(i.extend(e,{phoneNum:c.val(),areaCode:i("#areaCode").val(),token:i("#token").val()}),a="/passport/back/passwordByMobile"):(i.extend(e,{code:i("#email-code").val()}),a="/passport/back/passwordByEmail"),o.pwdValidate(s)?i.ajax({type:"POST",url:a,data:e,success:function(e){200===e.code?(d("密码修改成功"),setTimeout(function(){location.href=e.data},1e3)):d(e.message)}}):d("密码6-20位,请重新输入"))})}),define("js/guang/index",["zepto","lazyload","swiper","mlellipsis","iscroll-probe","index"],function(e,a,s){e("js/guang/plus-star/list"),e("js/guang/plus-star/detail"),e("js/guang/home"),e("js/guang/list"),e("js/guang/detail")}),define("js/guang/plus-star/list",["zepto","lazyload","swiper","index"],function(e,a,s){var i,t=e("zepto"),n=e("lazyload"),o=e("swiper"),l=t("#nav-tab > li"),r=t("#ps-content > .content");n(t("img.lazy")),i=new o(".swiper-container",{lazyLoading:!0,pagination:".swiper-pagination"}),t("#nav-tab").delegate("li","tap",function(){t(this).hasClass("focus")||(l.toggleClass("focus"),r.toggleClass("hide"),t(document).trigger("scroll"))})}),define("js/guang/plus-star/detail",["zepto","mlellipsis","lazyload"],function(e,a,s){var i,t,n=e("zepto"),o=e("mlellipsis"),l=e("lazyload"),r=n("#intro"),d=n("#intro-more-txt"),c=n("#related-infos-container"),p=e("js/guang/info"),u=e("js/plugin/tip"),h=n("#brand-info").data("id");o.init(),l(n("img.lazy")),r[0].mlellipsis(3),setTimeout(function(){i=r.text(),t=r.attr("title")}),p.initInfosEvt(c),n("#more-intro").bind("tap",function(){var e=n(this);e.toggleClass("spread"),e.hasClass("spread")?(r.text(t),d.text("收起")):(r.text(i),d.text("more"))}),n("#brand-like").bind("tap",function(e){var a="ok",s=n(this);e.preventDefault(),s.hasClass("like")&&(a="cancel"),n.ajax({type:"POST",url:"/product/opt/favoriteBrand",data:{id:h,opt:a},success:function(e){200===e.code?s.toggleClass("like"):400===e.code&&u.show("未登录")},error:function(){u.show("网络断开连接了~")}})})}),define("js/guang/info",["zepto","mlellipsis","lazyload"],function(e,a,s){function i(e){r(e.find("img.lazy")),e.each(function(){var e=o(this),a=e.find(".info-title"),s=e.find(".info-text");a[0].mlellipsis(2),s[0].mlellipsis(2)})}function t(e){e.delegate(".like-btn","tap",function(e){var a=o(e.currentTarget),s=a.closest(".guang-info"),i="ok";a.hasClass("like")&&(i="cancel"),o.ajax({type:"POST",url:"/guang/opt/praiseArticle",data:{id:s.data("id"),opt:i},success:function(e){var s=e.code;200===s&&(a.next(".like-count").text(e.data),a.toggleClass("like"))},error:function(){d.show("网络断开连接了~")}})}),i(e.find(".guang-info"))}function n(e,a){h||a.end||(h=!0,o.ajax({type:"GET",url:" /guang/index/page",data:a,success:function(s){return" "===s?(a.end=!0,h=!1,p.addClass("hide"),void u.removeClass("hide")):(e.append(s),i(e.find(".guang-info")),a.page++,void(h=!1))},error:function(){d.show("网络断开连接了~"),h=!1}}))}var o=e("zepto"),l=e("mlellipsis"),r=e("lazyload"),d=e("js/plugin/tip"),c=o("#load-more-info"),p=o(""),u=o(""),h=!1;l.init(),c.length>0&&(p=c.children(".loading"),u=c.children(".no-more")),a.initInfosEvt=t,a.setLazyLoadAndMellipsis=i,a.loadMore=n}),define("js/guang/home",["zepto","swiper","mlellipsis","lazyload","index"],function(e,a,s){var i,t=e("zepto"),n=e("swiper"),o=e("js/guang/info"),l=o.setLazyLoadAndMellipsis,r=o.loadMore,d=t("#load-more-info"),c=t(""),p=t(""),u=t(window).height(),h=d.height(),f=t("#info-list"),g=f.children(".info-list"),v=t("#guang-nav"),m=v.children(".focus"),w=m.data("type"),b={};d.length>0&&(c=d.children(".loading"),p=d.children(".no-more")),i=new n(".swiper-container",{lazyLoading:!0,pagination:".swiper-pagination"}),o.initInfosEvt(f),function(){var e=t("#gender").val();v.children(".guang-nav-item").each(function(){var a=t(this).data("type");b[a]={page:1,gender:e,type:a,end:!1}})}(),v.delegate(".guang-nav-item","tap",function(){var e,a,s=t(this);s.hasClass("focus")||(a=s.index(),s.addClass("focus"),m.removeClass("focus"),g.not(".hide").addClass("hide"),e=g.eq(a),e.removeClass("hide"),l(e.children(".guang-info")),m=s,w=s.data("type"),b[w].end?(c.addClass("hide"),p.removeClass("hide")):(c.removeClass("hide"),p.addClass("hide")))}),t(document).scroll(function(){t(window).scrollTop()+u>=t(document).height()-h&&r(g,b[w])})}),define("js/guang/list",["zepto","mlellipsis","lazyload"],function(e,a,s){var i=e("zepto"),t=e("js/guang/info"),n=t.loadMore,o=i(window).height(),l=i("#load-more").height(),r=i("#author-infos"),d=i("#tag"),c={page:1,end:!1},p=i("#info-list");t.initInfosEvt(p),r.length>0&&i.extend(c,{authorId:r.data("id")}),d.length>0&&i.extend(c,{tag:d.val()}),i(document).scroll(function(){i(window).scrollTop()+o>=i(document).height()-l&&n(p,c)})}),define("js/guang/detail",["zepto","mlellipsis","lazyload","iscroll-probe"],function(e,a,s){function i(e){var a=e.offset().left,s=-C+a+w/2+"px";o.css({backgroundPosition:s+" bottom"}),v&&b.css({backgroundPosition:s+" bottom"})}function t(e){var a,s,t,u=p(e.currentTarget),f=u.index();u.hasClass("focus")||(l.filter(".focus").removeClass("focus"),v&&(a=u.closest(".fixed-thumb-container").length>0?o:b,s=a.find(".thumb").eq(f),b.find(".thumb.focus").removeClass("focus"),s.addClass("focus")),u.addClass("focus"),i(u),r.not(".hide").addClass("hide"),t=r.eq(f),t.removeClass("hide"),h(t.find(".lazy")),v?c&&c.scrollToElement(d,400):p("body").animate({scrollTop:n.offset().top},400))}var n,o,l,r,d,c,p=e("zepto"),u=e("mlellipsis"),h=e("lazyload"),f=e("iscroll-probe"),g=p(".author .intro"),v=navigator.userAgent.indexOf("iPhone")>0?!0:!1,m=p(".collocation-block").length>0?!0:!1,w=0,b=p(""),d=document.querySelector("#wrapper .collocation-block"),C=p(window).width();v&&p("#wrapper").addClass("ios"),u.init(),h(p(".lazy")),p(".info-list .title, .one-good .reco-name").each(function(){this.mlellipsis(2)}),parseInt(g.offset().left,10)===parseInt(g.css("margin-left"),10)&&g.css("padding-top",0),m&&(n=p(".collocation-block"),o=n.children(".thumb-container"),l=o.find("li"),r=n.find(".prod"),w=l.width(),v&&(b=p("#wrapper").after(o.clone().addClass("fixed-thumb-container fixed-bottom")).next(".thumb-container"),h(b.find(".lazy"),{event:"sporty"})),i(l.filter(".focus")),o.delegate(".thumb","touchend",t),v&&b.delegate(".thumb","touchend",t)),window.onload=function(){var e,a,s,i,t,l=p("#scroller");if(v){if(c=new f("#wrapper",{probeType:3,mouseWheel:!0,click:!0}),document.addEventListener("touchmove",function(e){e.preventDefault()},!1),!m)return void c.on("scroll",function(){l.trigger("scroll")});e=p(window).height(),t=b[0],a=o.height(),s=n.height(),i=n.offset().top,c.on("scroll",function(){var n=-this.y,o=t.className;i-e+a>=n?-1===o.indexOf("fixed-bottom")&&b.addClass("fixed-bottom").removeClass("hide"):i>=n?-1===o.indexOf("hide")&&b.addClass("hide").removeClass("fixed-bottom fixed-top"):i+s-a>=n?-1===o.indexOf("fixed-top")&&b.addClass("fixed-top").removeClass("hide absolute").css("top",""):i+s>=n?(-1===o.indexOf("absolute")&&b.addClass("absolute").removeClass("fixed-top hide"),t.style.top=i+s-a-n+"px"):n>i+s&&-1===o.indexOf("hide")&&b.addClass("hide").removeClass("absolute"),l.trigger("scroll")})}}}),define("js/home/index",["zepto","swiper","lazyload","index"],function(e,a,s){e("js/home/home"),e("js/home/maybe-like")}),define("js/home/home",["zepto","swiper","lazyload","index"],function(e,a,s){function i(){m+=10,w.css({transform:"rotateX("+m+"deg)","-webkit-transform":"rotateX("+m+"deg)","-moz-transform":"rotateX("+m+"deg)"}),m/90%2===1&&(b?(w.addClass("animate"),b=!1):(w.removeClass("animate"),b=!0)),m/90%2===0&&m%360!==0?window.setTimeout(i,3e3):m%360===0?window.setTimeout(i,18e4):d(function(){i()})}var t,n,o,l,r,d,c,p,u,h,f=e("zepto"),g=e("swiper"),v=e("lazyload"),m=0,w=f(".home-header .logo"),b=!0;e("js/home/maybe-like"),v(f("img.lazy")),f(".nav-btn").on("tap",function(e){f(this).hasClass("menu-open")||(f(".mobile-wrap").addClass("menu-open"),f(".overlay").addClass("show"),f(".side-nav").addClass("on"),f("body").css({height:f(window).height(),width:"100%",overflow:"hidden"})),e.stopPropagation()}),f(".mobile-wrap").on("tap",function(){f(this).hasClass("menu-open")&&(f(".mobile-wrap").removeClass("menu-open"),f(".overlay").removeClass("show"),f(".sub-nav").removeClass("show"),f(".side-nav").removeClass("on"),f("body").css({height:"auto",overflow:"auto"}))}),f(".side-nav").on("tap","li",function(){f(this).find(".sub-nav").size()>0&&(f(".sub-nav").removeClass("show"),f(this).find(".sub-nav").addClass("show"))}),f(".sub-nav").each(function(){f(this).find("li").eq(0).on("tap",function(e){f(".sub-nav").removeClass("show"),e.stopPropagation()})}),f(".sub-nav").on("mouseenter","li",function(){0!==f(this).index()&&f(this).addClass("current").siblings().removeClass("current")}),f(".banner-swiper").find("li").size()>1&&(t=new g(".banner-swiper",{lazyLoading:!0,lazyLoadingInPrevNext:!0,loop:!0,autoplay:3e3,autoplayDisableOnInteraction:!1,paginationClickable:!0,slideElement:"li",pagination:".banner-top .pagination-inner"})),o=new g(".brands-swiper",{grabCursor:!0,slidesPerView:"auto",wrapperClass:"brands-list",slideElement:"li"}),n=new g(".recommend-swiper",{grabCursor:!0,slidesPerView:"auto",wrapperClass:"recommend-list",slideElement:"li"}),f(".trend-topic-swiper").find("li").size()>1&&(l=new g(".trend-topic-swiper",{loop:!0,autoplay:3e3,autoplayDisableOnInteraction:!1,paginationClickable:!0,slideElement:"li",pagination:".trend-topic-content .pagination-inner"})),f(".category-swiper").each(function(e,a){u="category-swiper"+e,f(this).addClass(u),f("."+u).find(".swiper-slide").size()>1&&(r=new g("."+u,{loop:!0,autoplay:3e3,autoplayDisableOnInteraction:!1,paginationClickable:!0,slideElement:"li",pagination:"."+u+" .pagination-inner"}))}),f(".header-download").on("tap",".close-btn",function(){f(this).parent().remove()}),d=function(){var e=null,a=["webkit","moz","ms"];for(p=0;p<a.length;p++)c=a[p]+"RequestAnimationFrame",window[c]&&(h=!0,e=c);return h?function(a){window[e](a)}:function(e){window.setTimeout(e,67)}}(),i()}),define("js/home/maybe-like",["zepto","lazyload"],function(e,a,s){var i,t,n,o,l=e("zepto"),r=e("js/plugin/tip"),d=e("lazyload"),c=l(window).height(),p=l("#load-more").height(),u=l("#goods-list"),h=!1,f=0,g=l(".mobile-wrap").hasClass("boys-wrap")?"1,3":"2,3",v=l(".mobile-wrap").hasClass("kids-wrap")?!0:!1,m=l(".mobile-wrap").hasClass("lifestyle-wrap")?!0:!1,w=l("#maybe-like-nav");t=v?"/product/recom/maylikekids":m?"/product/recom/maylikelife":"/product/recom/maylike?gender="+g,n=w.children(".focus"),l("#maybe-like-nav").delegate("li","tap",function(){var e,a=l(this),s=l(".goods-list");a.hasClass("focus")||(o=a.index(),a.addClass("focus"),n.removeClass("focus"),s.not(".hide").addClass("hide"),e=s.eq(o),e.removeClass("hide"),n=a,l(document).trigger("scroll"))}),l(window).scroll(function(){if(l(window).scrollTop()+c>=l(document).height()-p){if(h)return;h=!0,i=u.children(".good-info").length,l.ajax({type:"GET",url:t,data:{page:f+1},success:function(e){return" "===e?void(h=!0):(u.append(e),d(l(".good-info").find("img.lazy")),h=!1,void f++)},error:function(){r.show("网络断开连接了~"),h=!1}})}})}),define("js/product/index",["zepto","swiper","lazyload","index"],function(e,a,s){e("js/product/newsale/newarrival"),e("js/product/newsale/discount"),e("js/product/list"),e("js/product/detail/detail")}),define("js/product/newsale/newarrival",["zepto","swiper","lazyload","index"],function(e,a,s){function i(e){var a,s,i,t,r,c,p={};if(e){for(s in y)y.hasOwnProperty(s)&&(y[s].reload=!0);switch(C.children(".active").removeClass("active"),n.addClass("active"),e.type){case"gender":a={gender:e.id};break;case"brand":a={brand:e.id};break;case"msort":a={msort:e.id};break;case"color":a={color:e.id};break;case"size":a={size:e.id};break;case"price":a={price:e.id};break;case"discount":a={discount:e.id};break;case"limit":a={limit:e.id};break;case"channel":a={channel:e.id};break;case"p_d":a={p_d:e.id}}l.extend(v,a)}if(!o){if(n.hasClass("today")?(t="today",r=1):n.hasClass("week")?(t="week",r=2):n.hasClass("sale")&&(t="sale",r=3),i=y[t],c=i.page+1,i.reload)c=1;else if(i.end)return;l.extend(p,v,{dayLimit:r,page:c}),o=!0,l.ajax({type:"GET",url:"/product/newsale/selectNewSale",data:p,success:function(e){var a,s='<p class="no-result">未找到相关搜索结果</p>';switch(t){case"today":a=u;break;case"week":a=h;break;case"sale":a=f}" "===e?(i.end=!0,i.reload&&a.html(s)):(i.reload?a.html(e):a.append(e),d(a.find(".lazy"))),i.reload=!1,i.page=c,o=!1}})}}var t,n,o,l=e("zepto"),r=e("swiper"),d=e("lazyload"),c=e("js/plugin/filter"),p=l("#goods-container"),u=l(p.children().get(0)),h=l(p.children().get(1)),f=l(p.children().get(2)),g=l(window).height(),v={gender:l("#gender").val(),brand:l("#brand").val(),msort:l("#msort").val(),color:l("#color").val(),size:l("#size").val(),price:l("#price").val(),discount:l("#discount").val(),limit:l("#limit").val(),channel:l("#channel").val(),p_d:l("#p_d").val()},m=new Date,w=m.getMonth()+1,b=m.getDate(),C=l("#list-nav"),y={today:{reload:!0,page:0,end:!1},week:{reload:!0,page:0,end:!1},sale:{reload:!0,page:0,end:!1}};h.addClass("hide"),f.addClass("hide"),l("#today a").text(w+"月"+b+"号"),l(".swiper-container .swiper-slide").length>1&&(t=new r(".swiper-container",{lazyLoading:!0,loop:!0,autoplay:3e3,autoplayDisableOnInteraction:!1,paginationClickable:!0,pagination:".swiper-pagination"})),d(l(".lazy")),c.registerCbFn(i),C.delegate("li","tap",function(){var e,a,s,t=l(this);if(t.hasClass("filter"))t.hasClass("active")?(c.hideFilter(),n.addClass("active"),t.removeClass("active")):(n=t.siblings(".active"),n.removeClass("active"),t.addClass("active"),c.showFilter());else{if(t.hasClass("today")?a="today":t.hasClass("week")?a="week":t.hasClass("sale")&&(a="sale"),e=y[a],!t.hasClass("active")){if(s=t.siblings(".active"),n=t,s.hasClass("filter"))c.hideFilter();else switch(p.children(".container:not(.hide)").addClass("hide"),a){case"today":u.removeClass("hide");break;case"week":h.removeClass("hide");break;case"sale":f.removeClass("hide")}s.removeClass("active"),t.addClass("active")}e.reload&&i()}}),l(window).scroll(function(){l(window).scrollTop()+g>l(document).height()-.25*p.height()&&void 0!==n&&i()})}),define("js/plugin/filter",["zepto"],function(e,a,s){function i(){r.addClass("hide")}function t(){r.removeClass("hide")}function n(e){o=e}var o,l=e("zepto"),r=l(".filter-mask, .filter-body"),d=r.find(".classify"),c=r.find(".sub-classify");d.children(":first-child").addClass("active"),d.delegate(".classify-item","tap",function(){var e=l(this);e.hasClass("active")||(e.siblings(".active").removeClass("active"),e.addClass("active"))}),r.filter(".filter-mask").tap(function(){i()}),c.delegate("li","tap",function(e){var a,s,t=l(this),n=t.data("id"),r=t.closest(".sub-classify"),d=r.siblings(".shower");e.stopPropagation(),t.hasClass("chosed")||(r.children(".chosed").removeClass("chosed"),t.addClass("chosed"),a=l.trim(t.html()),s=l.trim(d.html()),d.html(s.substring(0,s.indexOf("</span>")+7)+a.substring(0,a.indexOf("<i"))),0===t.index()?d.addClass("default"):d.removeClass("default"),o&&o({type:r.data("type"),id:n}),i())}),a.showFilter=t,a.hideFilter=i,a.registerCbFn=n}),define("js/product/newsale/discount",["zepto","swiper","lazyload","index"],function(e,a,s){function i(e){var a,s,i,t,l,d={};if(e){for(s in m)m.hasOwnProperty(s)&&(m[s].reload=!0);switch(v.children(".active").removeClass("active"),w.addClass("active"),e.type){case"gender":a={gender:e.id};break;case"brand":a={brand:e.id};break;case"msort":a={msort:e.id};break;case"color":a={color:e.id};break;case"size":a={size:e.id};break;case"price":a={price:e.id};break;case"discount":a={discount:e.id}}o.extend(g,a)}if(!n){if(w.hasClass("new")?t="newest":w.hasClass("price")?t="price":w.hasClass("discount")&&(t="discount"),i=m[t],l=i.page+1,i.reload)l=1;else if(i.end)return;o.extend(d,g,{type:t,order:i.order,page:l}),n=!0,o.ajax({type:"GET",url:"/product/newsale/selectNewSale",data:d,success:function(e){var a,s='<p class="no-result">未找到相关搜索结果</p>';switch(t){case"newest":a=p;break;case"price":a=u;break;case"discount":a=h}" "===e?(i.end=!0,i.reload&&a.html(s)):(i.reload?a.html(e):a.append(e),r(a.find(".lazy"))),i.reload=!1,i.page=l,n=!1}})}}var t,n,o=e("zepto"),l=e("swiper"),r=e("lazyload"),d=e("js/plugin/filter"),c=o("#goods-container"),p=o(c.children().get(0)),u=o(c.children().get(1)),h=o(c.children().get(2)),f=o(window).height(),g={gender:o("#gender").val(),brand:o("#brand").val(),msort:o("#msort").val(),color:o("#color").val(),size:o("#size").val(),price:o("#price").val(),discount:o("#discount").val()},v=o("#list-nav"),m={newest:{order:1,reload:!0,page:0,end:!1},price:{order:0,reload:!0,page:0,end:!1},discount:{order:0,reload:!0,page:0,end:!1}},w=v.find(".active");o(".swiper-container .swiper-slide").length>1&&(t=new l(".swiper-container",{lazyLoading:!0,loop:!0,autoplay:3e3,autoplayDisableOnInteraction:!1,paginationClickable:!0,pagination:".swiper-pagination"})),r(o(".lazy")),d.registerCbFn(i),v.delegate("li","tap",function(){var e,a,s,t=o(this);if(t.hasClass("filter"))t.hasClass("active")?(d.hideFilter(),w.addClass("active"),t.removeClass("active")):(w=t.siblings(".active"),w.removeClass("active"),t.addClass("active"),d.showFilter());else{if(t.hasClass("new")?a="newest":t.hasClass("price")?a="price":t.hasClass("discount")&&(a="discount"),e=m[a],t.hasClass("active")){if(t.hasClass("new"))return;(t.hasClass("price")||t.hasClass("discount"))&&(t.find(".icon > .iconfont").toggleClass("cur"),w=t,e.reload=!0,e.order=0===e.order?1:0)}else{if(s=t.siblings(".active"),w=t,s.hasClass("filter"))d.hideFilter();else switch(c.children(".container:not(.hide)").addClass("hide"),a){case"newest":p.removeClass("hide");break;case"price":u.removeClass("hide");break;case"discount":h.removeClass("hide")}s.removeClass("active"),t.addClass("active")}e.reload&&i()}}),o(window).scroll(function(){o(window).scrollTop()+f>o(document).height()-.25*c.height()&&void 0!==w&&i()})}),define("js/product/list",["zepto","lazyload"],function(e,a,s){function i(e){var a,s,i,l,r,d={};if(e){for(s in w)w.hasOwnProperty(s)&&(w[s].reload=!0);switch(m.children(".active").removeClass("active"),b.addClass("active"),e.type){case"gender":a={gender:e.id};break;case"brand":a={brand:e.id};break;case"msort":a={msort:e.id};break;case"color":a={color:e.id};break;case"size":a={size:e.id};break;case"price":a={price:e.id};break;case"discount":a={discount:e.id}}n.extend(v,a)}if(!t){if(b.hasClass("new")?l="newest":b.hasClass("price")?l="price":b.hasClass("discount")&&(l="discount"),i=w[l],r=i.page+1,i.reload)r=1;else if(i.end)return;n.extend(d,v,{type:l,order:i.order,page:r}),t=!0,n.ajax({type:"GET",url:"/index/search/search",data:d,success:function(e){var a,s='<p class="no-result">未找到相关搜索结果</p>';switch(l){case"newest":a=u;break;case"price":a=h;break;case"discount":a=f}" "===e?(i.end=!0,i.reload&&a.html(s)):(i.reload?a.html(e):a.append(e),o(a.find(".lazy"))),i.reload=!1,i.page=r,t=!1}})}}var t,n=e("zepto"),o=e("lazyload"),l=n("#brand-header"),r=n("#intro-box"),d=e("js/plugin/filter"),c=e("js/plugin/tip"),p=n("#goods-container"),u=p.children(".new-goods"),h=p.children(".price-goods"),f=p.children(".discount-goods"),g=n(window).height(),v={gender:n("#gender").val(),brand:n("#brand").val(),msort:n("#msort").val(),color:n("#color").val(),size:n("#size").val(),price:n("#price").val(),discount:n("#discount").val()},m=n("#list-nav"),w={newest:{order:1,reload:!0,page:0,end:!1},price:{order:0,reload:!0,page:0,end:!1},discount:{order:0,reload:!0,page:0,end:!1}},b=m.find(".active");o(n(".lazy")),d.registerCbFn(i),m.delegate("li","tap",function(){var e,a,s,t=n(this);if(t.hasClass("filter"))t.hasClass("active")?(d.hideFilter(),b.addClass("active"),t.removeClass("active")):(b=t.siblings(".active"),b.removeClass("active"),t.addClass("active"),d.showFilter());else{if(t.hasClass("new")?a="newest":t.hasClass("price")?a="price":t.hasClass("discount")&&(a="discount"),e=w[a],t.hasClass("active")){if(t.hasClass("new"))return;(t.hasClass("price")||t.hasClass("discount"))&&(t.find(".icon > .iconfont").toggleClass("cur"),b=t,e.reload=!0,e.order=0===e.order?1:0)}else{if(s=t.siblings(".active"),b=t,s.hasClass("filter"))d.hideFilter();else switch(p.children(".container:not(.hide)").addClass("hide"),a){case"newest":u.removeClass("hide");break;case"price":h.removeClass("hide");break;case"discount":f.removeClass("hide")}s.removeClass("active"),t.addClass("active")}e.reload&&i()}}),n(window).scroll(function(){n(window).scrollTop()+g>n(document).height()-.25*p.height()&&i()}),l.children(".btn-intro").bind("tap",function(){r.removeClass("hide")}),n(".close-intro, .brand-intro-box").tap(function(){r.addClass("hide")}),n("#brand-intro").tap(function(e){e.stopPropagation()}),l.children(".btn-col").bind("tap",function(){var e,a=n(this),s=l.data("id");e=a.hasClass("coled")?"cancel":"ok",n.ajax({type:"POST",url:"/product/opt/favoriteBrand",data:{id:s,opt:e},success:function(e){200===e.code?a.toggleClass("coled"):400===e.code&&c.show("未登录")},error:function(){c.show("网络断开连接了~")}})})}),define("js/product/detail/detail",["zepto","swiper","lazyload","index"],function(e,a,s){var i,t=e("zepto"),n=e("swiper"),o=e("lazyload");o(t("img.lazy")),i=new n(".banner-swiper",{loop:!0,pagination:".banner-top .pagination-inner",slideElement:"div",nextButton:".swiper-button-next",prevButton:".swiper-button-prev"})}),define("js/index/index",["zepto"],function(e,a,s){e("js/index/search"),e("js/index/channel"),e("js/index/footer")}),define("js/index/search",["zepto"],function(e,a,s){ | ||
2 | +var i=e("zepto"),t=i("#search-input input"),n=i("#search-input .clear-input"),o=i(".history");i("#clear-history").bind("tap",function(){i.ajax({type:"POST",url:"/search/clearHistory",success:function(e){200===e.code&&o.html("")}})}),t.bind("input",function(){""===t.val()?n.addClass("hide"):n.removeClass("hide")}),n.bind("tap",function(){t.val("").trigger("input")})}),define("js/index/channel",[],function(e,a,s){}),define("js/index/footer",["zepto"],function(e,a,s){function i(){var e="http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445",a=new Date;setTimeout(function(){new Date-a<2e3&&(window.location=e)},500)}var t=e("zepto"),n=t(".search-box"),o=t(".index-search"),l=t(".index-logo");t("#float-layer-close").bind("tap",function(){t("#float-layer-app").hide(),window.setCookie("_float-layer-app","id490655927",{domain:".yohobuy.com"}),window.setCookie("_float-layer-app-close",1,{domain:".yohobuy.com",expires:1})}),t("#float-layer-btn").tap(function(){i("bottom")}),window.cookie("_float-layer-app")?t("#float-layer-app").hide():t("#float-layer-app").show(),n.find("input").on("focus",function(){l.css({width:0,display:"none"}),n.css({width:"12.8rem"}),o.css({width:"15.5rem"}),t(".clear-text, .no-search").show()}).on("blur",function(){l.css({width:"5.4rem",display:"block"}),n.css({width:"8.8rem"}),o.css({width:"9.6rem"}),t(".clear-text, .no-search").hide()}),n.find(".clear-text").tap(function(){n.find("input").val("").trigger("focus")}),n.find(".search-icon").tap(function(){o.submit()})}); |
static/dist/myohobuy/0.0.2/lib.js
0 → 100644
This diff could not be displayed because it is too large.
-
Please register or login to post a comment