<template>
  <view style="height: 98vh; background-color: #f2f4f7; padding-top: 10px;">
    <view v-if="list.length > 0">
      <uni-card v-for="(item, index) in list" class="list-item" @tap.stop="handleToDetail(item)" :key="index" :is-shadow="true" :border='false' shadow="0px 0px 3px 1px rgba(0,0,0,0.1)">
        <view class="font-weight-bold">实习企业： {{ formatName(item.enterprise.enterpriseName) }}</view>
				<view>创建时间：{{ timesTampChange(item.studentInternshipCertificate.createDate) }}</view>
        <view>实习点评：{{ item.studentInternshipCertificate.comment }}</view>
        <view style="text-align: end;">
          <text class="color-primary" @tap.stop="handleToDetail(item)">点击查看</text>
        </view>
      </uni-card>
		</view>
		<view v-else class="nodata-img-parent">
			<image src="https://minio.menduner.com/dev/bb43df1dc91945e05ee93da76e49b34f87b0d10203eb76c20e2d4999a13b9a0a.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image>
		</view>
  </view>
</template>

<script setup>
import { ref } from 'vue'
import { getEnterpriseCertificateList } from '@/api/student'
import { onShow } from '@dcloudio/uni-app'
import { formatName } from '@/utils/getText'
import { timesTampChange } from '@/utils/date'
import { preview } from '@/utils/preview'

const list = ref([
  {
    enterprise: {
      enterpriseName: '门墩儿科技有限公司',
    },
    entity: {
      createDate: 1740570206120,
      fileUrl: 'https://minio.menduner.com/dev/person/725759784858554368/attachment/7cde29dc69c1403649be55d4c2bfd3d8304c088dc79ab25afe9c4bf55d3b382f.docx'
    },
    studentInternshipCertificate: {
      comment: '这是一条测试数据',
      createDate: 1740570206120
    }
  }
])

// 查看证书详情
const handleToDetail = (item) => {
  console.log(111)
  uni.navigateTo({
    url: '/pagesA/student/certificateDetail?id=' + '1111'
  })
}

// 获取实习证书列表
const getList = async () => {
  try {
    const { data } = await getEnterpriseCertificateList({ size: 9999, current: 1 })
    console.log(data, '实习证书')
    // list.value = data.records.reverse()
  } catch {}
}

onShow(async () => {
  // await getList()
})
</script>

<style lang="scss" scoped>
.list-item {
  background-color: #fff;
  border-radius: 3px;
  padding: 20px;
  box-shadow: 0px 0px 3px 1px rgba(0,0,0,0.1);
}
</style>
