VideoDetails.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <template>
  2. <div>
  3. <h1>{{ resName }}</h1>
  4. <div class="user-info-container">
  5. <a-card :bordered="false" class="boxShadow cardBox mr-3 flex-3">
  6. <div class="video-info">
  7. <div style="height: 600px">
  8. <div v-if="isImageFile(resSrc)" style="width: 100%; height: 100%">
  9. <a-image width="100%" height="100%" :src="fileSrc(resSrc)" :preview="true" />
  10. </div>
  11. <div v-if="isVideoFile(resSrc)" style="width: 100%; height: 100%">
  12. <video :src="fileSrc(resSrc)" controls style="width: 100%; height: 100%" />
  13. </div>
  14. <div v-if="isDocumentFile(resSrc)" style="width: 100%; height: 100%">
  15. <FilePreviewer v-if="resSrc" :fileUrl="fileSrc(resSrc)" :fileName="resName" :fileType="fileType" />
  16. </div>
  17. <div class="imgBox" v-if="itemData.id && unknownFile">
  18. <a-image height="100%" :src="unknownFile" :preview="false" />
  19. </div>
  20. </div>
  21. <!-- 用户信息部分 -->
  22. <div class="user-info" style="display: flex; flex-direction: column">
  23. <div style="display: flex; align-items: center; justify-content: space-between; width: 100%">
  24. <div style="display: flex; align-items: center">
  25. <div class="user-avatar"></div>
  26. <div class="user-details">
  27. <div class="user-name">{{ itemData.resourceCreaterUserName }}</div>
  28. <div class="publish-time">{{ itemData.uploadTime }}</div>
  29. </div>
  30. </div>
  31. <div style="display: flex; align-items: center" v-if="!isState">
  32. <div class="metrics">
  33. <div class="metric-item">
  34. <span>{{ itemData.viewCount }}</span>
  35. <span>播放量</span>
  36. </div>
  37. <div class="liene"></div>
  38. <div class="metric-item">
  39. <span>{{ talkNum }}</span>
  40. <span>评论</span>
  41. </div>
  42. <div class="liene"></div>
  43. <div class="metric-item">
  44. <span>{{ collectNum }}</span>
  45. <span>收藏</span>
  46. </div>
  47. </div>
  48. <div style="width: 10px"></div>
  49. <div class="actions">
  50. <div
  51. style="display: flex; align-items: center; cursor: pointer; margin-right: 5px"
  52. @click="handlerShareDialog"
  53. >
  54. <ExportOutlined />
  55. <div style="width: 10px"></div>
  56. <button class="share-btn">分享资源</button>
  57. </div>
  58. <div style="display: flex; align-items: center; cursor: pointer" @click="handlerCollection">
  59. <StarOutlined v-if="starTag == false" />
  60. <StarFilled v-if="starTag == true" />
  61. <div style="width: 10px"></div>
  62. <button class="favorite-btn">收藏资源</button>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </a-card>
  70. <a-card class="flex-1">
  71. <div class="resInfo">
  72. <div class="titleBox">
  73. <span style="display: block; font-weight: bold; font-size: 20px">资源信息</span>
  74. </div>
  75. <div class="lableBox">
  76. <span style="display: block; font-weight: bold; font-size: 18px">{{ resName }}</span>
  77. </div>
  78. <div class="lableBox">
  79. <span class="lableName">所属院系: </span>
  80. <span class="lableVal">{{ department }}</span>
  81. </div>
  82. <div class="lableBox">
  83. <span class="lableName">资源类型: </span>
  84. <span class="lableVal">{{ courseType }}</span>
  85. </div>
  86. <div class="lableBox">
  87. <span class="lableName">资源格式: </span>
  88. <span class="lableVal">{{ videoFormat }}</span>
  89. </div>
  90. <div class="lableBox">
  91. <span class="lableName">容量大小: </span>
  92. <span class="lableVal">{{ videoSize }}</span>
  93. </div>
  94. <div class="lableBox">
  95. <span class="lableName">发布时间: </span>
  96. <span class="lableVal">{{ releaseTime }}</span>
  97. </div>
  98. <div class="lableBox">
  99. <span class="lableName">资源描述: </span>
  100. <span class="lableVal">{{ itemData.resourceDesc }}</span>
  101. </div>
  102. <span>资源标签</span>
  103. <div style="display: flex; width: 100%; flex-wrap: wrap">
  104. <a-tag style="margin-top: 5px" v-for="tag in tags" :key="tag">{{ tag }}</a-tag>
  105. </div>
  106. </div>
  107. </a-card>
  108. </div>
  109. <ShareDialog ref="ShareDialogRef"></ShareDialog>
  110. </div>
  111. </template>
  112. <script setup>
  113. import { ref } from 'vue'
  114. import { Tag, Typography, Space, message } from 'ant-design-vue'
  115. import ShareDialog from './ShareDialog.vue'
  116. import { addViewCount, detail, add, cancel, queryList, resourcecentreDetail, getShareLink } from '@/api/portal'
  117. import { useRoute, useRouter } from 'vue-router'
  118. import sysConfig from '@/config/index'
  119. import pdfRes from '@/assets/images/pdf.png'
  120. import FilePreviewer from './FilePreviewer.vue'
  121. import EventBus from '@/utils/EventBus'
  122. import tool from '@/utils/tool'
  123. import { isVideoFile, isImageFile, isDocumentFile } from '@/utils/fileUtil'
  124. const route = useRoute()
  125. const router = useRouter()
  126. const props = defineProps({
  127. isState: {
  128. type: Number,
  129. default: () => null
  130. }
  131. })
  132. const itemData = ref({})
  133. const starTag = ref(false)
  134. const ShareDialogRef = ref(null)
  135. const resSrc = ref('')
  136. const fileType = ref('')
  137. const resName = ref('资源名称')
  138. const teacherName = ref('王某某')
  139. const department = ref('学院本级-航空机务教研室-三级架构名')
  140. const major = ref('初级飞行训练')
  141. const courseType = ref('必修')
  142. const videoFormat = ref('MP4')
  143. const videoDuration = ref('59:34')
  144. const videoSize = ref('598M')
  145. const releaseTime = ref('2025-10-01 11:33:59')
  146. const talkNum = ref(0)
  147. const collectNum = ref(0)
  148. const tags = ref(['标签名称1', '标签名称2', '标签名称3', '标签名称4', '标签名称5'])
  149. const emit = defineEmits(['selectTab', 'onGetPageCommentNew'])
  150. const listUnpublishedView = ref(null)
  151. const handleDownload = (src) => {
  152. window.open(src)
  153. }
  154. const handlerShareDialog = () => {
  155. getShareLink({ id: route.query.id })
  156. .then((res) => {
  157. if (res.code == 200) {
  158. ShareDialogRef.value.open(res.data.shareLink)
  159. }
  160. })
  161. .catch((err) => {})
  162. }
  163. const handlerCollection = async () => {
  164. const id = route.query.id
  165. if (id != undefined && id != '') {
  166. if (starTag.value == true) {
  167. await cancel({ resourceId: id })
  168. message.success('取消收藏')
  169. upDataDetailsNum()
  170. } else {
  171. await add({ resourceId: id })
  172. message.success('收藏成功')
  173. upDataDetailsNum()
  174. }
  175. queryList({ resourceId: id })
  176. .then((ress) => {
  177. if (ress.data == true) {
  178. starTag.value = true
  179. } else {
  180. starTag.value = false
  181. }
  182. })
  183. .catch((err) => {
  184. console.log(err)
  185. })
  186. }
  187. }
  188. const setData = (data) => {
  189. itemData.value = data
  190. }
  191. const fileSrc = computed(() => (e) => sysConfig.FILE_URL + e)
  192. const imageUrl = new URL(`@/assets/images/fileImg/file.png`, import.meta.url).href
  193. const unknownFile = computed((e) => {
  194. if (!isImageFile(resSrc.value) && !isVideoFile(resSrc.value) && !isDocumentFile(resSrc.value)) {
  195. return imageUrl
  196. }
  197. })
  198. const getData = (item) => {
  199. detail({ id: item.id })
  200. .then((res) => {
  201. if (res.code == 200) {
  202. itemData.value = res.data
  203. courseType.value = itemData.value.resourceALLTypeName.split(',').join('/')
  204. department.value = itemData.value.collegeAllIdName.split(',').join('/')
  205. teacherName.value = itemData.value.resourceCreaterUserName
  206. resName.value = itemData.value.fileName
  207. videoFormat.value = itemData.value.suffix
  208. releaseTime.value = itemData.value.uploadTime
  209. videoSize.value = itemData.value.FILESIZE ? itemData.value.FILESIZE + 'b' : ''
  210. tags.value = []
  211. itemData.value.keywordList.forEach((item) => {
  212. tags.value.push(item.wordName)
  213. })
  214. resSrc.value = itemData.value.priviewFileUrl
  215. fileType.value = itemData.value.suffix
  216. emit('onGetPageCommentNew', {
  217. resourceType: itemData.value.resourceType,
  218. resourceTwoType: itemData.value.resourceTwoType
  219. })
  220. const isDump = route.query.isDump
  221. const id = route.query.id
  222. const resourceInfo = itemData.value
  223. if (isDump == 1) {
  224. coursestudentburialpoint({
  225. userFileId: resourceInfo.id, //文件资源id
  226. fileName: resourceInfo.fileName, //文件名称
  227. fileId: resourceInfo.fileId, //文件id
  228. filePath: resourceInfo.fileUrl, //文件路经
  229. funcType: '3', //3
  230. type: '5', //5
  231. resourceRecord: id //资源记录id
  232. })
  233. }
  234. }
  235. })
  236. .catch((err) => {})
  237. }
  238. const upDataList = (item) => {
  239. resourcecentreDetail({ id: item.id })
  240. .then((res) => {
  241. if (res.code == 200) {
  242. talkNum.value = res.data.commentNum
  243. collectNum.value = res.data.collectNum
  244. }
  245. })
  246. .catch((err) => {})
  247. }
  248. const fetchData = () => {
  249. const id = route.query.id
  250. if (id != undefined && id != '') {
  251. queryList({ resourceId: id })
  252. .then((res) => {
  253. if (res.data == true) {
  254. starTag.value = true
  255. } else {
  256. starTag.value = false
  257. }
  258. })
  259. .catch((err) => {
  260. console.log(err)
  261. })
  262. getData({ id: id })
  263. upDataList({ id: id })
  264. }
  265. }
  266. watch(
  267. () => route,
  268. (newRoute) => {
  269. fetchData() // 手动刷新数据的方法
  270. },
  271. { deep: true, immediate: true }
  272. )
  273. onMounted(() => {
  274. fetchData()
  275. })
  276. const upDataDetailsNum = () => {
  277. const id = route.query.id
  278. if (id != undefined && id != '') {
  279. upDataList({ id: id })
  280. }
  281. }
  282. const openResourceDetailsInner = (data) => {
  283. router.push({
  284. path: '/student/resourceDetails',
  285. query: {
  286. id: data.id,
  287. t: new Date().getTime()
  288. }
  289. })
  290. }
  291. defineExpose({
  292. setData
  293. })
  294. EventBus.off('upDataDetailsNum', upDataDetailsNum)
  295. EventBus.on('upDataDetailsNum', upDataDetailsNum)
  296. EventBus.off('openResourceDetailsInner', openResourceDetailsInner)
  297. EventBus.on('openResourceDetailsInner', openResourceDetailsInner)
  298. </script>
  299. <style scoped>
  300. .tab-switcher {
  301. display: flex;
  302. border-radius: 20px;
  303. border: 1px solid #1e90ff;
  304. overflow: hidden;
  305. }
  306. .tab-switcher div {
  307. padding: 2px 20px;
  308. background-color: #f5f5f5;
  309. cursor: pointer;
  310. }
  311. .tab-switcher div.active {
  312. background-color: #1e90ff;
  313. color: white;
  314. }
  315. .user-info {
  316. display: flex;
  317. align-items: center;
  318. width: 100%;
  319. padding: 20px;
  320. }
  321. .resource-container {
  322. width: 100%;
  323. margin: 0 auto;
  324. padding: 20px;
  325. border: 1px solid #dfe2e5;
  326. }
  327. .user-avatar {
  328. width: 40px;
  329. height: 40px;
  330. background: #1e90ff;
  331. border-radius: 50%;
  332. margin-right: 10px;
  333. }
  334. .user-details {
  335. flex: 1;
  336. }
  337. .user-name {
  338. font-size: 13px;
  339. font-weight: bold;
  340. }
  341. .publish-time {
  342. font-size: 12px;
  343. color: #999;
  344. margin-top: 5px;
  345. }
  346. .metrics {
  347. display: flex;
  348. align-items: center;
  349. justify-content: center;
  350. }
  351. .metric-item {
  352. display: flex;
  353. flex-direction: column;
  354. align-items: center;
  355. padding-left: 10px;
  356. padding-right: 10px;
  357. }
  358. .metric-item span:first-child {
  359. font-size: 18px;
  360. font-weight: bold;
  361. }
  362. .metric-item span:last-child {
  363. font-size: 12px;
  364. color: #666;
  365. }
  366. .actions {
  367. display: flex;
  368. }
  369. .share-btn,
  370. .favorite-btn {
  371. background-color: transparent;
  372. border: none;
  373. cursor: pointer;
  374. }
  375. .course-info {
  376. margin-top: 20px;
  377. line-height: 1.6;
  378. display: flex;
  379. width: 100%;
  380. }
  381. .liene {
  382. height: 35px;
  383. width: 1px;
  384. background: #00000018;
  385. }
  386. .resource-container {
  387. width: 100%;
  388. margin: 0 auto;
  389. padding: 20px;
  390. border: 1px solid #dfe2e5;
  391. }
  392. h1 {
  393. margin-bottom: 20px;
  394. }
  395. .ant-descriptions {
  396. margin-top: 20px;
  397. }
  398. .ant-typography-title {
  399. margin-top: 20px;
  400. }
  401. .ant-typography-paragraph {
  402. margin-top: 10px;
  403. }
  404. .ant-space {
  405. margin-top: 10px;
  406. }
  407. .video-info {
  408. height: 100%; /* 确保填满容器高度 */
  409. flex: 1;
  410. }
  411. .user-info-container {
  412. display: flex;
  413. align-items: stretch;
  414. }
  415. .resInfoTitile {
  416. width: 5px;
  417. height: 20px;
  418. background-color: #1e90ff;
  419. margin-right: 5px;
  420. }
  421. .tallList {
  422. display: flex;
  423. flex-direction: column;
  424. width: 100%;
  425. height: 200px;
  426. border: 1px solid #dfe2e5;
  427. padding: 20px;
  428. margin-top: 10px;
  429. }
  430. .tallListInfo {
  431. color: rgba(0, 0, 0, 0.116);
  432. font-size: 12px;
  433. }
  434. .titleBox {
  435. display: flex;
  436. align-items: center;
  437. }
  438. .lableBox {
  439. display: flex;
  440. align-items: center;
  441. margin: 16px 0;
  442. }
  443. .lableName {
  444. font-weight: bold;
  445. margin-right: 10px;
  446. }
  447. .lableVal {
  448. display: block;
  449. width: 200px;
  450. margin-left: 6px;
  451. }
  452. .boxShadow {
  453. border: 1px solid rgba(0, 0, 0, 0.04);
  454. border-radius: 4px;
  455. }
  456. :deep(.cardBox .ant-card-body) {
  457. padding: 0;
  458. }
  459. .flex-3 {
  460. flex: 3;
  461. }
  462. .flex-1 {
  463. flex: 1;
  464. }
  465. .imgBox {
  466. height: 100%;
  467. display: flex;
  468. justify-content: center;
  469. align-items: center;
  470. }
  471. </style>