VideoDetails.vue 16 KB

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