This commit is contained in:
魏啾
2024-08-03 11:31:54 +08:00
2 changed files with 25 additions and 51 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

@@ -347,6 +347,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,
@@ -516,31 +517,18 @@
* @param {Object} b * @param {Object} b
*/ */
shopAdd(item, index, index1, a, b) { shopAdd(item, index, index1, a, b) {
let flag = true; if ( a == "+" ){
if (this.cartLists.data.length > 0) { if ( this.skuNumber < this.skuSuit) {
this.cartLists.data.forEach((v, e) => { this.amountcartNumber = this.amountcartNumber + (item.suit==0?1:item.suit);
if (v.productId == item.id) { }else {
flag = false;
}
console.log(v)
})
}
console.log(a)
console.log(this.amountcartNumber)
console.log(flag)
console.log(item)
if (a == "+") {
if (this.amountcartNumber <= 0 && flag) {
this.amountcartNumber = this.amountcartNumber + (item.suit == 0 ? 1 : item.suit);
} else {
this.amountcartNumber++; this.amountcartNumber++;
} }
} else { } else {
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;
} }
@@ -729,33 +717,26 @@
productId: item.id, //商品id productId: item.id, //商品id
spec_tag: this.skuidname.join(",") spec_tag: this.skuidname.join(",")
}) })
if (res.data.stockNumber == 0) { this.salePrice = res.data.salePrice // 价格
uni.showToast({ let data = null;
title: '暂无库存', if (a == 1) { //1添加购物车 2是websocket返回这个商品的价格(应为不同的多规格商品返回不同的价格)
icon: "none", let params = {
}) "skuId": res.data.id,
} else { "num": num, //数量
this.skuidsearch = res.data.id // 储存skuid 用于筛选数量 "type": c == '+' ? 1 : 0,
this.salePrice = res.data.salePrice // 价格 "productId": item.id, //商品id
let data = null; "shopId": uni.cache.get('shopUser'),
if (a == 1) { //1添加购物车 2是websocket返回这个商品的价格(应为不同的多规格商品返回不同的价格) "userId": uni.cache.get('userInfo').id,
let params = { "tableId": uni.cache.get('tableCode'),
"skuId": res.data.id,
"num": num, //数量
"type": c == '+' ? 1 : 0,
"productId": item.id, //商品id
"shopId": uni.cache.get('shopUser'),
"userId": uni.cache.get('userInfo').id,
"tableId": uni.cache.get('tableCode'),
}
this.addCart(params);
} else {
this.skuId = res.data.id;
this.skuNumber = res.data.number;
this.showShopsku = true //打开弹框
} }
this.$set(this, 'amountcartNumber', 0) this.addCart(params);
} else {
this.skuId = res.data.id;
this.skuNumber = res.data.number;
this.skuSuit = res.data.suit;
this.showShopsku = true //打开弹框
} }
this.$set(this, 'amountcartNumber', 0)
} catch (e) {} } catch (e) {}
}, },