<route lang="json5" type="page">
{
  style: {
    navigationStyle: 'custom',
  },
}
</route>

<template>
  <view :scroll-y="true" class="flex flex-col h-screen relative custom-bg">
    <Navbar
      safeAreaInsetTop
      :bordered="false"
      leftArrow
      @clickLeft="handleBack"
      bg-color="transparent"
    >
      <template #title>
        <text class="text-[#1F2329] text-[36rpx] font-medium text-[#fff]">Solomon学习风格报告</text>
      </template>
    </Navbar>

    <view class="flex-1 overflow-auto relative">
      <view class="flex flex-col flex-1 overflow-auto pb-[20rpx]">
        <!-- 顶部卡片 -->
        <view class="mt-[60rpx] mx-[24rpx]">
          <LearnStyleChart :pic-data="chartData" :parsing="parsing" />
        </view>
        <view class="mx-[24rpx]">
          <LearnStudySuggestion
            :title="item.name"
            :item="item"
            v-for="(item, index) in suggestions"
            :key="index"
          />
        </view>
      </view>

      <!-- 底部AI智能顾问 -->
      <AiFooter :pageId="pageId" :pageType="pageType" />
    </view>
  </view>
</template>
<script setup lang="ts">
import Navbar from '@/pages-evaluation-sub/components/navbar/Navbar.vue'
import LearnStyleChart from '../components/studyChart/LearnStyleChart.vue'
import LearnStudySuggestion from '../components/LearnStudySuggestion.vue'
import AiFooter from '../components/AiFooter.vue'
import { getCustomScaleExplains } from '@/service/index/api'
import { handleBack } from '../hooks/useEvaluateBack'

const pageType = ref(0)
const pageId = ref(0)

const studyRecord = ref({
  description: '',
  title: '',
  result: '',
  tagName: '',
  suggestions: '',
})

const chartData = ref<any[]>([])
const parsing = ref('')
const suggestions = ref<any[]>([])

onLoad((options) => {
  pageType.value = +options.type
  pageId.value = options.id

  getCustomScaleExplains({ CustomScaleId: pageId.value }).then((resp) => {
    if (resp.code === 200) {
      studyRecord.value = resp.result as {
        description: string
        title: string
        result: string
        tagName: string
        suggestions: string
      }
      chartData.value = JSON.parse(studyRecord.value.result)
      parsing.value = studyRecord.value.suggestions
      suggestions.value = JSON.parse(studyRecord.value.description)
    }
  })
})
</script>

<style scoped lang="scss">
.custom-bg {
  background: linear-gradient(184deg, #0d79fc 0%, #2186fc 100%);
}
:deep(.icon-class) {
  color: #fff !important;
}

.custom-border {
  width: 162rpx;
  height: 162rpx;
  border-radius: 50%;
  border: 6rpx dashed;
  border-color: #05d69c transparent transparent transparent;
}
</style>
