|
|
@ -45,8 +45,8 @@ |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="main-right-list-count-row"> |
|
|
|
<image mode="aspectFit" src="/static/images/icon/retail/sub.png" @click="mainCountClick('sub', scrollItem.id, item.id)"></image> |
|
|
|
<view>{{ item.count }}</view> |
|
|
|
<image v-if="item.count>0?true:false" mode="aspectFit" src="/static/images/icon/retail/sub.png" @click="mainCountClick('sub', scrollItem.id, item.id)"></image> |
|
|
|
<view v-if="item.count>0?true:false">{{ item.count }}</view> |
|
|
|
<image mode="aspectFit" src="/static/images/icon/retail/add.png" @click="mainCountClick('add', scrollItem.id, item.id)"></image> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -235,20 +235,41 @@ export default { |
|
|
|
|
|
|
|
// 购物车列表数量选项触发 |
|
|
|
cartCountClick(type, i) { |
|
|
|
// 增减购物车对应的主页数量 |
|
|
|
let curId = this.cartList[i].id; |
|
|
|
let mainItem = null; |
|
|
|
for (let i = 0; i < this.goodsInfo.length; ++i) { |
|
|
|
for (let j = 0; j < this.goodsInfo[i].goodsData.length; ++j) { |
|
|
|
if (curId == this.goodsInfo[i].goodsData[j].id) { |
|
|
|
mainItem = this.goodsInfo[i].goodsData[j]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
case "add": { |
|
|
|
this.cartList[i].count += 1; |
|
|
|
mainItem.count += 1; |
|
|
|
} break; |
|
|
|
case "sub": { |
|
|
|
if (this.cartList[i].count <= 0) { |
|
|
|
return; |
|
|
|
if (this.cartList[i].count > 0) { |
|
|
|
this.cartList[i].count -= 1; |
|
|
|
} |
|
|
|
|
|
|
|
this.cartList[i].count -= 1; |
|
|
|
if (mainItem.count > 0) { |
|
|
|
mainItem.count -= 1; |
|
|
|
} |
|
|
|
} break; |
|
|
|
} |
|
|
|
|
|
|
|
// 没数量了就删掉 |
|
|
|
if (this.cartList[i].count <= 0) { |
|
|
|
this.cartList.splice(i, 1); |
|
|
|
} |
|
|
|
|
|
|
|
this.calcCartTotalPriceAndCount(); // 计算购物车总价跟总量 |
|
|
|
this.calcTotalPriceAndCount(); // 计算总价跟总量 |
|
|
|
this.cartListStatusChange(); // 购物车列表状态变化 |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取购物车列表的最终数据 |
|
|
@ -301,6 +322,28 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 购物车列表状态变化 |
|
|
|
cartListStatusChange() { |
|
|
|
// 根据数量改变列表高度 |
|
|
|
let num = this.cartList.length; |
|
|
|
this.cartListScroll = false; |
|
|
|
if (this.cartList.length > 5) { |
|
|
|
num = 5; |
|
|
|
this.cartListScroll = true; |
|
|
|
} |
|
|
|
|
|
|
|
// 只有一条数据就不会显示border |
|
|
|
if (this.cartList.length <= 1) { |
|
|
|
this.cartListItemBorderBottom = "0rpx solid rgb(216,216,216)"; |
|
|
|
} |
|
|
|
else { |
|
|
|
this.cartListItemBorderBottom = "1rpx solid rgb(216,216,216)"; |
|
|
|
} |
|
|
|
|
|
|
|
this.cartListHeight = `${151.6 * num}rpx`; |
|
|
|
this.cartListDialogHeight = `${(878 - 758) + 151.6 * num}rpx`; |
|
|
|
}, |
|
|
|
|
|
|
|
// 购物车点击 |
|
|
|
cartClick() { |
|
|
|
if (this.isShowCartList) { |
|
|
@ -308,27 +351,8 @@ export default { |
|
|
|
} |
|
|
|
else { |
|
|
|
this.addToCartList(); // 将主页数据加入到购物车列表 |
|
|
|
|
|
|
|
// 根据数量改变列表高度 |
|
|
|
let num = this.cartList.length; |
|
|
|
this.cartListScroll = false; |
|
|
|
if (this.cartList.length > 5) { |
|
|
|
num = 5; |
|
|
|
this.cartListScroll = true; |
|
|
|
} |
|
|
|
|
|
|
|
// 只有一条数据就不会显示border |
|
|
|
if (this.cartList.length <= 1) { |
|
|
|
this.cartListItemBorderBottom = "0rpx solid rgb(216,216,216)"; |
|
|
|
} |
|
|
|
else { |
|
|
|
this.cartListItemBorderBottom = "1rpx solid rgb(216,216,216)"; |
|
|
|
} |
|
|
|
|
|
|
|
this.cartListHeight = `${151.6 * num}rpx`; |
|
|
|
this.cartListDialogHeight = `${(878 - 758) + 151.6 * num}rpx`; |
|
|
|
this.cartListStatusChange(); // 购物车列表状态变化 |
|
|
|
this.isShowCartList = true; |
|
|
|
|
|
|
|
this.calcCartTotalPriceAndCount(); // 计算购物车总价跟总量 |
|
|
|
} |
|
|
|
}, |
|
|
@ -533,6 +557,8 @@ export default { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
_this.totalCount = 0; |
|
|
|
_this.totalPrice = 0; |
|
|
|
_this.goodsInfo[0].isSearch = false; |
|
|
|
_this.goodsInfo[0].goodsData = []; |
|
|
|
_this.goodsInfo[1].style = _this.categoryBtnStyle.click; |
|
|
@ -724,6 +750,8 @@ export default { |
|
|
|
padding-bottom: 24rpx; |
|
|
|
|
|
|
|
>view { |
|
|
|
padding-right: 24rpx; |
|
|
|
|
|
|
|
&:first-child { |
|
|
|
font-size: 28rpx; |
|
|
|
} |
|
|
|