Authored by yyq

商品详情调整

@@ -55,7 +55,8 @@ exports.intro = (req, res) => { @@ -55,7 +55,8 @@ exports.intro = (req, res) => {
55 productskn: req.params.productskn 55 productskn: req.params.productskn
56 }).then((result) => { 56 }).then((result) => {
57 res.render('detail/intro', { 57 res.render('detail/intro', {
58 - result: result 58 + result: result,
  59 + layout: false
59 }); 60 });
60 }); 61 });
61 }; 62 };
@@ -74,7 +75,7 @@ exports.preference = (req, res) => { @@ -74,7 +75,7 @@ exports.preference = (req, res) => {
74 }).then((result) => { 75 }).then((result) => {
75 res.render('detail/preference', { 76 res.render('detail/preference', {
76 result: result, 77 result: result,
77 - devEnv: true 78 + layout: false
78 }); 79 });
79 }); 80 });
80 }; 81 };
@@ -19,24 +19,23 @@ const api = new API(); @@ -19,24 +19,23 @@ const api = new API();
19 * @return {array} 19 * @return {array}
20 */ 20 */
21 const getShopsInfo = (data) => { 21 const getShopsInfo = (data) => {
22 - let enterStore = {}; 22 + let enterStore = [];
23 23
24 - _.forEach(data, function(value, key) {  
25 - enterStore[key] = { 24 + _.forEach(data, function(value) {
  25 + let shopInfo = {
26 img: value.brand_ico, 26 img: value.brand_ico,
27 storeName: value.brand_name 27 storeName: value.brand_name
28 }; 28 };
29 29
30 - if (value.shop_id !== null && typeof value.shop_id !== 'undefined') {  
31 - let params = {};  
32 -  
33 - params.shop_id = value.shop_id;  
34 - enterStore[key].url =  
35 - helpers.urlFormat('/product/index/brand', params); 30 + if (value.shop_id) {
  31 + shopInfo.url = helpers.urlFormat('/product/index/brand', {
  32 + shop_id: value.shop_id
  33 + });
36 } else { 34 } else {
37 - enterStore[key].url =  
38 - helpers.urlFormat('', null, value.brand_domain); 35 + shopInfo.url = helpers.urlFormat('', null, value.brand_domain);
39 } 36 }
  37 +
  38 + enterStore.push(shopInfo);
40 }); 39 });
41 return enterStore; 40 return enterStore;
42 }; 41 };
@@ -120,9 +119,9 @@ const getLimitCodeUrl = (productCode, skn, ua) => { @@ -120,9 +119,9 @@ const getLimitCodeUrl = (productCode, skn, ua) => {
120 */ 119 */
121 const detailDataPkg = (origin, uid, vipLevel, ua) => { 120 const detailDataPkg = (origin, uid, vipLevel, ua) => {
122 let dest = {}, // 结果输出 121 let dest = {}, // 结果输出
  122 + thumbImageList = [],
123 colorGroup = {}, 123 colorGroup = {},
124 - thumbImageList = {},  
125 - sizeGroup = {}, 124 + sizeGroup = [],
126 totalStorageNum = 0; 125 totalStorageNum = 0;
127 126
128 // 商品名称 127 // 商品名称
@@ -141,92 +140,110 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -141,92 +140,110 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
141 } 140 }
142 141
143 // 商品促销短语 142 // 商品促销短语
144 - if (origin.salesPhrase !== null && typeof origin.salesPhrase !== 'undefined') { 143 + if (origin.salesPhrase) {
145 dest.goodsSubtitle = origin.salesPhrase; 144 dest.goodsSubtitle = origin.salesPhrase;
146 } 145 }
147 146
148 // 商品标签 147 // 商品标签
149 - if (origin.productTagBoList !== null && typeof origin.productTagBoList !== 'undefined') { 148 + if (origin.productTagBoList) {
  149 + let productTags = {};
  150 +
150 _.forEach(origin.productTagBoList, function(value) { 151 _.forEach(origin.productTagBoList, function(value) {
151 switch (value.tagLabel) { 152 switch (value.tagLabel) {
152 case 'is_soon_sold_out': 153 case 'is_soon_sold_out':
153 - dest.tags.is_soon_sold_out = true; 154 + productTags.is_soon_sold_out = true;
154 break; 155 break;
155 case 'is_new': 156 case 'is_new':
156 - dest.tags.is_new = true; 157 + productTags.is_new = true;
157 break; 158 break;
158 case 'is_discount': 159 case 'is_discount':
159 - dest.tags.is_discount = true; 160 + productTags.is_discount = true;
160 break; 161 break;
161 case 'is_limited': 162 case 'is_limited':
162 - dest.tags.is_limited = true; 163 + productTags.is_limited = true;
163 break; 164 break;
164 case 'is_yohood': 165 case 'is_yohood':
165 - dest.tags.is_yohood = true; 166 + productTags.is_yohood = true;
166 break; 167 break;
167 case 'is_advance': 168 case 'is_advance':
168 - dest.tags.is_advance = true; 169 + productTags.is_advance = true;
169 break; 170 break;
170 default: 171 default:
171 break; 172 break;
172 } 173 }
173 }); 174 });
  175 +
  176 + dest.tags = productTags;
174 } 177 }
175 178
176 // 商品价格 179 // 商品价格
177 - dest.goodsPrice = {}; 180 + if (origin.productPriceBo) {
  181 + let originPrice = origin.productPriceBo;
  182 + let goodsPrice = {
  183 + currentPrice: originPrice.formatSalesPrice
  184 + };
178 185
179 - if (origin.productPriceBo !== null && typeof origin.productPriceBo !== 'undefined') {  
180 - dest.goodsPrice.currentPrice = origin.productPriceBo.formatSalesPrice;  
181 - if (origin.productPriceBo.formatMarketPrice !== origin.productPriceBo.formatSalesPrice) {  
182 - dest.goodsPrice.previousPrice = origin.productPriceBo.formatMarketPrice; 186 + if (originPrice.formatMarketPrice !== originPrice.formatSalesPrice) {
  187 + goodsPrice.previousPrice = originPrice.formatMarketPrice;
183 } 188 }
184 189
  190 + dest.goodsPrice = goodsPrice;
  191 +
185 // 商品返回 YOHO 币 192 // 商品返回 YOHO 币
186 - if (origin.productPriceBo.yohoCoinNum !== null && origin.productPriceBo.yohoCoinNum !== 0) {  
187 - dest.commodityReturn = origin.productPriceBo.yohoCoinNum; 193 + if (originPrice.yohoCoinNum) {
  194 + dest.commodityReturn = originPrice.yohoCoinNum;
188 } 195 }
189 } 196 }
190 197
191 // VIP 商品价格 198 // VIP 商品价格
192 - dest.vipLevel = {};  
193 - dest.vipLevel.list = []; 199 + if (origin.productPriceBo.vipPrices) {
  200 + let vipList = [];
194 201
195 - if (origin.productPriceBo.vipPrices !== null && typeof origin.productPriceBo.vipPrices !== 'undefined') {  
196 _.forEach(origin.productPriceBo.vipPrices, function(value) { 202 _.forEach(origin.productPriceBo.vipPrices, function(value) {
197 - dest.vipLevel.list.push({ 203 + vipList.push({
198 level: value.vipLevel, 204 level: value.vipLevel,
199 text: value.vipPrice, 205 text: value.vipPrice,
200 currentLevel: (value.vipLevel === vipLevel) 206 currentLevel: (value.vipLevel === vipLevel)
201 }); 207 });
202 }); 208 });
  209 +
  210 + if (vipList.length) {
  211 + dest.vipLevel = {
  212 + list: vipList
  213 + };
  214 + }
  215 +
203 } 216 }
204 217
205 // 上市期 218 // 上市期
206 - if (origin.expectArrivalTime !== null && typeof origin.expectArrivalTime !== 'undefined') {  
207 - dest.periodOfMarket = origin.expectArrivalTime + '月'; 219 + if (origin.expectArrivalTime) {
  220 + dest.periodOfMarket = `${origin.expectArrivalTime}月`;
208 } 221 }
209 222
210 // 促销信息 223 // 促销信息
211 - dest.goodsDiscount = {};  
212 - dest.goodsDiscount.list = []; 224 + if (origin.promotionBoList) {
  225 + let discountList = [];
213 226
214 - if (origin.promotionBoList !== null && typeof origin.promotionBoList !== 'undefined') {  
215 _.forEach(origin.promotionBoList, function(value) { 227 _.forEach(origin.promotionBoList, function(value) {
216 - let temp = {};  
217 -  
218 - temp.text = '【' + value.promotionType + '】' +  
219 - value.promotionTitle;  
220 - dest.goodsDiscount.list.push(temp); 228 + discountList.push({
  229 + text: `【${value.promotionType}${value.promotionTitle}`
  230 + });
221 }); 231 });
  232 +
  233 + if (discountList.length) {
  234 + dest.goodsDiscount = {
  235 + list: discountList
  236 + };
  237 + }
222 } 238 }
223 239
224 // 商品咨询 240 // 商品咨询
225 - dest.feedbacks = {};  
226 - dest.feedbacks.consults = [];  
227 - dest.feedbacks.consultsNum = 0; 241 + dest.feedbacks = {
  242 + consults: [],
  243 + consultsNum: 0
  244 + };
228 245
229 - if (origin.consultBoWrapper !== null && typeof origin.consultBoWrapper !== 'undefined') { 246 + if (origin.consultBoWrapper) {
230 dest.feedbacks.consultsNum = origin.consultBoWrapper.consultTotal; 247 dest.feedbacks.consultsNum = origin.consultBoWrapper.consultTotal;
231 _.forEach(origin.consultBoWrapper.consultBoList, function(value) { 248 _.forEach(origin.consultBoWrapper.consultBoList, function(value) {
232 dest.feedbacks.consults.push({ 249 dest.feedbacks.consults.push({
@@ -235,62 +252,57 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -235,62 +252,57 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
235 answer: value.answer 252 answer: value.answer
236 }); 253 });
237 }); 254 });
  255 + }
238 256
239 - let params = {};  
240 -  
241 - params.product_id = origin.id;  
242 - params.total = dest.feedbacks.consultsNum;  
243 -  
244 - dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consults', params);  
245 -  
246 - } else { // 暂无咨询 257 + let consultParams = {
  258 + product_id: origin.id
  259 + };
247 260
248 - let params = {}; 261 + if (_.has(dest, 'feedbacks.consultsNum')) {
  262 + consultParams.total = dest.feedbacks.consultsNum;
  263 + }
249 264
250 - params.product_id = origin.id; 265 + dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consultform', consultParams);
251 266
252 - dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consultform', params);  
253 - }  
254 267
255 // 商品评价 268 // 商品评价
256 dest.feedbacks.commentsNum = 0; 269 dest.feedbacks.commentsNum = 0;
257 - if (origin.commentBoWrapper !== null && typeof origin.commentBoWrapper !== 'undefined') { 270 + if (origin.commentBoWrapper) {
258 dest.feedbacks.commentsNum = origin.commentBoWrapper.commentTotal; 271 dest.feedbacks.commentsNum = origin.commentBoWrapper.commentTotal;
259 - dest.feedbacks.comments = []; 272 +
  273 + let commentList = [];
260 274
261 _.forEach(origin.commentBoWrapper.commentBoList, function(value) { 275 _.forEach(origin.commentBoWrapper.commentBoList, function(value) {
262 - dest.feedbacks.comments.push({ 276 + commentList.push({
263 userName: value.nickName, 277 userName: value.nickName,
264 - desc: value.colorName + '/' + value.sizeName, 278 + desc: `${value.colorName}/${value.sizeName}`,
265 content: value.content ? value.content : '', 279 content: value.content ? value.content : '',
266 time: value.createTime 280 time: value.createTime
267 }); 281 });
268 }); 282 });
269 283
270 - let params = {};  
271 -  
272 - params.product_id = origin.id;  
273 - params.total = dest.feedbacks.commentsNum; 284 + dest.feedbacks.comments = commentList;
274 285
275 - dest.feedbacks.commentsUrl = helpers.urlFormat('/product/detail/comments', params); 286 + dest.feedbacks.commentsUrl = helpers.urlFormat('/product/detail/comments', {
  287 + product_id: origin.id,
  288 + total: dest.feedbacks.commentsNum
  289 + });
276 } 290 }
277 291
278 // 品牌信息 292 // 品牌信息
279 - if (origin.brand !== null && typeof origin.brand !== 'undefined') {  
280 -  
281 - // 为你优选的链接  
282 - let params = {}; 293 + if (origin.brand) {
283 294
284 - params.productSkn = origin.erpProductId;  
285 - params.brandId = origin.brand.id;  
286 - dest.preferenceUrl = helpers.urlFormat('/product/detail/preference', params, ''); 295 + dest.preferenceUrl = helpers.urlFormat('/product/detail/preference', {
  296 + productSkn: origin.erpProductId,
  297 + brandId: origin.brand.id
  298 + });
287 } 299 }
288 300
289 dest.productSkn = origin.erpProductId; 301 dest.productSkn = origin.erpProductId;
290 302
291 // 商品信息 303 // 商品信息
292 - if (origin.goodsList !== null && typeof origin.goodsList !== 'undefined') {  
293 - let goodsGroup = {}, 304 + if (origin.goodsList) {
  305 + let goodsGroup = [],
294 sizeName = '', 306 sizeName = '',
295 colorList = {}, 307 colorList = {},
296 sizeList = {}, 308 sizeList = {},
@@ -300,42 +312,44 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -300,42 +312,44 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
300 312
301 _.forEach(origin.goodsList, function(value, key) { 313 _.forEach(origin.goodsList, function(value, key) {
302 if (value.status === 0) { 314 if (value.status === 0) {
303 - return true; 315 + return;
304 } 316 }
305 317
306 colorStorageNum = 0; 318 colorStorageNum = 0;
307 319
308 // 商品分组 320 // 商品分组
309 - if (value.goodsImagesList !== null && typeof value.goodsImagesList !== 'undefined') {  
310 - _.forEach(value.goodsImagesList, function(good, keyForGood) {  
311 - goodsGroup[keyForGood] = {};  
312 - goodsGroup[keyForGood].goodsId = good.goodsId;  
313 - goodsGroup[keyForGood].img = good.imageUrl; 321 + if (value.goodsImagesList) {
  322 + _.forEach(value.goodsImagesList, function(good) {
  323 + goodsGroup.push({
  324 + goodsId: good.goodsId,
  325 + img: good.imageUrl
  326 + });
314 }); 327 });
315 } 328 }
316 329
317 // 商品的尺码列表 330 // 商品的尺码列表
318 colorStorageGroup[value.productSkc] = {}; 331 colorStorageGroup[value.productSkc] = {};
319 - if (value.goodsSizeBoList !== null && typeof value.goodsSizeBoList !== 'undefined') {  
320 -  
321 - _.forEach(value.goodsSizeBoList, function(size, keyForSize) {  
322 - sizeList[value.productSkc] = {};  
323 - sizeList[value.productSkc][keyForSize] = {};  
324 - sizeList[value.productSkc][keyForSize].id = size.id;  
325 - sizeList[value.productSkc][keyForSize].skuId = size.goodsSizeSkuId;  
326 - sizeList[value.productSkc][keyForSize].goodsId = size.goodsId;  
327 - sizeList[value.productSkc][keyForSize].colorId = size.colorId;  
328 - sizeList[value.productSkc][keyForSize].name = size.sizeName;  
329 - sizeList[value.productSkc][keyForSize].sizeNum = size.goodsSizeStorageNum; 332 + if (value.goodsSizeBoList) {
  333 + sizeList[value.productSkc] = [];
  334 + _.forEach(value.goodsSizeBoList, function(size) {
  335 + sizeList[value.productSkc].push({
  336 + id: size.id,
  337 + skuId: size.goodsSizeSkuId,
  338 + goodsId: size.goodsId,
  339 + colorId: size.colorId,
  340 + name: size.sizeName,
  341 + sizeNum: size.goodsSizeStorageNum
  342 + });
330 343
331 sizeName = size.sizeName; 344 sizeName = size.sizeName;
332 345
333 // 所有尺码列表,赋值用于前端展示默认尺码的时候 346 // 所有尺码列表,赋值用于前端展示默认尺码的时候
334 // 判断出没有库存则显示灰色 347 // 判断出没有库存则显示灰色
335 - let build = {}; 348 + let build = {
  349 + id: size.id,
  350 + storage: size.goodsSizeStorageNum
  351 + };
336 352
337 - build.storage = size.goodsSizeStorageNum;  
338 - build.id = size.id;  
339 allSizeList[sizeName] = (allSizeList[sizeName] === null || 353 allSizeList[sizeName] = (allSizeList[sizeName] === null ||
340 typeof allSizeList[sizeName] === 'undefined') ? build : 354 typeof allSizeList[sizeName] === 'undefined') ? build :
341 allSizeList[sizeName]; 355 allSizeList[sizeName];
@@ -345,94 +359,100 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -345,94 +359,100 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
345 }); 359 });
346 360
347 // 颜色分组 361 // 颜色分组
348 - colorList[key] = {};  
349 - colorList[key].id = value.colorId;  
350 - colorList[key].skcId = value.productSkc;  
351 - colorList[key].name = value.colorName;  
352 - colorList[key].goodsName = value.goodsName;  
353 - colorList[key].colorNum = colorStorageNum; 362 + colorList[key] = {
  363 + id: value.colorId,
  364 + skcId: value.productSkc,
  365 + name: value.colorName,
  366 + goodsName: value.goodsName,
  367 + colorNum: colorStorageNum
  368 + };
354 } 369 }
355 370
356 // 缩略图 371 // 缩略图
357 - let params = {};  
358 -  
359 - params.img = value.colorImage;  
360 - thumbImageList[key] = params; 372 + thumbImageList.push({
  373 + img: value.colorImage
  374 + });
361 375
362 // 商品库存总数 376 // 商品库存总数
363 - totalStorageNum += colorStorageNum; 377 + totalStorageNum += _.toNumber(colorStorageNum);
364 }); 378 });
365 379
366 // 遍历所有尺码,构建颜色显示数据 380 // 遍历所有尺码,构建颜色显示数据
367 let i = 1; 381 let i = 1;
368 382
369 - _.forEach(allSizeList, function(value, key) {  
370 - 383 + sizeGroup[0] = {
  384 + size: []
  385 + };
  386 + _.forEach(allSizeList, function(value) {
371 // 默认尺码 387 // 默认尺码
372 - sizeGroup[0] = {}; 388 + sizeGroup[0].size.push({
  389 + name: sizeName,
  390 + sizeNum: _.toNumber(value.storage) > 0 ? true : false,
  391 + id: value.id
  392 + });
373 393
374 - sizeGroup[0].size = {};  
375 - sizeGroup[0].size[key] = {};  
376 - sizeGroup[0].size[key].name = sizeName;  
377 - sizeGroup[0].size[key].sizeNum = (typeof value.storage === 'undefined' ||  
378 - value.storage === null) ? false : true;  
379 - sizeGroup[0].size[key].id = value.id; 394 + colorGroup[i] = {
  395 + color: []
  396 + };
380 397
381 // 各个颜色的尺码, 每行显示一个尺码对应的颜色 398 // 各个颜色的尺码, 每行显示一个尺码对应的颜色
382 - _.forEach(colorList, function(colorArr, keyForColorArr) {  
383 - colorGroup[i] = {};  
384 - colorGroup[i].color = {};  
385 - colorGroup[i].color[keyForColorArr] = {};  
386 - colorGroup[i].color[keyForColorArr].colorNum =  
387 - (colorStorageGroup[colorArr.skcId][sizeName] !== null &&  
388 - typeof colorStorageGroup[colorArr.skcId][sizeName] !== 'undefined') ?  
389 - colorStorageGroup[colorArr.skcId][sizeName] : 0; 399 + _.forEach(colorList, function(colorArr) {
  400 + colorArr.colorNum = 0;
  401 + if (colorStorageGroup[colorArr.skcId] &&
  402 + colorStorageGroup[colorArr.skcId][sizeName]) {
  403 + colorArr.colorNum = colorStorageGroup[colorArr.skcId][sizeName];
  404 + }
  405 + colorGroup[i].color.push(colorArr);
390 }); 406 });
391 colorGroup[i].id = value.id; 407 colorGroup[i].id = value.id;
392 408
393 ++i; 409 ++i;
394 }); 410 });
395 411
396 - // 遍历所有颜色, 构建尺码显示数据 412 + colorGroup[0] = {
  413 + color: []
  414 + };
397 415
  416 + // 遍历所有颜色, 构建尺码显示数据
398 i = 1; 417 i = 1;
399 - _.forEach(colorList, function(value, key) { 418 + _.forEach(colorList, function(value) {
400 // 各个尺码的颜色, 每行显示一个颜色的对应尺码 419 // 各个尺码的颜色, 每行显示一个颜色的对应尺码
401 - sizeGroup[i] = {};  
402 - sizeGroup[i].size = sizeList[value.skcId];  
403 - sizeGroup[i].colorId = value.skcId; 420 + sizeGroup[i] = {
  421 + size: sizeList[value.skcId],
  422 + colorId: value.skcId
  423 + };
404 424
405 // 默认颜色 425 // 默认颜色
406 - colorGroup[0] = {};  
407 - colorGroup[0].color = {};  
408 - colorGroup[0].color[key] = value;  
409 - 426 + colorGroup[0].color.push(value);
410 ++i; 427 ++i;
411 }); 428 });
412 429
413 // 商品图:多个 430 // 商品图:多个
414 - if (goodsGroup[1] !== null && typeof goodsGroup[1] !== 'undefined') {  
415 -  
416 - dest.bannerTop = {};  
417 - dest.bannerTop.list = []; 431 + if (goodsGroup.length > 1) {
  432 + let bannerList = [];
418 433
419 _.forEach(goodsGroup, function(value) { 434 _.forEach(goodsGroup, function(value) {
420 - let params = {};  
421 -  
422 - params.img = value.img;  
423 - dest.bannerTop.list.push(params); 435 + bannerList.push({
  436 + img: value.img
  437 + });
424 }); 438 });
  439 +
  440 + dest.bannerTop = {
  441 + list: bannerList
  442 + };
425 } else if (goodsGroup[0] !== null && typeof goodsGroup[0] !== 'undefined') { 443 } else if (goodsGroup[0] !== null && typeof goodsGroup[0] !== 'undefined') {
426 - dest.bannerTop = {};  
427 - dest.bannerTop.img = goodsGroup[0].img; 444 + dest.bannerTop = {
  445 + img: goodsGroup[0].img
  446 + };
428 } 447 }
429 } 448 }
430 449
431 // 悬浮的购物车信息 450 // 悬浮的购物车信息
432 - dest.cartInfo = {};  
433 - dest.cartInfo.cartUrl = helpers.urlFormat('/cart/index/index', null);  
434 - dest.cartInfo.numInCart = 0;  
435 - dest.cartInfo.goodsInstore = origin.storage; 451 + dest.cartInfo = {
  452 + cartUrl: helpers.urlFormat('/cart/index/index'),
  453 + numInCart: 0,
  454 + goodsInstore: origin.storage
  455 + };
436 456
437 let soldOut = (origin.storage === 0) || (origin.status === 0 || totalStorageNum === 0); 457 let soldOut = (origin.storage === 0) || (origin.status === 0 || totalStorageNum === 0);
438 let notForSale = origin.attribute === 2; 458 let notForSale = origin.attribute === 2;
@@ -441,17 +461,16 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -441,17 +461,16 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
441 if (!soldOut && !notForSale) { 461 if (!soldOut && !notForSale) {
442 _.orderBy(colorGroup); 462 _.orderBy(colorGroup);
443 463
444 - dest.cartInfo = {};  
445 - dest.cartInfo.productId = origin.id;  
446 - dest.cartInfo.thumbs = thumbImageList;  
447 - dest.cartInfo.name = (dest.goodsName !== null && typeof dest.goodsName !== 'undefined') ? dest.goodsName : '';  
448 - dest.cartInfo.price = (dest.goodsPrice.previousPrice !== null &&  
449 - typeof dest.goodsPrice.previousPrice !== 'undefined') ? dest.goodsPrice.previousPrice : '';  
450 - dest.cartInfo.salePrice = (dest.goodsPrice.currentPrice !== null &&  
451 - typeof dest.goodsPrice.currentPrice !== 'undefined') ? dest.goodsPrice.currentPrice : '';  
452 - dest.cartInfo.totalNum = totalStorageNum;  
453 - dest.cartInfo.colors = colorGroup;  
454 - dest.cartInfo.sizes = sizeGroup; 464 + Object.assign(dest.cartInfo, {
  465 + productId: origin.id,
  466 + thumbs: thumbImageList,
  467 + name: dest.goodsName ? dest.goodsName : '',
  468 + price: dest.goodsPrice.previousPrice ? dest.goodsPrice.previousPrice : '',
  469 + salePrice: dest.goodsPrice.currentPrice ? dest.goodsPrice.currentPrice : '',
  470 + totalNum: totalStorageNum,
  471 + colors: _.toArray(colorGroup),
  472 + sizes: sizeGroup
  473 + });
455 474
456 // 限购商品 475 // 限购商品
457 if (origin.isLimitBuy === 'Y') { 476 if (origin.isLimitBuy === 'Y') {
@@ -468,6 +487,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -468,6 +487,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
468 487
469 // 处理限购商品有关的按钮状态 488 // 处理限购商品有关的按钮状态
470 dest = procShowStatus(dest, showStatus, isBeginSale); 489 dest = procShowStatus(dest, showStatus, isBeginSale);
  490 + Object.assign;
471 dest.cartInfo.limitProductCode = origin.limitProductCode; 491 dest.cartInfo.limitProductCode = origin.limitProductCode;
472 dest.cartInfo.limitCodeUrl = getLimitCodeUrl(origin.limitProductCode, origin.erpProductId, ua); 492 dest.cartInfo.limitCodeUrl = getLimitCodeUrl(origin.limitProductCode, origin.erpProductId, ua);
473 dest.cartInfo.limitProductPay = helpers.urlFormat('/cart/index/orderEnsure'); // 待处理 相关处理逻辑还不存在 493 dest.cartInfo.limitProductPay = helpers.urlFormat('/cart/index/orderEnsure'); // 待处理 相关处理逻辑还不存在
@@ -488,11 +508,8 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -488,11 +508,8 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
488 dest.isCollect = true; 508 dest.isCollect = true;
489 } 509 }
490 510
491 - // 底部简介的URL链接 待处理  
492 - // dest.introUrl = helpers.urlFormat('/product/intro_' + origin.erpProductId +  
493 - // '/' + origin.cnAlphabet + '.html', null, '');  
494 -  
495 - dest.introUrl = 'http://localhost:6001/product/detail/intro/' + origin.erpProductId; 511 + // 底部简介URL链接
  512 + dest.introUrl = '/product/detail/intro/' + origin.erpProductId;
496 dest.id = origin.id; 513 dest.id = origin.id;
497 514
498 return dest; 515 return dest;
@@ -10,20 +10,19 @@ @@ -10,20 +10,19 @@
10 const library = '../../../library'; 10 const library = '../../../library';
11 const utils = '../../../utils'; 11 const utils = '../../../utils';
12 const API = require(`${library}/api`).API; 12 const API = require(`${library}/api`).API;
13 -const sign = require(`${library}/sign`);  
14 const _ = require('lodash'); 13 const _ = require('lodash');
15 const productProcess = require(`${utils}/product-process`); 14 const productProcess = require(`${utils}/product-process`);
16 -var api = new API(); 15 +const api = new API();
17 16
18 module.exports = (data) => { 17 module.exports = (data) => {
19 - var finalResult; 18 + let finalResult;
20 19
21 - return api.get('', sign.apiSign({ 20 + return api.get('', {
22 method: 'h5.preference.Search', 21 method: 'h5.preference.Search',
23 productskn: data.productskn, 22 productskn: data.productskn,
24 yhchannel: data.yhchannel, 23 yhchannel: data.yhchannel,
25 brandId: data.brandId 24 brandId: data.brandId
26 - })).then(result => { 25 + }).then(result => {
27 if (!_.isEmpty(result) && result.code === 200) { 26 if (!_.isEmpty(result) && result.code === 200) {
28 // 为你优选数据处理,接口没有数据,待处理,待验证 27 // 为你优选数据处理,接口没有数据,待处理,待验证
29 finalResult = productProcess.processProductList(result.data); 28 finalResult = productProcess.processProductList(result.data);
@@ -23,7 +23,7 @@ const outlet = require(`${cRoot}/outlet`); @@ -23,7 +23,7 @@ const outlet = require(`${cRoot}/outlet`);
23 // /pro_136349_455445/HEARTSOFARMianMaShuJiaoXiuXianKuPS1684.html 23 // /pro_136349_455445/HEARTSOFARMianMaShuJiaoXiuXianKuPS1684.html
24 router.get(/\/pro_([\d]+)_([\d]+)\/(.*)/, detail.index); 24 router.get(/\/pro_([\d]+)_([\d]+)\/(.*)/, detail.index);
25 router.get('/detail/intro/:productskn', detail.intro); 25 router.get('/detail/intro/:productskn', detail.intro);
26 -router.get('/detail/preference/:productskn/:yhchannel/:brandId', detail.preference); 26 +router.get('/detail/preference', detail.preference);
27 27
28 router.get('/sale', sale.index); 28 router.get('/sale', sale.index);
29 router.get('/sale/discount', sale.discount); 29 router.get('/sale/discount', sale.discount);
@@ -75,25 +75,25 @@ @@ -75,25 +75,25 @@
75 </li> 75 </li>
76 {{/ list}} 76 {{/ list}}
77 </ul> 77 </ul>
78 - {{/vipLevel}} 78 + {{/ vipLevel}}
79 79
80 {{# goodsDiscount}} 80 {{# goodsDiscount}}
81 <div class="goods-discount" id="goodsDiscount"> 81 <div class="goods-discount" id="goodsDiscount">
82 {{# list}} 82 {{# list}}
83 - {{#if @first}}  
84 - {{#if text}}  
85 - <h1 class="first-item short-text tap-hightlight">{{text}}<span class="icon-down iconfont dropdown">&#xe609;</span></h1>  
86 - {{/if}}  
87 - {{/if}} 83 + {{#if @first}}
  84 + {{#if text}}
  85 + <h1 class="first-item short-text tap-hightlight">{{text}}<span class="icon-down iconfont dropdown">&#xe609;</span></h1>
  86 + {{/if}}
  87 + {{/if}}
88 {{/ list}} 88 {{/ list}}
89 <div class="discount-folder"> 89 <div class="discount-folder">
90 {{# list}} 90 {{# list}}
91 - {{#if @first}}  
92 - {{else}}  
93 - {{#if text}}  
94 - <h1 class="folder-item tap-hightlight">{{text}}</h1>  
95 - {{/if}}  
96 - {{/if}} 91 + {{#if @first}}
  92 + {{else}}
  93 + {{#if text}}
  94 + <h1 class="folder-item tap-hightlight">{{text}}</h1>
  95 + {{/if}}
  96 + {{/if}}
97 {{/list}} 97 {{/list}}
98 </div> 98 </div>
99 </div> 99 </div>
@@ -101,25 +101,25 @@ @@ -101,25 +101,25 @@
101 101
102 {{# feedbacks}} 102 {{# feedbacks}}
103 <div class="feedback-list "> 103 <div class="feedback-list ">
104 - {{#if commentsNum}}  
105 - {{> product/detail/feedback-tab}}  
106 - {{else}}  
107 - {{#if consultsNum}}  
108 - {{> product/detail/feedback-tab}} 104 + {{#if commentsNum}}
  105 + {{> product/detail/feedback-tab}}
109 {{else}} 106 {{else}}
110 - <div class="nodata tap-hightlight" id="goto-consult">  
111 - <span>暂无商品评价和咨询</span>  
112 - <a href="{{consultsUrl}}" class="go-consult">我要咨询<span class="iconfont">&#xe604;</span></a>  
113 - </div> 107 + {{#if consultsNum}}
  108 + {{> product/detail/feedback-tab}}
  109 + {{else}}
  110 + <div class="nodata tap-hightlight" id="goto-consult">
  111 + <span>暂无商品评价和咨询</span>
  112 + <a href="{{consultsUrl}}" class="go-consult">我要咨询<span class="iconfont">&#xe604;</span></a>
  113 + </div>
  114 + {{/if}}
114 {{/if}} 115 {{/if}}
115 - {{/if}}  
116 </div> 116 </div>
117 {{/ feedbacks}} 117 {{/ feedbacks}}
118 118
119 {{# enterStore}} 119 {{# enterStore}}
120 <div id="enter-store" class="enter-store page-block tap-hightlight"> 120 <div id="enter-store" class="enter-store page-block tap-hightlight">
121 <a class="store-logo" href="{{url}}" style=""> 121 <a class="store-logo" href="{{url}}" style="">
122 - <img class="lazy" data-original="{{img}}" alt="{{storeName}}"> 122 + <img class="lazy" data-original="{{image img 47 47}}" alt="{{storeName}}">
123 </a> 123 </a>
124 <a class="store-name" href="{{url}}">{{storeName}}</a> 124 <a class="store-name" href="{{url}}">{{storeName}}</a>
125 <a class="store-link" href="{{url}}">进入店铺<span class="iconfont">&#xe604;</span></a> 125 <a class="store-link" href="{{url}}">进入店铺<span class="iconfont">&#xe604;</span></a>
1 -{{> product/recommend-content}}  
  1 +{{> product/detail/recommend-for-you}}
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <div class="infos"> 4 <div class="infos">
5 <div class="basic-info" > 5 <div class="basic-info" >
6 {{#thumbs}} 6 {{#thumbs}}
7 - <img class="thumb {{#unless @first}}hide{{/unless}}" src={{img}}> 7 + <img class="thumb {{#unless @first}}hide{{/unless}}" src={{image img 60 60}}>
8 {{/thumbs}} 8 {{/thumbs}}
9 <div class="text-info"> 9 <div class="text-info">
10 <p class="name">{{name}}</p> 10 <p class="name">{{name}}</p>
@@ -272,7 +272,6 @@ @@ -272,7 +272,6 @@
272 .nav-tab { 272 .nav-tab {
273 padding: 10px 0; 273 padding: 10px 0;
274 width: 100%; 274 width: 100%;
275 - height: 60px;  
276 border-top: 1px solid $borderC; 275 border-top: 1px solid $borderC;
277 border-bottom: 1px solid $borderC; 276 border-bottom: 1px solid $borderC;
278 background-color: #fff; 277 background-color: #fff;
@@ -569,6 +569,3 @@ $basicBtnC: #eb0313; @@ -569,6 +569,3 @@ $basicBtnC: #eb0313;
569 top: 40%; 569 top: 40%;
570 } 570 }
571 } 571 }
572 -  
573 -@import "comments-consults";  
574 -@import "product-description";  
1 @import "detail"; 1 @import "detail";
2 @import "comments-consults"; 2 @import "comments-consults";
3 -@import "comments-consults"; 3 +@import "product-description";
4 @import "recommend-for-you"; 4 @import "recommend-for-you";