VideoDetails.vue 15 KB

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