增加确认订单页面菜品折叠,修改商品购物车数量显示
This commit is contained in:
@@ -40,9 +40,19 @@
|
||||
:nowCarts="nowCarts"
|
||||
:limitDiscount="cartStore.limitTimeDiscount"
|
||||
></orderItemVue> -->
|
||||
<orderItemVue :useVipPrice="useVipPrice" v-if="cartStore.allGoods.length" :nowCarts="cartStore.allGoods"
|
||||
<orderItemVue :useVipPrice="useVipPrice" v-if="nowCarts" :nowCarts="nowCarts"
|
||||
:shopInfo="cartStore.shopInfo" :shopUserInfo="cartStore.shopUserInfo"
|
||||
:limitDiscount="cartStore.limitTimeDiscount"></orderItemVue>
|
||||
|
||||
<view class="u-flex u-row-center u-m-t-16 u-font-28">
|
||||
<view class="u-flex u-col-baseline" @click="showAllGoods=!showAllGoods">
|
||||
<text>{{showAllGoods?'收起':'展开'}}</text>
|
||||
<view class="guodu u-m-l-10 u-m-t-2" :class="{rotate:!showAllGoods}">
|
||||
<up-icon name="arrow-down" size="14"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<template v-if="listinfo.id&&listinfo.status=='done'">
|
||||
<view class="cell-item" v-if="is_type != 0">
|
||||
@@ -328,7 +338,9 @@
|
||||
import {
|
||||
BigNumber
|
||||
} from "bignumber.js";
|
||||
|
||||
|
||||
|
||||
const showAllGoods=ref(false)
|
||||
let hasCouponCanUse = ref(false);
|
||||
|
||||
const usePoints = ref(false);
|
||||
@@ -852,6 +864,16 @@
|
||||
await getConsumeDiscount();
|
||||
getDiscountActivity();
|
||||
});
|
||||
|
||||
const nowCarts=computed(()=>{
|
||||
if(cartStore.allGoods.length<=0){
|
||||
return []
|
||||
}
|
||||
if(showAllGoods.value){
|
||||
return cartStore.allGoods
|
||||
}
|
||||
return cartStore.allGoods.slice(0,4)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -1587,4 +1609,11 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
.guodu{
|
||||
transition:all .3s linear;
|
||||
padding-top: 2rpx;
|
||||
}
|
||||
.rotate{
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
</style>
|
||||
@@ -148,8 +148,10 @@
|
||||
@click.stop="clickspecifications(item, index, index1)">
|
||||
<text class="t no-wrap" v-if="item.groupType == '1'">选择套餐</text>
|
||||
<text class="t" v-else>选规格</text>
|
||||
<!-- <text class="dot num"
|
||||
v-if="item.cartNumber > 0">{{ ifcartNumber(item) < 99 ? ifcartNumber(item) : '99+' }}</text> -->
|
||||
<text class="dot num"
|
||||
v-if="item.cartNumber > 0">{{ ifcartNumber(item) < 99 ? ifcartNumber(item) : '99+' }}</text>
|
||||
v-if="returnGoodsImCartNum(item)">{{ returnGoodsImCartNum(item) < 99 ? returnGoodsImCartNum(item) : '99+' }}</text>
|
||||
</view>
|
||||
<view class="Controls" v-else>
|
||||
<view class="btn" v-if="item.cartNumber != '0'">
|
||||
@@ -288,8 +290,11 @@
|
||||
@click.stop="clickspecifications(item1, index, index1)">
|
||||
<text class="t no-wrap" v-if="item1.groupType == '1'">选择套餐</text>
|
||||
<text class="t" v-else>选规格</text>
|
||||
<text class="dot num"
|
||||
v-if="item1.cartNumber > 0">{{ ifcartNumber(item1) < 99 ? ifcartNumber(item1) : '99+' }}</text>
|
||||
<!-- <text class="dot num"
|
||||
v-if="item1.cartNumber > 0">{{ ifcartNumber(item1) < 99 ? ifcartNumber(item1) : '99+' }}</text> -->
|
||||
|
||||
<text class="dot num"
|
||||
v-if="returnGoodsImCartNum(item1)">{{ returnGoodsImCartNum(item1) < 99 ? returnGoodsImCartNum(item1) : '99+' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="Controls" v-else>
|
||||
@@ -700,6 +705,7 @@
|
||||
import {
|
||||
useCartStore
|
||||
} from '@/stores/order.js';
|
||||
import { computed } from 'vue';
|
||||
const cartStore = useCartStore();
|
||||
/**
|
||||
* store本地存储 end
|
||||
@@ -800,9 +806,35 @@
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 购物车对应的商品数
|
||||
const GoodsIDInCartNumMap=computed(()=>{
|
||||
const map={}
|
||||
for(let cart in cartStore.carts){
|
||||
if(map[cart.product_id]){
|
||||
map[cart.product_id]+=cart.number*1
|
||||
}else{
|
||||
map[cart.product_id]=cart.number*1
|
||||
}
|
||||
|
||||
}
|
||||
return map
|
||||
})
|
||||
|
||||
/**
|
||||
* 返回购物车对应的商品数量
|
||||
*/
|
||||
function returnGoodsImCartNum(goods){
|
||||
if(GoodsIDInCartNumMap.value.hasOwnProperty([goods.id]) ){
|
||||
GoodsIDInCartNumMap.value[goods.id]
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
// 获取商品数据
|
||||
const shopProductList = reactive({
|
||||
@@ -2106,7 +2138,6 @@
|
||||
//第一步:将所有商品的 cartNumber 初始化为 0
|
||||
shopProductList.productInfo.forEach((group) => {
|
||||
group.productList.forEach(async (product) => {
|
||||
product.cartNumber = 0;
|
||||
product.isSaleTimeshow = await isProductAvailable(product.days, product
|
||||
.startTime, product.endTime);
|
||||
|
||||
@@ -2116,7 +2147,6 @@
|
||||
});
|
||||
});
|
||||
shopProductList.hots.forEach(async (i) => {
|
||||
i.cartNumber = 0;
|
||||
i.isSaleTimeshow = await isProductAvailable(i.days, i.startTime, i.endTime);
|
||||
allGoodsArr.push(i)
|
||||
cartStore.setGoodsMap(i.id, i);
|
||||
|
||||
Reference in New Issue
Block a user