Skip to content

Commit

Permalink
fix(Sku): add choosable check (#6674)
Browse files Browse the repository at this point in the history
* fix(Sku): add choosable check

* fix(Sku): change code style

* fix(Sku): change code style

Co-authored-by: songweite <songweite@youzan.com>
  • Loading branch information
waiter and songweite committed Jul 2, 2020
1 parent 2908161 commit 2ad40a7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/sku/Sku.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,15 @@ export default createComponent({

// 重置 selectedSku
this.skuTree.forEach((item) => {
this.selectedSku[item.k_s] =
this.initialSku[item.k_s] || UNSELECTED_SKU_VALUE_ID;
this.selectedSku[item.k_s] = UNSELECTED_SKU_VALUE_ID;
});

// 只有一个 sku 规格值时默认选中
this.skuTree.forEach((item) => {
const key = item.k_s;
const valueId = item.v[0].id;
// 规格值只有1个时,优先判断
const valueId =
item.v.length === 1 ? item.v[0].id : this.initialSku[key];
if (
item.v.length === 1 &&
valueId &&
isSkuChoosable(this.sku.list, this.selectedSku, { key, valueId })
) {
this.selectedSku[key] = valueId;
Expand Down

0 comments on commit 2ad40a7

Please sign in to comment.