Correlation.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 class="item"></div>
  7. <div style="display: flex; flex-direction: column; justify-content: space-between; margin-left: 10px">
  8. <span style="font-weight: bold; font-size: 12px; margin-top: 5px">{{ item.title }}</span>
  9. <div style="display: flex; justify-content: center; align-items: space-between">
  10. <div style="display: flex; justify-content: center; align-items: center">
  11. <FieldTimeOutlined />
  12. <div style="width: 5px"></div>
  13. <span style="font-size: 12px">{{ item.time }}</span>
  14. </div>
  15. <div style="width: 20px"></div>
  16. <div style="display: flex; justify-content: center; align-items: center">
  17. <EyeOutlined />
  18. <div style="width: 5px"></div>
  19. <span style="font-size: 12px">{{ item.look }}</span>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </template>
  27. <script setup>
  28. const emit = defineEmits(['handlerItem'])
  29. import { list } from '@/api/portal'
  30. import tool from '@/utils/tool'
  31. import sysConfig from '@/config/index'
  32. import EventBus from '@/utils/EventBus'
  33. const currentPage = reactive({
  34. funcType: 2,
  35. current: 1,
  36. size: 6
  37. })
  38. const recommendations = [
  39. // { id: '1', title: '资源名称', time: '05-22', look: '10000' },
  40. // { id: '2', title: '资源名称', time: '05-22', look: '10000' },
  41. // { id: '3', title: '资源名称', time: '05-22', look: '10000' },
  42. // { id: '4', title: '资源名称', time: '05-22', look: '10000' },
  43. // { id: '5', title: '资源名称', time: '05-22', look: '10000' },
  44. // { id: '6', title: '资源名称', time: '05-22', look: '10000' }
  45. // 更多数据...
  46. ]
  47. const getList = () => {
  48. list(currentPage)
  49. .then((res) => {
  50. console.log('下面列表获取', res)
  51. if (res.code == 200) {
  52. recommendations.value = res.data.records
  53. currentPage.current = res.data.current
  54. // "size": 20,
  55. // "current": 1,
  56. // "pages": 1
  57. }
  58. // {
  59. // "code": 200,
  60. // "msg": "操作成功",
  61. // "data": {
  62. // "records": [
  63. // {
  64. // "publishTime": 1750820852119,
  65. // "courseName": "转手绢",
  66. // "collegeIdName": "二人转研究学院",
  67. // "teacherId": "1936984714123436034",
  68. // "coverImageId": "1936957954687279104",
  69. // "collegeId": "1",
  70. // "timeLimitType": "0",
  71. // "viewCount": 0,
  72. // "courseId": "1937091089341124610",
  73. // "teacherIdName": "老师"
  74. // },
  75. // {
  76. // "publishTime": 1750820875604,
  77. // "courseName": "胸口碎大石",
  78. // "collegeIdName": "二人转研究学院",
  79. // "teacherId": "1936984714123436034",
  80. // "coverImageId": "1937056330116354050",
  81. // "coverImagePath": "http://localhost:9003/api/webapp/dev/file/download?id=1937056330116354050",
  82. // "collegeId": "1",
  83. // "timeLimitType": "0",
  84. // "viewCount": 10000,
  85. // "courseId": "1937326992873689089",
  86. // "teacherIdName": "老师"
  87. // }
  88. // ],
  89. // "total": 2,
  90. // "size": 20,
  91. // "current": 1,
  92. // "orders": [],
  93. // "optimizeCountSql": true,
  94. // "searchCount": true,
  95. // "maxLimit": null,
  96. // "countId": null,
  97. // "pages": 1
  98. // }
  99. // }
  100. })
  101. .catch((err) => {
  102. console.log(err)
  103. })
  104. }
  105. onMounted(() => {
  106. getList()
  107. })
  108. const handlerItem = (item) => {
  109. // emit('handlerItem', item)
  110. EventBus.emit('openResourceDetails', { id: item.id })
  111. }
  112. </script>
  113. <style scoped>
  114. .recommend-container {
  115. display: flex;
  116. flex-direction: column;
  117. border: 1px solid #e8e8e8;
  118. margin-bottom: 10px;
  119. border-radius: 4px;
  120. padding: 10px;
  121. }
  122. .recommend-item {
  123. display: flex;
  124. cursor: pointer;
  125. margin-bottom: 10px;
  126. }
  127. .recommend-avatar {
  128. margin-right: 15px;
  129. }
  130. .recommend-content {
  131. flex: 1;
  132. }
  133. .recommend-title {
  134. font-size: 16px;
  135. color: #1890ff;
  136. margin-bottom: 5px;
  137. }
  138. .recommend-description {
  139. font-size: 14px;
  140. color: #666;
  141. }
  142. .item {
  143. width: 100px;
  144. height: 70px;
  145. background-color: rgba(5, 5, 5, 0.219);
  146. }
  147. </style>