feat(orders): tg notifications, ya metrika, meta tags

This commit is contained in:
Nikita Kiselev
2025-08-03 09:39:51 +03:00
parent 454bd39f1f
commit 86d0fa9594
32 changed files with 1205 additions and 76 deletions

View File

@@ -12,6 +12,7 @@ export const useCheckoutStore = defineStore('checkout', {
phone: "+79999999999",
address: "Москва, Красная площадь, 1",
comment: "Доставить срочно❗️",
tgData: null,
},
validationErrors: {},
@@ -26,6 +27,19 @@ export const useCheckoutStore = defineStore('checkout', {
actions: {
async makeOrder() {
try {
const data = window.Telegram.WebApp.initDataUnsafe;
if (! data.allows_write_to_pm) {
await window.Telegram.WebApp.requestWriteAccess((granted) => {
if (granted) {
console.log('Пользователь разрешил отправку сообщений');
} else {
alert('Вы не дали разрешение — бот не сможет отправлять вам уведомления');
}
});
}
this.customer.tgData = data.user;
await storeOrder(this.customer);
await window.Telegram.WebApp.HapticFeedback.notificationOccurred('success');
await useCartStore().getProducts();
@@ -44,6 +58,6 @@ export const useCheckoutStore = defineStore('checkout', {
clearError(field) {
this.validationErrors[field] = null;
}
},
},
});