VideoDetails.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  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" style="width: 850px">
  7. <div
  8. v-if="videoFormat == 'jpg' || videoFormat == 'bmp' || videoFormat == 'png' || videoFormat == 'jpeg'"
  9. style="width: 850px; 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="850px" 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: 850px; 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: 850px; 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. console.log('打开分享弹窗')
  216. getShareLink({ id: route.query.id })
  217. .then((res) => {
  218. if (res.code == 200) {
  219. ShareDialogRef.value.open(res.data.shareLink)
  220. }
  221. })
  222. .catch((err) => {})
  223. }
  224. const handlerCollection = async () => {
  225. console.log('打开收藏', itemData.value)
  226. const id = route.query.id
  227. if (id != undefined && id != '') {
  228. if (starTag.value == true) {
  229. await cancel({ resourceId: id })
  230. message.success('取消收藏')
  231. upDataDetailsNum()
  232. } else {
  233. await add({ resourceId: id })
  234. message.success('收藏成功')
  235. upDataDetailsNum()
  236. }
  237. queryList({ resourceId: id })
  238. .then((ress) => {
  239. if (ress.data == true) {
  240. starTag.value = true
  241. } else {
  242. starTag.value = false
  243. }
  244. })
  245. .catch((err) => {
  246. console.log(err)
  247. })
  248. }
  249. }
  250. const getList = () => {
  251. //....
  252. // listUnpublishedView.value.setData(tableData.value)
  253. }
  254. const setData = (data) => {
  255. itemData.value = data
  256. }
  257. const getData = (item) => {
  258. detail({ id: item.id })
  259. .then((res) => {
  260. if (res.code == 200) {
  261. itemData.value = res.data
  262. courseType.value = itemData.value.resourceALLTypeName.split(',').join('/')
  263. department.value = itemData.value.collegeAllIdName.split(',').join('/')
  264. teacherName.value = itemData.value.resourceCreaterUserName
  265. resName.value = itemData.value.fileName
  266. videoFormat.value = itemData.value.suffix
  267. releaseTime.value = tool.formatTimestamp(itemData.value.uploadTime)
  268. videoSize.value = itemData.value.FILESIZE ? itemData.value.FILESIZE + 'b' : ''
  269. tags.value = []
  270. itemData.value.keywordList.forEach((item) => {
  271. tags.value.push(item.wordName)
  272. })
  273. console.log('应该施舍你们', tags.value)
  274. //关键的资源在线地址
  275. // resSrc.value = sysConfig.FILE_URL + itemData.value.fileUrl
  276. resSrc.value = sysConfig.FILE_URL + itemData.value.priviewFileUrl
  277. fileType.value = itemData.value.suffix
  278. // imagess.value = ''+itemData.value.coverImagePath
  279. // imagess.value = 'http://192.168.1.245:10005/education/' + itemData.value.priviewFileUrl
  280. // VideoDetailsRef.value.setData(res.sdata)
  281. console.log('发消息去请求网卡罗')
  282. emit('onGetPageCommentNew', {
  283. resourceType: itemData.value.resourceType,
  284. resourceTwoType: itemData.value.resourceTwoType
  285. })
  286. }
  287. })
  288. .catch((err) => {})
  289. }
  290. const upDataList = (item) => {
  291. console.log('upDataList', item)
  292. resourcecentreDetail({ id: item.id })
  293. .then((res) => {
  294. if (res.code == 200) {
  295. talkNum.value = res.data.commentNum
  296. collectNum.value = res.data.collectNum
  297. }
  298. })
  299. .catch((err) => {})
  300. }
  301. const fetchData = () => {
  302. getList()
  303. const id = route.query.id
  304. if (id != undefined && id != '') {
  305. queryList({ resourceId: id })
  306. .then((res) => {
  307. if (res.data == true) {
  308. starTag.value = true
  309. } else {
  310. starTag.value = false
  311. }
  312. })
  313. .catch((err) => {
  314. console.log(err)
  315. })
  316. getData({ id: id })
  317. upDataList({ id: id })
  318. }
  319. }
  320. watch(
  321. () => route,
  322. (newRoute) => {
  323. console.log('路由发生变化', newRoute)
  324. fetchData() // 手动刷新数据的方法
  325. },
  326. { deep: true, immediate: true }
  327. )
  328. onMounted(() => {
  329. fetchData()
  330. })
  331. const upDataDetailsNum = () => {
  332. const id = route.query.id
  333. if (id != undefined && id != '') {
  334. upDataList({ id: id })
  335. }
  336. }
  337. const openResourceDetailsInner = (data) => {
  338. console.log('收到消息了吗', data)
  339. router.push({
  340. path: '/portal/resourceDetails',
  341. query: {
  342. id: data.id,
  343. t: new Date().getTime()
  344. }
  345. })
  346. }
  347. defineExpose({
  348. setData
  349. })
  350. EventBus.off('upDataDetailsNum', upDataDetailsNum)
  351. EventBus.on('upDataDetailsNum', upDataDetailsNum)
  352. EventBus.off('openResourceDetailsInner', openResourceDetailsInner)
  353. EventBus.on('openResourceDetailsInner', openResourceDetailsInner)
  354. </script>
  355. <style scoped>
  356. .tab-switcher {
  357. display: flex;
  358. border-radius: 20px;
  359. border: 1px solid #1e90ff;
  360. overflow: hidden;
  361. }
  362. .tab-switcher div {
  363. padding: 2px 20px;
  364. background-color: #f5f5f5;
  365. cursor: pointer;
  366. }
  367. .tab-switcher div.active {
  368. background-color: #1e90ff;
  369. color: white;
  370. }
  371. .tab-switcher div:not(:last-child) {
  372. }
  373. .user-info {
  374. display: flex;
  375. align-items: center;
  376. width: 100%;
  377. height: 200px;
  378. border: 1px solid #dfe2e5;
  379. padding: 20px;
  380. }
  381. .resource-container {
  382. width: 850px;
  383. margin: 0 auto;
  384. padding: 20px;
  385. border: 1px solid #dfe2e5;
  386. }
  387. .user-avatar {
  388. width: 40px;
  389. height: 40px;
  390. background: #1e90ff;
  391. border-radius: 50%;
  392. margin-right: 10px;
  393. }
  394. .user-details {
  395. flex: 1;
  396. }
  397. .user-name {
  398. font-size: 13px;
  399. font-weight: bold;
  400. }
  401. .publish-time {
  402. font-size: 12px;
  403. color: #999;
  404. margin-top: 5px;
  405. }
  406. .metrics {
  407. display: flex;
  408. align-items: center;
  409. justify-content: center;
  410. }
  411. .metric-item {
  412. display: flex;
  413. flex-direction: column;
  414. align-items: center;
  415. padding-left: 10px;
  416. padding-right: 10px;
  417. }
  418. .metric-item span:first-child {
  419. font-size: 18px;
  420. font-weight: bold;
  421. }
  422. .metric-item span:last-child {
  423. font-size: 12px;
  424. color: #666;
  425. }
  426. .actions {
  427. display: flex;
  428. }
  429. .share-btn,
  430. .favorite-btn {
  431. background-color: transparent;
  432. border: none;
  433. cursor: pointer;
  434. }
  435. .course-info {
  436. margin-top: 20px;
  437. line-height: 1.6;
  438. display: flex;
  439. width: 100%;
  440. }
  441. .liene {
  442. height: 35px;
  443. width: 1px;
  444. background: #00000018;
  445. }
  446. .resource-container {
  447. width: 850px;
  448. margin: 0 auto;
  449. padding: 20px;
  450. border: 1px solid #dfe2e5;
  451. }
  452. h1 {
  453. text-align: center;
  454. margin-bottom: 20px;
  455. }
  456. .ant-descriptions {
  457. margin-top: 20px;
  458. }
  459. .ant-typography-title {
  460. margin-top: 20px;
  461. }
  462. .ant-typography-paragraph {
  463. margin-top: 10px;
  464. }
  465. .ant-space {
  466. margin-top: 10px;
  467. }
  468. .video-info {
  469. height: 100%; /* 确保填满容器高度 */
  470. }
  471. .resInfo {
  472. margin-left: 10px;
  473. width: 300px;
  474. height: 570px;
  475. border: 1px solid #dfe2e5;
  476. padding: 10px;
  477. }
  478. .user-info-container {
  479. display: flex;
  480. }
  481. .resInfoTitile {
  482. width: 5px;
  483. height: 14px;
  484. background-color: #1e90ff;
  485. margin-right: 5px;
  486. }
  487. .tallList {
  488. display: flex;
  489. flex-direction: column;
  490. width: 850px;
  491. height: 200px;
  492. border: 1px solid #dfe2e5;
  493. padding: 20px;
  494. margin-top: 10px;
  495. }
  496. .tallListInfo {
  497. color: rgba(0, 0, 0, 0.116);
  498. font-size: 12px;
  499. }
  500. </style>