<!--
 * @desc 我的-合规测评
 * @author linyuanjie
 * @date 2023/10/19
-->

<template>
  <view class="quiz-page">
    <view
      v-for="(quizItem, index) in testResults"
      :key="index"
      class="quiz-item"
      @click="detailFn(quizItem)"
    >
      <view class="quiz-list">
        <view class="title">
          <text>{{ quizItem.quiz.title }}</text>
          <text v-if="quizItem.valid" class="success">（已通过）</text>
          <text v-else class="danger">（未通过）</text>
        </view>
        <view class="content">
          总分：<text class="mr40">{{ quizItem?.quiz?.expand?.totalMark }}</text
          >测试分数：<text>{{ quizItem.finalMark || '无' }}</text>
        </view>
      </view>
    </view>
  </view>
</template>
<script setup lang="ts">
import { getQuizPltTextResultApi } from '@/service/modules/quiz'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'

const detailFn = (row: any) => {
  uni.navigateTo({
    url: `/pages-sub-mine/quizDetail/index?id=${row.quiz.quizId}`
  })
}
onLoad(() => {
  getPltQuizResultFn()
})

const testResults = ref<any[]>([])
const getPltQuizResultFn = async () => {
  const res = await getQuizPltTextResultApi()
  if (res.code === 0) {
    testResults.value = res.data.testResults || []
  }
}
</script>

<style lang="scss" scoped>
.quiz-page {
  padding: 24rpx;
  min-height: 100vh;
  background-color: #f6f6f6;
  .quiz-item {
    padding: 30rpx;
    background-color: #fff;
    margin-bottom: 30rpx;
    border-radius: 12rpx;
    box-shadow: 0px 4rpx 4rpx 0px rgba(0, 0, 0, 0.05);

    .quiz-list {
      .title {
        font-size: 36rpx;
        color: #333;
        .success {
          font-size: 32rpx;
          color: #6eb657;
        }
        .danger {
          font-size: 32rpx;
          color: #edb252;
        }
      }
      .content {
        margin-top: 20rpx;
        font-size: 32rpx;
      }
    }
  }
}
</style>
