优化规格选择
This commit is contained in:
@@ -134,30 +134,33 @@ function show(item, t = 'shop') {
|
||||
goods.value = item
|
||||
type.value = t
|
||||
goods.value.selectSpec = JSON.parse(goods.value.selectSpec)
|
||||
goods.value.selectSpec.map(item => {
|
||||
let arr = []
|
||||
item.selectSpecResult.map(val => {
|
||||
switch (type.value) {
|
||||
case 'shop':
|
||||
arr.push({
|
||||
active: false,
|
||||
name: val
|
||||
})
|
||||
break;
|
||||
case 'cart':
|
||||
// 如果从购物车选择规格需要做选中效果
|
||||
const skus = goods.value.skuName.split(',')
|
||||
arr.push({
|
||||
active: !!skus.find(item => item === val),
|
||||
name: val
|
||||
})
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
})
|
||||
item.selectSpecResult = arr
|
||||
goods.value.selectSpec.map((item, index) => {
|
||||
if (item.selectSpecResult.length) {
|
||||
let arr = []
|
||||
item.selectSpecResult.map(val => {
|
||||
switch (type.value) {
|
||||
case 'shop':
|
||||
arr.push({
|
||||
active: false,
|
||||
name: val
|
||||
})
|
||||
break;
|
||||
case 'cart':
|
||||
// 如果从购物车选择规格需要做选中效果
|
||||
const skus = goods.value.skuName.split(',')
|
||||
arr.push({
|
||||
active: !!skus.find(item => item === val),
|
||||
name: val
|
||||
})
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
})
|
||||
item.selectSpecResult = arr
|
||||
} else {
|
||||
goods.value.selectSpec.splice(index, 1)
|
||||
}
|
||||
})
|
||||
console.log(goods.value)
|
||||
selectedSuccess()
|
||||
|
||||
Reference in New Issue
Block a user