<template>
  <div class="collection">
    <div class="gap10 title">
      <div class="line_vertical"></div>
      <div class="">{{ $t('personalCenter.myCollection') }}</div>
    </div>
    <ul class="collection-list">
      <li class="flex-center-between" v-for="(item, index) in list" :key="index">
        <img class="image"
          src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png" alt="">
        <div class="collection-list-main">
          <div class="collection-list-main-left">
            <div class="titles">UI界面设计教程</div>
            <div class="gap10 tag">
              <el-button type="primary" size="large" plain>技能标签</el-button>
            </div>
            <div class="">这是课程介绍这是课程介绍这是课程介绍这是课程介绍这是课程介绍这是课程介绍这是课程介绍这是课程介绍这是课程介绍</div>
          </div>
          <div class="btn flex-center">
            <img src="/src/assets/imgs/my/star-a@2x.png" alt="">
            <div class="">{{ index == 0 ? $t('common.collected') : $t('common.cancelCollect') }}</div>
          </div>
        </div>
      </li>
    </ul>
    <template v-if="list.length">
      <Pagination :total="form.total" :page-size="form.pageSize" :current-page="form.pageNum"
        @page-change="handlePageChange" />
    </template>
    <el-empty v-else :description="$t('common.empty')" />
  </div>
</template>
<script setup lang="ts">
import Pagination from '@/components/Pagination.vue'
import { ref, onMounted } from 'vue'
import { collectList } from '@/api/my.js'
const form = ref({
  pageNum: 1,
  pageSize: 10,
  total: 0
})

const list = ref([])

const getList = async () => {
  let res = await collectList(form.value);
  console.log(res);
  form.value.total = res.total;
  list.value = res.rows
}
const handlePageChange = (page) => {
  list.value = []
  form.value.pageNum = page;
  getList()
}
onMounted(() => {
  getList()
})
</script>
<style scoped lang="scss">
.collection {
  padding-bottom: 20px;

  .title {
    height: 60px;
    font-size: 20px;
    font-weight: bold;
    color: #333333;
  }

  .collection-list {
    li {
      padding: 16px;
      margin-bottom: 16px;
      background: #F5F7FA;
      border-radius: 16px;

      &:last-child {
        margin-bottom: 0;
      }

      .image {
        width: 213px;
        height: 120px;
        object-fit: cover;
        border-radius: 8px;
        margin-right: 16px;
      }

      .collection-list-main {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;

        .collection-list-main-left {
          flex: 1;
          margin-right: 16px;

          .titles {
            font-size: 18px;
            font-weight: bold;
            color: #333333;
          }

          .tag {
            margin: 8px 0;
          }

          .content {
            color: #666666;
            font-size: 14px;
            line-height: 22px;
          }
        }

        .btn {
          width: 120px;
          height: 32px;
          color: #FFFFFF;
          font-size: 14px;
          cursor: pointer;
          background: linear-gradient(270deg, #0055FE 0%, #C832FA 100%);
          border-radius: 4px;

          &:hover {
            opacity: 0.7;
          }

          img {
            width: 14px;
            height: 14px;
            margin-right: 4px;
          }
        }

        .active {
          background: #FFFFFF;
          color: #2D71FF;
        }
      }
    }
  }
}
</style>