Correlation.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div>
  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. // "code": 200,
  64. // "msg": "操作成功",
  65. // "data": {
  66. // "records": [
  67. // {
  68. // "publishTime": 1750820852119,
  69. // "courseName": "转手绢",
  70. // "collegeIdName": "二人转研究学院",
  71. // "teacherId": "1936984714123436034",
  72. // "coverImageId": "1936957954687279104",
  73. // "collegeId": "1",
  74. // "timeLimitType": "0",
  75. // "viewCount": 0,
  76. // "courseId": "1937091089341124610",
  77. // "teacherIdName": "老师"
  78. // },
  79. // {
  80. // "publishTime": 1750820875604,
  81. // "courseName": "胸口碎大石",
  82. // "collegeIdName": "二人转研究学院",
  83. // "teacherId": "1936984714123436034",
  84. // "coverImageId": "1937056330116354050",
  85. // "coverImagePath": "http://localhost:9003/api/webapp/dev/file/download?id=1937056330116354050",
  86. // "collegeId": "1",
  87. // "timeLimitType": "0",
  88. // "viewCount": 10000,
  89. // "courseId": "1937326992873689089",
  90. // "teacherIdName": "老师"
  91. // }
  92. // ],
  93. // "total": 2,
  94. // "size": 20,
  95. // "current": 1,
  96. // "orders": [],
  97. // "optimizeCountSql": true,
  98. // "searchCount": true,
  99. // "maxLimit": null,
  100. // "countId": null,
  101. // "pages": 1
  102. // }
  103. // }
  104. })
  105. .catch((err) => {
  106. console.log(err)
  107. })
  108. }
  109. onMounted(() => {
  110. getList()
  111. })
  112. const handlerItem = (item) => {
  113. // emit('handlerItem', item)
  114. EventBus.emit('openResourceDetails', { id: item.id })
  115. }
  116. </script>
  117. <style scoped>
  118. .recommend-container {
  119. display: flex;
  120. flex-direction: column;
  121. border: 1px solid #e8e8e8;
  122. margin-bottom: 10px;
  123. border-radius: 4px;
  124. padding: 10px;
  125. }
  126. .recommend-item {
  127. display: flex;
  128. cursor: pointer;
  129. margin-bottom: 10px;
  130. }
  131. .recommend-avatar {
  132. margin-right: 15px;
  133. }
  134. .recommend-content {
  135. flex: 1;
  136. }
  137. .recommend-title {
  138. font-size: 16px;
  139. color: #1890ff;
  140. margin-bottom: 5px;
  141. }
  142. .recommend-description {
  143. font-size: 14px;
  144. color: #666;
  145. }
  146. .item {
  147. min-width: 100px;
  148. height: 70px;
  149. background-color: rgba(5, 5, 5, 0.219);
  150. }
  151. </style>