import { View, Text, ScrollView } from '@tarojs/components' import { useState, useEffect } from 'react' import Taro from '@tarojs/taro' import { getConversations, ChatConversation } from '../../services/chat' import './index.scss' export default function Chat() { const [conversations, setConversations] = useState([]) useEffect(() => { loadConversations() }, []) const loadConversations = async () => { const data = await getConversations() setConversations(data) } const handleConversationClick = (conversation: ChatConversation) => { Taro.navigateTo({ url: `/pages/chat/detail/index?id=${conversation.id}&name=${encodeURIComponent(conversation.name)}` }) } return ( AI 玩伴 选择玩伴开始对话 {conversations.map((conversation) => ( handleConversationClick(conversation)} > {conversation.avatar} {conversation.name} {conversation.time} {conversation.lastMessage} {conversation.unreadCount && conversation.unreadCount > 0 && ( {conversation.unreadCount} )} ))} ) }