Correlation.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div>
  3. <div class="recommend-container">
  4. <div class="flc">
  5. <a-image :width="24" :src="resourceIcon" :preview="false" />
  6. <div style="margin-bottom: 0; font-size: 20px; font-weight: bold; margin-left: 8px">
  7. <span>相关</span>
  8. <span style="color: #1890ff">课程</span>
  9. </div>
  10. </div>
  11. <div
  12. v-for="(item, index) in recommendations"
  13. :key="index"
  14. class="recommend-item"
  15. :class="recommendations.length - 1 > index ? 'borderBottom' : ''"
  16. @click="handlerItem(item)"
  17. >
  18. <div
  19. class="item"
  20. :style="{
  21. backgroundSize: 'cover',
  22. backgroundPosition: 'center',
  23. borderRadius: '4px',
  24. overflow: 'hidden',
  25. backgroundImage:
  26. 'url(' +
  27. (item.coverImagePath != '' && sysConfig.FILE_URL + item.coverImagePath
  28. ? sysConfig.FILE_URL + item.coverImagePath
  29. : '') +
  30. ')'
  31. }"
  32. ></div>
  33. <div style="display: flex; flex-direction: column; justify-content: space-between; margin-left: 10px; flex: 1">
  34. <span style="font-weight: bold; margin-top: 5px" class="single-line">{{ item.fileName }}</span>
  35. <div style="display: flex; justify-content: space-between; align-items: space-between">
  36. <div style="display: flex; justify-content: center; align-items: center">
  37. <FieldTimeOutlined class="fzcoloe" />
  38. <div style="width: 5px"></div>
  39. <span class="f12 fzcoloe">{{ item.uploadTime.slice(0, 10) }}</span>
  40. </div>
  41. <div style="width: 20px"></div>
  42. <div style="display: flex; justify-content: center; align-items: center">
  43. <EyeOutlined class="fzcoloe" />
  44. <div style="width: 5px"></div>
  45. <span class="f12 fzcoloe">{{ item.viewCount }}</span>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </template>
  53. <script setup>
  54. const emit = defineEmits(['handlerItem'])
  55. import { list } from '@/api/portal'
  56. import tool from '@/utils/tool'
  57. import sysConfig from '@/config/index'
  58. import EventBus from '@/utils/EventBus'
  59. import resourceIcon from '@/assets/images/resourceIcon.png'
  60. const currentPage = reactive({
  61. funcType: 2,
  62. current: 1,
  63. size: 6
  64. })
  65. const recommendations = ref([])
  66. const getList = () => {
  67. list(currentPage)
  68. .then((res) => {
  69. if (res.code == 200) {
  70. recommendations.value = res.data.records
  71. currentPage.current = res.data.current
  72. // "size": 20,
  73. // "current": 1,
  74. // "pages": 1
  75. }
  76. })
  77. .catch((err) => {
  78. console.log(err)
  79. })
  80. }
  81. onMounted(() => {
  82. getList()
  83. })
  84. const upLoadList = (data) => {
  85. let queryData = data
  86. list({ ...currentPage, ...queryData })
  87. .then((res) => {
  88. if (res.code == 200) {
  89. recommendations.value = res.data.records
  90. currentPage.current = res.data.current
  91. }
  92. })
  93. .catch((err) => {
  94. console.log(err)
  95. })
  96. }
  97. const handlerItem = (item) => {
  98. // emit('handlerItem', item)
  99. EventBus.emit('openResourceDetails', { id: item.id })
  100. }
  101. EventBus.off('upLoadList', upLoadList)
  102. EventBus.on('upLoadList', upLoadList)
  103. </script>
  104. <style scoped>
  105. .recommend-container {
  106. display: flex;
  107. flex-direction: column;
  108. border-radius: 4px;
  109. }
  110. .recommend-item {
  111. display: flex;
  112. cursor: pointer;
  113. margin-top: 16px;
  114. padding-bottom: 16px;
  115. }
  116. .recommend-avatar {
  117. margin-right: 15px;
  118. }
  119. .recommend-content {
  120. flex: 1;
  121. }
  122. .recommend-title {
  123. font-size: 16px;
  124. color: #1890ff;
  125. margin-bottom: 5px;
  126. }
  127. .recommend-description {
  128. font-size: 14px;
  129. color: #666;
  130. }
  131. .flc {
  132. display: flex;
  133. justify-content: flex-start;
  134. align-items: center;
  135. }
  136. .item {
  137. min-width: 100px;
  138. height: 100px;
  139. background-color: rgba(5, 5, 5, 0.219);
  140. flex: 1;
  141. }
  142. .borderBottom {
  143. border-bottom: 1px solid #ebebeb;
  144. }
  145. .f12 {
  146. font-size: 12px;
  147. }
  148. .single-line {
  149. max-width: 150px;
  150. overflow: hidden;
  151. text-overflow: ellipsis;
  152. white-space: nowrap;
  153. }
  154. .fzcoloe {
  155. color: #86909c;
  156. }
  157. </style>