Authored by 陈轩

fix YH-5118

@@ -104,28 +104,12 @@ function fetchProductList(activityInfo, uid) { @@ -104,28 +104,12 @@ function fetchProductList(activityInfo, uid) {
104 }); 104 });
105 } 105 }
106 106
107 -let _helpers = {  
108 - statusClass: (nav) => {  
109 - if (nav.over) {  
110 - return 'over';  
111 - } else if (nav.now) {  
112 - return 'now';  
113 - } else if (nav.wait) {  
114 - return 'wait';  
115 - } else {  
116 - return '';  
117 - }  
118 - },  
119 - readaleTime: (unixStamp) => {  
120 - return moment.unix(unixStamp).format('MM月DD日 HH:mm');  
121 - }  
122 -};  
123 -  
124 107
125 /** 108 /**
126 * [秒杀列表页面] 109 * [秒杀列表页面]
127 */ 110 */
128 const index = (req, res, next) => { 111 const index = (req, res, next) => {
  112 + let focusTime = Number.parseInt(req.query.t, 10) || 0;
129 let headerData = headerModel.setNav({ 113 let headerData = headerModel.setNav({
130 navTitle: '秒杀活动', 114 navTitle: '秒杀活动',
131 navBtn: true, 115 navBtn: true,
@@ -145,6 +129,9 @@ const index = (req, res, next) => { @@ -145,6 +129,9 @@ const index = (req, res, next) => {
145 129
146 return seckillModel.queryActivity().then((resultActivity) => { 130 return seckillModel.queryActivity().then((resultActivity) => {
147 // console.log(resultActivity) 131 // console.log(resultActivity)
  132 + let focusIndex = false;
  133 + let nowTime = Date.parse(new Date());
  134 +
148 if (resultActivity.code !== 200) { 135 if (resultActivity.code !== 200) {
149 return next(); 136 return next();
150 } 137 }
@@ -162,7 +149,17 @@ const index = (req, res, next) => { @@ -162,7 +149,17 @@ const index = (req, res, next) => {
162 } 149 }
163 150
164 result.activitys = resultActivity.data.secKillProductVoList.sort((a, b) => a.startTime - b.startTime); // orderBy startTime ASC 151 result.activitys = resultActivity.data.secKillProductVoList.sort((a, b) => a.startTime - b.startTime); // orderBy startTime ASC
165 - let nowTime = Date.parse(new Date()); 152 +
  153 + if (focusTime) {
  154 + focusTime = moment(focusTime, 'YYYYMMDDHHmmss').unix();
  155 + focusIndex = result.activitys.findIndex(activity=> activity.startTime === focusTime);
  156 + console.log(focusIndex)
  157 + if (focusIndex !== -1) {
  158 + result.activitys[focusIndex].focus = true;
  159 + focusIndex = true;
  160 + }
  161 + }
  162 +
166 163
167 result.activitys.forEach((activity, i) => { 164 result.activitys.forEach((activity, i) => {
168 let date, 165 let date,
@@ -181,7 +178,7 @@ const index = (req, res, next) => { @@ -181,7 +178,7 @@ const index = (req, res, next) => {
181 178
182 if (nowTime < nextTime) { // 下一个时间段与当前时间来区别是否正在抢购 179 if (nowTime < nextTime) { // 下一个时间段与当前时间来区别是否正在抢购
183 activity.now = true; 180 activity.now = true;
184 - activity.focus = true; 181 + focusIndex || (activity.focus = true);
185 } else { 182 } else {
186 activity.over = true; 183 activity.over = true;
187 } 184 }
@@ -28,8 +28,6 @@ const queryProductList = (activityId) => { @@ -28,8 +28,6 @@ const queryProductList = (activityId) => {
28 return api.get('', { 28 return api.get('', {
29 method: 'app.seckill.queryProductList', 29 method: 'app.seckill.queryProductList',
30 activityId: activityId 30 activityId: activityId
31 - }, {  
32 - cache: true  
33 }); 31 });
34 }; 32 };
35 33
@@ -380,7 +380,7 @@ seckillObj = { @@ -380,7 +380,7 @@ seckillObj = {
380 var $xhr; 380 var $xhr;
381 381
382 loading.show(); 382 loading.show();
383 - $xhr = $.get('/product/seckill') 383 + $xhr = $.get(location.href)
384 .done(function(result) { 384 .done(function(result) {
385 self.$container.html( 385 self.$container.html(
386 self.pageTemplate($.extend(result, { 386 self.pageTemplate($.extend(result, {