<route lang="json5" type="page">
{
  style: {
    navigationBarTitleText: '六纬AI小助手',
  },
  needLogin: true,
}
</route>
<template>
  <web-view :src="url" @message="handleChildMessage" :update-title="false" />
  <!-- <input
    v-model="message"
    type="text"
    placeholder="请输入你的高考分数"
    confirm-type="done"
    class="flex-auto"
    @confirm="handleMessage"
  /> -->
</template>

<script setup lang="ts">
import { useUserStore } from '@/store'
import { sendMessage } from '@/service/index/api'
import { onPageHide } from '@dcloudio/uni-app'

const userStore = useUserStore()

const message = ref('')

const handleMessage = () => {
  sendMessage({ conversation_id: '123', user: '1234', query: '山东省计算机考研推荐' }).then(
    (resp) => {},
  )
}

//chat.ycymedu.com
const url = ref(
  `https://chat.ycymedu.com?userId=${userStore.userInfo.estimatedAchievement.wxId}&subjectGroup=${userStore.userInfo.estimatedAchievement.subjectGroup}&expectedScore=${userStore.userInfo.estimatedAchievement.expectedScore}&provinceName=${userStore.userInfo.estimatedAchievement.provinceName}`,
)

const handleChildMessage = (event) => {
  console.log('子应用传递的消息', event)
}

onLoad(() => {
  uni.getRecorderManager()
  uni.getBackgroundAudioManager()
})

onShow(() => {
  uni.showModal({
    title: '温馨提示',
    content: '进入房间后退出时请挂断对话以免浪费金额',
  })

  return true
})
</script>

<style lang="scss" scoped></style>
