|
|
@@ -15,7 +15,7 @@
|
|
|
<uploader
|
|
|
class="uploader-example"
|
|
|
:options="options"
|
|
|
- :autoStart="true"
|
|
|
+ :auto-start="true"
|
|
|
@file-added="onFileAdded"
|
|
|
@file-success="onFileSuccess"
|
|
|
@file-progress="onFileProgress"
|
|
|
@@ -50,7 +50,7 @@
|
|
|
label="封面"
|
|
|
@change="setFile"
|
|
|
/>
|
|
|
- <v-btn color="primary" @click="uploadFile">
|
|
|
+ <v-btn color="primary" @click="uploadVideoCover">
|
|
|
上传
|
|
|
</v-btn>
|
|
|
</v-col>
|
|
|
@@ -103,6 +103,15 @@
|
|
|
/>
|
|
|
</v-col>
|
|
|
</v-row>
|
|
|
+ <v-row justify="center">
|
|
|
+ <v-col cols="10">
|
|
|
+ <v-select
|
|
|
+ :items="scope"
|
|
|
+ label="可见范围"
|
|
|
+ @change="setVideoScope"
|
|
|
+ />
|
|
|
+ </v-col>
|
|
|
+ </v-row>
|
|
|
<v-row justify="center">
|
|
|
<v-col cols="10">
|
|
|
<v-btn large color="primary" @click="publish">立即投稿</v-btn>
|
|
|
@@ -139,7 +148,7 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
options: {
|
|
|
- target: '//localhost:8000' + '/api/file/upload/video',
|
|
|
+ target: '//file.reghao.cn' + '/api/file/upload/video',
|
|
|
chunkSize: 1024 * 1024 * 20,
|
|
|
forceChunkSize: true,
|
|
|
fileParameterName: 'file',
|
|
|
@@ -167,13 +176,16 @@ export default {
|
|
|
],
|
|
|
// 提交给后端的数据
|
|
|
videoPost: {
|
|
|
- videoFileId: '',
|
|
|
- duration: 0,
|
|
|
- horizontal: false,
|
|
|
- coverUrl: '',
|
|
|
- title: '',
|
|
|
- description: '',
|
|
|
- categoryId: -1,
|
|
|
+ videoUploadId: null,
|
|
|
+ videoFileId: null,
|
|
|
+ duration: null,
|
|
|
+ horizontal: null,
|
|
|
+ scope: null,
|
|
|
+ coverUrl: null,
|
|
|
+ coverUrlOriginal: null,
|
|
|
+ title: null,
|
|
|
+ description: null,
|
|
|
+ categoryId: null,
|
|
|
tags: []
|
|
|
},
|
|
|
categoryMap: {
|
|
|
@@ -184,8 +196,14 @@ export default {
|
|
|
},
|
|
|
category: [],
|
|
|
childCategory: [],
|
|
|
+ scope: [
|
|
|
+ '全部可见',
|
|
|
+ '验证码可见',
|
|
|
+ 'VIP 可见',
|
|
|
+ '自己可见'
|
|
|
+ ],
|
|
|
nowCategory: {},
|
|
|
- files: [],
|
|
|
+ coverFile: null,
|
|
|
showMessage: false,
|
|
|
message: ''
|
|
|
}
|
|
|
@@ -202,7 +220,7 @@ export default {
|
|
|
formData.append('filename', file.file.name)
|
|
|
formData.append('size', file.file.size)
|
|
|
formData.append('sha256sum', res.sha256sum)
|
|
|
- fetch(`//localhost:8000` + `/api/file/upload/video/prepare`, {
|
|
|
+ fetch(`//file.reghao.cn` + `/api/file/upload/video/prepare`, {
|
|
|
headers: {
|
|
|
Authorization: 'Bearer ' + this.$store.getters.token
|
|
|
},
|
|
|
@@ -255,8 +273,8 @@ export default {
|
|
|
this.showMessage = true
|
|
|
return
|
|
|
}
|
|
|
- if (this.videoPost.tags.length > 6) {
|
|
|
- this.message = '标签超过6个'
|
|
|
+ if (this.videoPost.tags.length > 10) {
|
|
|
+ this.message = '最多可以有 10 个标签'
|
|
|
this.showMessage = true
|
|
|
return
|
|
|
}
|
|
|
@@ -264,7 +282,7 @@ export default {
|
|
|
submitVideoPost(this.videoPost)
|
|
|
.then(res => {
|
|
|
if (res.code === 0) {
|
|
|
- this.message = '投稿成功,等待审核通过后你就可以看到你的视频了'
|
|
|
+ this.message = '投稿成功,等待审核通过后其他人就可以看到你的视频了'
|
|
|
this.showMessage = true
|
|
|
this.$router.push('/studio')
|
|
|
} else {
|
|
|
@@ -277,8 +295,7 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
setFile(value) {
|
|
|
- this.files = []
|
|
|
- this.files.push(value)
|
|
|
+ this.coverFile = value
|
|
|
},
|
|
|
setTitle(title) {
|
|
|
if (title.length > 50) {
|
|
|
@@ -287,17 +304,23 @@ export default {
|
|
|
this.videoPost.title = title
|
|
|
}
|
|
|
},
|
|
|
- uploadFile() {
|
|
|
- if (this.files.length === 0) {
|
|
|
+ uploadVideoCover() {
|
|
|
+ if (this.coverFile === null) {
|
|
|
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])
|
|
|
+
|
|
|
+ if (this.videoPost.videoFileId === null) {
|
|
|
+ this.message = '等待视频上传完成后再上传封面!'
|
|
|
+ this.showMessage = true
|
|
|
+ return
|
|
|
}
|
|
|
- fetch(`http://file.reghao.cn/api/file/upload/image`, {
|
|
|
+
|
|
|
+ const formData = new FormData()
|
|
|
+ formData.append('videoFileId', this.videoPost.videoFileId)
|
|
|
+ formData.append('file', this.coverFile)
|
|
|
+ fetch(`http://file.reghao.cn/api/file/upload/video/cover`, {
|
|
|
headers: {
|
|
|
'Authorization': 'Bearer ' + this.$store.getters.token
|
|
|
},
|
|
|
@@ -307,7 +330,9 @@ export default {
|
|
|
}).then(response => response.json())
|
|
|
.then(json => {
|
|
|
if (json.code === 0) {
|
|
|
- this.videoPost.coverUrl = json.data[0].url
|
|
|
+ console.log(json)
|
|
|
+ this.videoPost.coverUrl = json.data.thumbnailUrl
|
|
|
+ this.videoPost.coverUrlOriginal = json.data.originalUrl
|
|
|
} else {
|
|
|
this.message = '上传失败,请重试!' + json.message
|
|
|
this.showMessage = true
|
|
|
@@ -354,6 +379,19 @@ export default {
|
|
|
this.videoPost.categoryId = c[i].id
|
|
|
}
|
|
|
}
|
|
|
+ },
|
|
|
+ setVideoScope(scope) {
|
|
|
+ if (scope === '全部可见') {
|
|
|
+ this.videoPost.scope = 1
|
|
|
+ } else if (scope === '验证码可见') {
|
|
|
+ this.videoPost.scope = 2
|
|
|
+ } else if (scope === 'VIP 可见') {
|
|
|
+ this.videoPost.scope = 3
|
|
|
+ } else if (scope === '自己可见') {
|
|
|
+ this.videoPost.scope = 4
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(this.videoPost)
|
|
|
}
|
|
|
}
|
|
|
}
|