Ver Fonte

更新状态页面和视频发布页面

reghao há 3 anos atrás
pai
commit
132907fb73

+ 2 - 1
src/components/upload/filepond-image.vue

@@ -10,6 +10,7 @@
       label-tap-to-retry="尝试重试"
       label-file-processing-complete="图片上传成功!"
       accepted-file-types="image/png, image/jpeg, image/jpg, image/gif"
+      :imagePreviewHeight="32"
       :allow-multiple="true"
       :max-files="9"
       :server="server"
@@ -23,9 +24,9 @@
 <script>
 import vueFilePond from 'vue-filepond'
 import 'filepond/dist/filepond.min.css'
+import FilePondPluginImagePreview from 'filepond-plugin-image-preview'
 import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css'
 import FilePondPluginFileValidateType from 'filepond-plugin-file-validate-type'
-import FilePondPluginImagePreview from 'filepond-plugin-image-preview'
 import FilePondPluginFileValidateSize from 'filepond-plugin-file-validate-size'
 
 // Create component

+ 0 - 23
src/components/upload/upload-article.vue

@@ -1,23 +0,0 @@
-<template>
-  <v-row justify="center" align="center">
-    <v-col>
-      <v-card
-        class="mx-auto"
-        outlined
-      >
-        文章投稿开发中
-      </v-card>
-    </v-col>
-  </v-row>
-</template>
-
-<script>
-export default {
-  name: 'UploadArticle'
-
-}
-</script>
-
-<style>
-
-</style>

+ 0 - 120
src/components/upload/upload-image.vue

@@ -1,120 +0,0 @@
-<template>
-  <v-row justify="center" align="center">
-    <v-col>
-      <v-card
-        class="mx-auto"
-        outlined
-      >
-        <v-row justify="center">
-          <v-col cols="10">
-            <h2>发布图片贴</h2>
-          </v-col>
-        </v-row>
-        <v-row justify="center">
-          <v-col cols="10">
-            <!-- 接收 filepond-image 中 this.$emit('resp', resp) 的数据 -->
-            <FilePondUploadImage @resp="uploadCallback" />
-          </v-col>
-        </v-row>
-        <v-row justify="center">
-          <v-col cols="10">
-            <v-text-field
-              v-model="statusPost.content"
-              label="内容(50字以内)"
-              placeholder="写点什么吧..."
-              clearable
-              :rules="[() => statusPost.content !== '' || '内容不能为空']"
-            />
-          </v-col>
-        </v-row>
-        <v-row justify="center">
-          <v-col cols="10">
-            <v-btn large color="primary" @click="publish">发布</v-btn>
-          </v-col>
-        </v-row>
-      </v-card>
-    </v-col>
-
-    <v-snackbar
-      v-model="showMessage"
-      :top="true"
-      :timeout="3000"
-    >
-      {{ message }}
-      <template v-slot:action="{ attrs }">
-        <v-btn
-          color="pink"
-          text
-          v-bind="attrs"
-          @click="showMessage = false"
-        >
-          关闭
-        </v-btn>
-      </template>
-    </v-snackbar>
-  </v-row>
-</template>
-
-<script>
-import FilePondUploadImage from '@/components/upload/filepond-image.vue'
-import { pubStatus } from '@/api/mblog/status'
-
-export default {
-  components: {
-    FilePondUploadImage
-  },
-  data() {
-    return {
-      // 提交给后端的数据
-      statusPost: {
-        uploadIds: [],
-        content: ''
-      },
-      showMessage: false,
-      message: ''
-    }
-  },
-  created() {
-  },
-  methods: {
-    uploadCallback(resp) {
-      if (resp.code === 0) {
-        this.statusPost.uploadIds.push(resp.data.uploadId)
-      } else {
-        if (resp.msg != null) {
-          this.message = '上传文件出现异常,请重新上传!' + resp.msg
-        } else {
-          this.message = '上传文件出现异常,请重新上传!'
-        }
-        this.showMessage = true
-      }
-    },
-    publish() {
-      if (this.statusPost.content === '') {
-        this.message = '内容不能为空'
-        this.showMessage = true
-      }
-
-      pubStatus(this.statusPost)
-        .then(res => {
-          if (res.code === 0) {
-            this.message = '状态已发布'
-            this.showMessage = true
-
-            this.$router.push('/mblog')
-          } else {
-            this.message = res.msg
-            this.showMessage = true
-          }
-        })
-        .catch(error => {
-          this.message = error.message
-          this.showMessage = true
-        })
-    }
-  }
-}
-</script>
-
-<style>
-</style>

+ 0 - 23
src/components/upload/upload-music.vue

@@ -1,23 +0,0 @@
-<template>
-  <v-row justify="center" align="center">
-    <v-col>
-      <v-card
-        class="mx-auto"
-        outlined
-      >
-        音乐投稿开发中
-      </v-card>
-    </v-col>
-  </v-row>
-</template>
-
-<script>
-export default {
-  name: 'UploadMusic'
-
-}
-</script>
-
-<style>
-
-</style>

+ 0 - 300
src/components/upload/upload-video.vue

@@ -1,300 +0,0 @@
-<template>
-  <v-row justify="center" align="center">
-    <v-col>
-      <v-card
-        class="mx-auto"
-        outlined
-      >
-        <v-row justify="center">
-          <v-col cols="10">
-            <h2>上传视频</h2>
-          </v-col>
-        </v-row>
-        <v-row justify="center">
-          <v-col cols="10">
-            <!-- <v-file-input prepend-icon="mdi-video" show-size counter accept="video/*,.flv" chips label="请选择视频文件" @change="setFile" /> -->
-            <FilePondUpload @video="videoUploadCallback" />
-          </v-col>
-        </v-row>
-        <v-row justify="center">
-          <v-col cols="10">
-            <h2>基本信息</h2>
-          </v-col>
-        </v-row>
-        <v-row justify="center">
-          <v-col cols="5">
-            <v-card outlined>
-              <v-img :src="videoInfo.coverUrl" aspect-ratio="1.77" contain max-height="150" alt="封面图,推荐16:9" />
-            </v-card>
-          </v-col>
-          <v-col cols="5">
-            <v-file-input
-              :rules="rules"
-              accept="image/png, image/jpeg, image/bmp"
-              placeholder="上传视频封面"
-              prepend-icon="mdi-camera"
-              label="封面"
-              @change="setFile"
-            />
-            <v-btn color="primary" @click="uploadFile">
-              上传
-            </v-btn>
-          </v-col>
-        </v-row>
-        <v-row justify="center">
-          <v-col cols="5">
-            <v-select
-              :items="category"
-              label="分区"
-              @change="getCategory"
-            />
-          </v-col>
-          <v-col cols="5">
-            <v-select
-              :items="childCategory"
-              label="子分区"
-              @change="getChildCategory"
-            />
-          </v-col>
-        </v-row>
-        <v-row justify="center">
-          <v-col cols="10">
-            <v-text-field
-              v-model="videoInfo.title"
-              placeholder="标题"
-              label="标题(50字以内)"
-              clearable
-              :rules="[() => videoInfo.title != null || '标题不能为空']"
-            />
-          </v-col>
-        </v-row>
-        <v-row justify="center">
-          <v-col cols="10">
-            <v-textarea
-              v-model="videoInfo.description"
-              label="简介(200字以内)"
-              clearable
-              placeholder="填写更全面的视频信息,让更多的人找到你!"
-            />
-          </v-col>
-        </v-row>
-        <v-row justify="center">
-          <v-col cols="10">
-            <v-combobox
-              v-model="videoInfo.tags"
-              label="添加标签让更多人找到你(最多6个)"
-              multiple
-              chips
-              clearable
-            />
-          </v-col>
-        </v-row>
-        <v-row justify="center">
-          <v-col cols="10">
-            <v-btn large color="primary" @click="publish">立即投稿</v-btn>
-          </v-col>
-        </v-row>
-      </v-card>
-
-    </v-col>
-    <v-snackbar
-      v-model="showMessage"
-      :top="true"
-      :timeout="3000"
-    >
-      {{ message }}
-
-      <template v-slot:action="{ attrs }">
-        <v-btn
-          color="pink"
-          text
-          v-bind="attrs"
-          @click="showMessage = false"
-        >
-          关闭
-        </v-btn>
-      </template>
-    </v-snackbar>
-  </v-row>
-</template>
-
-<script>
-import FilePondUpload from '@/components/upload/filepond-upload.vue'
-import { videoCategory, submitVideoPost } from '@/api/media/video'
-export default {
-  components: {
-    FilePondUpload
-  },
-  data() {
-    return {
-      rules: [
-        value => !value || value.size < 2000000 || 'Avatar size should be less than 2 MB!'
-      ],
-      // 提交给后端的数据
-      videoInfo: {
-        videoId: '',
-        title: '',
-        description: '',
-        coverUrl: '',
-        duration: 0,
-        categoryId: -1,
-        tags: [],
-        fileId: ''
-      },
-      categoryMap: {
-        Set: function(key, value) { this[key] = value },
-        Get: function(key) { return this[key] },
-        Contains: function(key) { return this.Get(key) !== null },
-        Remove: function(key) { delete this[key] }
-      },
-      category: [],
-      childCategory: [],
-      nowCategory: {},
-      files: [],
-      showMessage: false,
-      message: ''
-    }
-  },
-  created() {
-    this.getVideoCategory()
-  },
-  methods: {
-    publish() {
-      if (!this.videoInfo.fileId) {
-        this.message = '你还没有上传视频'
-        this.showMessage = true
-        return
-      }
-      if (this.videoInfo.title === '' || this.coverUrl === '' || this.videoInfo.tags.length === 0 || this.videoInfo.categoryId === -1) {
-        this.message = '标题,封面,标签,分区不能为空'
-        this.showMessage = true
-        return
-      }
-
-      if (this.videoInfo.tags.length > 6) {
-        this.message = '标签超过6个'
-        this.showMessage = true
-        return
-      }
-
-      submitVideoPost(this.videoInfo)
-        .then(res => {
-          if (res.code === 0) {
-            this.message = '投稿成功,等待审核通过后你就可以看到你的视频了'
-            this.showMessage = true
-            this.$router.push('/studio')
-          } else {
-            this.message = res.msg
-            this.showMessage = true
-          }
-        })
-        .catch(error => {
-          console.error(error.message)
-        })
-    },
-    setFile(value) {
-      this.files = []
-      this.files.push(value)
-    },
-    // filepond 组件上传文件完成时调用
-    videoUploadCallback(value) {
-      if (value.code === 0) {
-        this.videoInfo.videoId = value.data.videoId
-        this.setTitle(value.data.filename)
-        this.videoInfo.duration = value.data.duration
-        this.videoInfo.coverUrl = value.data.coverUrl
-        this.videoInfo.fileId = value.data.fileId
-
-        this.message = '视频上传成功'
-        this.showMessage = true
-      } else {
-        // TODO 返回错误原因,网络错误或是服务端错误
-        if (value.msg != null) {
-          this.message = '上传文件出现异常,请重新上传!' + value.msg
-        } else {
-          this.message = '上传文件出现异常,请重新上传!'
-        }
-        this.showMessage = true
-      }
-    },
-    setTitle(title) {
-      if (title.length > 50) {
-        this.videoInfo.title = title.substring(0, 50)
-      } else {
-        this.videoInfo.title = title
-      }
-    },
-    uploadFile() {
-      if (this.files.length === 0) {
-        this.message = '请先选择视频封面,然后上传!'
-        this.showMessage = true
-        return
-      }
-      const formData = new FormData()
-      for (let i = 0; i < this.files.length; i++) {
-        formData.append('file[]', this.files[i])
-      }
-      fetch(`http://file.reghao.cn/api/file/upload/image`, {
-        headers: {
-          'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')
-        },
-        method: 'POST',
-        credentials: 'include',
-        body: formData
-      }).then(response => response.json())
-        .then(json => {
-          if (json.code === 0) {
-            this.videoInfo.coverUrl = json.data[0].url
-          } else {
-            this.message = '上传失败,请重试!' + json.message
-            this.showMessage = true
-          }
-        })
-        .catch(e => {
-          return null
-        })
-    },
-    getVideoCategory() {
-      videoCategory()
-        .then(res => {
-          if (res.code === 0) {
-            for (let i = 0; i < res.data.length; i++) {
-              const name = res.data[i].name
-              this.category.push(name)
-              this.categoryMap.Set(name, res.data[i])
-            }
-          } else {
-            console.error(res.msg)
-          }
-        })
-        .catch(error => {
-          console.error(error.message)
-        })
-    },
-    getCategory(name) {
-      // 重置子分区,清除前一次选择分区时留下的缓存
-      this.childCategory = []
-      this.currentCategory = this.categoryMap.Get(name)
-      this.videoInfo.categoryId = this.currentCategory.id
-
-      const c = this.currentCategory.children
-      if (c) {
-        for (let i = 0; i < c.length; i++) {
-          this.childCategory.push(c[i].name)
-        }
-      }
-    },
-    getChildCategory(name) {
-      const c = this.currentCategory.children
-      for (let i = 0; i < c.length; i++) {
-        if (c[i].name === name) {
-          this.videoInfo.categoryId = c[i].id
-        }
-      }
-    }
-  }
-}
-</script>
-
-<style>
-</style>

+ 71 - 25
src/views/home/mblog.vue

@@ -34,6 +34,7 @@
             >
               <v-row dense>
                 <v-textarea
+                  v-model="statusPost.content"
                   solo
                   falt
                   filled
@@ -42,10 +43,16 @@
                   rows="3"
                 />
               </v-row>
+              <v-row>
+                <v-col>
+                  <!-- 接收 filepond-image 中 this.$emit('resp', resp) 的数据 -->
+                  <FilePondUploadImage @resp="uploadCallback" />
+                </v-col>
+              </v-row>
               <v-row dense>
                 <v-col>
                   <v-card-actions>
-                    <v-btn text>
+                    <v-btn text @click="publish">
                       发布
                     </v-btn>
                   </v-card-actions>
@@ -149,25 +156,51 @@
         </v-row>
       </v-col>
     </v-row>
+
+    <v-snackbar
+      v-model="showMessage"
+      :top="true"
+      :timeout="3000"
+    >
+      {{ message }}
+      <template v-slot:action="{ attrs }">
+        <v-btn
+          color="pink"
+          text
+          v-bind="attrs"
+          @click="showMessage = false"
+        >
+          关闭
+        </v-btn>
+      </template>
+    </v-snackbar>
   </v-container>
 </template>
 
 <script>
 import { mapActions, mapGetters } from 'vuex'
-import { statusRecommend } from '@/api/mblog/status'
+import { pubStatus, statusRecommend } from '@/api/mblog/status'
 import StatusCard from '@/components/status/status-card'
+import FilePondUploadImage from '@/components/upload/filepond-image.vue'
 
 export default {
   name: 'Home',
   components: {
-    StatusCard
+    StatusCard,
+    FilePondUploadImage
   },
   data() {
     return {
+      statusPost: {
+        uploadIds: [],
+        content: ''
+      },
       list: [],
       busy: false,
       page: 1,
-      model: null
+      model: null,
+      showMessage: false,
+      message: ''
     }
   },
   computed: {
@@ -202,22 +235,16 @@ export default {
   },
   mounted() {
   },
-  activated() {
-    window.addEventListener('scroll', this.scrollBar)
-  },
-  deactivated() {
-    window.removeEventListener('scroll', this.scrollBar)
-  },
   methods: {
     ...mapActions([
       'getMyContent'
     ]),
-    /*    loadMore: function() {
+    loadMore: function() {
       this.busy = true
       setTimeout(() => {
         this.getFollowingStatus(this.page)
       }, 1000)
-    },*/
+    },
     getFollowingStatus(page) {
       statusRecommend(page)
         .then(res => {
@@ -244,24 +271,43 @@ export default {
     selectCategory() {
       console.log('加载选中分类的用户状态...')
     },
-    loadMore() {
-      /* const vue = this
-      vue.option.refresh = true
-      var page = vue.option.page + 1
-      vue.myContent(page)*/
+    uploadCallback(resp) {
+      if (resp.code === 0) {
+        this.statusPost.uploadIds.push(resp.data.uploadId)
+      } else {
+        if (resp.msg != null) {
+          this.message = '上传文件出现异常,请重新上传!' + resp.msg
+        } else {
+          this.message = '上传文件出现异常,请重新上传!'
+        }
+        this.showMessage = true
+      }
     },
-    scrollBar() {
-      var a = document.documentElement.scrollTop === 0 ? document.body.clientHeight : document.documentElement.clientHeight
-      var b = document.documentElement.scrollTop === 0 ? document.body.scrollTop : document.documentElement.scrollTop
-      var c = document.documentElement.scrollTop === 0 ? document.body.scrollHeight : document.documentElement.scrollHeight
-      if (a + b === c && !this.showImage) {
-        console.log(a + b)
-        this.loadMore()
+    publish() {
+      if (this.statusPost.content === '') {
+        this.message = '内容不能为空'
+        this.showMessage = true
       }
+
+      pubStatus(this.statusPost)
+        .then(res => {
+          if (res.code === 0) {
+            this.message = '状态已发布'
+            this.showMessage = true
+          } else {
+            this.message = res.msg
+            this.showMessage = true
+          }
+        })
+        .catch(error => {
+          this.message = error.message
+          this.showMessage = true
+        })
     }
   }
 
 }
 </script>
 
-<style></style>
+<style>
+</style>

+ 1 - 2
src/views/studio/index.vue

@@ -5,7 +5,6 @@
         <v-sheet rounded="lg">
           <v-list color="transparent">
             <router-link :to="`/user/home`">
-            <!--<router-link :to="`/u/${this.$store.state.user.userInfo.userId}`">-->
               <v-row justify="center" align="center">
                 <v-col cols="12" style="text-align: center">
                   <v-avatar size="62">
@@ -69,8 +68,8 @@ export default {
     CheckPower,
     drawer: true,
     items: [
-      { icon: 'mdi-filmstrip-box-multiple', text: '稿件列表', link: '/studio' },
       { icon: 'mdi-upload', text: '投稿', link: '/studio/upload' },
+      { icon: 'mdi-filmstrip-box-multiple', text: '稿件列表', link: '/studio' },
       { icon: 'mdi-database', text: '数据统计', link: '/studio/statistics' }
     ],
     adminList: [

+ 281 - 25
src/views/studio/upload.vue

@@ -1,40 +1,296 @@
 <template>
-  <v-container fill-height>
-    <v-tabs>
-      <v-tab @click="setShow(0)">图片</v-tab>
-      <v-tab @click="setShow(1)">视频</v-tab>
-      <v-tab @click="setShow(2)">音乐</v-tab>
-      <v-tab @click="setShow(3)">文章</v-tab>
-    </v-tabs>
-    <VideoPhoto v-if="show === 0" />
-    <VideoUpload v-if="show === 1" />
-    <VideoMusic v-if="show === 2" />
-    <VideoArticle v-if="show === 3" />
-  </v-container>
+  <v-row justify="center" align="center">
+    <v-col>
+      <v-card
+        class="mx-auto"
+        outlined
+      >
+        <v-row justify="center">
+          <v-col cols="10">
+            <h2>发布视频贴</h2>
+          </v-col>
+        </v-row>
+        <v-row justify="center">
+          <v-col cols="10">
+            <!-- <v-file-input prepend-icon="mdi-video" show-size counter accept="video/*,.flv" chips label="请选择视频文件" @change="setFile" /> -->
+            <FilePondUpload @video="videoUploadCallback" />
+          </v-col>
+        </v-row>
+        <v-row justify="center">
+          <v-col cols="10">
+            <h2>基本信息</h2>
+          </v-col>
+        </v-row>
+        <v-row justify="center">
+          <v-col cols="5">
+            <v-card outlined>
+              <v-img :src="videoInfo.coverUrl" aspect-ratio="1.77" contain max-height="150" alt="封面图,推荐16:9" />
+            </v-card>
+          </v-col>
+          <v-col cols="5">
+            <v-file-input
+              :rules="rules"
+              accept="image/png, image/jpeg, image/bmp"
+              placeholder="上传视频封面"
+              prepend-icon="mdi-camera"
+              label="封面"
+              @change="setFile"
+            />
+            <v-btn color="primary" @click="uploadFile">
+              上传
+            </v-btn>
+          </v-col>
+        </v-row>
+        <v-row justify="center">
+          <v-col cols="5">
+            <v-select
+              :items="category"
+              label="分区"
+              @change="getCategory"
+            />
+          </v-col>
+          <v-col cols="5">
+            <v-select
+              :items="childCategory"
+              label="子分区"
+              @change="getChildCategory"
+            />
+          </v-col>
+        </v-row>
+        <v-row justify="center">
+          <v-col cols="10">
+            <v-text-field
+              v-model="videoInfo.title"
+              placeholder="标题"
+              label="标题(50字以内)"
+              clearable
+              :rules="[() => videoInfo.title != null || '标题不能为空']"
+            />
+          </v-col>
+        </v-row>
+        <v-row justify="center">
+          <v-col cols="10">
+            <v-textarea
+              v-model="videoInfo.description"
+              label="简介(200字以内)"
+              clearable
+              placeholder="填写更全面的视频信息,让更多的人找到你!"
+            />
+          </v-col>
+        </v-row>
+        <v-row justify="center">
+          <v-col cols="10">
+            <v-combobox
+              v-model="videoInfo.tags"
+              label="添加标签让更多人找到你(最多6个)"
+              multiple
+              chips
+              clearable
+            />
+          </v-col>
+        </v-row>
+        <v-row justify="center">
+          <v-col cols="10">
+            <v-btn large color="primary" @click="publish">立即投稿</v-btn>
+          </v-col>
+        </v-row>
+      </v-card>
+
+    </v-col>
+    <v-snackbar
+      v-model="showMessage"
+      :top="true"
+      :timeout="3000"
+    >
+      {{ message }}
+
+      <template v-slot:action="{ attrs }">
+        <v-btn
+          color="pink"
+          text
+          v-bind="attrs"
+          @click="showMessage = false"
+        >
+          关闭
+        </v-btn>
+      </template>
+    </v-snackbar>
+  </v-row>
 </template>
 
 <script>
-import VideoUpload from '@/components/upload/upload-video.vue'
-import VideoPhoto from '@/components/upload/upload-image.vue'
-import VideoArticle from '@/components/upload/upload-article.vue'
-import VideoMusic from '@/components/upload/upload-music.vue'
-
+import FilePondUpload from '@/components/upload/filepond-upload.vue'
+import { videoCategory, submitVideoPost } from '@/api/media/video'
 export default {
-  name: 'Upload',
   components: {
-    VideoUpload,
-    VideoPhoto,
-    VideoArticle,
-    VideoMusic
+    FilePondUpload
   },
   data() {
     return {
-      show: 0
+      rules: [
+        value => !value || value.size < 2000000 || 'Avatar size should be less than 2 MB!'
+      ],
+      // 提交给后端的数据
+      videoInfo: {
+        videoId: '',
+        title: '',
+        description: '',
+        coverUrl: '',
+        duration: 0,
+        categoryId: -1,
+        tags: [],
+        fileId: ''
+      },
+      categoryMap: {
+        Set: function(key, value) { this[key] = value },
+        Get: function(key) { return this[key] },
+        Contains: function(key) { return this.Get(key) !== null },
+        Remove: function(key) { delete this[key] }
+      },
+      category: [],
+      childCategory: [],
+      nowCategory: {},
+      files: [],
+      showMessage: false,
+      message: ''
     }
   },
+  created() {
+    this.getVideoCategory()
+  },
   methods: {
-    setShow(value) {
-      this.show = value
+    publish() {
+      if (!this.videoInfo.fileId) {
+        this.message = '你还没有上传视频'
+        this.showMessage = true
+        return
+      }
+      if (this.videoInfo.title === '' || this.coverUrl === '' || this.videoInfo.tags.length === 0 || this.videoInfo.categoryId === -1) {
+        this.message = '标题,封面,标签,分区不能为空'
+        this.showMessage = true
+        return
+      }
+
+      if (this.videoInfo.tags.length > 6) {
+        this.message = '标签超过6个'
+        this.showMessage = true
+        return
+      }
+
+      submitVideoPost(this.videoInfo)
+        .then(res => {
+          if (res.code === 0) {
+            this.message = '投稿成功,等待审核通过后你就可以看到你的视频了'
+            this.showMessage = true
+            this.$router.push('/studio')
+          } else {
+            this.message = res.msg
+            this.showMessage = true
+          }
+        })
+        .catch(error => {
+          console.error(error.message)
+        })
+    },
+    setFile(value) {
+      this.files = []
+      this.files.push(value)
+    },
+    // filepond 组件上传文件完成时调用
+    videoUploadCallback(value) {
+      if (value.code === 0) {
+        this.videoInfo.videoId = value.data.videoId
+        this.setTitle(value.data.filename)
+        this.videoInfo.duration = value.data.duration
+        this.videoInfo.coverUrl = value.data.coverUrl
+        this.videoInfo.fileId = value.data.fileId
+
+        this.message = '视频上传成功'
+        this.showMessage = true
+      } else {
+        // TODO 返回错误原因,网络错误或是服务端错误
+        if (value.msg != null) {
+          this.message = '上传文件出现异常,请重新上传!' + value.msg
+        } else {
+          this.message = '上传文件出现异常,请重新上传!'
+        }
+        this.showMessage = true
+      }
+    },
+    setTitle(title) {
+      if (title.length > 50) {
+        this.videoInfo.title = title.substring(0, 50)
+      } else {
+        this.videoInfo.title = title
+      }
+    },
+    uploadFile() {
+      if (this.files.length === 0) {
+        this.message = '请先选择视频封面,然后上传!'
+        this.showMessage = true
+        return
+      }
+      const formData = new FormData()
+      for (let i = 0; i < this.files.length; i++) {
+        formData.append('file[]', this.files[i])
+      }
+      fetch(`http://file.reghao.cn/api/file/upload/image`, {
+        headers: {
+          'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')
+        },
+        method: 'POST',
+        credentials: 'include',
+        body: formData
+      }).then(response => response.json())
+        .then(json => {
+          if (json.code === 0) {
+            this.videoInfo.coverUrl = json.data[0].url
+          } else {
+            this.message = '上传失败,请重试!' + json.message
+            this.showMessage = true
+          }
+        })
+        .catch(e => {
+          return null
+        })
+    },
+    getVideoCategory() {
+      videoCategory()
+        .then(res => {
+          if (res.code === 0) {
+            for (let i = 0; i < res.data.length; i++) {
+              const name = res.data[i].name
+              this.category.push(name)
+              this.categoryMap.Set(name, res.data[i])
+            }
+          } else {
+            console.error(res.msg)
+          }
+        })
+        .catch(error => {
+          console.error(error.message)
+        })
+    },
+    getCategory(name) {
+      // 重置子分区,清除前一次选择分区时留下的缓存
+      this.childCategory = []
+      this.currentCategory = this.categoryMap.Get(name)
+      this.videoInfo.categoryId = this.currentCategory.id
+
+      const c = this.currentCategory.children
+      if (c) {
+        for (let i = 0; i < c.length; i++) {
+          this.childCategory.push(c[i].name)
+        }
+      }
+    },
+    getChildCategory(name) {
+      const c = this.currentCategory.children
+      for (let i = 0; i < c.length; i++) {
+        if (c[i].name === name) {
+          this.videoInfo.categoryId = c[i].id
+        }
+      }
     }
   }
 }