shish 1 сар өмнө
parent
commit
b9dc167f41

+ 219 - 1
ghsApp/src/admin/billing/index2.vue

@@ -53,6 +53,8 @@
 							</view>
 						</view>
 					</view>
+					<!-- 底部占位,避免最后一项花材被底部「选好了」栏遮挡 -->
+					<view style="height: 200upx;"></view>
 				</block>
 				<block v-else>
 					<app-wrapper-empty title="加载中" :is-empty="$util.isEmpty(globalItemData)" />
@@ -111,7 +113,43 @@
 			</template>
 		</modal-module>
 
-		<footer-cart :price="allPrice" :count="allCount" @confirm="confirmToSave" ></footer-cart>
+		<footer-cart :price="allPrice" :count="allCount" @confirm="confirmToSave" @showCartItem="showCartItem"></footer-cart>
+
+		<!-- 购物车弹框:展示已选花材列表 -->
+		<view v-if="cartItemShow == true" class="cart-popup-mask" @click="hideCartItem()">
+			<!-- 弹框底部需留出底部购物车栏高度,避免最后一项被「选好了」遮挡 -->
+			<view class="cart-popup-panel" @click.stop="">
+				<view class="commodity-view">
+					<view class="summary-bar">
+						<button class="admin-button-com blue middle" @click.stop="clearCartInPopup()" style="background-color: red;border:1upx solid red;">清空购物车</button>
+					</view>
+					<view class="commodity-list">
+						<view class="commodity-item" v-for="(item, index) in selectList" :key="index">
+							<image class="item-icon" :src="item.cover" />
+							<view class="item-info">
+								<view class="info-line">
+									<text class="item-name">{{ item.name }}</text>
+									<text class="item-price">
+										<text class="unit">¥</text>
+										<text class="price">{{ getCartItemUnitPrice(item) }}</text>
+									</text>
+								</view>
+								<view style="text-align:right;">
+									<view class="open-bx">
+										<text class="iconfont iconjian" @click.stop="delItem(item)" v-if="item.bigCount > 0 || item.smallCount > 0"></text>
+										<text class="num" @click.stop="customUpdate(item)">
+											<text v-if="item.bigCount > 0" style="font-weight:bold;color:#3385ff;">{{ item.bigCount }}</text>
+											<text v-if="item.smallCount > 0"><text v-if="item.bigCount > 0">/</text>{{ item.smallCount }}</text>
+										</text>
+										<text class="iconfont iconzeng" @click.stop="addAction(item)"></text>
+									</view>
+								</view>
+							</view>
+						</view>
+					</view>
+				</view>
+			</view>
+		</view>
 
 		<uni-popup ref="globalClassImgRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
 			<view style="display:flex;padding:20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;">
@@ -161,6 +199,7 @@ export default {
 			xjDataInfo:{},
 			treeData:{},
 			treeDataInfo:{},
+			cartItemShow: false,
 		};
 	},
 	computed: {
@@ -318,6 +357,83 @@ export default {
 		selectFlowerNumFn(){
 			this.$refs.globalClassImgRef.open('top')
 		},
+		/**
+		 * 展开/收起购物车弹框
+		 */
+		showCartItem() {
+			if (this.cartItemShow == true) {
+				this.cartItemShow = false
+			} else if (!this.$util.isEmpty(this.selectList)) {
+				this.cartItemShow = true
+			}
+		},
+		/**
+		 * 关闭购物车弹框
+		 */
+		hideCartItem() {
+			this.cartItemShow = false
+		},
+		/**
+		 * 弹框内清空购物车
+		 */
+		clearCartInPopup() {
+			this.cartItemShow = false
+			this.removeFromSave()
+		},
+		/**
+		 * 获取购物车单项单价
+		 * @param {object} item - 已选花材
+		 */
+		getCartItemUnitPrice(item) {
+			if (item.userPrice > 0) {
+				return parseFloat(item.userPrice).toFixed(2)
+			}
+			return parseFloat(item.bigPrice || item.price || 0).toFixed(2)
+		},
+		/**
+		 * 购物车弹框内减少数量
+		 * @param {object} item - 已选花材
+		 */
+		delItem(item) {
+			if (item.variety == 1) {
+				this.$msg('多颜色请在列表里修改')
+				return
+			}
+			this.replaceItemFn(item, 0, 'sub')
+		},
+		/**
+		 * 购物车弹框内增加数量
+		 * @param {object} item - 已选花材
+		 */
+		addAction(item) {
+			if (item.variety == 1) {
+				this.$msg('多颜色请在列表里修改')
+				return
+			}
+			if (this.globalCheckStock) {
+				const ratio = Number(item.ratio) || 1
+				const bigCount = Number(item.bigCount) || 0
+				const smallCount = Number(item.smallCount) || 0
+				const bigNum = Number(item.bigNum) || 0
+				const smallNum = Number(item.smallNum) || 0
+				if (bigCount * ratio + smallCount + 1 > bigNum * ratio + smallNum) {
+					this.$msg('库存不足哦')
+					return
+				}
+			}
+			this.replaceItemFn(item, 0, 'add')
+		},
+		/**
+		 * 购物车弹框内点击数量,打开编辑弹框
+		 * @param {object} item - 已选花材
+		 */
+		customUpdate(item) {
+			if (item.variety == 1) {
+				this.$msg('多颜色请在列表里修改')
+				return
+			}
+			this.showAddModelFn(item)
+		},
 		confirmToSave() {
 			if(this.$util.isEmpty(this.selectList)){
 				this.$msg('请选择花材')
@@ -468,4 +584,106 @@ export default {
 	color:red;
 	font-weight:bold;
 }
+
+/* 购物车弹框遮罩 */
+.cart-popup-mask {
+	position: fixed;
+	z-index: 190;
+	top: 0;
+	left: 0;
+	width: 100vw;
+	height: 100vh;
+	background: rgba(0, 0, 0, 0.6);
+	color: #fff;
+}
+/* 弹框面板:bottom 对齐底部购物车栏上沿(约 118upx + 安全区) */
+.cart-popup-panel {
+	position: fixed;
+	bottom: calc(140upx + env(safe-area-inset-bottom));
+	left: 0;
+	width: 100vw;
+	background-color: white;
+	max-height: calc(100vh - 140upx - env(safe-area-inset-bottom));
+}
+
+.commodity-view {
+	display: flex;
+	flex-direction: column;
+	max-height: calc(100vh - 140upx - env(safe-area-inset-bottom));
+	.commodity-list {
+		overflow: scroll;
+		flex: 1;
+		max-height: 50vh;
+		padding: 20upx;
+		/* 列表底部留白,滚动到底时最后一项不被底部栏挡住 */
+		padding-bottom: 60upx;
+		.commodity-item {
+			display: flex;
+			margin-bottom: 20upx;
+			.item-icon {
+				flex-shrink: 0;
+				width: 140upx;
+				height: 140upx;
+			}
+			.item-info {
+				display: flex;
+				flex-direction: column;
+				justify-content: center;
+				flex: 1;
+				margin-left: 20upx;
+				.info-line {
+					margin-bottom: 20upx;
+					display: flex;
+					justify-content: space-between;
+					align-items: flex-end;
+					.item-name {
+						color: #666;
+						font-size: 28upx;
+						overflow: hidden;
+						white-space: nowrap;
+						text-overflow: ellipsis;
+						width: 400upx;
+					}
+					.item-price {
+						color: #333;
+						font-size: 22upx;
+						.price {
+							font-size: 32upx;
+							font-weight: bold;
+						}
+					}
+				}
+				.open-bx {
+					display: flex;
+					align-items: center;
+					justify-content: flex-end;
+					.iconfont {
+						color: #3385ff;
+						font-size: 60upx;
+					}
+					.num {
+						display: inline-block;
+						width: 130upx;
+						height: 55upx;
+						line-height: 55upx;
+						text-align: center;
+						margin: 0 8upx;
+						color: #868686;
+						border-radius: 22upx;
+						background-color: #f5f5f5;
+						font-size: 28upx;
+					}
+				}
+			}
+		}
+	}
+	.summary-bar {
+		padding: 0 20upx;
+		height: 90upx;
+		display: flex;
+		align-items: center;
+		justify-content: space-between;
+		border-top: 1upx solid #eeeeee;
+	}
+}
 </style>

+ 5 - 1
ghsApp/src/components/module/app-footer-cart.vue

@@ -1,7 +1,7 @@
 <template>
 	<view class="cart-ft_bx">
 		<view class="cart-ct_bx">
-			<view class="cart-lf_bx">
+			<view class="cart-lf_bx" @click="showCartItem">
 				<view class="cart-dot_bx">
 					<i class="iconfont icongouwuche"></i>
 				</view>
@@ -39,6 +39,10 @@ export default {
 	methods: {
 		confirmEvent() {
 			this.$emit("confirm");
+		},
+		// 点击左侧购物车区域,展开已选花材列表
+		showCartItem() {
+			this.$emit("showCartItem");
 		}
 	}
 };

+ 1 - 1
hdApp/src/pagesPurchase/ghsProduct.vue

@@ -101,7 +101,7 @@
 			<view style="position: fixed;bottom: 108upx;width:100vw;background-color:white;" @click.stop="">
 				<view class="commodity-view">
 					<view class="summary-bar">
-						<button class="admin-button-com blue middle" @click.stop="delMemory()" style="background-color: red;border:1upx solid red;">清空购物</button>
+						<button class="admin-button-com blue middle" @click.stop="delMemory()" style="background-color: red;border:1upx solid red;">清空购物</button>
 					</view>
 					<view class="commodity-list">
 						<view class="commodity-item" v-for="(item, index) in selectList" :key="index">