SidebarRecommend.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div>
  3. <div class="recommend-container">
  4. <div class="flc">
  5. <a-image :width="24" :src="resourceIcon" />
  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. import resourceIcon from '@/assets/images/resourceIcon.png'
  55. const emit = defineEmits(['handlerItem'])
  56. import { list } from '@/api/portal'
  57. import tool from '@/utils/tool'
  58. import sysConfig from '@/config/index'
  59. import EventBus from '@/utils/EventBus'
  60. const currentPage = reactive({
  61. funcType: 1,
  62. current: 1,
  63. size: 6
  64. })
  65. const recommendations = ref([
  66. // { id: '1', title: '资源名称', time: '05-22', look: '10000' },
  67. // { id: '2', title: '资源名称', time: '05-22', look: '10000' },
  68. // { id: '3', title: '资源名称', time: '05-22', look: '10000' },
  69. // { id: '4', title: '资源名称', time: '05-22', look: '10000' },
  70. // { id: '5', title: '资源名称', time: '05-22', look: '10000' },
  71. // { id: '6', title: '资源名称', time: '05-22', look: '10000' }
  72. ])
  73. // 更多数据...
  74. const getList = () => {
  75. list(currentPage)
  76. .then((res) => {
  77. if (res.code == 200) {
  78. recommendations.value = res.data.records
  79. currentPage.current = res.data.current
  80. // "size": 20,
  81. // "current": 1,
  82. // "pages": 1
  83. }
  84. })
  85. .catch((err) => {
  86. console.log(err)
  87. })
  88. }
  89. onMounted(() => {
  90. getList()
  91. })
  92. const upLoadList = (data) => {
  93. let queryData = data
  94. list({ ...currentPage, ...queryData })
  95. .then((res) => {
  96. if (res.code == 200) {
  97. recommendations.value = res.data.records
  98. currentPage.current = res.data.current
  99. }
  100. })
  101. .catch((err) => {
  102. console.log(err)
  103. })
  104. }
  105. const handlerItem = (item) => {
  106. // emit('handlerItem', item)
  107. EventBus.emit('openResourceDetails', { id: item.id })
  108. }
  109. EventBus.off('upLoadList', upLoadList)
  110. EventBus.on('upLoadList', upLoadList)
  111. </script>
  112. <style scoped>
  113. .recommend-container {
  114. display: flex;
  115. flex-direction: column;
  116. border-radius: 4px;
  117. }
  118. .recommend-item {
  119. display: flex;
  120. cursor: pointer;
  121. margin-top: 16px;
  122. padding-bottom: 16px;
  123. }
  124. .recommend-avatar {
  125. margin-right: 15px;
  126. }
  127. .recommend-content {
  128. flex: 1;
  129. }
  130. .recommend-title {
  131. font-size: 16px;
  132. color: #1890ff;
  133. margin-bottom: 5px;
  134. }
  135. .recommend-description {
  136. font-size: 14px;
  137. color: #666;
  138. }
  139. .item {
  140. min-width: 100px;
  141. height: 100px;
  142. background-color: rgba(5, 5, 5, 0.219);
  143. flex: 1;
  144. }
  145. .flc {
  146. display: flex;
  147. justify-content: flex-start;
  148. align-items: center;
  149. }
  150. .borderBottom {
  151. border-bottom: 1px solid #ebebeb;
  152. }
  153. .f12 {
  154. font-size: 12px;
  155. }
  156. .single-line {
  157. max-width: 150px;
  158. overflow: hidden;
  159. text-overflow: ellipsis;
  160. white-space: nowrap;
  161. }
  162. .fzcoloe {
  163. color: #86909c;
  164. }
  165. </style>