Collection.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div class="collection">
  3. <div class="gap10 title">
  4. <div class="line_vertical"></div>
  5. <div class="">{{ $t('personalCenter.myCollection') }}</div>
  6. </div>
  7. <ul class="collection-list">
  8. <li class="flex-center-between" v-for="(item, index) in list" :key="index">
  9. <img class="image"
  10. src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png" alt="">
  11. <div class="collection-list-main">
  12. <div class="collection-list-main-left">
  13. <div class="titles">UI界面设计教程</div>
  14. <div class="gap10 tag">
  15. <el-button type="primary" size="large" plain>技能标签</el-button>
  16. </div>
  17. <div class="">这是课程介绍这是课程介绍这是课程介绍这是课程介绍这是课程介绍这是课程介绍这是课程介绍这是课程介绍这是课程介绍</div>
  18. </div>
  19. <div class="btn flex-center">
  20. <img src="/src/assets/imgs/my/star-a@2x.png" alt="">
  21. <div class="">{{ index == 0 ? $t('common.collected') : $t('common.cancelCollect') }}</div>
  22. </div>
  23. </div>
  24. </li>
  25. </ul>
  26. <template v-if="list.length">
  27. <Pagination :total="form.total" :page-size="form.pageSize" :current-page="form.pageNum"
  28. @page-change="handlePageChange" />
  29. </template>
  30. <el-empty v-else :description="$t('common.empty')" />
  31. </div>
  32. </template>
  33. <script setup lang="ts">
  34. import Pagination from '@/components/Pagination.vue'
  35. import { ref, onMounted } from 'vue'
  36. import { collectList } from '@/api/my.js'
  37. const form = ref({
  38. pageNum: 1,
  39. pageSize: 10,
  40. total: 0
  41. })
  42. const list = ref([])
  43. const getList = async () => {
  44. let res = await collectList(form.value);
  45. console.log(res);
  46. form.value.total = res.total;
  47. list.value = res.rows
  48. }
  49. const handlePageChange = (page) => {
  50. list.value = []
  51. form.value.pageNum = page;
  52. getList()
  53. }
  54. onMounted(() => {
  55. getList()
  56. })
  57. </script>
  58. <style scoped lang="scss">
  59. .collection {
  60. padding-bottom: 20px;
  61. .title {
  62. height: 60px;
  63. font-size: 20px;
  64. font-weight: bold;
  65. color: #333333;
  66. }
  67. .collection-list {
  68. li {
  69. padding: 16px;
  70. margin-bottom: 16px;
  71. background: #F5F7FA;
  72. border-radius: 16px;
  73. &:last-child {
  74. margin-bottom: 0;
  75. }
  76. .image {
  77. width: 213px;
  78. height: 120px;
  79. object-fit: cover;
  80. border-radius: 8px;
  81. margin-right: 16px;
  82. }
  83. .collection-list-main {
  84. flex: 1;
  85. display: flex;
  86. align-items: center;
  87. justify-content: space-between;
  88. .collection-list-main-left {
  89. flex: 1;
  90. margin-right: 16px;
  91. .titles {
  92. font-size: 18px;
  93. font-weight: bold;
  94. color: #333333;
  95. }
  96. .tag {
  97. margin: 8px 0;
  98. }
  99. .content {
  100. color: #666666;
  101. font-size: 14px;
  102. line-height: 22px;
  103. }
  104. }
  105. .btn {
  106. width: 120px;
  107. height: 32px;
  108. color: #FFFFFF;
  109. font-size: 14px;
  110. cursor: pointer;
  111. background: linear-gradient(270deg, #0055FE 0%, #C832FA 100%);
  112. border-radius: 4px;
  113. &:hover {
  114. opacity: 0.7;
  115. }
  116. img {
  117. width: 14px;
  118. height: 14px;
  119. margin-right: 4px;
  120. }
  121. }
  122. .active {
  123. background: #FFFFFF;
  124. color: #2D71FF;
  125. }
  126. }
  127. }
  128. }
  129. }
  130. </style>