sku选择问题,提交订单金额

feature/task1.0.0-0505-ch
ch 3 years ago
parent c4ecf74934
commit 3358e2c5a7

@ -235,7 +235,10 @@ export default {
let res2 = await ApiGetGoodsSkus({ productId: id });
let res3 = await ApiGetRecommendedGoodsList();
vm.detailData = res1.result;
vm.skuData = res2.result;
vm.skuData = res2.result.map(i => {
i.attributeSymbolList = i.attributeSymbolList.split(',')
return i;
});
vm.recommendedData = res3.result;
if (
vm.detailData.productActivityVO.isActivity &&
@ -266,7 +269,7 @@ export default {
curSku() {
return (
this.skuData.find(
(i) => i.attributeSymbolList === this.selectedSymbol.join(",")
(i) => i.attributeSymbolList.join(',') === this.selectedSymbol.join(",")
) || {}
);
},
@ -275,9 +278,9 @@ export default {
return this.detailData.attributeGroupList
.map((item) => {
const activeAttr = item.attributes.find((i) => i.active);
return activeAttr ? activeAttr.symbol : ".";
return activeAttr?.symbol;
})
.filter((i) => i); //.sort();
.filter((i) => i).sort();
},
/**
* 最大可购买数量
@ -378,26 +381,6 @@ export default {
vm.activeImg++;
}
},
/**
* 设置默认选中规格
*/
setDefaultAttr() {
let vm = this;
const curSku = vm.skuData.find((i) => i.stock > 0);
if (!curSku) {
return false;
}
vm.detailData.attributeGroupList.forEach((item, index) => {
for (let i of item.attributes) {
if (curSku.attributeSymbolList.includes(i.symbol)) {
this.$set(i, "active", true);
this.setDisabledItem(i, index, true);
break;
}
}
});
this.$emit("input", this.curSku);
},
/**
* 点击属性项设置选中和禁用项
*/
@ -426,26 +409,43 @@ export default {
setDisabledItem(item, groupIndex) {
let vm = this;
vm.detailData.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 = vm.skuData
.filter((i) => reg.test(i.attributeSymbolList))
.find((i) => i.stock > 0);
// if(groupIndex === idx) return false;
//
group.attributes.forEach( item => {
let symbolCache = Object.assign([],vm.selectedSymbol);
symbolCache.push(item.symbol);
symbolCache.sort();
const res = vm.skuData.filter(item =>
symbolCache.map(i => item.attributeSymbolList.includes(i.toString())).every(i => i)
).find(i => i.stock > 0);
if(res){
item.disabled = false;
}else{
item.disabled = true;
}
});
});
})
// vm.detailData.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 = vm.skuData
// .filter((i) => reg.test(i.attributeSymbolList))
// .find((i) => i.stock > 0);
// if (res) {
// item.disabled = false;
// } else {
// item.disabled = true;
// }
// });
// });
},
buyNow() {
if (!this.$isLoginValidate()) {

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-05-04 17:30:58
* @LastEditors: ch
* @LastEditTime: 2022-05-16 16:01:17
* @LastEditTime: 2022-05-17 16:44:30
* @Description: file content
-->
@ -18,7 +18,7 @@
<h3 class="title">确认商品信息</h3>
<OrderInfo :products="orderInfo.products" />
<Message :orderInfo="orderInfo" :message.sync="userMessage"/>
<Amount :amount="orderInfo.payAmount" :address="address"/>
<Amount :amount="orderInfo.productAmount" :address="address"/>
<div class="pay">
<UiButton radius type="red_panel" @click="submit"></UiButton>
</div>

Loading…
Cancel
Save