商品详情页为你优化换接口 code review by bikai
Showing
6 changed files
with
33 additions
and
107 deletions
@@ -18,8 +18,6 @@ var introUrl = $('#introUrl').val(), | @@ -18,8 +18,6 @@ var introUrl = $('#introUrl').val(), | ||
18 | var sizeSwiper, | 18 | var sizeSwiper, |
19 | refSwiper; | 19 | refSwiper; |
20 | 20 | ||
21 | -require('../recommend-for-you.js'); | ||
22 | - | ||
23 | //判断是否要显示向左滑动提示 | 21 | //判断是否要显示向左滑动提示 |
24 | function hiddenTips($ele) { | 22 | function hiddenTips($ele) { |
25 | if ($ele.length > 0) { | 23 | if ($ele.length > 0) { |
@@ -17,6 +17,7 @@ var goodsDiscountEl = document.getElementById('goodsDiscount'), | @@ -17,6 +17,7 @@ var goodsDiscountEl = document.getElementById('goodsDiscount'), | ||
17 | 17 | ||
18 | require('./desc'); | 18 | require('./desc'); |
19 | require('./comments-consults'); | 19 | require('./comments-consults'); |
20 | +require('../recommend-for-you-product-desc'); | ||
20 | 21 | ||
21 | //add extra marign-bottom for footer to show the yoho copyright | 22 | //add extra marign-bottom for footer to show the yoho copyright |
22 | function showFooter() { | 23 | function showFooter() { |
static/js/product/detail/loadmore.js
deleted
100644 → 0
1 | -/** | ||
2 | - * 商品详情 --滚动页面加载 | ||
3 | - * @author: Lynnic | ||
4 | - * @date: 2015/11/25 | ||
5 | - */ | ||
6 | - | ||
7 | -// var $ = require('jquery'), | ||
8 | -// loading = require('../../plugin/loading'), | ||
9 | -// tip = require('../../plugin/tip'); | ||
10 | - | ||
11 | -// var loadMoreUrl = $('#loadMoreUrl').val(), | ||
12 | -// $commentsDiv = $('#goods-comments'), | ||
13 | -// $consultsDiv = $('#goods-consults'), | ||
14 | -// winH = $(window).height(), | ||
15 | -// searching = false, | ||
16 | -// end = false; | ||
17 | - | ||
18 | -// var jsonObj; | ||
19 | - | ||
20 | -// //插入评论列表底部 | ||
21 | -// function insertCommentsDiv(json) { | ||
22 | -// var html = ''; | ||
23 | -// var i; | ||
24 | - | ||
25 | - | ||
26 | -// for (i = 0; i < json.length; i++) { | ||
27 | -// html += '<div class="comment-item">'; | ||
28 | -// html += '<span class="user-name">' + json[i].userName + '</span>'; | ||
29 | -// html += '<span class="goods-spec">' + json[i].desc + '</span>'; | ||
30 | -// html += '<span class="goods-spec">' + json[i].content + '</span>'; | ||
31 | -// html += '<span class="goods-spec">' + json[i].time + '</span>'; | ||
32 | -// } | ||
33 | -// $commentsDiv.append(html); | ||
34 | -// } | ||
35 | - | ||
36 | -// //插入咨询列表底部 | ||
37 | -// function insertConsultsDiv(json) { | ||
38 | -// var html = ''; | ||
39 | -// var i; | ||
40 | - | ||
41 | - | ||
42 | -// for (i = 0; i < json.length; i++) { | ||
43 | -// html += '<div class="consult-item"> '; | ||
44 | -// html += '<div class="question"> '; | ||
45 | -// html += '<span class="iconfont"></span> '; | ||
46 | -// html += '<p> '; | ||
47 | -// html += json[i].question + '<br> '; | ||
48 | -// html += '<span class="time">' + json[i].time + '</span> '; | ||
49 | -// html += '</p> '; | ||
50 | -// html += '</div> '; | ||
51 | - | ||
52 | -// html += '<div class="answer"> '; | ||
53 | -// html += '<span class="iconfont"></span> '; | ||
54 | -// html += '<p>' + json[i].answer + '</p> '; | ||
55 | -// html += '</div> '; | ||
56 | -// html += '</div> '; | ||
57 | -// } | ||
58 | -// $consultsDiv.append(html); | ||
59 | -// } | ||
60 | - | ||
61 | -// function search() { | ||
62 | -// if (searching || end) { | ||
63 | -// return; | ||
64 | -// } | ||
65 | -// searching = true; | ||
66 | - | ||
67 | -// loading.showLoadingMask(); | ||
68 | - | ||
69 | -// $.ajax({ | ||
70 | -// type: 'GET', | ||
71 | -// url: loadMoreUrl, | ||
72 | -// success: function(data) { | ||
73 | -// if (data.length > 0) { | ||
74 | -// jsonObj = JSON.parse(data); | ||
75 | -// if ($commentsDiv.length > 0) { | ||
76 | -// insertCommentsDiv(jsonObj); | ||
77 | -// } else if ($consultsDiv.length > 0) { | ||
78 | -// insertConsultsDiv(jsonObj); | ||
79 | -// } | ||
80 | -// } | ||
81 | -// searching = false; | ||
82 | -// end = true; | ||
83 | -// loading.hideLoadingMask(); | ||
84 | -// }, | ||
85 | -// error: function() { | ||
86 | -// tip.show('网络断开连接了~'); | ||
87 | -// searching = false; | ||
88 | -// loading.hideLoadingMask(); | ||
89 | -// } | ||
90 | -// }); | ||
91 | -// } | ||
92 | - | ||
93 | - | ||
94 | -// function scrollHandler() { | ||
95 | -// if (!end || $(window).scrollTop() + winH >= $(document).height() - 50) { | ||
96 | -// search(); | ||
97 | -// } | ||
98 | -// } | ||
99 | - | ||
100 | -// //srcoll to load more | ||
101 | -// $(window).scroll(function() { | ||
102 | -// window.requestAnimationFrame(scrollHandler); | ||
103 | -// }); |
@@ -8,5 +8,4 @@ require('./newsale/newarrival'); | @@ -8,5 +8,4 @@ require('./newsale/newarrival'); | ||
8 | require('./newsale/discount'); | 8 | require('./newsale/discount'); |
9 | require('./list'); | 9 | require('./list'); |
10 | require('./detail/detail'); | 10 | require('./detail/detail'); |
11 | -require('./detail/loadmore'); | ||
12 | require('./detail/consultform'); | 11 | require('./detail/consultform'); |
1 | +/** | ||
2 | + * 为您优选 | ||
3 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
4 | + * @date: 2015/11/16 | ||
5 | + */ | ||
6 | + | ||
7 | + | ||
8 | +var Swiper = require('yoho.iswiper'), | ||
9 | + $ = require('jquery'); | ||
10 | + | ||
11 | +var recommendSwiper, | ||
12 | + $recommendForYou = $('.recommend-for-you'), | ||
13 | + productSkn = $('#productSkn').val(); | ||
14 | + | ||
15 | +$.get('/product/detail/preference', {productSkn: productSkn}).then(function(html) { | ||
16 | + $recommendForYou.html(html).show(); | ||
17 | + if ($('#swiper-recommend').length) { | ||
18 | + recommendSwiper = new Swiper('#swiper-recommend', { | ||
19 | + slidesPerView: 'auto', | ||
20 | + grabCursor: true, | ||
21 | + slideElement: 'a', | ||
22 | + lazyLoading: true, | ||
23 | + watchSlidesVisibility: true | ||
24 | + }); | ||
25 | + } | ||
26 | +}).fail(function() { | ||
27 | + $recommendForYou.hide(); | ||
28 | +}); |
@@ -136,6 +136,9 @@ | @@ -136,6 +136,9 @@ | ||
136 | {{#if id}} | 136 | {{#if id}} |
137 | <input id="productId" type="hidden" value="{{id}}"> | 137 | <input id="productId" type="hidden" value="{{id}}"> |
138 | {{/if}} | 138 | {{/if}} |
139 | - | 139 | + {{#if productSkn}} |
140 | + <input id="productSkn" type="hidden" value="{{productSkn}}"> | ||
141 | + {{/if}} | ||
142 | + | ||
140 | </div> | 143 | </div> |
141 | {{> layout/footer}} | 144 | {{> layout/footer}} |
-
Please register or login to post a comment