Authored by 郭成尧

chose-panel-default-chosed

... ... @@ -28,7 +28,7 @@
<span class="name">{{name}}</span>
<ul class="size-row clearfix">
{{#each values}}
<li class="block" data-prop-id="{{../type}}" data-value-id="{{id}}">{{name}}</li>
<li class="block{{#if chosed}} chosed{{/if}}" data-prop-id="{{../type}}" data-value-id="{{id}}">{{name}}</li>
{{/each}}
</ul>
</div>
... ...
... ... @@ -431,9 +431,22 @@ exports.processSkusInfo = (origin) => {
values: []
}]
};
let colorChosed = false;
// 只有一个颜色,默认选中
if (_.get(origin, 'goods_list.length') === 1) {
colorChosed = true;
}
// 解析接口数据构造为带属性列表的sku列表
_.each(origin.goods_list, color => {
let sizeChosed = false;
// 只有一个尺码,默认选中
if (_.get(color, 'size_list.length') === 1) {
sizeChosed = true;
}
_.each(color.size_list, size => {
let colorProp = dest.props.find(prop => prop.type === 'color'),
sizeProp = dest.props.find(prop => prop.type === 'size');
... ... @@ -441,13 +454,15 @@ exports.processSkusInfo = (origin) => {
if (!_.some(colorProp.values, prop => prop.id === color.product_skc)) {
colorProp.values.push({
id: color.product_skc,
name: color.factory_goods_name || color.color_name
name: color.factory_goods_name || color.color_name,
chosed: colorChosed
});
}
if (!_.some(sizeProp.values, prop => prop.id === size.size_id)) {
sizeProp.values.push({
id: size.size_id,
name: size.size_name
name: size.size_name,
chosed: sizeChosed
});
}
... ...