VideoDetails.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <template>
  2. <div>
  3. <h1>{{ resName }}</h1>
  4. <div style="height: 25px"></div>
  5. <div class="user-info-container">
  6. <div class="video-info">
  7. <div
  8. v-if="videoFormat == 'jpg' || videoFormat == 'bmp' || videoFormat == 'png' || videoFormat == 'jpeg'"
  9. style="width: 100%; height: 350px"
  10. >
  11. <!-- <img :src="imgs + itemData.coverImagePath" style="width: 100%; height: 100%" /> -->
  12. <!-- <img :v-lazy="imagess" style="width: 100%; height: 100%" /> -->
  13. <a-image width="100%" height="350px" :src="resSrc" :preview="true" />
  14. <!-- <image :src="resSrc" style="object-fit: cover" /> -->
  15. </div>
  16. <!-- "wmv","avi","flv","mpeg","mpg","rmvb","mov","mkv" -->
  17. <div
  18. v-if="
  19. videoFormat == 'mkv' ||
  20. videoFormat == 'mp4' ||
  21. videoFormat == 'wmv' ||
  22. videoFormat == 'avi' ||
  23. videoFormat == 'flv' ||
  24. videoFormat == 'mpeg' ||
  25. videoFormat == 'mpg' ||
  26. videoFormat == 'rmvb' ||
  27. videoFormat == 'mov'
  28. "
  29. style="width: 100%; height: 350px"
  30. >
  31. <video :src="resSrc" controls style="width: 100%; height: 100%" />
  32. </div>
  33. <!-- "doc","docx","ppt","pptx","xls","xlsx" -->
  34. <div
  35. v-if="
  36. videoFormat == 'docx' ||
  37. videoFormat == 'doc' ||
  38. videoFormat == 'ppt' ||
  39. videoFormat == 'pptx' ||
  40. videoFormat == 'xls' ||
  41. videoFormat == 'xlsx' ||
  42. videoFormat == 'pdf'
  43. "
  44. style="width: 100%; height: 350px"
  45. >
  46. <!-- <PDF :src="resSrc" :width="850" :height="350" /> -->
  47. <FilePreviewer :fileUrl="resSrc" :fileName="resName" :fileType="fileType" />
  48. <!-- <a-image width="200px" height="220px" :src="pdfRes" :preview="false" @click="handleDownload(resSrc)" /> -->
  49. <!-- <a-button type="primary" @click="handleDownload(resSrc)">去预览</a-button> -->
  50. </div>
  51. <div style="height: 20px"></div>
  52. <!-- 用户信息部分 -->
  53. <div class="user-info" style="display: flex; flex-direction: column">
  54. <div style="display: flex; align-items: center; justify-content: space-between; width: 100%">
  55. <div style="display: flex; align-items: center">
  56. <div class="user-avatar"></div>
  57. <div class="user-details">
  58. <div class="user-name">{{ itemData.resourceCreaterUserName }}</div>
  59. <div class="publish-time">{{ itemData.uploadTime }}</div>
  60. </div>
  61. </div>
  62. <div style="display: flex; align-items: center" v-if="!isState">
  63. <div class="metrics">
  64. <div class="metric-item">
  65. <span>{{ itemData.viewCount }}</span>
  66. <span>播放量</span>
  67. </div>
  68. <div class="liene"></div>
  69. <div class="metric-item">
  70. <span>{{ talkNum }}</span>
  71. <span>评论</span>
  72. </div>
  73. <div class="liene"></div>
  74. <div class="metric-item">
  75. <span>{{ collectNum }}</span>
  76. <span>收藏</span>
  77. </div>
  78. </div>
  79. <div style="width: 10px"></div>
  80. <div class="actions">
  81. <div
  82. style="display: flex; align-items: center; cursor: pointer; margin-right: 5px"
  83. @click="handlerShareDialog"
  84. >
  85. <ExportOutlined />
  86. <div style="width: 10px"></div>
  87. <button class="share-btn">分享资源</button>
  88. </div>
  89. <div style="display: flex; align-items: center; cursor: pointer" @click="handlerCollection">
  90. <StarOutlined v-if="starTag == false" />
  91. <StarFilled v-if="starTag == true" />
  92. <div style="width: 10px"></div>
  93. <button class="favorite-btn">收藏资源</button>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. <!-- 课程信息部分 -->
  99. <div class="course-info">
  100. <span>
  101. {{ itemData.resourceDesc }}
  102. </span>
  103. </div>
  104. </div>
  105. </div>
  106. <div class="resInfo">
  107. <div style="display: flex; align-items: center">
  108. <div class="resInfoTitile"></div>
  109. <span style="display: block; font-weight: bold">资源信息</span>
  110. </div>
  111. <div style="display: flex; justify-content: center; align-items: center; height: 40px">
  112. <span style="display: block; font-weight: bold">{{ resName }}</span>
  113. </div>
  114. <!-- <div style="display: flex; align-items: center">
  115. <span style="font-weight: bold; margin-right: 10px">授课老师: </span>
  116. <span style="display: block">{{ teacherName }}</span>
  117. </div> -->
  118. <div style="display: flex">
  119. <span style="font-weight: bold; margin-right: 10px">所属院系: </span>
  120. <span style="display: block; width: 200px">{{ department }}</span>
  121. </div>
  122. <!-- <div style="display: flex; align-items: center">
  123. <span style="font-weight: bold; margin-right: 10px">所属专业: </span>
  124. <span style="display: block">{{ major }}</span>
  125. </div> -->
  126. <div style="display: flex; align-items: center">
  127. <span style="font-weight: bold; margin-right: 10px">资源类型: </span>
  128. <span style="display: block; width: 200px">{{ courseType }}</span>
  129. </div>
  130. <div style="display: flex; align-items: center">
  131. <span style="font-weight: bold; margin-right: 10px">资源格式: </span>
  132. <span style="display: block; width: 200px">{{ videoFormat }}</span>
  133. </div>
  134. <!-- <div style="display: flex; align-items: center" v-if="videoFormat != 'jpg'">
  135. <span style="font-weight: bold; margin-right: 10px">视频时长: </span>
  136. <span style="display: block">{{ videoDuration }}</span>
  137. </div> -->
  138. <div style="display: flex; align-items: center">
  139. <span style="font-weight: bold; margin-right: 10px">容量大小: </span>
  140. <span style="display: block; width: 200px">{{ videoSize }}</span>
  141. </div>
  142. <div style="display: flex; align-items: center">
  143. <span style="font-weight: bold; margin-right: 10px">发布时间: </span>
  144. <span style="display: block; width: 200px">{{ releaseTime }}</span>
  145. </div>
  146. <!-- <div style="display: flex; flex-direction: column">
  147. <span style="font-weight: bold; margin-right: 10px">课程介绍: </span>
  148. <br />
  149. <span style="display: block">{{ courseDescription }}</span>
  150. </div> -->
  151. <br />
  152. <span>资源标签</span>
  153. <div style="display: flex; width: 100%; flex-wrap: wrap">
  154. <a-tag style="margin-top: 5px" v-for="tag in tags" :key="tag">{{ tag }}</a-tag>
  155. </div>
  156. </div>
  157. </div>
  158. <ShareDialog ref="ShareDialogRef"></ShareDialog>
  159. </div>
  160. </template>
  161. <script setup>
  162. import { ref } from 'vue'
  163. // import PDF from 'vue-pdf'
  164. import { Tag, Typography, Space, message } from 'ant-design-vue'
  165. import ShareDialog from './ShareDialog.vue'
  166. import { addViewCount, detail, add, cancel, queryList, resourcecentreDetail, getShareLink } from '@/api/portal'
  167. import { useRoute, useRouter } from 'vue-router'
  168. import sysConfig from '@/config/index'
  169. import pdfRes from '@/assets/images/pdf.png'
  170. import FilePreviewer from './FilePreviewer.vue'
  171. import EventBus from '@/utils/EventBus'
  172. import tool from '@/utils/tool'
  173. // import VueOfficePdf from '@vue-office/pdf'
  174. // import pdfView from 'pdfvuer'
  175. // import 'pdfvuer/dist/pdfvuer.css'
  176. const route = useRoute()
  177. const router = useRouter()
  178. const props = defineProps({
  179. // itemData: {
  180. // type: Object,
  181. // default: () => {}
  182. // }
  183. //是否从资源列表来 1 是 0 否
  184. isState: {
  185. type: Number,
  186. default: () => null
  187. }
  188. })
  189. const itemData = ref({})
  190. const starTag = ref(false)
  191. const ShareDialogRef = ref(null)
  192. const resSrc = ref('')
  193. const fileType = ref('')
  194. const resName = ref('资源名称')
  195. const teacherName = ref('王某某')
  196. const department = ref('学院本级-航空机务教研室-三级架构名')
  197. const major = ref('初级飞行训练')
  198. const courseType = ref('必修')
  199. const videoFormat = ref('MP4')
  200. const videoDuration = ref('59:34')
  201. const videoSize = ref('598M')
  202. const releaseTime = ref('2025-10-01 11:33:59')
  203. const talkNum = ref(0)
  204. const collectNum = ref(0)
  205. // const courseDescription = ref(
  206. // '“我们正步入一个数据或许比软件更重要的新时代。——Tim O’ Reilly” 运用数据是精准刻画事物、呈现发展规律的主要手段,分析数据展示规律,把思想变得更精细!——“弹指之间·享受创新”,通过4周学习,你将掌握利用Python语言表示、清洗、统计和展示数据的能力。'
  207. // )
  208. const tags = ref(['标签名称1', '标签名称2', '标签名称3', '标签名称4', '标签名称5'])
  209. const emit = defineEmits(['selectTab'])
  210. const listUnpublishedView = ref(null)
  211. const handleDownload = (src) => {
  212. window.open(src)
  213. }
  214. const handlerShareDialog = () => {
  215. getShareLink({ id: route.query.id })
  216. .then((res) => {
  217. if (res.code == 200) {
  218. ShareDialogRef.value.open(res.data.shareLink)
  219. }
  220. })
  221. .catch((err) => {})
  222. }
  223. const handlerCollection = async () => {
  224. const id = route.query.id
  225. if (id != undefined && id != '') {
  226. if (starTag.value == true) {
  227. await cancel({ resourceId: id })
  228. message.success('取消收藏')
  229. upDataDetailsNum()
  230. } else {
  231. await add({ resourceId: id })
  232. message.success('收藏成功')
  233. upDataDetailsNum()
  234. }
  235. queryList({ resourceId: id })
  236. .then((ress) => {
  237. if (ress.data == true) {
  238. starTag.value = true
  239. } else {
  240. starTag.value = false
  241. }
  242. })
  243. .catch((err) => {
  244. console.log(err)
  245. })
  246. }
  247. }
  248. const getList = () => {
  249. //....
  250. // listUnpublishedView.value.setData(tableData.value)
  251. }
  252. const setData = (data) => {
  253. itemData.value = data
  254. }
  255. const getData = (item) => {
  256. detail({ id: item.id })
  257. .then((res) => {
  258. if (res.code == 200) {
  259. itemData.value = res.data
  260. courseType.value = itemData.value.resourceALLTypeName.split(',').join('/')
  261. department.value = itemData.value.collegeAllIdName.split(',').join('/')
  262. teacherName.value = itemData.value.resourceCreaterUserName
  263. resName.value = itemData.value.fileName
  264. videoFormat.value = itemData.value.suffix
  265. // releaseTime.value = tool.formatTimestamp(itemData.value.uploadTime)
  266. releaseTime.value = itemData.value.uploadTime
  267. videoSize.value = itemData.value.FILESIZE ? itemData.value.FILESIZE + 'b' : ''
  268. tags.value = []
  269. itemData.value.keywordList.forEach((item) => {
  270. tags.value.push(item.wordName)
  271. })
  272. //关键的资源在线地址
  273. // resSrc.value = sysConfig.FILE_URL + itemData.value.fileUrl
  274. resSrc.value = sysConfig.FILE_URL + itemData.value.priviewFileUrl
  275. fileType.value = itemData.value.suffix
  276. // imagess.value = ''+itemData.value.coverImagePath
  277. // imagess.value = 'http://192.168.1.245:10005/education/' + itemData.value.priviewFileUrl
  278. // VideoDetailsRef.value.setData(res.sdata)
  279. emit('onGetPageCommentNew', {
  280. resourceType: itemData.value.resourceType,
  281. resourceTwoType: itemData.value.resourceTwoType
  282. })
  283. }
  284. })
  285. .catch((err) => {})
  286. }
  287. const upDataList = (item) => {
  288. resourcecentreDetail({ id: item.id })
  289. .then((res) => {
  290. if (res.code == 200) {
  291. talkNum.value = res.data.commentNum
  292. collectNum.value = res.data.collectNum
  293. }
  294. })
  295. .catch((err) => {})
  296. }
  297. const fetchData = () => {
  298. getList()
  299. const id = route.query.id
  300. if (id != undefined && id != '') {
  301. // isHaveAuth : 0 1
  302. // checkAuth
  303. queryList({ resourceId: id })
  304. .then((res) => {
  305. if (res.data == true) {
  306. starTag.value = true
  307. } else {
  308. starTag.value = false
  309. }
  310. })
  311. .catch((err) => {
  312. console.log(err)
  313. })
  314. getData({ id: id })
  315. upDataList({ id: id })
  316. }
  317. }
  318. watch(
  319. () => route,
  320. (newRoute) => {
  321. fetchData() // 手动刷新数据的方法
  322. },
  323. { deep: true, immediate: true }
  324. )
  325. onMounted(() => {
  326. fetchData()
  327. })
  328. const upDataDetailsNum = () => {
  329. const id = route.query.id
  330. if (id != undefined && id != '') {
  331. upDataList({ id: id })
  332. }
  333. }
  334. const openResourceDetailsInner = (data) => {
  335. router.push({
  336. path: '/portal/resourceDetails',
  337. query: {
  338. id: data.id,
  339. t: new Date().getTime()
  340. }
  341. })
  342. }
  343. defineExpose({
  344. setData
  345. })
  346. EventBus.off('upDataDetailsNum', upDataDetailsNum)
  347. EventBus.on('upDataDetailsNum', upDataDetailsNum)
  348. EventBus.off('openResourceDetailsInner', openResourceDetailsInner)
  349. EventBus.on('openResourceDetailsInner', openResourceDetailsInner)
  350. </script>
  351. <style scoped>
  352. .tab-switcher {
  353. display: flex;
  354. border-radius: 20px;
  355. border: 1px solid #1e90ff;
  356. overflow: hidden;
  357. }
  358. .tab-switcher div {
  359. padding: 2px 20px;
  360. background-color: #f5f5f5;
  361. cursor: pointer;
  362. }
  363. .tab-switcher div.active {
  364. background-color: #1e90ff;
  365. color: white;
  366. }
  367. .user-info {
  368. display: flex;
  369. align-items: center;
  370. width: 100%;
  371. height: 200px;
  372. border: 1px solid #dfe2e5;
  373. padding: 20px;
  374. }
  375. .resource-container {
  376. width: 100%;
  377. margin: 0 auto;
  378. padding: 20px;
  379. border: 1px solid #dfe2e5;
  380. }
  381. .user-avatar {
  382. width: 40px;
  383. height: 40px;
  384. background: #1e90ff;
  385. border-radius: 50%;
  386. margin-right: 10px;
  387. }
  388. .user-details {
  389. flex: 1;
  390. }
  391. .user-name {
  392. font-size: 13px;
  393. font-weight: bold;
  394. }
  395. .publish-time {
  396. font-size: 12px;
  397. color: #999;
  398. margin-top: 5px;
  399. }
  400. .metrics {
  401. display: flex;
  402. align-items: center;
  403. justify-content: center;
  404. }
  405. .metric-item {
  406. display: flex;
  407. flex-direction: column;
  408. align-items: center;
  409. padding-left: 10px;
  410. padding-right: 10px;
  411. }
  412. .metric-item span:first-child {
  413. font-size: 18px;
  414. font-weight: bold;
  415. }
  416. .metric-item span:last-child {
  417. font-size: 12px;
  418. color: #666;
  419. }
  420. .actions {
  421. display: flex;
  422. }
  423. .share-btn,
  424. .favorite-btn {
  425. background-color: transparent;
  426. border: none;
  427. cursor: pointer;
  428. }
  429. .course-info {
  430. margin-top: 20px;
  431. line-height: 1.6;
  432. display: flex;
  433. width: 100%;
  434. }
  435. .liene {
  436. height: 35px;
  437. width: 1px;
  438. background: #00000018;
  439. }
  440. .resource-container {
  441. width: 100%;
  442. margin: 0 auto;
  443. padding: 20px;
  444. border: 1px solid #dfe2e5;
  445. }
  446. h1 {
  447. text-align: center;
  448. margin-bottom: 20px;
  449. }
  450. .ant-descriptions {
  451. margin-top: 20px;
  452. }
  453. .ant-typography-title {
  454. margin-top: 20px;
  455. }
  456. .ant-typography-paragraph {
  457. margin-top: 10px;
  458. }
  459. .ant-space {
  460. margin-top: 10px;
  461. }
  462. .video-info {
  463. height: 100%; /* 确保填满容器高度 */
  464. flex:1;
  465. }
  466. .resInfo {
  467. margin-left: 10px;
  468. width: 300px;
  469. height: 570px;
  470. border: 1px solid #dfe2e5;
  471. padding: 10px;
  472. }
  473. .user-info-container {
  474. display: flex;
  475. }
  476. .resInfoTitile {
  477. width: 5px;
  478. height: 14px;
  479. background-color: #1e90ff;
  480. margin-right: 5px;
  481. }
  482. .tallList {
  483. display: flex;
  484. flex-direction: column;
  485. width: 100%;
  486. height: 200px;
  487. border: 1px solid #dfe2e5;
  488. padding: 20px;
  489. margin-top: 10px;
  490. }
  491. .tallListInfo {
  492. color: rgba(0, 0, 0, 0.116);
  493. font-size: 12px;
  494. }
  495. </style>