Correlation.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div style="margin-bottom: 50px">
  3. <div class="recommend-container">
  4. <h3>相关课程</h3>
  5. <div v-for="(item, index) in recommendations" :key="index" class="recommend-item" @click="handlerItem(item)">
  6. <div
  7. class="item"
  8. :style="{
  9. backgroundSize: 'cover',
  10. backgroundPosition: 'center',
  11. backgroundImage:
  12. 'url(' +
  13. (item.coverImagePath != '' && sysConfig.FILE_URL + item.coverImagePath
  14. ? sysConfig.FILE_URL + item.coverImagePath
  15. : '') +
  16. ')'
  17. }"
  18. ></div>
  19. <div style="display: flex; flex-direction: column; justify-content: space-between; margin-left: 10px">
  20. <span style="font-weight: bold; font-size: 12px; margin-top: 5px">{{ item.fileName }}</span>
  21. <div style="display: flex; justify-content: center; align-items: space-between">
  22. <div style="display: flex; justify-content: center; align-items: center">
  23. <FieldTimeOutlined />
  24. <div style="width: 5px"></div>
  25. <span style="font-size: 12px">{{ item.uploadTime }}</span>
  26. </div>
  27. <div style="width: 20px"></div>
  28. <div style="display: flex; justify-content: center; align-items: center">
  29. <EyeOutlined />
  30. <div style="width: 5px"></div>
  31. <span style="font-size: 12px">{{ item.viewCount }}</span>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script setup>
  40. const emit = defineEmits(['handlerItem'])
  41. import { list } from '@/api/portal'
  42. import tool from '@/utils/tool'
  43. import sysConfig from '@/config/index'
  44. import EventBus from '@/utils/EventBus'
  45. const currentPage = reactive({
  46. funcType: 2,
  47. current: 1,
  48. size: 6
  49. })
  50. const recommendations = ref([])
  51. const getList = () => {
  52. list(currentPage)
  53. .then((res) => {
  54. console.log('下面列表获取', res)
  55. if (res.code == 200) {
  56. recommendations.value = res.data.records
  57. currentPage.current = res.data.current
  58. // "size": 20,
  59. // "current": 1,
  60. // "pages": 1
  61. }
  62. })
  63. .catch((err) => {
  64. console.log(err)
  65. })
  66. }
  67. onMounted(() => {
  68. getList()
  69. })
  70. const upLoadList = (data) => {
  71. let queryData = data
  72. list({ ...currentPage, ...queryData })
  73. .then((res) => {
  74. if (res.code == 200) {
  75. recommendations.value = res.data.records
  76. currentPage.current = res.data.current
  77. }
  78. })
  79. .catch((err) => {
  80. console.log(err)
  81. })
  82. }
  83. const handlerItem = (item) => {
  84. // emit('handlerItem', item)
  85. EventBus.emit('openResourceDetails', { id: item.id })
  86. }
  87. EventBus.off('upLoadList', upLoadList)
  88. EventBus.on('upLoadList', upLoadList)
  89. </script>
  90. <style scoped>
  91. .recommend-container {
  92. display: flex;
  93. flex-direction: column;
  94. border: 1px solid #e8e8e8;
  95. margin-bottom: 10px;
  96. border-radius: 4px;
  97. padding: 10px;
  98. }
  99. .recommend-item {
  100. display: flex;
  101. cursor: pointer;
  102. margin-bottom: 10px;
  103. }
  104. .recommend-avatar {
  105. margin-right: 15px;
  106. }
  107. .recommend-content {
  108. flex: 1;
  109. }
  110. .recommend-title {
  111. font-size: 16px;
  112. color: #1890ff;
  113. margin-bottom: 5px;
  114. }
  115. .recommend-description {
  116. font-size: 14px;
  117. color: #666;
  118. }
  119. .item {
  120. min-width: 100px;
  121. height: 70px;
  122. background-color: rgba(5, 5, 5, 0.219);
  123. }
  124. </style>