diff --git a/yshop-drink-uniapp-vue3/pages.json b/yshop-drink-uniapp-vue3/pages.json
index 4aca628..7c92c66 100644
--- a/yshop-drink-uniapp-vue3/pages.json
+++ b/yshop-drink-uniapp-vue3/pages.json
@@ -207,7 +207,7 @@
},
"tabBar": {
"color": "#919293",
- "selectedColor": "#09b4f1",
+ "selectedColor": "#ff7417",
"backgroundColor": "#fff",
"borderStyle": "black",
"list": [{
diff --git a/yshop-drink-uniapp-vue3/pages/menu/menu.vue b/yshop-drink-uniapp-vue3/pages/menu/menu.vue
index 202bc80..bc9c3c5 100644
--- a/yshop-drink-uniapp-vue3/pages/menu/menu.vue
+++ b/yshop-drink-uniapp-vue3/pages/menu/menu.vue
@@ -90,8 +90,9 @@
{{ good.storeName }}
{{ good.storeInfo }}
- ¥{{ good.price }}
-
+ ¥{{ good.price }}
+
+
{{ goodCartNum(good.id) }}
+
+
+
+ {{ goodCartNum(good.id) }}
+
+
@@ -313,6 +320,8 @@ const spread = computed(() => { //差多少元起送
})
const isGoodVisible = (good) => !keyword.value || [good.storeName, good.storeInfo]
.filter(Boolean).join(' ').toLowerCase().includes(keyword.value.trim().toLowerCase())
+const hasSpecialSpecs = (good) => (good.productAttr || []).some(attr => (attr.attrValueArr || []).length > 1)
+const defaultSpec = (good) => (good.productAttr || []).map(attr => attr.attrValueArr?.[0]).filter(Boolean).join(',')
// 监听自定义事件
uni.$on('refreshMenu', () => {
@@ -545,13 +554,8 @@ const calcSize = () => {
sizeCalcState.value = true
}
const handleAddToCart = (cate, newGood, num) =>{ //添加到购物车
- const index = cart.value.findIndex(item => {
- if (newGood) {
- return (item.id === newGood.id) && (item.valueStr === good.value.valueStr)
- } else {
- return item.id === newGood.id
- }
- })
+ const valueStr = newGood.valueStr || ''
+ const index = cart.value.findIndex(item => item.id === newGood.id && item.valueStr === valueStr)
if (index > -1) {
cart.value[index].number += num
} else {
@@ -562,20 +566,25 @@ const handleAddToCart = (cate, newGood, num) =>{ //添加到购物车
price: newGood.price,
number: num,
image: newGood.image,
- valueStr: good.value.valueStr
+ valueStr
})
}
uni.setStorageSync('cart', JSON.parse(JSON.stringify(cart.value)))
}
-const handleReduceFromCart = (item, good) => {
- const index = cart.value.findIndex(item => item.id === good.id)
- cart.value[index].number -= 1
- if (cart.value[index].number <= 0) {
- cart.value.splice(index, 1)
+const adjustSimpleGood = (cate, newGood, num) => {
+ const valueStr = defaultSpec(newGood)
+ const index = cart.value.findIndex(item => item.id === newGood.id && item.valueStr === valueStr)
+ if (num > 0) {
+ handleAddToCart(cate, { ...newGood, valueStr }, num)
+ return
}
+ if (index < 0) return
+ cart.value[index].number += num
+ if (cart.value[index].number <= 0) cart.value.splice(index, 1)
uni.setStorageSync('cart', JSON.parse(JSON.stringify(cart.value)))
}
const showGoodDetailModal = (item, newGood) => {
+ if (!hasSpecialSpecs(newGood)) return adjustSimpleGood(item, newGood, 1)
isCartShow.value = true
good.value = JSON.parse(JSON.stringify({
...newGood,
@@ -752,7 +761,7 @@ $menu-divider-height: 2rpx;
text-align: center;
}
- .btn {
+ .btn {
//padding: 0;
border-radius: $border-radius-circle;
}
@@ -1071,9 +1080,15 @@ page {
font-size: $font-size-sm;
line-height: var(--menu-control-size-sm);
- &.property_btn {
- border-radius: 24rpx;
- }
+ &.property_btn {
+ border-radius: 24rpx;
+ }
+
+ &.quantity-btn {
+ width: var(--menu-control-size-sm);
+ padding: 0;
+ border-radius: 50%;
+ }
&.add_btn,
&.reduce_btn {
@@ -1098,7 +1113,13 @@ page {
border-radius: $border-radius-circle;
}
- @include quantity-control(var(--menu-control-size-sm));
+ @include quantity-control(var(--menu-control-size-sm));
+
+ .number {
+ min-width: 38rpx;
+ padding: 0 8rpx;
+ font-size: $font-size-sm;
+ }
}
}
}
diff --git a/yshop-drink-uniapp-vue3/uni.scss b/yshop-drink-uniapp-vue3/uni.scss
index f4bb2d1..bac3799 100644
--- a/yshop-drink-uniapp-vue3/uni.scss
+++ b/yshop-drink-uniapp-vue3/uni.scss
@@ -14,7 +14,7 @@
/* 颜色变量 */
/* 行为相关颜色 */
-$color-primary: #09b4f1;
+$color-primary: #ff7417;
$color-success: #4cd964;
$color-warning: #FAB714;
$color-error: #D12E32;
@@ -28,9 +28,9 @@ $text-color-white: #ffffff; //白
$text-color-light-muted: #A9A5A0; //浅灰
/* 背景颜色 */
-$bg-color: #F1F8FA;
-$bg-color-grey: #F5F5F5;
-$bg-color-primary: #dbe7ea;
+$bg-color: #fff8f1;
+$bg-color-grey: #fffaf6;
+$bg-color-primary: #fff0df;
/* 边框颜色 */
$border-color: #e6e6e6;
@@ -87,10 +87,10 @@ $uv-border-color: #dadbde;
$uv-bg-color: #f3f4f6;
$uv-disabled-color: #c8c9cc;
-$uv-primary: #EE6D46;
-$uv-primary-dark: #EE6D46;
-$uv-primary-disabled: #FDEDE8;
-$uv-primary-light: #ecf5ff;
+$uv-primary: #ff7417;
+$uv-primary-dark: #e9600b;
+$uv-primary-disabled: #ffe1c8;
+$uv-primary-light: #fff1e5;
$uv-warning: #f9ae3d;
$uv-warning-dark: #f1a532;