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>
</view>
</view>
</block>
</u-radio-group>
</view>
</view>
@@ -179,7 +173,6 @@
order: {
phone: "",
},
passwordArr: [],
cartLists: [],
listinfo: {
details: [],

View File

@@ -347,6 +347,7 @@
socketTicket: null,
amountcartNumber: 0,
skuNumber: 0,
skuSuit: 0,
salePrice: '', //钱数
cartListsdatashow: false, //是否显示购物车
showCart: false,
@@ -516,31 +517,18 @@
* @param {Object} b
*/
shopAdd(item, index, index1, a, b) {
let flag = true;
if (this.cartLists.data.length > 0) {
this.cartLists.data.forEach((v, e) => {
if (v.productId == item.id) {
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 {
if ( a == "+" ){
if ( this.skuNumber < this.skuSuit) {
this.amountcartNumber = this.amountcartNumber + (item.suit==0?1:item.suit);
}else {
this.amountcartNumber++;
}
} else {
if (this.amountcartNumber > 0) {
console.log(item)
if (this.amountcartNumber <= item.suit && flag) {
this.amountcartNumber = this.amountcartNumber - (item.suit == 0 ? 1 : item.suit);
if ( this.skuNumber < this.skuSuit) {
this.amountcartNumber = this.amountcartNumber - (item.suit==0?1:item.suit);
} else {
this.amountcartNumber = this.amountcartNumber - 1;
}
@@ -729,33 +717,26 @@
productId: item.id, //商品id
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 // 价格
let data = null;
if (a == 1) { //1添加购物车 2是websocket返回这个商品的价格(应为不同的多规格商品返回不同的价格)
let params = {
"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.salePrice = res.data.salePrice // 价格
let data = null;
if (a == 1) { //1添加购物车 2是websocket返回这个商品的价格(应为不同的多规格商品返回不同的价格)
let params = {
"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.$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) {}
},