reghao пре 2 година
родитељ
комит
889ba407a2
2 измењених фајлова са 16 додато и 2 уклоњено
  1. 6 0
      src/api/video.js
  2. 10 2
      src/views/home/VideoPage.vue

+ 6 - 0
src/api/video.js

@@ -20,6 +20,7 @@ const videoApi = {
   videoErrorReportApi: '/api/content/video/report',
   videoDownloadApi: '/api/content/video/download',
   cacheBiliApi: '/api/content/video/cache/bili',
+  shortUrlApi: '/api/content/share',
 
   videoRecommendApi: '/api/content/video/recommend',
   similarVideoApi: '/api/content/video/similar',
@@ -129,6 +130,11 @@ export function cacheBiliVideo(bvId) {
   return post(videoApi.cacheBiliApi + '/' + bvId)
 }
 
+// 获取分享视频的短链接
+export function getShortUrl(bvId) {
+  return get(videoApi.shortUrlApi + '?videoId=' + bvId)
+}
+
 // ********************************************************************************************************************
 // 获取推荐视频
 export function videoRecommend(nextId) {

+ 10 - 2
src/views/home/VideoPage.vue

@@ -48,7 +48,7 @@
                   size="mini"
                   icon="el-icon-share"
                   :disabled="isCollected"
-                  @click="collection(video.videoId)"
+                  @click="getShareUrl(video.videoId)"
                 >
                   <span>分享 {{ video.share }}</span>
                 </el-button>
@@ -218,7 +218,7 @@ import SideVideoCard from 'components/card/SideVideoCard'
 import UserAvatarCard from '@/components/card/UserAvatarCard'
 import comment from '@/components/comment'
 
-import { similarVideo, videoInfo, videoErrorReport, downloadVideo, cacheBiliVideo } from '@/api/video'
+import { similarVideo, videoInfo, videoErrorReport, downloadVideo, cacheBiliVideo, getShortUrl } from '@/api/video'
 import { collectItem } from '@/api/collect'
 import { getUserInfo } from '@/api/user'
 import { submitAccessCode } from '@/api/content'
@@ -438,6 +438,14 @@ export default {
         }
       })
     },
+    getShareUrl(videoId) {
+      getShortUrl(videoId).then(resp => {
+        if (resp.code === 0) {
+          console.log(resp.data)
+          this.video.share += 1
+        }
+      })
+    },
     getDownloadUrl(videoId) {
       // let filename
       downloadVideo(videoId).then(resp => {