Files
hereconnect/src/views/ReadQRCodeView.vue
T

52 lines
1.7 KiB
Vue
Raw Normal View History

<template>
<div class="flex flex-col min-h-screen">
<main class="flex-grow flex items-center justify-center py-6 px-4 md:px-6">
2024-11-19 00:51:11 +02:00
<section class="max-w-lg w-full flex flex-col gap-10">
2024-11-19 01:17:16 +02:00
<template v-for="action in actions">
<ReadContactInfo v-if="action === 'viewContactInfo'" :contactInfo="contactInfo" />
<ReadMessageSender
v-else-if="action === 'sendMessage'"
:qr_code_uri="qr_code_uri"
:predefinedMessages="predefinedMessages"
/>
</template>
</section>
</main>
<footer class="bg-gray-100 text-center py-4 border-t text-sm text-gray-700">
<p>
Нужен такой же?
<a href="/create" class="underline">Создайте свой QRкод</a>.
</p>
<p class="mt-1">
2024-11-19 01:17:16 +02:00
Сделайте НаСвязи удобнее. Будем рады вашей&nbsp;<a href="/donate" class="underline"
>поддержке</a
>.
</p>
</footer>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { getQrCodeDocument } from '@/api/qrCode'
2024-11-19 00:51:11 +02:00
const { qr_code_uri } = defineProps<{ qr_code_uri: string }>()
// Локальные состояния
2024-11-19 00:51:11 +02:00
const predefinedMessages = ref<string[]>([])
const contactInfo = ref<{ name?: string; phone?: string; email?: string }>({})
const actions = ref<string[]>([])
onMounted(async () => {
try {
const qrCodeDoc = await getQrCodeDocument(qr_code_uri)
2024-11-19 00:51:11 +02:00
predefinedMessages.value = qrCodeDoc!.predefinedMessage || []
contactInfo.value = qrCodeDoc!.contactInfo || { name: 'waka', phone: '+123' }
actions.value = qrCodeDoc!.actions || []
2024-11-19 00:18:24 +02:00
} catch (err) {
console.error(err)
}
})
</script>