<route lang="json5" type="page">
{
  style: {
    navigationBarTitleText: '测评结果',
  },
}
</route>

<template>
  <scroll-view scroll-y class="pb-safe bg-[#f8f8f8] h-screen">
    <view class="px-[32rpx] mt-[32rpx] flex flex-col gap-[16rpx]">
      <view
        v-for="(item, index) in list"
        :key="index"
        class="flex gap-[24rpx] wish-border justify-between p-[32rpx] rounded-[8rpx]"
        @click="toDetail(item)"
      >
        <view class="flex flex-col gap-[14rpx]">
          <text class="text-[#303030] text-[32rpx] font-semibold">
            {{ item.title }}
          </text>
          <text class="text-[22rpx] text-[#303030]">{{ item.createTime || '时间消失了' }}</text>
        </view>
      </view>
    </view>
  </scroll-view>
</template>

<script setup lang="ts">
import { getMyBusReports } from '@/service/index/api'
import { useUserStore } from '@/store'

const userStore = useUserStore()

const list = ref([])

const toDetail = (item: any) => {
  // type=0  兴趣测评报告
  // =1 性格测评报告
  // =2 能力测评
  // =3 学生考试考虑
  // =4 学习风格
  // =5 学习技能
  // =6 SAS
  // =7 SDS
  // =8 SCL-90
  // =9 MHT
  /// =-1 价值观
  /// =-2 留学咨询
  let url = ''

  if (item.type === 0) {
    url = `/pages-evaluation-sub/evaluate/academicReport/interestReport?id=${item.reportsId}&type=${item.type}`
  } else if (item.type === 1) {
    url = `/pages-evaluation-sub/evaluate/academicReport/characterReport?id=${item.reportsId}&type=${item.type}`
  } else if (item.type === 2) {
    url = `/pages-evaluation-sub/evaluate/academicReport/capabilityReport?id=${item.reportsId}&type=${item.type}`
  } else if (item.type === -1) {
    url = `/pages-evaluation-sub/evaluate/academicReport/opinionAboutReport?id=${item.reportsId}&type=${item.type}`
  } else if (item.type === 6) {
    url = `/pages-evaluation-sub/evaluate/psychologicalReport/sasReport?id=${item.reportsId}&type=${item.type}`
  } else if (item.type === 7) {
    url = `/pages-evaluation-sub/evaluate/psychologicalReport/sdsReport?id=${item.reportsId}&type=${item.type}`
  } else if (item.type === 9) {
    // url = `/pages-evaluation-sub/evaluate/psychologicalReport/mhtReport?id=${item.reportsId}&type=${item.type}`
    uni.showToast({
      title: '开发中....',
      icon: 'none',
    })
    return
  } else if (item.type === 4) {
    url = `/pages-evaluation-sub/evaluate/studyReport/learnStudyReport?id=${item.reportsId}&type=${item.type}`
  } else if (item.type === 5) {
    url = `/pages-evaluation-sub/evaluate/studyReport/learnSkillReport?id=${item.reportsId}&type=${item.type}`
  } else if (item.type === 3) {
    url = `/pages-evaluation-sub/evaluate/studyReport/anxietyReport?id=${item.reportsId}&type=${item.type}`
  } else {
    uni.showToast({
      title: '开发中....',
      icon: 'none',
    })
    return
  }
  uni.navigateTo({
    url,
  })
}

onLoad(() => {
  getMyBusReports({ CustomId: userStore.userInfo?.estimatedAchievement.wxId }).then((res) => {
    if (res.code === 200) {
      list.value = (res.result as { customReports: any[] }).customReports
    }
  })
})
</script>

<style lang="scss" scoped>
.wish-border {
  background-color: #ffffff;
  border-radius: 8rpx;
}
</style>
