feat: add haptictouch to bottom buttons

This commit is contained in:
Nikita Kiselev
2025-07-21 01:08:00 +03:00
parent b0cc0237af
commit 51ce6ed959
2 changed files with 11 additions and 6 deletions

View File

@@ -1,8 +1,8 @@
<template> <template>
<div class="flex items-center text-center"> <div class="flex items-center text-center">
<button class="btn btn-neutral w-10 h-10" @click="inc">-</button> <button class="btn btn-lg btn-neutral" @click="inc">-</button>
<div class="w-10 h-10 flex items-center justify-center bg-neutral">{{ model }}</div> <div class="w-10 h-10 flex items-center justify-center bg-neutral font-bold">{{ model }}</div>
<button class="btn btn-neutral w-10 h-10" @click="dec">+</button> <button class="btn btn-lg btn-neutral" @click="dec">+</button>
</div> </div>
</template> </template>

View File

@@ -34,9 +34,10 @@
</div> </div>
</div> </div>
<div class="p-2 fixed bottom-0 left-0 w-full bg-info-content z-50 flex justify-between gap-2"> <div class="px-4 pb-10 pt-4 fixed bottom-0 left-0 w-full bg-info-content z-50 flex justify-between gap-2 border-t-1 border-t-success-content">
<button <button
class="btn btn-primary flex-1" class="btn btn-lg flex-1"
:class="isInCartNow ? 'btn-success' : 'btn-primary'"
@click="actionBtnClick" @click="actionBtnClick"
> >
{{ buttonText }} {{ buttonText }}
@@ -71,7 +72,7 @@ const cart = useCartStore();
const buttonText = computed(() => { const buttonText = computed(() => {
const item = cart.items.find(i => i.productId === productId.value); const item = cart.items.find(i => i.productId === productId.value);
return item && item.quantity > 0 return item && item.quantity > 0
? `Перейти в корзину` ? `В корзине`
: 'Добавить в корзину' : 'Добавить в корзину'
}); });
@@ -85,17 +86,21 @@ const quantity = computed(() => {
function actionBtnClick() { function actionBtnClick() {
if (cart.hasProduct(productId.value)) { if (cart.hasProduct(productId.value)) {
window.Telegram.WebApp.HapticFeedback.selectionChanged();
router.push({name: 'cart.show'}); router.push({name: 'cart.show'});
} else { } else {
cart.addProduct(productId.value, product.value.name, product.value.price, 1, product.value.options); cart.addProduct(productId.value, product.value.name, product.value.price, 1, product.value.options);
window.Telegram.WebApp.HapticFeedback.notificationOccurred('success');
} }
} }
function setQuantity(newQuantity) { function setQuantity(newQuantity) {
if (newQuantity === 0) { if (newQuantity === 0) {
cart.removeProduct(productId.value); cart.removeProduct(productId.value);
window.Telegram.WebApp.HapticFeedback.notificationOccurred('warning');
} else { } else {
cart.setQuantity(productId.value, newQuantity); cart.setQuantity(productId.value, newQuantity);
window.Telegram.WebApp.HapticFeedback.selectionChanged();
} }
} }