ResourceList.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <div class="resource-list">
  3. <div class="list-header">
  4. <div style="display: flex">
  5. <div style="display: flex; justify-content: center; align-items: center">
  6. <div class="line"></div>
  7. <span style="font-weight: bold">共计 {{ total }} 个资源</span>
  8. </div>
  9. <div style="width: 20px"></div>
  10. <TabSwitcher @selectTab="selectTab" />
  11. </div>
  12. <a-input-search
  13. v-model:value="currentPage.queryInfo"
  14. placeholder="请输入资源关键词"
  15. style="width: 200px"
  16. @search="onSearch"
  17. />
  18. </div>
  19. <a-row :gutter="[16, 16]">
  20. <a-col :span="8" v-for="(item, index) in resources" :key="index">
  21. <div style="border-radius: 10px 10px 5px 5px; border: 1px solid #dcdcdc">
  22. <div style="display: flex; position: relative">
  23. <div
  24. class="resource"
  25. @click="handleItem(item)"
  26. :style="{
  27. backgroundSize: 'cover',
  28. backgroundPosition: 'center',
  29. backgroundImage:
  30. 'url(' +
  31. (item.coverImagePath != '' && sysConfig.FILE_URL + item.coverImagePath
  32. ? sysConfig.FILE_URL + item.coverImagePath
  33. : '') +
  34. ')'
  35. }"
  36. >
  37. <!-- <a-image
  38. style="width: 100%; height: 100%"
  39. :src="
  40. item.coverImagePath != '' && sysConfig.FILE_URL + item.coverImagePath
  41. ? sysConfig.FILE_URL + item.coverImagePath
  42. : ''
  43. "
  44. alt=""
  45. :preview="false"
  46. ></a-image> -->
  47. <PlayCircleOutlined
  48. :style="{ fontSize: '40px', color: 'white' }"
  49. style="position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%)"
  50. />
  51. </div>
  52. </div>
  53. <div style="display: flex; flex-direction: column; padding: 5px 10px">
  54. <span style="font-size: 16px; font-weight: bold">{{ item.fileName }}</span>
  55. <span style="font-size: 12px">{{ item.collegeIdName }}</span>
  56. <span style="font-size: 12px">{{ item.majorIdName }}</span>
  57. <div style="display: flex; justify-content: space-between">
  58. <div style="display: flex; justify-content: center; align-items: center">
  59. <FieldTimeOutlined />
  60. <div style="width: 5px"></div>
  61. <span style="font-size: 12px">{{ item.uploadTime }}</span>
  62. </div>
  63. <div style="display: flex; justify-content: center; align-items: center">
  64. <EyeOutlined />
  65. <div style="width: 5px"></div>
  66. <span style="font-size: 12px">{{ item.viewCount }}</span>
  67. </div>
  68. </div>
  69. </div>
  70. <!-- <a-card-meta :title="item.title">
  71. <template #description>
  72. <p>{{ item.description }}</p>
  73. </template>
  74. </a-card-meta> -->
  75. </div>
  76. </a-col>
  77. </a-row>
  78. <div style="height: 20px"></div>
  79. <div style="display: flex; width: 100%; align-items: center; justify-content: center">
  80. <a-pagination v-model:current="currentPage.current" :total="total" @change="onChange" show-size-changer />
  81. </div>
  82. <div style="height: 20px"></div>
  83. </div>
  84. </template>
  85. <script setup>
  86. import { ref } from 'vue'
  87. import TabSwitcher from './TabSwitcher.vue'
  88. import { list } from '@/api/portal'
  89. import tool from '@/utils/tool'
  90. import EventBus from '@/utils/EventBus'
  91. import sysConfig from '@/config/index'
  92. const total = ref(1024)
  93. const tabKey = ref('new')
  94. const currentPage = reactive({
  95. current: 1,
  96. size: 10,
  97. queryInfo: ''
  98. })
  99. const searchKeyword = ref('')
  100. const resources = ref([
  101. // { id: 1, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  102. // { id: 2, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  103. // { id: 3, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  104. // { id: 4, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  105. // { id: 5, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  106. // { id: 6, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  107. // { id: 7, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  108. // { id: 8, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  109. // { id: 9, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  110. // { id: 10, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  111. // { id: 11, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  112. // { id: 12, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 }
  113. // 更多数据...
  114. ])
  115. const selectTab = (key) => {
  116. console.log('现在是点了tab', key)
  117. }
  118. const handleItem = (item) => {
  119. console.log('点了看教材的条目了', item)
  120. EventBus.emit('openResourceDetails', { id: item.id })
  121. }
  122. const onSearch = (value) => {
  123. console.log('搜索了', value)
  124. currentPage.current = 1
  125. currentPage.size = 10
  126. getList()
  127. }
  128. const onChange = (page, pageSize) => {
  129. console.log('翻页', page, pageSize)
  130. getList()
  131. }
  132. // watch(currentPage.value.current, (newValue) => {
  133. // console.log('变化了', newValue)
  134. // // getList()
  135. // })
  136. const getList = () => {
  137. list(currentPage)
  138. .then((res) => {
  139. console.log('下面列表获取', res)
  140. if (res.code == 200) {
  141. resources.value = res.data.records
  142. total.value = res.data.total
  143. currentPage.current = res.data.current
  144. // "size": 20,
  145. // "current": 1,
  146. // "pages": 1
  147. }
  148. // {
  149. // "code": 200,
  150. // "msg": "操作成功",
  151. // "data": {
  152. // "records": [
  153. // {
  154. // "publishTime": 1750820852119,
  155. // "courseName": "转手绢",
  156. // "collegeIdName": "二人转研究学院",
  157. // "teacherId": "1936984714123436034",
  158. // "coverImageId": "1936957954687279104",
  159. // "collegeId": "1",
  160. // "timeLimitType": "0",
  161. // "viewCount": 0,
  162. // "courseId": "1937091089341124610",
  163. // "teacherIdName": "老师"
  164. // },
  165. // {
  166. // "publishTime": 1750820875604,
  167. // "courseName": "胸口碎大石",
  168. // "collegeIdName": "二人转研究学院",
  169. // "teacherId": "1936984714123436034",
  170. // "coverImageId": "1937056330116354050",
  171. // "coverImagePath": "http://localhost:9003/api/webapp/dev/file/download?id=1937056330116354050",
  172. // "collegeId": "1",
  173. // "timeLimitType": "0",
  174. // "viewCount": 10000,
  175. // "courseId": "1937326992873689089",
  176. // "teacherIdName": "老师"
  177. // }
  178. // ],
  179. // "total": 2,
  180. // "size": 20,
  181. // "current": 1,
  182. // "orders": [],
  183. // "optimizeCountSql": true,
  184. // "searchCount": true,
  185. // "maxLimit": null,
  186. // "countId": null,
  187. // "pages": 1
  188. // }
  189. // }
  190. })
  191. .catch((err) => {
  192. console.log(err)
  193. })
  194. }
  195. onMounted(() => {
  196. getList()
  197. })
  198. </script>
  199. <style scoped>
  200. .list-header {
  201. display: flex;
  202. align-items: center;
  203. justify-content: space-between;
  204. margin-bottom: 20px;
  205. }
  206. .line {
  207. width: 6px;
  208. height: 15px;
  209. background-color: rgb(0, 140, 255);
  210. margin-right: 5px;
  211. }
  212. .resource {
  213. width: 100%;
  214. height: 150px;
  215. background: #00000011;
  216. border-radius: 10px 10px 0 0;
  217. display: flex;
  218. justify-content: center;
  219. align-items: center;
  220. cursor: pointer;
  221. position: relative;
  222. overflow: hidden;
  223. }
  224. .resource::before {
  225. content: '';
  226. position: absolute;
  227. top: 0;
  228. left: 0;
  229. width: 100%;
  230. height: 100%;
  231. background-color: transparent;
  232. transition: background-color 0.6s ease;
  233. z-index: 1;
  234. }
  235. .resource:hover::before {
  236. background-color: rgba(0, 0, 0, 0.4); /* 悬停变暗 */
  237. }
  238. /* 图标或其他内容要放在最上层 */
  239. .resource > * {
  240. position: relative;
  241. z-index: 2;
  242. }
  243. /* .resource:hover {
  244. background-color: #ffffff8c;
  245. } */
  246. </style>