Authored by ccbikai

Merge branch 'release/4.6' of git.yoho.cn:fe/yohobuywap-node into release/4.6

@@ -21,7 +21,7 @@ exports.index = (req, res) => { @@ -21,7 +21,7 @@ exports.index = (req, res) => {
21 }); 21 });
22 22
23 let categoryId = req.query.category_id; 23 let categoryId = req.query.category_id;
24 - let yhChannel = req.query.yh_channel || 1; 24 + let yhChannel = req.query.yh_channel || 0;
25 let contentcode = req.query.content_code; 25 let contentcode = req.query.content_code;
26 26
27 outletModel.getContent(categoryId, yhChannel, contentcode).then(result => { 27 outletModel.getContent(categoryId, yhChannel, contentcode).then(result => {
@@ -70,7 +70,7 @@ const contentCode = { @@ -70,7 +70,7 @@ const contentCode = {
70 }; 70 };
71 71
72 /** 72 /**
73 - * 折扣专场列表数据处理 73 + * 折扣专场列表页及详情页公共方法
74 * @param {[array]} list 74 * @param {[array]} list
75 * @return {[array]} 75 * @return {[array]}
76 */ 76 */
@@ -81,6 +81,7 @@ const _processDiscount = (list, channel) => { @@ -81,6 +81,7 @@ const _processDiscount = (list, channel) => {
81 list = list || []; 81 list = list || [];
82 list = camelCase(list); 82 list = camelCase(list);
83 83
  84 + // list为1条数据是表示详情页,flag 设为false,不需要拼接跳转链接
84 if (list.length === 1) { 85 if (list.length === 1) {
85 flag = false; 86 flag = false;
86 } 87 }
@@ -88,7 +89,7 @@ const _processDiscount = (list, channel) => { @@ -88,7 +89,7 @@ const _processDiscount = (list, channel) => {
88 _.forEach(list, (data) => { 89 _.forEach(list, (data) => {
89 if (flag === true) { 90 if (flag === true) {
90 data.specialUrl = `/product/sale/discount/detail?id=${data.id}&channel=${channel}`; 91 data.specialUrl = `/product/sale/discount/detail?id=${data.id}&channel=${channel}`;
91 - _.merge(data, processTime(data.leftTime)); 92 + Object.assign(data, processTime(data.leftTime));
92 } 93 }
93 94
94 formatData.push(data); 95 formatData.push(data);
@@ -356,11 +357,11 @@ const getDiscountDetailData = (id, yhChannel) => { @@ -356,11 +357,11 @@ const getDiscountDetailData = (id, yhChannel) => {
356 res = _processDiscount(result.data); 357 res = _processDiscount(result.data);
357 358
358 return { 359 return {
359 - title: res[0].title,  
360 - productPool: res[0].productPool, 360 + title: res[0] && res[0].title,
  361 + productPool: res[0] && res[0].productPool,
361 activity: { 362 activity: {
362 - coverUrl: res[0].coverUrl,  
363 - leftTime: res[0].leftTime 363 + coverUrl: res[0] && res[0].coverUrl,
  364 + leftTime: res[0] && res[0].leftTime
364 } 365 }
365 }; 366 };
366 } else { 367 } else {
@@ -26,6 +26,12 @@ @@ -26,6 +26,12 @@
26 {{# isSoonSoldOut}} 26 {{# isSoonSoldOut}}
27 <p class="few-tag">即将售罄</p> 27 <p class="few-tag">即将售罄</p>
28 {{/ isSoonSoldOut}} 28 {{/ isSoonSoldOut}}
  29 +
  30 + {{#if noStorage}}
  31 + <div class="no-storage">
  32 + <div class="no-storage-img"></div>
  33 + </div>
  34 + {{/if}}
29 </div> 35 </div>
30 <div class="good-detail-text"> 36 <div class="good-detail-text">
31 <div class="name"> 37 <div class="name">
@@ -14,14 +14,10 @@ var $ = require('yoho-jquery'), @@ -14,14 +14,10 @@ var $ = require('yoho-jquery'),
14 14
15 var $window = $(window), 15 var $window = $(window),
16 $starArticle = $('.star-article'), 16 $starArticle = $('.star-article'),
17 -  
18 - // $headTab = $('.head-tab'),  
19 - stopLoading = false,  
20 - avatarSwiper,  
21 - avatarSwiperClone,  
22 - getIndexHtml; 17 + stopLoading = false;
23 18
24 /* 19 /*
  20 + $headTab = $('.head-tab'),
25 $swiperView = $('.swiper-view'), 21 $swiperView = $('.swiper-view'),
26 $viewImg = $('.view-img'), 22 $viewImg = $('.view-img'),
27 $body = $('body'), 23 $body = $('body'),
@@ -31,7 +27,7 @@ var $window = $(window), @@ -31,7 +27,7 @@ var $window = $(window),
31 var mySwiper; 27 var mySwiper;
32 */ 28 */
33 29
34 -var avatarKey, bannerLen, res; 30 +var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml, $avatarClone, $avatar;
35 31
36 require('../common'); 32 require('../common');
37 33
@@ -124,7 +120,7 @@ function setIndexAction() { @@ -124,7 +120,7 @@ function setIndexAction() {
124 120
125 starIScroll.iScroll.on('scroll', function() { 121 starIScroll.iScroll.on('scroll', function() {
126 if ($avatarWrap.offset().top <= 0) { 122 if ($avatarWrap.offset().top <= 0) {
127 - $('.avatar-clone').show(); 123 + $avatarClone.show();
128 124
129 if (!avatarSwiperClone) { 125 if (!avatarSwiperClone) {
130 avatarSwiperClone = new Swiper('.avatar-0', { 126 avatarSwiperClone = new Swiper('.avatar-0', {
@@ -151,7 +147,7 @@ function setIndexAction() { @@ -151,7 +147,7 @@ function setIndexAction() {
151 } 147 }
152 148
153 if ($avatarWrap.offset().top > $('.avatar-1')[0].scrollHeight) { 149 if ($avatarWrap.offset().top > $('.avatar-1')[0].scrollHeight) {
154 - $('.avatar-clone').hide(); 150 + $avatarClone.hide();
155 } 151 }
156 }); 152 });
157 153
@@ -164,63 +160,6 @@ function setIndexAction() { @@ -164,63 +160,6 @@ function setIndexAction() {
164 $loadingTip.slideUp(); 160 $loadingTip.slideUp();
165 }); 161 });
166 162
167 - // 明星动态文章图片相关操作  
168 - /*  
169 - function articleImgAction(dom, key) {  
170 - var $articeImgs = dom.find('.artice-imgs'),  
171 - $li = $articeImgs.find('li'),  
172 - imgLen = $articeImgs.find('img').length,  
173 - addFlagDom = $li.eq(2);  
174 -  
175 - var i;  
176 -  
177 - imgs = [];  
178 -  
179 - $li.each(function() {  
180 - imgs.push($(this).find('img').attr('src'));  
181 - });  
182 -  
183 - allImgs[key] = imgs;  
184 -  
185 - $li.on('click', function() {  
186 - for (i = 0; i < imgLen; i++) {  
187 - $swiperView.find('ul').append('<li class="swiper-slide">' +  
188 - '<img class="swiper-lazy" data-src="' + allImgs[key][i] + '">' +  
189 - '<div class="swiper-lazy-preloader"></div></li>');  
190 - }  
191 - setTimeout(function() {  
192 - mySwiper = new Swiper('.swiper-view', {  
193 - lazyLoading: true,  
194 - lazyLoadingInPrevNext: true,  
195 - slideElement: 'li'  
196 - });  
197 -  
198 - $('.swiper-view li').on('click', function(e) {  
199 - if (e.target.nodeName === 'IMG') {  
200 - return;  
201 - }  
202 - $viewImg.hide();  
203 - $body.css({  
204 - overflow: 'auto'  
205 - });  
206 - $viewImg.find('li').remove();  
207 - mySwiper.destroy(false);  
208 - });  
209 - }, 100);  
210 -  
211 - $viewImg.show();  
212 -  
213 - $body.css({  
214 - overflow: 'hidden'  
215 - });  
216 - });  
217 -  
218 - if (imgLen > 3 && addFlagDom.find('.img-size').length < 1) {  
219 - addFlagDom.append('<div class="img-size"><i class="pic-icon"></i>' + imgLen + '</div>');  
220 - }  
221 - }  
222 - */  
223 -  
224 $('.avatar').each(function(key, item) { 163 $('.avatar').each(function(key, item) {
225 $(item).addClass('avatar-' + key); 164 $(item).addClass('avatar-' + key);
226 }); 165 });
@@ -307,10 +246,11 @@ getIndexHtml = function() { @@ -307,10 +246,11 @@ getIndexHtml = function() {
307 } 246 }
308 247
309 $starMain.html(data); 248 $starMain.html(data);
310 - bannerLen = $('.avatar .swiper-slide').length; 249 + $avatar = $('.avatar');
  250 + bannerLen = $avatar.find('.swiper-slide').length;
311 251
312 - if ($('.avatar-clone').length) {  
313 - $('.avatar-clone').remove(); 252 + if ($avatarClone) {
  253 + $avatarClone.remove();
314 } 254 }
315 255
316 $('.avatar li').each(function() { 256 $('.avatar li').each(function() {
@@ -319,6 +259,8 @@ getIndexHtml = function() { @@ -319,6 +259,8 @@ getIndexHtml = function() {
319 259
320 $starMain.before($('.avatar-swiper').clone().addClass('avatar-clone').hide()); 260 $starMain.before($('.avatar-swiper').clone().addClass('avatar-clone').hide());
321 261
  262 + $avatarClone = $('.avatar-clone');
  263 +
322 // 限制标题字数 264 // 限制标题字数
323 $('.cont-area').each(function() { 265 $('.cont-area').each(function() {
324 txtLimit($(this), '.title', '.cont-txt'); 266 txtLimit($(this), '.title', '.cont-txt');
@@ -339,3 +281,60 @@ getIndexHtml = function() { @@ -339,3 +281,60 @@ getIndexHtml = function() {
339 }; 281 };
340 282
341 getIndexHtml(); 283 getIndexHtml();
  284 +
  285 +// 明星动态文章图片相关操作
  286 +/*
  287 +function articleImgAction(dom, key) {
  288 + var $articeImgs = dom.find('.artice-imgs'),
  289 + $li = $articeImgs.find('li'),
  290 + imgLen = $articeImgs.find('img').length,
  291 + addFlagDom = $li.eq(2);
  292 +
  293 + var i;
  294 +
  295 + imgs = [];
  296 +
  297 + $li.each(function() {
  298 + imgs.push($(this).find('img').attr('src'));
  299 + });
  300 +
  301 + allImgs[key] = imgs;
  302 +
  303 + $li.on('click', function() {
  304 + for (i = 0; i < imgLen; i++) {
  305 + $swiperView.find('ul').append('<li class="swiper-slide">' +
  306 + '<img class="swiper-lazy" data-src="' + allImgs[key][i] + '">' +
  307 + '<div class="swiper-lazy-preloader"></div></li>');
  308 + }
  309 + setTimeout(function() {
  310 + mySwiper = new Swiper('.swiper-view', {
  311 + lazyLoading: true,
  312 + lazyLoadingInPrevNext: true,
  313 + slideElement: 'li'
  314 + });
  315 +
  316 + $('.swiper-view li').on('click', function(e) {
  317 + if (e.target.nodeName === 'IMG') {
  318 + return;
  319 + }
  320 + $viewImg.hide();
  321 + $body.css({
  322 + overflow: 'auto'
  323 + });
  324 + $viewImg.find('li').remove();
  325 + mySwiper.destroy(false);
  326 + });
  327 + }, 100);
  328 +
  329 + $viewImg.show();
  330 +
  331 + $body.css({
  332 + overflow: 'hidden'
  333 + });
  334 + });
  335 +
  336 + if (imgLen > 3 && addFlagDom.find('.img-size').length < 1) {
  337 + addFlagDom.append('<div class="img-size"><i class="pic-icon"></i>' + imgLen + '</div>');
  338 + }
  339 +}
  340 +*/
@@ -77,6 +77,7 @@ if ($('.outlet-category-nav').length > 0) { @@ -77,6 +77,7 @@ if ($('.outlet-category-nav').length > 0) {
77 }).goto(0); 77 }).goto(0);
78 } 78 }
79 79
  80 +//更多活动按钮
80 if ($('.back-ground-white').length > 10) { 81 if ($('.back-ground-white').length > 10) {
81 $('.more-activity').show(); 82 $('.more-activity').show();
82 $('.back-ground-white').each(function(index, e) { 83 $('.back-ground-white').each(function(index, e) {
@@ -94,6 +94,28 @@ @@ -94,6 +94,28 @@
94 font-size: 18px; 94 font-size: 18px;
95 line-height: 28px; 95 line-height: 28px;
96 } 96 }
  97 +
  98 + .no-storage {
  99 + width: 100%;
  100 + height: 100%;
  101 + overflow: hidden;
  102 + background-color: #000;
  103 + opacity: 0.4;
  104 + z-index: 10;
  105 + position: absolute;
  106 + top: 0;
  107 +
  108 + .no-storage-img {
  109 + display: block;
  110 + width: 90px;
  111 + height: 90px;
  112 + margin-left: 93px;
  113 + margin-top: 139px;
  114 + background-image: resolve("product/bag_moren.png");
  115 + background-repeat: no-repeat;
  116 + background-size: contain;
  117 + }
  118 + }
97 } 119 }
98 120
99 .good-detail-text { 121 .good-detail-text {
@@ -43,6 +43,11 @@ exports.processProductList = (list, options) => { @@ -43,6 +43,11 @@ exports.processProductList = (list, options) => {
43 return; 43 return;
44 } 44 }
45 45
  46 + //如果库存为0,显示已抢完
  47 + if (product.storageNum === 0){
  48 + product.noStorage = true;
  49 + }
  50 +
46 // 市场价和售价一样,则不显示市场价 51 // 市场价和售价一样,则不显示市场价
47 if (product.marketPrice === product.salesPrice) { 52 if (product.marketPrice === product.salesPrice) {
48 product.marketPrice = false; 53 product.marketPrice = false;
@@ -103,7 +108,7 @@ exports.processProductList = (list, options) => { @@ -103,7 +108,7 @@ exports.processProductList = (list, options) => {
103 108
104 pruductList.push(product); 109 pruductList.push(product);
105 }); 110 });
106 - 111 + console.log(pruductList);
107 return pruductList; 112 return pruductList;
108 }; 113 };
109 114