Commit dfe5c97c by 宋冰琦

修改首页加购逻辑

parent 2837aad0
......@@ -135,7 +135,7 @@ export default {
uni.removeStorageSync('goodsList');
const goodsInfo = JSON.parse(uni.getStorageSync('goodsInfo'));
this.goodInfo = goodsInfo;
console.log(this.goodInfo);
console.log(JSON.parse(JSON.stringify(this.goodInfo)));
const skus = goodsInfo.skus;
if (skus) {
const sku = skus.find(v => v.isDefault == 1 && v.state == 1) || skus.find(v => v.isDefault == 0 && v.state == 1);
......@@ -274,7 +274,14 @@ export default {
}
const { goods } = this;
const { data } = await Order.checkSku({skuId:goods.skuId})
if(data.data&&data.data.state===2){
const {state,goods:newgoods} = data.data
const newInfo = JSON.parse(JSON.stringify(newgoods))
newInfo.skus.map(res=>res.state = 2)
this.goodInfo = {...newInfo}
console.log(this.goodInfo)
if(state==1){
this.showToast({ title: '本商品已经售罄', icon: 'none' });
return;
}else{
......
......@@ -265,16 +265,18 @@ export default {
let itemCopy = JSON.parse(JSON.stringify(item));
const sku = itemCopy.skus.find(v => v.isDefault == 1 && v.state != 2) || itemCopy.skus.find(v => v.isDefault == 0 && v.state != 2);
const {data} = await Order.checkSku({skuId:sku.skuId})
if(data.data&&data.data.state===2){
const {goods} = data.data
const newsku = goods.skus.find(v => v.isDefault == 1 && v.state != 2) || goods.skus.find(v => v.isDefault == 0 && v.state != 2);
if(!newsku){
this.showToast({ title: '本商品已经售罄', icon: 'none' });
return;
}else{
if(sku.isDefault != 1){
if(newsku.isDefault != 1){
this.showToast({ title: '默认规格已售罄,已添加其他规格', icon: 'none' });
}
itemCopy.skus = [sku];
itemCopy.sku = sku
itemCopy.skuId = sku?.skuId
itemCopy.skus = [newsku];
itemCopy.sku = newsku
itemCopy.skuId = newsku?.skuId
itemCopy.num = 1;
itemCopy.flag = true;
itemCopy.categoryId = category.id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment