Authored by 郭成尧

Merge branch 'feature/detailchose' into release/6.1

@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 <span class="name">{{name}}</span> 28 <span class="name">{{name}}</span>
29 <ul class="size-row clearfix"> 29 <ul class="size-row clearfix">
30 {{#each values}} 30 {{#each values}}
31 - <li class="block" data-prop-id="{{../type}}" data-value-id="{{id}}">{{name}}</li> 31 + <li class="block{{#if chosed}} chosed{{/if}}" data-prop-id="{{../type}}" data-value-id="{{id}}">{{name}}</li>
32 {{/each}} 32 {{/each}}
33 </ul> 33 </ul>
34 </div> 34 </div>
@@ -431,9 +431,22 @@ exports.processSkusInfo = (origin) => { @@ -431,9 +431,22 @@ exports.processSkusInfo = (origin) => {
431 values: [] 431 values: []
432 }] 432 }]
433 }; 433 };
  434 + let colorChosed = false;
  435 +
  436 + // 只有一个颜色,默认选中
  437 + if (_.get(origin, 'goods_list.length') === 1) {
  438 + colorChosed = true;
  439 + }
434 440
435 // 解析接口数据构造为带属性列表的sku列表 441 // 解析接口数据构造为带属性列表的sku列表
436 _.each(origin.goods_list, color => { 442 _.each(origin.goods_list, color => {
  443 + let sizeChosed = false;
  444 +
  445 + // 只有一个尺码,默认选中
  446 + if (_.get(color, 'size_list.length') === 1) {
  447 + sizeChosed = true;
  448 + }
  449 +
437 _.each(color.size_list, size => { 450 _.each(color.size_list, size => {
438 let colorProp = dest.props.find(prop => prop.type === 'color'), 451 let colorProp = dest.props.find(prop => prop.type === 'color'),
439 sizeProp = dest.props.find(prop => prop.type === 'size'); 452 sizeProp = dest.props.find(prop => prop.type === 'size');
@@ -441,13 +454,15 @@ exports.processSkusInfo = (origin) => { @@ -441,13 +454,15 @@ exports.processSkusInfo = (origin) => {
441 if (!_.some(colorProp.values, prop => prop.id === color.product_skc)) { 454 if (!_.some(colorProp.values, prop => prop.id === color.product_skc)) {
442 colorProp.values.push({ 455 colorProp.values.push({
443 id: color.product_skc, 456 id: color.product_skc,
444 - name: color.factory_goods_name || color.color_name 457 + name: color.factory_goods_name || color.color_name,
  458 + chosed: colorChosed
445 }); 459 });
446 } 460 }
447 if (!_.some(sizeProp.values, prop => prop.id === size.size_id)) { 461 if (!_.some(sizeProp.values, prop => prop.id === size.size_id)) {
448 sizeProp.values.push({ 462 sizeProp.values.push({
449 id: size.size_id, 463 id: size.size_id,
450 - name: size.size_name 464 + name: size.size_name,
  465 + chosed: sizeChosed
451 }); 466 });
452 } 467 }
453 468