ResourceList.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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; position: relative">
  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. <PlayCircleOutlined
  38. :style="{ fontSize: '40px', color: 'white' }"
  39. style="position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%)"
  40. />
  41. <div
  42. style="
  43. position: absolute;
  44. bottom: 0;
  45. right: 0;
  46. background-color: #40a0ff;
  47. color: white;
  48. padding: 5px 20px;
  49. border-radius: 4px;
  50. "
  51. >
  52. 共{{ item.lessonCount }}节课
  53. </div>
  54. </div>
  55. </div>
  56. <div style="display: flex; flex-direction: column; padding: 5px 10px">
  57. <span style="font-size: 16px; font-weight: bold">{{ item.fileName }}</span>
  58. <span style="font-size: 12px">{{ item.collegeIdName }}</span>
  59. <span style="font-size: 12px">{{ item.majorIdName }}</span>
  60. <div style="display: flex; justify-content: space-between">
  61. <div style="display: flex; justify-content: center; align-items: center">
  62. <FieldTimeOutlined />
  63. <div style="width: 5px"></div>
  64. <span style="font-size: 12px">{{ item.uploadTime }}</span>
  65. </div>
  66. <div style="display: flex; justify-content: center; align-items: center">
  67. <EyeOutlined />
  68. <div style="width: 5px"></div>
  69. <span style="font-size: 12px">{{ item.viewCount }}</span>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </a-col>
  75. </a-row>
  76. <div style="height: 20px"></div>
  77. <div style="display: flex; width: 100%; align-items: center; justify-content: center">
  78. <a-pagination
  79. v-model:current="currentPage.current"
  80. v-model:pageSize="currentPage.size"
  81. :total="total"
  82. @change="onChange"
  83. />
  84. </div>
  85. <div style="height: 20px"></div>
  86. </div>
  87. </template>
  88. <script setup>
  89. import { ref, onMounted } from 'vue'
  90. import TabSwitcher from './TabSwitcher.vue'
  91. import { list } from '@/api/portal'
  92. import tool from '@/utils/tool'
  93. import EventBus from '@/utils/EventBus'
  94. import sysConfig from '@/config/index'
  95. const queryData = ref({})
  96. const total = ref(0)
  97. const tabKey = ref(0)
  98. const currentPage = reactive({
  99. current: 1,
  100. size: 12,
  101. queryInfo: '',
  102. sortflag: tabKey
  103. })
  104. const searchKeyword = ref('')
  105. const resources = ref([])
  106. const selectTab = (key) => {
  107. if (key == 'latest') {
  108. tabKey.value = 0
  109. } else {
  110. tabKey.value = 1
  111. }
  112. currentPage.sortflag = tabKey.value
  113. currentPage.current = 1
  114. currentPage.size = 12
  115. getList()
  116. }
  117. const handleItem = (item) => {
  118. EventBus.emit('openCourseDetails', { id: item.id })
  119. }
  120. const onSearch = (value) => {
  121. currentPage.current = 1
  122. currentPage.size = 12
  123. getList()
  124. }
  125. const onChange = (page, pageSize) => {
  126. getList()
  127. }
  128. const getList = () => {
  129. list({ ...currentPage, ...queryData.value })
  130. .then((res) => {
  131. if (res.code == 200) {
  132. resources.value = res.data.records
  133. total.value = res.data.total
  134. currentPage.current = res.data.current
  135. }
  136. })
  137. .catch((err) => {
  138. console.log(err)
  139. })
  140. }
  141. const upLoadList = (data) => {
  142. currentPage.current = 1
  143. currentPage.size = 12
  144. queryData.value = data
  145. list({ ...currentPage, ...queryData.value })
  146. .then((res) => {
  147. if (res.code == 200) {
  148. resources.value = res.data.records
  149. total.value = res.data.total
  150. currentPage.current = res.data.current
  151. }
  152. })
  153. .catch((err) => {
  154. console.log(err)
  155. })
  156. }
  157. onMounted(() => {
  158. getList()
  159. })
  160. EventBus.off('upLoadList', upLoadList)
  161. EventBus.on('upLoadList', upLoadList)
  162. </script>
  163. <style scoped>
  164. .list-header {
  165. display: flex;
  166. align-items: center;
  167. justify-content: space-between;
  168. margin-bottom: 20px;
  169. }
  170. .line {
  171. width: 6px;
  172. height: 15px;
  173. background-color: rgb(0, 140, 255);
  174. margin-right: 5px;
  175. }
  176. .resource {
  177. width: 100%;
  178. height: 150px;
  179. position: relative;
  180. background: #00000011;
  181. border-radius: 10px 10px 0 0;
  182. display: flex;
  183. justify-content: center;
  184. align-items: center;
  185. cursor: pointer;
  186. position: relative;
  187. overflow: hidden;
  188. }
  189. .resource::before {
  190. content: '';
  191. position: absolute;
  192. top: 0;
  193. left: 0;
  194. width: 100%;
  195. height: 100%;
  196. background-color: transparent;
  197. transition: background-color 0.6s ease;
  198. z-index: 1;
  199. }
  200. .resource:hover::before {
  201. background-color: rgba(0, 0, 0, 0.4); /* 悬停变暗 */
  202. }
  203. .resource > * {
  204. position: relative;
  205. z-index: 2;
  206. }
  207. </style>