ResourceList.vue 5.1 KB

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