|
@@ -31,8 +31,8 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <!-- 数量选择器 -->
|
|
|
|
|
- <view class="cart-item__actions">
|
|
|
|
|
|
|
+ <!-- 数量选择器(餐具费 0 元时不可修改) -->
|
|
|
|
|
+ <view class="cart-item__actions" :class="{ 'cart-item__actions--disabled': !canEditItemQuantity(item) }">
|
|
|
<view class="action-btn minus" :class="{ disabled: item.quantity === 0 }"
|
|
<view class="action-btn minus" :class="{ disabled: item.quantity === 0 }"
|
|
|
@click="handleDecrease(item)" hover-class="hover-active">
|
|
@click="handleDecrease(item)" hover-class="hover-active">
|
|
|
<image :src="getFileUrl('img/icon/reduce1.png')" mode="aspectFit" class="action-icon"
|
|
<image :src="getFileUrl('img/icon/reduce1.png')" mode="aspectFit" class="action-icon"
|
|
@@ -119,27 +119,37 @@ const getItemLinePrice = (item) => {
|
|
|
return qty * unitPrice;
|
|
return qty * unitPrice;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-// 餐具(cuisineId 或 id 为 -1)可修改数量(含减至 0)
|
|
|
|
|
|
|
+// 餐具(cuisineId 或 id 为 -1)可修改数量(含减至 0);餐具费为 0 元时不允许修改数量
|
|
|
const isTablewareItem = (item) => {
|
|
const isTablewareItem = (item) => {
|
|
|
if (!item) return false;
|
|
if (!item) return false;
|
|
|
const id = item.cuisineId ?? item.id;
|
|
const id = item.cuisineId ?? item.id;
|
|
|
return Number(id) === -1;
|
|
return Number(id) === -1;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+// 该项是否允许修改数量:非餐具允许;餐具仅当单价>0 时允许
|
|
|
|
|
+const canEditItemQuantity = (item) => {
|
|
|
|
|
+ if (!item) return false;
|
|
|
|
|
+ if (!isTablewareItem(item)) return true;
|
|
|
|
|
+ const price = getItemPrice(item);
|
|
|
|
|
+ return Number(price) > 0;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
// 处理关闭
|
|
// 处理关闭
|
|
|
const handleClose = () => {
|
|
const handleClose = () => {
|
|
|
getOpen.value = false;
|
|
getOpen.value = false;
|
|
|
emit('close');
|
|
emit('close');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-// 增加数量
|
|
|
|
|
|
|
+// 增加数量(餐具费 0 元时不触发)
|
|
|
const handleIncrease = (item) => {
|
|
const handleIncrease = (item) => {
|
|
|
|
|
+ if (!canEditItemQuantity(item)) return;
|
|
|
if (item.quantity >= 99) return;
|
|
if (item.quantity >= 99) return;
|
|
|
emit('increase', item);
|
|
emit('increase', item);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-// 减少数量
|
|
|
|
|
|
|
+// 减少数量(餐具费 0 元时不触发)
|
|
|
const handleDecrease = (item) => {
|
|
const handleDecrease = (item) => {
|
|
|
|
|
+ if (!canEditItemQuantity(item)) return;
|
|
|
if (item && item.quantity > 0) {
|
|
if (item && item.quantity > 0) {
|
|
|
emit('decrease', item);
|
|
emit('decrease', item);
|
|
|
}
|
|
}
|
|
@@ -309,6 +319,11 @@ const handleClear = () => {
|
|
|
box-sizing: border-box;
|
|
box-sizing: border-box;
|
|
|
padding: 0 3rpx;
|
|
padding: 0 3rpx;
|
|
|
margin-left: 20rpx;
|
|
margin-left: 20rpx;
|
|
|
|
|
+
|
|
|
|
|
+ &--disabled {
|
|
|
|
|
+ opacity: 0.6;
|
|
|
|
|
+ pointer-events: none;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|