<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
const { createApp } = Vue;
createApp({
data() {
return {
newMessage: '',
messages: [
{
role: 'bot',
text: 'Здравствуйте, я ваш персональный ассистент, чем я могу помочь?',
buttons: [
'Получить документы',
'Сдать документы в бухгалтерию',
'Получить сведения'
]
}
]
}
},
methods: {
newChat() {
this.messages = [
{
role: 'bot',
text: 'Новый чат создан. Чем могу помочь?',
buttons: [
'Получить документы',
'Сдать документы в бухгалтерию'
]
}
];
},
sendMessage() {
if (!this.newMessage.trim()) return;
this.messages.push({
role: 'user',
text: this.newMessage
});
// мок ответа бота
setTimeout(() => {
this.messages.push({
role: 'bot',
text: 'Ответ на: ' + this.newMessage,
buttons: ['Продолжить', 'Переформулировать']
});
}, 500);
this.newMessage = '';
},
handleBotAction(action) {
this.messages.push({
role: 'user',
text: action
});
this.messages.push({
role: 'bot',
text: 'Вы выбрали: ' + action
});
}
}
}).mount('#chatApp');
</script>