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 res2 = await ApiGetGoodsSkus({ productId: id });
let res3 = await ApiGetRecommendedGoodsList(); let res3 = await ApiGetRecommendedGoodsList();
vm.detailData = res1.result; 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; vm.recommendedData = res3.result;
if ( if (
vm.detailData.productActivityVO.isActivity && vm.detailData.productActivityVO.isActivity &&
@ -266,7 +269,7 @@ export default {
curSku() { curSku() {
return ( return (
this.skuData.find( 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 return this.detailData.attributeGroupList
.map((item) => { .map((item) => {
const activeAttr = item.attributes.find((i) => i.active); 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++; 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) { setDisabledItem(item, groupIndex) {
let vm = this; let vm = this;
vm.detailData.attributeGroupList.forEach((group, idx) => { vm.detailData.attributeGroupList.forEach((group, idx) => {
// // if(groupIndex === idx) return false;
let symbolCache = Object.assign([], this.selectedSymbol); //
// group.attributes.forEach( item => {
if (groupIndex === idx) return false; let symbolCache = Object.assign([],vm.selectedSymbol);
// symbolCache.push(item.symbol);
group.attributes.forEach((item) => { symbolCache.sort();
// const res = vm.skuData.filter(item =>
symbolCache[idx] = item.symbol; symbolCache.map(i => item.attributeSymbolList.includes(i.toString())).every(i => i)
const reg = new RegExp(symbolCache.join(",")); ).find(i => i.stock > 0);
// SKU
const res = vm.skuData
.filter((i) => reg.test(i.attributeSymbolList))
.find((i) => i.stock > 0);
if(res){ if(res){
item.disabled = false; item.disabled = false;
}else{ }else{
item.disabled = true; 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() { buyNow() {
if (!this.$isLoginValidate()) { if (!this.$isLoginValidate()) {

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

Loading…
Cancel
Save