feat: 起订倍数修改
This commit is contained in:
@@ -496,7 +496,14 @@ export default {
|
|||||||
* @param {Object} index 需要修改的数据节点
|
* @param {Object} index 需要修改的数据节点
|
||||||
*/
|
*/
|
||||||
async quantityFun(type, index, addIndex, pIndex) {
|
async quantityFun(type, index, addIndex, pIndex) {
|
||||||
|
console.log("数量进行增加删除---",this.orderInfo,)
|
||||||
|
|
||||||
const data = this.orderInfo.shops[index].addrTimes[addIndex].goods[pIndex];
|
const data = this.orderInfo.shops[index].addrTimes[addIndex].goods[pIndex];
|
||||||
|
|
||||||
|
// 起订倍数
|
||||||
|
const minBuyNum =data.minBuyNum || 1; // 起订倍数
|
||||||
|
const step = Math.max(minBuyNum, 1);
|
||||||
|
|
||||||
let currentQuantity = Number(data.num);// 当前数量
|
let currentQuantity = Number(data.num);// 当前数量
|
||||||
let currentTotalPrice = Number(data.totalPrice);// 当前金额
|
let currentTotalPrice = Number(data.totalPrice);// 当前金额
|
||||||
let currentAmount = Number(this.orderInfo.amount);// 总金额
|
let currentAmount = Number(this.orderInfo.amount);// 总金额
|
||||||
@@ -507,13 +514,13 @@ export default {
|
|||||||
message: "不能再减拉,不能小于最低购买数量~",
|
message: "不能再减拉,不能小于最低购买数量~",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
currentQuantity = currentQuantity - 1;
|
currentQuantity = currentQuantity - step;
|
||||||
currentAmount = currentAmount - data.unitPrice;
|
currentAmount = currentAmount - data.unitPrice;
|
||||||
currentTotalPrice = currentTotalPrice - data.unitPrice;
|
currentTotalPrice = currentTotalPrice - data.unitPrice;
|
||||||
}
|
}
|
||||||
} else if (type === "add") {
|
} else if (type === "add") {
|
||||||
// 需要判断一下库存
|
// 需要判断一下库存
|
||||||
currentQuantity = currentQuantity + 1;
|
currentQuantity = currentQuantity + step;
|
||||||
currentAmount = currentAmount + data.unitPrice;
|
currentAmount = currentAmount + data.unitPrice;
|
||||||
currentTotalPrice = currentTotalPrice + data.unitPrice;
|
currentTotalPrice = currentTotalPrice + data.unitPrice;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@
|
|||||||
:class="oItem.inventory === 0 ? 'item_Warp item_Warp_no_warp' : item.selectVal === oItem.n ? 'item_Warp item_Warp_yes_warp' : 'item_Warp'"
|
:class="oItem.inventory === 0 ? 'item_Warp item_Warp_no_warp' : item.selectVal === oItem.n ? 'item_Warp item_Warp_yes_warp' : 'item_Warp'"
|
||||||
v-for="(oItem, oIndex) in item.items"
|
v-for="(oItem, oIndex) in item.items"
|
||||||
:key="oItem.n"
|
:key="oItem.n"
|
||||||
@click="clickSpecification(index, oItem)"
|
@click="clickSpecification(index,item, oItem)"
|
||||||
>
|
>
|
||||||
{{ oItem.n }}
|
{{ oItem.n }}
|
||||||
</view>
|
</view>
|
||||||
@@ -433,10 +433,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
//改变规格的样式
|
//改变规格的样式
|
||||||
clickSpecification(pIndex, oItem) {
|
clickSpecification(pIndex,item, oItem) {
|
||||||
// if(oItem.inventory<=0){
|
console.log("改变规格的样式",item,oItem,this.specificationTempl)
|
||||||
// return;
|
|
||||||
// }
|
const currentSelectSpecification = this.specificationTempl.find(ele=>ele.combTypes == item.type && ele.combNames == oItem.n);
|
||||||
|
console.log("当前规格",currentSelectSpecification)
|
||||||
|
this.orderInfo.quantity = currentSelectSpecification?.minBuyNum || 1;
|
||||||
|
|
||||||
this.specificationList[pIndex].selectVal = oItem.n;
|
this.specificationList[pIndex].selectVal = oItem.n;
|
||||||
// 计算规格的价格
|
// 计算规格的价格
|
||||||
this.selectSpecificationFun(pIndex, oItem);
|
this.selectSpecificationFun(pIndex, oItem);
|
||||||
@@ -467,6 +470,7 @@ export default {
|
|||||||
quantityFun(type) {
|
quantityFun(type) {
|
||||||
let currentQuantity = this.orderInfo.quantity; // 当前数量
|
let currentQuantity = this.orderInfo.quantity; // 当前数量
|
||||||
const minBuyNum = this.selectSpecificationTempl.minBuyNum || 1; // 当前起订量,默认为1
|
const minBuyNum = this.selectSpecificationTempl.minBuyNum || 1; // 当前起订量,默认为1
|
||||||
|
console.log(' 当前起订量,默认为1',currentQuantity,minBuyNum)
|
||||||
|
|
||||||
// 确保起订量至少为1
|
// 确保起订量至少为1
|
||||||
const step = Math.max(minBuyNum, 1);
|
const step = Math.max(minBuyNum, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user