Authored by 陈轩

秒杀列表 使用前端渲染

@@ -152,7 +152,7 @@ const index = (req, res, next) => { @@ -152,7 +152,7 @@ const index = (req, res, next) => {
152 resultActivity.data.secKillProductVoList && 152 resultActivity.data.secKillProductVoList &&
153 resultActivity.data.secKillProductVoList.length 153 resultActivity.data.secKillProductVoList.length
154 )) { 154 )) {
155 - return res.render('seckill', { 155 + return res.json({
156 title: '秒杀活动', 156 title: '秒杀活动',
157 pageHeader: headerData, 157 pageHeader: headerData,
158 error: '来晚啦~秒杀已结束' 158 error: '来晚啦~秒杀已结束'
@@ -247,8 +247,6 @@ const getProductList = (req, res, next) => { @@ -247,8 +247,6 @@ const getProductList = (req, res, next) => {
247 startTime 247 startTime
248 }; 248 };
249 249
250 - console.log(activityInfo)  
251 -  
252 return fetchProductList(activityInfo, uid).then(resultProducts => { 250 return fetchProductList(activityInfo, uid).then(resultProducts => {
253 res.json({products: resultProducts}); 251 res.json({products: resultProducts});
254 }).catch(error => { 252 }).catch(error => {
1 <div class="seckill-list yoho-page"> 1 <div class="seckill-list yoho-page">
2 - <div style="height: 100vh"></div> 2 + <div id="seckill-list-loading" style="height: 100vh"></div>
3 </div> 3 </div>
@@ -234,6 +234,7 @@ seckillObj = { @@ -234,6 +234,7 @@ seckillObj = {
234 startTime: startTime 234 startTime: startTime
235 }, 235 },
236 success: function(data) { 236 success: function(data) {
  237 + data = $.extend(data, {isApp: yoho.isApp});
237 $('.product-list').html(self.listTemplate(data)); 238 $('.product-list').html(self.listTemplate(data));
238 lazyload('img.lazy'); 239 lazyload('img.lazy');
239 window.rePosFooter(); 240 window.rePosFooter();
@@ -376,21 +377,27 @@ seckillObj = { @@ -376,21 +377,27 @@ seckillObj = {
376 377
377 pageLoad: function(callback) { 378 pageLoad: function(callback) {
378 var self = this; 379 var self = this;
  380 + var $xhr;
379 381
380 loading.show(); 382 loading.show();
381 - return $.get('/product/seckill') 383 + $xhr = $.get('/product/seckill')
382 .done(function(result) { 384 .done(function(result) {
383 self.$container.html( 385 self.$container.html(
384 self.pageTemplate($.extend(result, { 386 self.pageTemplate($.extend(result, {
385 isApp: yoho.isApp 387 isApp: yoho.isApp
386 })) 388 }))
387 ); 389 );
  390 + lazyload('img.lazy');
388 window.rePosFooter(); 391 window.rePosFooter();
389 callback(); 392 callback();
390 }) 393 })
  394 + .error(function() {
  395 + })
391 .always(function() { 396 .always(function() {
392 loading.hide(); 397 loading.hide();
393 }); 398 });
  399 +
  400 + return $xhr;
394 } 401 }
395 }; 402 };
396 403