Authored by htoooth

fix css

@@ -13,6 +13,7 @@ const Fn = require('lodash/fp'); @@ -13,6 +13,7 @@ const Fn = require('lodash/fp');
13 const cheerio = require('cheerio'); 13 const cheerio = require('cheerio');
14 const url = require('url'); 14 const url = require('url');
15 const helpers = global.yoho.helpers; 15 const helpers = global.yoho.helpers;
  16 +const config = global.yoho.config;
16 const crypto = global.yoho.crypto; 17 const crypto = global.yoho.crypto;
17 18
18 const videoPlayerTpl = require('../helper/video-player-tpl'); 19 const videoPlayerTpl = require('../helper/video-player-tpl');
@@ -191,8 +192,10 @@ const _getVipDataByProductBaseInfo = (data, vipLevel, uid) => { @@ -191,8 +192,10 @@ const _getVipDataByProductBaseInfo = (data, vipLevel, uid) => {
191 const _getProductActivityBanner = (additionalData) => { 192 const _getProductActivityBanner = (additionalData) => {
192 let data = additionalData.productBanner; 193 let data = additionalData.productBanner;
193 194
194 - if (_.isEmpty(data) || _.get(data, 'code', 400) !== 200 || !_.get(data, 'data.bannerImg')) {  
195 - return {}; 195 + if (_.isEmpty(data) ||
  196 + _.get(data, 'code', 400) !== 200 ||
  197 + !_.get(data, 'data.bannerImg')) {
  198 + return false;
196 } 199 }
197 200
198 return { 201 return {
@@ -211,17 +214,11 @@ const _getBundleAsync = (result) => { @@ -211,17 +214,11 @@ const _getBundleAsync = (result) => {
211 }; 214 };
212 215
213 const _getActivityDataByProductBaseInfo = (data) => { 216 const _getActivityDataByProductBaseInfo = (data) => {
214 - let result = [];  
215 -  
216 - _.get(data, 'data', []).forEach(value => {  
217 - result.push({ 217 + return _.get(data, 'data', []).map(value => ({
218 type: value.promotionType.replace(/¥/g, '¥'), 218 type: value.promotionType.replace(/¥/g, '¥'),
219 des: value.promotionTitle.replace(/¥/g, '¥'), 219 des: value.promotionTitle.replace(/¥/g, '¥'),
220 url: helpers.urlFormat('', {psp_id: value.id}, 'list') 220 url: helpers.urlFormat('', {psp_id: value.id}, 'list')
221 - });  
222 - });  
223 -  
224 - return result; 221 + }));
225 }; 222 };
226 223
227 /** 224 /**
@@ -279,7 +276,7 @@ const _getSkuDataByProductBaseInfo = (data) => { @@ -279,7 +276,7 @@ const _getSkuDataByProductBaseInfo = (data) => {
279 let totalStorageNum = 0; 276 let totalStorageNum = 0;
280 let skuGoods = null;// sku商品 277 let skuGoods = null;// sku商品
281 let defaultImage = '';// 默认图 278 let defaultImage = '';// 默认图
282 - let chooseSkuFlag = false; // 选中状态 279 + let defaultSkuFlag = false; // 选中状态
283 280
284 if (_.isEmpty(_.get(data, 'goods_list', []))) { 281 if (_.isEmpty(_.get(data, 'goods_list', []))) {
285 return { 282 return {
@@ -289,33 +286,34 @@ const _getSkuDataByProductBaseInfo = (data) => { @@ -289,33 +286,34 @@ const _getSkuDataByProductBaseInfo = (data) => {
289 }; 286 };
290 } 287 }
291 288
292 - skuGoods = _.get(data, 'goods_list', []).reduce((acc, cur)=> { 289 + skuGoods = _.get(data, 'goods_list', []).reduce((goodsDetailList, goods)=> {
293 290
294 // 如果status为0,即skc下架时就跳过该商品$value['status'] === 0 291 // 如果status为0,即skc下架时就跳过该商品$value['status'] === 0
295 - let goodsGroup = {}; 292 + let goodsDetail = {};
296 293
297 - if (_.isEmpty(cur.color_image)) {  
298 - return acc; 294 + if (_.isEmpty(goods.color_image)) {
  295 + return goodsDetailList;
299 } 296 }
300 297
301 - if (cur.images_list) { 298 + if (goods.images_list) {
302 // 商品列表 299 // 商品列表
303 - goodsGroup.productSkc = cur.product_skc;  
304 - goodsGroup.src = cur.color_image;  
305 - goodsGroup.title = `${_.trim(data.product_name)} ${cur.factory_goods_name}`;  
306 - goodsGroup.name = cur.factory_goods_name;  
307 - goodsGroup.focus = false;  
308 - goodsGroup.total = 0;  
309 - goodsGroup.thumbs = [];  
310 - goodsGroup.size = [];  
311 - if (goodsGroup.title.length > 20) {  
312 - goodsGroup.title = goodsGroup.title.substr(0, 20) + '...'; 300 + goodsDetail.productSkc = goods.product_skc;
  301 + goodsDetail.src = goods.color_image;
  302 + goodsDetail.title = `${_.trim(data.product_name)} ${goods.factory_goods_name}`;
  303 + goodsDetail.name = goods.factory_goods_name;
  304 + goodsDetail.focus = false;
  305 + goodsDetail.total = 0;
  306 + goodsDetail.thumbs = [];
  307 + goodsDetail.size = [];
  308 +
  309 + if (goodsDetail.title.length > 20) {
  310 + goodsDetail.title = goodsDetail.title.substr(0, 20) + '...';
313 } 311 }
314 } 312 }
315 313
316 - _.get(cur, 'images_list', []).forEach((good) => { 314 + _.get(goods, 'images_list', []).forEach((good) => {
317 if (good.image_url) { 315 if (good.image_url) {
318 - goodsGroup.thumbs.push({ 316 + goodsDetail.thumbs.push({
319 url: '', 317 url: '',
320 shower: good.image_url, 318 shower: good.image_url,
321 img: good.image_url 319 img: good.image_url
@@ -324,26 +322,27 @@ const _getSkuDataByProductBaseInfo = (data) => { @@ -324,26 +322,27 @@ const _getSkuDataByProductBaseInfo = (data) => {
324 }); 322 });
325 323
326 // 缩略图空,不显示 324 // 缩略图空,不显示
327 - if (_.isEmpty(goodsGroup.thumbs)) {  
328 - return acc; 325 + if (_.isEmpty(goodsDetail.thumbs)) {
  326 + return goodsDetailList;
329 } 327 }
330 328
331 // 商品的尺码列表 329 // 商品的尺码列表
332 - _.get(cur, 'size_list', []).forEach((size) => { 330 + _.get(goods, 'size_list', []).forEach((size) => {
333 if (data.attribute === 3) { 331 if (data.attribute === 3) {
334 // 虚拟商品,门票默认最大为4, 332 // 虚拟商品,门票默认最大为4,
335 size.storage_number = size.storage_number > 4 ? 4 : size.storage_number; 333 size.storage_number = size.storage_number > 4 ? 4 : size.storage_number;
336 } 334 }
337 335
338 // 如果status为0,即skc下架时就跳过该商品 336 // 如果status为0,即skc下架时就跳过该商品
339 - if (cur.status === 0) { 337 + if (goods.status === 0) {
340 size.storage_number = 0; 338 size.storage_number = 0;
341 } 339 }
342 340
343 // 是否显示到货通知 341 // 是否显示到货通知
344 size.notify = size.isSuppled === 'Y' && size.storage_number === 0 ? 'Y' : 'N'; 342 size.notify = size.isSuppled === 'Y' && size.storage_number === 0 ? 'Y' : 'N';
345 343
346 - goodsGroup.size.push({ 344 + // 尺码信息
  345 + goodsDetail.size.push({
347 name: size.size_name, 346 name: size.size_name,
348 sku: size.product_sku, 347 sku: size.product_sku,
349 num: _.parseInt(size.storage_number), 348 num: _.parseInt(size.storage_number),
@@ -354,22 +353,22 @@ const _getSkuDataByProductBaseInfo = (data) => { @@ -354,22 +353,22 @@ const _getSkuDataByProductBaseInfo = (data) => {
354 }); 353 });
355 354
356 // 单个sku商品的总数 355 // 单个sku商品的总数
357 - goodsGroup.total += _.parseInt(size.storage_number); 356 + goodsDetail.total += _.parseInt(size.storage_number);
358 357
359 - if (goodsGroup.total > 0 && !chooseSkuFlag) { // 默认选中该sku商品  
360 - goodsGroup.focus = true;  
361 - defaultImage = goodsGroup.src; // 默认为选中的skc  
362 - chooseSkuFlag = true;// 选中sku商品 358 + if (goodsDetail.total > 0 && !defaultSkuFlag) { // 默认选中该sku商品
  359 + goodsDetail.focus = true;
  360 + defaultImage = goodsDetail.src; // 默认为选中的skc
  361 + defaultSkuFlag = true;// 选中sku商品
363 } 362 }
364 363
365 - goodsGroup.disable = !goodsGroup.total > 0; 364 + goodsDetail.disable = !goodsDetail.total > 0;
366 365
367 totalStorageNum += _.parseInt(size.storage_number); 366 totalStorageNum += _.parseInt(size.storage_number);
368 367
369 }); 368 });
370 369
371 - if (goodsGroup.focus) {  
372 - _.some(goodsGroup.size, function(value) { 370 + if (goodsDetail.focus) {
  371 + _.some(goodsDetail.size, function(value) {
373 if (value.num !== 0) { 372 if (value.num !== 0) {
374 value.focus = true; 373 value.focus = true;
375 return true; 374 return true;
@@ -378,11 +377,11 @@ const _getSkuDataByProductBaseInfo = (data) => { @@ -378,11 +377,11 @@ const _getSkuDataByProductBaseInfo = (data) => {
378 }); 377 });
379 } 378 }
380 379
381 - acc.push(goodsGroup);  
382 - return acc; 380 + goodsDetailList.push(goodsDetail);
  381 + return goodsDetailList;
383 }, []); 382 }, []);
384 383
385 - if (!_.isEmpty(skuGoods) && !chooseSkuFlag) { // 没有选中一个sku商品,默认选中第一个sku商品 384 + if (!_.isEmpty(skuGoods) && !defaultSkuFlag) { // 没有选中一个sku商品,默认选中第一个sku商品
386 // 所有商品都售罄 385 // 所有商品都售罄
387 _.head(skuGoods).focus = true; 386 _.head(skuGoods).focus = true;
388 defaultImage = _.head(skuGoods).src; 387 defaultImage = _.head(skuGoods).src;
@@ -510,16 +509,13 @@ function _getSortNavAsync(smallSortId, gender) { @@ -510,16 +509,13 @@ function _getSortNavAsync(smallSortId, gender) {
510 509
511 // 保存在 gids 和 skns ,最近流览功能 510 // 保存在 gids 和 skns ,最近流览功能
512 const saveRecentGoodInCookies = (oldSkns, res, addSkns) => { 511 const saveRecentGoodInCookies = (oldSkns, res, addSkns) => {
513 -  
514 oldSkns = oldSkns ? oldSkns.split(',') : []; 512 oldSkns = oldSkns ? oldSkns.split(',') : [];
515 -  
516 oldSkns = _.reject(oldSkns, old => old === String(addSkns) ? true : false); 513 oldSkns = _.reject(oldSkns, old => old === String(addSkns) ? true : false);
517 -  
518 oldSkns.unshift(addSkns); 514 oldSkns.unshift(addSkns);
519 515
520 - res.cookie('_browseskn', oldSkns.splice(0, 30).join(','), { 516 + res.cookie('_browseskn', _.take(oldSkns, 30).join(','), {
521 maxAge: 2000000000, 517 maxAge: 2000000000,
522 - domain: '.yohobuy.com' 518 + domain: config.cookieDomain
523 }); 519 });
524 }; 520 };
525 521
@@ -527,14 +523,13 @@ const saveRecentGoodInCookies = (oldSkns, res, addSkns) => { @@ -527,14 +523,13 @@ const saveRecentGoodInCookies = (oldSkns, res, addSkns) => {
527 * 获取商品的舒适度 523 * 获取商品的舒适度
528 */ 524 */
529 const _getProductComfort = (data) => { 525 const _getProductComfort = (data) => {
530 - let result = [];  
531 let comfort = data.productComfort; 526 let comfort = data.productComfort;
532 527
533 if (_.isEmpty(comfort) || !comfort || !comfort.data) { 528 if (_.isEmpty(comfort) || !comfort || !comfort.data) {
534 - return result; 529 + return [];
535 } 530 }
536 531
537 - _.get(comfort, 'data', []).forEach(value => { 532 + return _.get(comfort, 'data', []).reduce((all, value) => {
538 let blocks = []; 533 let blocks = [];
539 let flag = false; 534 let flag = false;
540 535
@@ -551,19 +546,19 @@ const _getProductComfort = (data) => { @@ -551,19 +546,19 @@ const _getProductComfort = (data) => {
551 546
552 // 不存在 547 // 不存在
553 if (!flag) { 548 if (!flag) {
554 - return; 549 + return all;
555 } 550 }
556 551
557 // 存在,添加 552 // 存在,添加
558 - result.push({ 553 + all.push({
559 name: value.caption.caption, 554 name: value.caption.caption,
560 minDes: value.caption.low, 555 minDes: value.caption.low,
561 blocks: blocks, 556 blocks: blocks,
562 maxDes: value.caption.high 557 maxDes: value.caption.high
563 }); 558 });
564 - });  
565 559
566 - return result; 560 + return all;
  561 + }, []);
567 }; 562 };
568 563
569 /** 564 /**
@@ -580,30 +575,26 @@ const _getBasicDescription = (productDescBo) => { @@ -580,30 +575,26 @@ const _getBasicDescription = (productDescBo) => {
580 } 575 }
581 }(productDescBo.gender)); 576 }(productDescBo.gender));
582 577
583 - let basic = [  
584 - { 578 + const basic = [{
585 key: '编号', 579 key: '编号',
586 value: productDescBo.erpProductId 580 value: productDescBo.erpProductId
587 - },  
588 - { 581 + }, {
589 key: '颜色', 582 key: '颜色',
590 value: productDescBo.factoryGoodsName, 583 value: productDescBo.factoryGoodsName,
591 dColor: true 584 dColor: true
592 - },  
593 - { 585 + }, {
594 key: '性别', 586 key: '性别',
595 value: sex 587 value: sex
596 - }  
597 - ]; 588 + }];
598 589
599 - _.get(productDescBo, 'standardBos', []).forEach(value => {  
600 - basic.push({ 590 + return _.get(productDescBo, 'standardBos', []).reduce((all, value) => {
  591 + all.push({
601 key: value.standardName, 592 key: value.standardName,
602 value: value.standardVal 593 value: value.standardVal
603 }); 594 });
604 - });  
605 595
606 - return basic; 596 + return all;
  597 + }, basic);
607 }; 598 };
608 599
609 /** 600 /**
@@ -611,7 +602,7 @@ const _getBasicDescription = (productDescBo) => { @@ -611,7 +602,7 @@ const _getBasicDescription = (productDescBo) => {
611 */ 602 */
612 const _getDescriptionDataBySizeInfo = (sizeInfo, additionalData) => { 603 const _getDescriptionDataBySizeInfo = (sizeInfo, additionalData) => {
613 if (!sizeInfo.productDescBo || !sizeInfo.productDescBo.erpProductId) { 604 if (!sizeInfo.productDescBo || !sizeInfo.productDescBo.erpProductId) {
614 - return {}; 605 + return false;
615 } 606 }
616 607
617 return { 608 return {
@@ -805,7 +796,7 @@ const _getProductModelCard = (sortId, sizeInfo) => { @@ -805,7 +796,7 @@ const _getProductModelCard = (sortId, sizeInfo) => {
805 */ 796 */
806 const getReferenceDataBySizeInfo = (sizeInfo) => { 797 const getReferenceDataBySizeInfo = (sizeInfo) => {
807 if (_.isEmpty(sizeInfo.modelBos)) { 798 if (_.isEmpty(sizeInfo.modelBos)) {
808 - return {}; 799 + return false;
809 } 800 }
810 801
811 // 模特试穿, 竖着输出排列显示 802 // 模特试穿, 竖着输出排列显示
@@ -925,7 +916,7 @@ const _getProductModelTry = (data) => { @@ -925,7 +916,7 @@ const _getProductModelTry = (data) => {
925 let result = data.productModelTry; 916 let result = data.productModelTry;
926 917
927 if (_.isEmpty(result) || result.code !== 200 || _.isEmpty(result.data)) { 918 if (_.isEmpty(result) || result.code !== 200 || _.isEmpty(result.data)) {
928 - return {}; 919 + return false;
929 } 920 }
930 921
931 let modelTry = { 922 let modelTry = {
@@ -961,60 +952,6 @@ const _getProductModelTry = (data) => { @@ -961,60 +952,6 @@ const _getProductModelTry = (data) => {
961 }; 952 };
962 953
963 /** 954 /**
964 - * 根据最大分类ID获取尺寸属性  
965 - * @param maxSortId  
966 - * @param sizeInfoBo  
967 - */  
968 -const _getSizeAttrByMaxSortId = (maxSortId, sizeList) => {  
969 - if (_.isEmpty(sizeList)) {  
970 - return [];  
971 - }  
972 -  
973 - // 不同分类,取得属性值不同  
974 - let attributeIds = (function(id) {  
975 - if (id === 1 && id === 2) {  
976 - return [3, 4];  
977 - } else if (id === 3) {  
978 - return [6, 10];  
979 - } else if (id === 6) {  
980 - return [13];  
981 - } else {  
982 - return [];  
983 - }  
984 - }(maxSortId));  
985 -  
986 - let sizeInfos = [];  
987 - let attributeNames = {};  
988 -  
989 - // 获取属性名称  
990 - _.get(sizeList, 'sizeAttributeBos', []).forEach((size) => {  
991 - attributeNames[size.id] = size.attributeName;  
992 - });  
993 -  
994 - _.get(sizeList, 'sizeBoList', []).forEach((size) => {  
995 - let sizeValues = [];  
996 -  
997 - _.get(size, 'sortAttributes', []).forEach((sort) => {  
998 - if (_.includes(attributeIds, sort.id)) {  
999 - if (sort.sizeValue) {  
1000 - sizeValues.push(  
1001 - `${attributeNames[sort.id]} ${sort.sizeValue}cm`  
1002 - );  
1003 - }  
1004 - }  
1005 - });  
1006 -  
1007 - // 获取尺寸属性  
1008 - if (!_.isEmpty(sizeValues)) {  
1009 - sizeInfos[size.sizeName] = sizeValues.join(' / ');  
1010 - }  
1011 - });  
1012 -  
1013 - return sizeInfos;  
1014 -  
1015 -};  
1016 -  
1017 -/**  
1018 * 商品尺码信息 955 * 商品尺码信息
1019 * 956 *
1020 * @param productSkn 957 * @param productSkn
@@ -1041,21 +978,13 @@ const _getIntroInfo = (productSkn, maxSortId, additionalData)=> { @@ -1041,21 +978,13 @@ const _getIntroInfo = (productSkn, maxSortId, additionalData)=> {
1041 result.modelCards = _getProductModelCard(maxSortId, sizeInfo); 978 result.modelCards = _getProductModelCard(maxSortId, sizeInfo);
1042 979
1043 // 试穿模特 980 // 试穿模特
1044 - let fittingReport = _getProductModelTry(additionalData);  
1045 -  
1046 - if (!_.isEmpty(fittingReport)) {  
1047 - result.fittingReport = fittingReport;  
1048 - } 981 + result.fittingReport = _getProductModelTry(additionalData);
1049 982
1050 // 尺寸数据 983 // 尺寸数据
1051 result.size = _getSizeData(sizeInfo); 984 result.size = _getSizeData(sizeInfo);
1052 985
1053 // 模特数据 986 // 模特数据
1054 - let reference = getReferenceDataBySizeInfo(sizeInfo);  
1055 -  
1056 - if (!_.isEmpty(reference)) {  
1057 - result.reference = reference;  
1058 - } 987 + result.reference = getReferenceDataBySizeInfo(sizeInfo);
1059 988
1060 // 洗涤材质 989 // 洗涤材质
1061 result.material = _getMaterialDataBySizeInfo(sizeInfo); 990 result.material = _getMaterialDataBySizeInfo(sizeInfo);
@@ -1063,10 +992,6 @@ const _getIntroInfo = (productSkn, maxSortId, additionalData)=> { @@ -1063,10 +992,6 @@ const _getIntroInfo = (productSkn, maxSortId, additionalData)=> {
1063 // 商品详情页介绍 992 // 商品详情页介绍
1064 result.details = _getDetailDataBySizeInfo(sizeInfo); 993 result.details = _getDetailDataBySizeInfo(sizeInfo);
1065 994
1066 - // 获取尺寸说明  
1067 - result.sizeTitleJson =  
1068 - sizeInfo.sizeInfoBo ? JSON.stringify(_getSizeAttrByMaxSortId(maxSortId, sizeInfo.sizeInfoBo)) : '';  
1069 -  
1070 return result; 995 return result;
1071 }; 996 };
1072 997
@@ -1663,7 +1588,7 @@ const recommendAsync = (skn, page, limit) => { @@ -1663,7 +1588,7 @@ const recommendAsync = (skn, page, limit) => {
1663 } 1588 }
1664 1589
1665 const formatPrice = p => ${p}`; 1590 const formatPrice = p => ${p}`;
1666 - const productUrl = (pid, gid, cn) => helpers.urlFormat(`/product/pro_${pid}_${gid}/${cn}.html`, null, 'item'); 1591 + const productUrl = (pid, gid, cn) => helpers.getUrlBySkc(pid, gid, cn);
1667 const productImageUrl = Fn.pipe(Fn.prop('default_images'), _.partial(helpers.image, _, 280, 382, 2, 70)); 1592 const productImageUrl = Fn.pipe(Fn.prop('default_images'), _.partial(helpers.image, _, 280, 382, 2, 70));
1668 1593
1669 let products = _.get(recommendData, 'data.product_list', []).map((rp) => { 1594 let products = _.get(recommendData, 'data.product_list', []).map((rp) => {