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

<template>
  <scroll-view scroll-y class="pb-safe bg-[#f8f8f8]">
    <view class="item-wrapper" v-for="(item, index) in wishList" :key="index">
      <view class="flex gap-[24rpx] wish-border justify-between p-[32rpx] rounded-[8rpx]">
        <view class="flex flex-col gap-[14rpx]">
          <text class="text-[#303030] text-[32rpx] font-semibold">
            {{ item.tableName }}
          </text>
          <text class="text-[22rpx] text-[#303030]">{{ item.createTime || '时间消失了' }}</text>
        </view>
        <view class="flex flex-col justify-between items-end">
          <view class="i-carbon-trash-can" @click="handleDelete(item, index)"></view>
        </view>
      </view>
    </view>
  </scroll-view>
</template>

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

const userStore = useUserStore()

const wishList = ref([])

onLoad(() => {
  getWishList().then((res) => {
    if (res.code === 200) {
      wishList.value = res.result as any[]
    }
  })
})

const handleDelete = (item, index) => {
  deleteWishList({ id: item.vId }).then((res) => {
    if (res.code === 200) {
      wishList.value.splice(index, 1)
      uni.showToast({ title: '删除成功' })
    }
  })
}
</script>

<style lang="scss" scoped>
.item-wrapper {
  padding: 32rpx;
}

.wish-border {
  background-color: #ffffff;
  border-radius: 8rpx;
}
</style>
