|
@@ -40,28 +40,30 @@
|
|
|
</el-row>
|
|
</el-row>
|
|
|
<el-form ref="form" :model="form" label-width="80px">
|
|
<el-form ref="form" :model="form" label-width="80px">
|
|
|
<el-form-item label="标题">
|
|
<el-form-item label="标题">
|
|
|
- <el-input v-model="form.name" style="width: 70%; padding-right: 2px" placeholder="标题不能超过 50 个字符" />
|
|
|
|
|
|
|
+ <el-input v-model="form.title" style="width: 70%; padding-right: 2px" placeholder="标题不能超过 50 个字符" />
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="描述">
|
|
<el-form-item label="描述">
|
|
|
- <el-input v-model="form.desc" type="textarea" style="width: 70%; padding-right: 2px" />
|
|
|
|
|
|
|
+ <el-input v-model="form.description" type="textarea" style="width: 70%; padding-right: 2px" />
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="分区">
|
|
<el-form-item label="分区">
|
|
|
<el-select v-model="category" placeholder="请选择分区">
|
|
<el-select v-model="category" placeholder="请选择分区">
|
|
|
- <el-option label="区域一" value="shanghai" />
|
|
|
|
|
- <el-option label="区域二" value="beijing" />
|
|
|
|
|
|
|
+ <el-option label="新闻" value="shanghai" />
|
|
|
|
|
+ <el-option label="教育" value="beijing" />
|
|
|
</el-select>
|
|
</el-select>
|
|
|
<el-select v-model="childCategory" placeholder="请选择子分区">
|
|
<el-select v-model="childCategory" placeholder="请选择子分区">
|
|
|
- <el-option label="区域一" value="shanghai" />
|
|
|
|
|
- <el-option label="区域二" value="beijing" />
|
|
|
|
|
|
|
+ <el-option label="历史" value="shanghai" />
|
|
|
|
|
+ <el-option label="计算机" value="beijing" />
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="标签">
|
|
<el-form-item label="标签">
|
|
|
<el-input v-model="form.tags" style="width: 70%; padding-right: 2px" placeholder="多个标签之间使用英文逗号分隔" />
|
|
<el-input v-model="form.tags" style="width: 70%; padding-right: 2px" placeholder="多个标签之间使用英文逗号分隔" />
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="可见范围">
|
|
<el-form-item label="可见范围">
|
|
|
- <el-select v-model="scope" placeholder="选择可见范围">
|
|
|
|
|
- <el-option label="区域一" value="shanghai" />
|
|
|
|
|
- <el-option label="区域二" value="beijing" />
|
|
|
|
|
|
|
+ <el-select v-model="form.scope" placeholder="选择可见范围">
|
|
|
|
|
+ <el-option label="所有人可见" value="1" />
|
|
|
|
|
+ <el-option label="验证码可见" value="2" />
|
|
|
|
|
+ <el-option label="VIP 可见" value="3" />
|
|
|
|
|
+ <el-option label="仅自己可见" value="4" />
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
<el-form-item>
|
|
@@ -74,22 +76,34 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import { videoCategory, submitVideoPost } from '@/api/video'
|
|
|
|
|
-import { getVideoId } from '@/api/file'
|
|
|
|
|
|
|
+import { videoCategory, submitVideo } from '@/api/video'
|
|
|
|
|
+import { getOssPolicy } from '@/api/file'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'PublishVideo',
|
|
name: 'PublishVideo',
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
- activeName: 'first',
|
|
|
|
|
|
|
+ /***********************************************************************/
|
|
|
options: {
|
|
options: {
|
|
|
- target: '//api.reghao.cn/api/file/upload/video',
|
|
|
|
|
|
|
+ target: '//oss.reghao.cn/',
|
|
|
chunkSize: 1024 * 1024 * 1024 * 5, // 5GiB
|
|
chunkSize: 1024 * 1024 * 1024 * 5, // 5GiB
|
|
|
fileParameterName: 'file',
|
|
fileParameterName: 'file',
|
|
|
testChunks: false,
|
|
testChunks: false,
|
|
|
query: (file, chunk) => {
|
|
query: (file, chunk) => {
|
|
|
- this.videoPost.urlObjectName = 'video/playback/' + this.videoUrlId
|
|
|
|
|
- return { key: this.videoPost.urlObjectName }
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ key: this.form.videoObjectName,
|
|
|
|
|
+ acl: '',
|
|
|
|
|
+ policy: '',
|
|
|
|
|
+ 'content-type': '',
|
|
|
|
|
+ 'success_action_redirect': '',
|
|
|
|
|
+ 'x-amz-meta-uuid': '',
|
|
|
|
|
+ 'x-amz-server-side-encryption': '',
|
|
|
|
|
+ 'X-amz-credential': '',
|
|
|
|
|
+ 'x-amz-algorithm': '',
|
|
|
|
|
+ 'x-amz-date': '',
|
|
|
|
|
+ 'x-amz-meta-tag': '',
|
|
|
|
|
+ 'x-amz-signature': ''
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
headers: {
|
|
headers: {
|
|
|
}
|
|
}
|
|
@@ -97,25 +111,8 @@ export default {
|
|
|
attrs: {
|
|
attrs: {
|
|
|
accept: 'video/*'
|
|
accept: 'video/*'
|
|
|
},
|
|
},
|
|
|
- rules: [
|
|
|
|
|
- value => !value || value.size < 2000000 || 'Avatar size should be less than 2 MB!'
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ /***********************************************************************/
|
|
|
coverUrl: null,
|
|
coverUrl: null,
|
|
|
- videoUrlId: null,
|
|
|
|
|
- // 提交给后端的数据
|
|
|
|
|
- videoPost: {
|
|
|
|
|
- videoFileId: null,
|
|
|
|
|
- urlObjectName: null,
|
|
|
|
|
- coverFileId: null,
|
|
|
|
|
- title: null,
|
|
|
|
|
- description: null,
|
|
|
|
|
- categoryId: null,
|
|
|
|
|
- tags: [],
|
|
|
|
|
- scope: 1,
|
|
|
|
|
- width: null,
|
|
|
|
|
- height: null,
|
|
|
|
|
- duration: null
|
|
|
|
|
- },
|
|
|
|
|
categoryMap: {
|
|
categoryMap: {
|
|
|
Set: function(key, value) { this[key] = value },
|
|
Set: function(key, value) { this[key] = value },
|
|
|
Get: function(key) { return this[key] },
|
|
Get: function(key) { return this[key] },
|
|
@@ -124,30 +121,18 @@ export default {
|
|
|
},
|
|
},
|
|
|
category: [],
|
|
category: [],
|
|
|
childCategory: [],
|
|
childCategory: [],
|
|
|
- scope: [
|
|
|
|
|
- '所有人可见',
|
|
|
|
|
- '验证码可见',
|
|
|
|
|
- 'VIP 可见',
|
|
|
|
|
- '仅自己可见'
|
|
|
|
|
- ],
|
|
|
|
|
- nowCategory: {},
|
|
|
|
|
coverFile: null,
|
|
coverFile: null,
|
|
|
- showMessage: false,
|
|
|
|
|
- message: '',
|
|
|
|
|
- dialogImageUrl: '',
|
|
|
|
|
- dialogVisible: false,
|
|
|
|
|
- disabled: false,
|
|
|
|
|
imageList: [],
|
|
imageList: [],
|
|
|
imageUrl: '',
|
|
imageUrl: '',
|
|
|
|
|
+ // 提交给后端的数据
|
|
|
form: {
|
|
form: {
|
|
|
- videoFileId: null,
|
|
|
|
|
- urlObjectName: null,
|
|
|
|
|
|
|
+ videoObjectName: null,
|
|
|
coverFileId: null,
|
|
coverFileId: null,
|
|
|
title: null,
|
|
title: null,
|
|
|
- desc: null,
|
|
|
|
|
|
|
+ description: null,
|
|
|
categoryId: 0,
|
|
categoryId: 0,
|
|
|
tags: null,
|
|
tags: null,
|
|
|
- scope: 1,
|
|
|
|
|
|
|
+ scope: null,
|
|
|
width: 0,
|
|
width: 0,
|
|
|
height: 0,
|
|
height: 0,
|
|
|
duration: 0
|
|
duration: 0
|
|
@@ -155,10 +140,53 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
|
- this.getVideoIdWrapper()
|
|
|
|
|
|
|
+ this.getOssPolicyWrapper()
|
|
|
this.getVideoCategory()
|
|
this.getVideoCategory()
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ /***********************************************************************/
|
|
|
|
|
+ onFileAdded(file) {
|
|
|
|
|
+ if (file.file.size > 1024*1024*1024*5) {
|
|
|
|
|
+ file.cancel()
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '视频文件应小于 5GiB',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this.setTitle(file.file.name)
|
|
|
|
|
+ this.processVideo(file.file)
|
|
|
|
|
+ },
|
|
|
|
|
+ onFileProgress(rootFile, file, chunk) {
|
|
|
|
|
+ },
|
|
|
|
|
+ onFileSuccess(rootFile, file, response, chunk) {
|
|
|
|
|
+ const res = JSON.parse(response)
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '视频已上传',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ onFileError(rootFile, file, response, chunk) {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '文件上传错误',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ },
|
|
|
|
|
+ /***********************************************************************/
|
|
|
beforeAvatarUpload(file) {
|
|
beforeAvatarUpload(file) {
|
|
|
const isJPG = file.type === 'image/jpeg'
|
|
const isJPG = file.type === 'image/jpeg'
|
|
|
const isLt2M = file.size / 1024 / 1024 < 2
|
|
const isLt2M = file.size / 1024 / 1024 < 2
|
|
@@ -172,7 +200,6 @@ export default {
|
|
|
},
|
|
},
|
|
|
handleAvatarSuccess(res, file) {
|
|
handleAvatarSuccess(res, file) {
|
|
|
this.imageList.push(file)
|
|
this.imageList.push(file)
|
|
|
- console.log(this.imageList)
|
|
|
|
|
this.imageUrl = URL.createObjectURL(file.raw)
|
|
this.imageUrl = URL.createObjectURL(file.raw)
|
|
|
},
|
|
},
|
|
|
// 选择视频后获取视频的分辨率和时长, 并截取第一秒的内容作为封面
|
|
// 选择视频后获取视频的分辨率和时长, 并截取第一秒的内容作为封面
|
|
@@ -202,13 +229,11 @@ export default {
|
|
|
// 视频视频分辨率
|
|
// 视频视频分辨率
|
|
|
const videoWidth = videoElem.videoWidth
|
|
const videoWidth = videoElem.videoWidth
|
|
|
const videoHeight = videoElem.videoHeight
|
|
const videoHeight = videoElem.videoHeight
|
|
|
- this.videoPost.width = videoWidth
|
|
|
|
|
- this.videoPost.height = videoHeight
|
|
|
|
|
- this.videoPost.duration = videoElem.duration
|
|
|
|
|
|
|
+ this.form.width = videoWidth
|
|
|
|
|
+ this.form.height = videoHeight
|
|
|
|
|
+ this.form.duration = videoElem.duration
|
|
|
|
|
|
|
|
videoElem.pause()
|
|
videoElem.pause()
|
|
|
- /* const ratio = window.devicePixelRatio || 1
|
|
|
|
|
- canvasCtx.scale(ratio, ratio)*/
|
|
|
|
|
// 设置画布尺寸
|
|
// 设置画布尺寸
|
|
|
canvas.width = videoWidth
|
|
canvas.width = videoWidth
|
|
|
canvas.height = videoHeight
|
|
canvas.height = videoHeight
|
|
@@ -228,7 +253,6 @@ export default {
|
|
|
u8arr[n] = bstr.charCodeAt(n)
|
|
u8arr[n] = bstr.charCodeAt(n)
|
|
|
}
|
|
}
|
|
|
const coverFile = new File([u8arr], 'cover.jpg', { type: 'image/jpeg' })
|
|
const coverFile = new File([u8arr], 'cover.jpg', { type: 'image/jpeg' })
|
|
|
-
|
|
|
|
|
if (coverFile instanceof File) {
|
|
if (coverFile instanceof File) {
|
|
|
const formData = new FormData()
|
|
const formData = new FormData()
|
|
|
formData.append('file', coverFile)
|
|
formData.append('file', coverFile)
|
|
@@ -240,11 +264,17 @@ export default {
|
|
|
}).then(response => response.json())
|
|
}).then(response => response.json())
|
|
|
.then(json => {
|
|
.then(json => {
|
|
|
if (json.code === 0) {
|
|
if (json.code === 0) {
|
|
|
- this.videoPost.coverFileId = json.data.imageFileId
|
|
|
|
|
|
|
+ this.form.coverFileId = json.data.imageFileId
|
|
|
this.imageUrl = json.data.imageUrl
|
|
this.imageUrl = json.data.imageUrl
|
|
|
} else {
|
|
} else {
|
|
|
- this.message = '视频封面上传失败,请重试!' + json.message
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '视频封面上传失败,请重试!' + json.message,
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
.catch(e => {
|
|
.catch(e => {
|
|
@@ -255,170 +285,49 @@ export default {
|
|
|
// 防止拖动进度条的时候重复触发
|
|
// 防止拖动进度条的时候重复触发
|
|
|
// videoElem.removeEventListener('canplay', arguments.callee)
|
|
// videoElem.removeEventListener('canplay', arguments.callee)
|
|
|
},
|
|
},
|
|
|
- onFileAdded(file) {
|
|
|
|
|
- this.setTitle(file.file.name)
|
|
|
|
|
- this.processVideo(file.file)
|
|
|
|
|
- /* file.pause()
|
|
|
|
|
- hashFile(file.file).then(res => {
|
|
|
|
|
- const formData = new FormData()
|
|
|
|
|
- formData.append('filename', file.file.name)
|
|
|
|
|
- formData.append('size', file.file.size)
|
|
|
|
|
- formData.append('sha256sum', res.sha256sum)
|
|
|
|
|
- fetch(`//file.reghao.cn` + `/api/file/upload/video/prepare`, {
|
|
|
|
|
- headers: {
|
|
|
|
|
- Authorization: 'Bearer ' + this.$store.getters.token
|
|
|
|
|
- },
|
|
|
|
|
- method: 'POST',
|
|
|
|
|
- credentials: 'include',
|
|
|
|
|
- body: formData
|
|
|
|
|
- }).then(response => response.json())
|
|
|
|
|
- .then(json => {
|
|
|
|
|
- const uploadId = json.data.uploadId
|
|
|
|
|
- const exist = json.data.exist
|
|
|
|
|
- if (exist) {
|
|
|
|
|
- this.message = '视频已存在'
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- file.cancel()
|
|
|
|
|
- } else {
|
|
|
|
|
- file.uniqueIdentifier = uploadId
|
|
|
|
|
- file.resume()
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .catch(e => {
|
|
|
|
|
- return null
|
|
|
|
|
- })
|
|
|
|
|
- })*/
|
|
|
|
|
- },
|
|
|
|
|
- onFileProgress(rootFile, file, chunk) {
|
|
|
|
|
- },
|
|
|
|
|
- onFileSuccess(rootFile, file, response, chunk) {
|
|
|
|
|
- const res = JSON.parse(response)
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
- this.message = '视频已上传'
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- onFileError(rootFile, file, response, chunk) {
|
|
|
|
|
- console.log('文件上传错误')
|
|
|
|
|
- },
|
|
|
|
|
- publish() {
|
|
|
|
|
- if (!this.videoPost.videoFileId) {
|
|
|
|
|
- this.message = '你还没有上传视频'
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!this.videoPost.coverFileId) {
|
|
|
|
|
- this.message = '你还没有上传视频封面'
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (this.videoPost.title === '' || this.videoPost.categoryId === -1) {
|
|
|
|
|
- this.message = '分区和稿件标题不能为空'
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /* if (this.videoPost.scope === null) {
|
|
|
|
|
- this.message = '稿件可见范围不能为空'
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- return
|
|
|
|
|
- }*/
|
|
|
|
|
-
|
|
|
|
|
- if (this.videoPost.tags.length === 0 || this.videoPost.tags.length > 10) {
|
|
|
|
|
- this.message = '标签最少 1 个, 最多 10 个'
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- submitVideoPost(this.videoPost)
|
|
|
|
|
- .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.coverFile = value
|
|
|
|
|
- },
|
|
|
|
|
setTitle(title) {
|
|
setTitle(title) {
|
|
|
if (title.length > 50) {
|
|
if (title.length > 50) {
|
|
|
- this.videoPost.title = title.substring(0, 50)
|
|
|
|
|
- this.videoPost.description = title
|
|
|
|
|
|
|
+ this.form.title = title.substring(0, 50)
|
|
|
|
|
+ this.form.description = title
|
|
|
} else {
|
|
} else {
|
|
|
- this.videoPost.title = title
|
|
|
|
|
|
|
+ this.form.title = title
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- /* uploadVideoCover() {
|
|
|
|
|
- if (this.coverFile === null) {
|
|
|
|
|
- this.message = '请先选择视频封面,然后上传!'
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (this.videoPost.videoFileId === null) {
|
|
|
|
|
- this.message = '等待视频上传完成后再上传封面!'
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const formData = new FormData()
|
|
|
|
|
- formData.append('videoFileId', this.videoPost.videoFileId)
|
|
|
|
|
- formData.append('file', this.coverFile)
|
|
|
|
|
- fetch(`//api.reghao.cn/api/file/upload/video/cover`, {
|
|
|
|
|
- headers: {
|
|
|
|
|
- 'Authorization': 'Bearer ' + this.$store.getters.token
|
|
|
|
|
- },
|
|
|
|
|
- method: 'POST',
|
|
|
|
|
- credentials: 'include',
|
|
|
|
|
- body: formData
|
|
|
|
|
- }).then(response => response.json())
|
|
|
|
|
- .then(json => {
|
|
|
|
|
- if (json.code === 0) {
|
|
|
|
|
- this.message = '封面已上传'
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- this.videoPost.coverFileId = json.data.imageFileId
|
|
|
|
|
- this.videoPost.imageUrl = json.data.imageUrl
|
|
|
|
|
- } else {
|
|
|
|
|
- this.message = '上传失败,请重试!' + json.message
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .catch(e => {
|
|
|
|
|
- return null
|
|
|
|
|
- })
|
|
|
|
|
- },*/
|
|
|
|
|
getVideoCategory() {
|
|
getVideoCategory() {
|
|
|
videoCategory()
|
|
videoCategory()
|
|
|
.then(res => {
|
|
.then(res => {
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
for (let i = 0; i < res.data.length; i++) {
|
|
for (let i = 0; i < res.data.length; i++) {
|
|
|
const name = res.data[i].name
|
|
const name = res.data[i].name
|
|
|
- this.category.push(name)
|
|
|
|
|
|
|
+ //this.category.push(name)
|
|
|
this.categoryMap.Set(name, res.data[i])
|
|
this.categoryMap.Set(name, res.data[i])
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- console.error(res.msg)
|
|
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: res.msg,
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
- .catch(error => {
|
|
|
|
|
- console.error(error.message)
|
|
|
|
|
|
|
+ }).catch(error => {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: error.message,
|
|
|
|
|
+ type: 'error',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
getCategory(name) {
|
|
getCategory(name) {
|
|
|
// 重置子分区,清除前一次选择分区时留下的缓存
|
|
// 重置子分区,清除前一次选择分区时留下的缓存
|
|
|
this.childCategory = []
|
|
this.childCategory = []
|
|
|
this.currentCategory = this.categoryMap.Get(name)
|
|
this.currentCategory = this.categoryMap.Get(name)
|
|
|
- this.videoPost.categoryId = this.currentCategory.id
|
|
|
|
|
|
|
+ this.form.categoryId = this.currentCategory.id
|
|
|
|
|
|
|
|
const c = this.currentCategory.children
|
|
const c = this.currentCategory.children
|
|
|
if (c) {
|
|
if (c) {
|
|
@@ -431,39 +340,128 @@ export default {
|
|
|
const c = this.currentCategory.children
|
|
const c = this.currentCategory.children
|
|
|
for (let i = 0; i < c.length; i++) {
|
|
for (let i = 0; i < c.length; i++) {
|
|
|
if (c[i].name === name) {
|
|
if (c[i].name === name) {
|
|
|
- this.videoPost.categoryId = c[i].id
|
|
|
|
|
|
|
+ this.form.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
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- getVideoIdWrapper() {
|
|
|
|
|
- getVideoId(this.videoPost)
|
|
|
|
|
|
|
+ getOssPolicyWrapper() {
|
|
|
|
|
+ getOssPolicy(this.videoPost)
|
|
|
.then(res => {
|
|
.then(res => {
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
- console.log(res.data)
|
|
|
|
|
- this.videoPost.videoFileId = res.data.videoFileId
|
|
|
|
|
- this.videoUrlId = res.data.videoUrlId
|
|
|
|
|
|
|
+ this.form.videoObjectName = res.data.videoObjectName
|
|
|
} else {
|
|
} else {
|
|
|
- this.message = res.msg
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: res.msg,
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
- .catch(error => {
|
|
|
|
|
- console.error(error.message)
|
|
|
|
|
|
|
+ }).catch(error => {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: error.message,
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
onSubmit() {
|
|
onSubmit() {
|
|
|
- console.log('submit!')
|
|
|
|
|
|
|
+ if (!this.form.videoObjectName) {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '你还没有上传视频',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!this.form.coverFileId) {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '你还没有上传视频封面',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (this.form.title === '' || this.form.categoryId === -1) {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '分区和稿件标题不能为空',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (this.form.scope === null) {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '稿件可见范围不能为空',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*if (this.form.tags.length === 0 || this.videoPost.tags.length > 10) {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '标签最少 1 个, 最多 10 个',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ return
|
|
|
|
|
+ }*/
|
|
|
|
|
+ submitVideo(this.form)
|
|
|
|
|
+ .then(res => {
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '投稿成功,等待审核通过后其他人就可以看到你的视频了',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ this.$router.push('/user/post/list')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: res.msg,
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(error => {
|
|
|
|
|
+ this.$notify(
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: error.message,
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|