Compare commits
No commits in common. "ecc9fa14e63480924e233efcae13da10a977c5a3" and "33bf3d47c5d4ae77faa014f0580a293e41a5427a" have entirely different histories.
ecc9fa14e6
...
33bf3d47c5
|
|
@ -42,15 +42,10 @@
|
||||||
|
|
||||||
<!-- 中间菜单列表(可滑动) -->
|
<!-- 中间菜单列表(可滑动) -->
|
||||||
<scroll-view class="menu-list" scroll-y="true">
|
<scroll-view class="menu-list" scroll-y="true">
|
||||||
<view
|
<view class="menu-item" v-for="(item, index) in menuList" :key="index">
|
||||||
class="menu-item"
|
|
||||||
v-for="(item, index) in menuList"
|
|
||||||
:key="index"
|
|
||||||
:class="{ 'out-of-stock': item.stock === 0 }"
|
|
||||||
>
|
|
||||||
<view
|
<view
|
||||||
class="checkbox"
|
class="checkbox"
|
||||||
:class="{ checked: item.selected, disabled: item.stock === 0 }"
|
:class="{ checked: item.selected }"
|
||||||
@click="toggleMenuItem(index)"
|
@click="toggleMenuItem(index)"
|
||||||
>
|
>
|
||||||
<text v-if="item.selected" class="checkmark">✓</text>
|
<text v-if="item.selected" class="checkmark">✓</text>
|
||||||
|
|
@ -80,21 +75,17 @@
|
||||||
<view
|
<view
|
||||||
class="quantity-btn minus"
|
class="quantity-btn minus"
|
||||||
:class="{
|
:class="{
|
||||||
disabled: (item.quantity || 0) <= 0 || item.stock === 0,
|
disabled: (item.quantity || 0) <= 0,
|
||||||
}"
|
}"
|
||||||
@click="decreaseQuantity(index)"
|
@click="decreaseQuantity(index)"
|
||||||
>-</view
|
>-</view
|
||||||
>
|
>
|
||||||
<text class="quantity-number">{{ item.quantity || 0 }}</text>
|
<text class="quantity-number">{{ item.quantity || 0 }}</text>
|
||||||
<view
|
<view class="quantity-btn plus" @click="increaseQuantity(index)"
|
||||||
class="quantity-btn plus"
|
|
||||||
:class="{ disabled: item.stock === 0 }"
|
|
||||||
@click="increaseQuantity(index)"
|
|
||||||
>+</view
|
>+</view
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="item.stock === 0" class="stock-tip">库存不足,不可选择</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
@ -284,10 +275,6 @@ export default {
|
||||||
// 切换菜单项选择状态
|
// 切换菜单项选择状态
|
||||||
toggleMenuItem(index) {
|
toggleMenuItem(index) {
|
||||||
const item = this.menuList[index];
|
const item = this.menuList[index];
|
||||||
// 库存不足时不可选择
|
|
||||||
if (item && item.stock === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
item.selected = !item.selected;
|
item.selected = !item.selected;
|
||||||
if (!item.selected) {
|
if (!item.selected) {
|
||||||
item.quantity = 0;
|
item.quantity = 0;
|
||||||
|
|
@ -300,10 +287,6 @@ export default {
|
||||||
// 增加数量
|
// 增加数量
|
||||||
increaseQuantity(index) {
|
increaseQuantity(index) {
|
||||||
const item = this.menuList[index];
|
const item = this.menuList[index];
|
||||||
// 库存不足时不可增加数量
|
|
||||||
if (item && item.stock === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 如果未选中,先选中
|
// 如果未选中,先选中
|
||||||
if (!item.selected) {
|
if (!item.selected) {
|
||||||
item.selected = true;
|
item.selected = true;
|
||||||
|
|
@ -315,10 +298,6 @@ export default {
|
||||||
// 减少数量
|
// 减少数量
|
||||||
decreaseQuantity(index) {
|
decreaseQuantity(index) {
|
||||||
const item = this.menuList[index];
|
const item = this.menuList[index];
|
||||||
// 库存不足时不处理数量变化
|
|
||||||
if (item && item.stock === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const currentQuantity = item.quantity || 0;
|
const currentQuantity = item.quantity || 0;
|
||||||
// 确保数量不能小于0
|
// 确保数量不能小于0
|
||||||
if (currentQuantity > 0) {
|
if (currentQuantity > 0) {
|
||||||
|
|
@ -600,10 +579,6 @@ export default {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
&.out-of-stock {
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox {
|
.checkbox {
|
||||||
width: 30rpx;
|
width: 30rpx;
|
||||||
height: 30rpx;
|
height: 30rpx;
|
||||||
|
|
@ -615,11 +590,6 @@ export default {
|
||||||
margin-right: 19rpx;
|
margin-right: 19rpx;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
|
||||||
&.disabled {
|
|
||||||
border-color: #dddddd;
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.checked {
|
&.checked {
|
||||||
background-color: #004294;
|
background-color: #004294;
|
||||||
border-color: #004294;
|
border-color: #004294;
|
||||||
|
|
@ -724,12 +694,6 @@ export default {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
border-radius: 4rpx;
|
border-radius: 4rpx;
|
||||||
|
|
||||||
&.disabled {
|
|
||||||
color: #bbbbbb;
|
|
||||||
border-color: #dddddd;
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.quantity-number {
|
.quantity-number {
|
||||||
|
|
@ -742,11 +706,6 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.stock-tip {
|
|
||||||
margin-top: 10rpx;
|
|
||||||
font-size: 20rpx;
|
|
||||||
color: #999999;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue