规格数量处理

This commit is contained in:
GaoHao
2024-08-03 11:19:44 +08:00
parent 0e3e975627
commit 520d791326
2 changed files with 31 additions and 42 deletions

View File

@@ -104,14 +104,8 @@
<text class="topUpNow" @click="goRecharge">去充值</text> <text class="topUpNow" @click="goRecharge">去充值</text>
</view> </view>
</view> </view>
</block> </block>
</u-radio-group> </u-radio-group>
</view> </view>
</view> </view>
@@ -179,7 +173,6 @@
order: { order: {
phone: "", phone: "",
}, },
passwordArr: [],
cartLists: [], cartLists: [],
listinfo: { listinfo: {
details: [], details: [],

View File

@@ -350,6 +350,7 @@
socketTicket: null, socketTicket: null,
amountcartNumber: 0, amountcartNumber: 0,
skuNumber: 0, skuNumber: 0,
skuSuit: 0,
salePrice: '', //钱数 salePrice: '', //钱数
cartListsdatashow: false, //是否显示购物车 cartListsdatashow: false, //是否显示购物车
showCart: false, showCart: false,
@@ -526,20 +527,22 @@
*/ */
shopAdd(item, index, index1, a, b) { shopAdd(item, index, index1, a, b) {
let flag = true; let flag = true;
if ( this.cartLists.data.length > 0) { // if ( this.cartLists.data.length > 0) {
this.cartLists.data.forEach((v,e)=>{ // this.cartLists.data.forEach((v,e)=>{
if ( v.productId == item.id) { // if ( v.productId == item.id) {
flag = false; // flag = false;
} // }
console.log(v) // console.log(v)
}) // })
} // }
console.log(a) console.log(a)
console.log(this.amountcartNumber) console.log(this.amountcartNumber)
console.log(this.skuNumber)
console.log(this.skuSuit)
console.log(flag) console.log(flag)
console.log(item) console.log(item)
if ( a == "+" ){ if ( a == "+" ){
if ( this.amountcartNumber <= 0 && flag) { if ( this.skuNumber < this.skuSuit) {
this.amountcartNumber = this.amountcartNumber + (item.suit==0?1:item.suit); this.amountcartNumber = this.amountcartNumber + (item.suit==0?1:item.suit);
}else { }else {
this.amountcartNumber++; this.amountcartNumber++;
@@ -548,7 +551,7 @@
if (this.amountcartNumber > 0) { if (this.amountcartNumber > 0) {
console.log(item) console.log(item)
if ( this.amountcartNumber <= item.suit && flag) { if ( this.skuNumber < this.skuSuit) {
this.amountcartNumber = this.amountcartNumber - (item.suit==0?1:item.suit); this.amountcartNumber = this.amountcartNumber - (item.suit==0?1:item.suit);
} else { } else {
this.amountcartNumber = this.amountcartNumber - 1; this.amountcartNumber = this.amountcartNumber - 1;
@@ -738,13 +741,6 @@
productId: item.id, //商品id productId: item.id, //商品id
spec_tag: this.skuidname.join(",") spec_tag: this.skuidname.join(",")
}) })
if (res.data.stockNumber == 0) {
uni.showToast({
title: '暂无库存',
icon: "none",
})
} else {
this.skuidsearch = res.data.id // 储存skuid 用于筛选数量
this.salePrice = res.data.salePrice // 价格 this.salePrice = res.data.salePrice // 价格
let data = null; let data = null;
if (a == 1) { //1添加购物车 2是websocket返回这个商品的价格(应为不同的多规格商品返回不同的价格) if (a == 1) { //1添加购物车 2是websocket返回这个商品的价格(应为不同的多规格商品返回不同的价格)
@@ -761,10 +757,10 @@
} else { } else {
this.skuId = res.data.id; this.skuId = res.data.id;
this.skuNumber = res.data.number; this.skuNumber = res.data.number;
this.skuSuit = res.data.suit;
this.showShopsku = true //打开弹框 this.showShopsku = true //打开弹框
} }
this.$set(this, 'amountcartNumber', 0) this.$set(this, 'amountcartNumber', 0)
}
} catch (e) {} } catch (e) {}
}, },