sku处理回退

msb_beta
ch 3 years ago
parent b9d4614665
commit 4e55bc7c94

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-03-24 11:30:55 * @Date: 2022-03-24 11:30:55
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-17 16:32:32 * @LastEditTime: 2022-05-17 22:21:10
* @Description: file content * @Description: file content
--> -->
<template> <template>
@ -116,14 +116,14 @@ export default {
* 当前选中SKU根据选中规格计算 * 当前选中SKU根据选中规格计算
*/ */
curSku(){ curSku(){
return this.skuInfo.find(i => i.attributeSymbolList.join(',') === this.selectedSymbol.join(',')) || {}; return this.skuInfo.find(i => i.attributeSymbolList === this.selectedSymbol.join(',')) || {};
}, },
// [1,.,3] // [1,.,3]
selectedSymbol(){ selectedSymbol(){
return this.attributeGroupList.map(item => { return this.attributeGroupList.map(item => {
const activeAttr = item.attributes.find(i => i.active); const activeAttr = item.attributes.find(i => i.active);
return activeAttr?.symbol return activeAttr ? activeAttr.symbol : '.'
}).filter(i => i).sort(); }).filter(i => i)//.sort();
}, },
/** /**
* 最大可购买数量 * 最大可购买数量
@ -147,7 +147,7 @@ export default {
} }
this.attributeGroupList.forEach((item, index) => { this.attributeGroupList.forEach((item, index) => {
for(let i of item.attributes){ for(let i of item.attributes){
if(curSku.attributeSymbolList.includes((i.symbol).toString())){ if(curSku.attributeSymbolList.includes(i.symbol)){
this.$set(i,'active', true); this.$set(i,'active', true);
this.setDisabledItem(i, index, true); this.setDisabledItem(i, index, true);
break; break;
@ -178,49 +178,36 @@ export default {
this.$emit('input',this.curSku); this.$emit('input',this.curSku);
}, },
/** /**
* 每次点击选项属性时计算不可选属性 * 每次点击选项属性时计算不可选属性
*/ */
setDisabledItem(item, groupIndex){ setDisabledItem(item, groupIndex){
this.attributeGroupList.forEach((group, idx) => { this.attributeGroupList.forEach((group, idx) => {
// if(groupIndex === idx) return false; //
//
group.attributes.forEach( item => {
let symbolCache = Object.assign([],this.selectedSymbol); let symbolCache = Object.assign([],this.selectedSymbol);
symbolCache.push(item.symbol); //
symbolCache.sort(); if(groupIndex === idx) return false;
const res = this.skuInfo.filter(item => //
symbolCache.map(i => item.attributeSymbolList.includes(i.toString())).every(i => i) group.attributes.forEach( item => {
).find(i => i.stock > 0); //
symbolCache[idx] = item.symbol;
const reg = new RegExp(symbolCache.join(','));
// SKU
const res = this.skuInfo.filter(i => {
let v = reg.test(i.attributeSymbolList)
console.log(reg, i.attributeSymbolList , v);
return v
}).find(i => i.stock > 0);
if(res){ if(res){
item.disabled = false; item.disabled = false;
}else{ }else{
item.disabled = true; item.disabled = true;
} }
});
}) })
})
// this.attributeGroupList.forEach((group, idx) => {
// //
// let symbolCache = Object.assign([],this.selectedSymbol);
// //
// if(groupIndex === idx) return false;
// //
// group.attributes.forEach( item => {
// //
// symbolCache[idx] = item.symbol;
// const reg = new RegExp(symbolCache.join(','));
// // SKU
// const res = this.skuInfo.filter(i => reg.test(i.attributeSymbolList)).find(i => i.stock > 0);
// if(res){
// item.disabled = false;
// }else{
// item.disabled = true;
// }
// })
// })
}, },
/** /**
* 加入购物车 * 加入购物车

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-03-23 17:27:21 * @Date: 2022-03-23 17:27:21
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-17 18:00:53 * @LastEditTime: 2022-05-17 22:25:52
* @Description: file content * @Description: file content
--> -->
<template> <template>
@ -132,7 +132,7 @@ export default {
this.stock = 0; this.stock = 0;
this.skuInfoData = result.map(i => { this.skuInfoData = result.map(i => {
this.stock += i.stock; this.stock += i.stock;
i.attributeSymbolList = i.attributeSymbolList.split(',') // i.attributeSymbolList = i.attributeSymbolList.split(',')
return i; return i;
}); });
}, },

@ -1,2 +1,2 @@
<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>马士兵严选</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)')) <!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>马士兵严选</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/static/index.a5c69d49.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.b5602bf5.js></script><script src=/static/js/index.c8830f41.js></script></body></html> document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/static/index.a5c69d49.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.b5602bf5.js></script><script src=/static/js/index.0e74cf6a.js></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save