规格数量处理
This commit is contained in:
@@ -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: [],
|
||||||
|
|||||||
@@ -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,33 +741,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) {}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user