|
@@ -8,6 +8,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="text item">
|
|
<div class="text item">
|
|
|
<uploader
|
|
<uploader
|
|
|
|
|
+ v-if="options !== null"
|
|
|
class="uploader-example"
|
|
class="uploader-example"
|
|
|
:options="options"
|
|
:options="options"
|
|
|
:auto-start="true"
|
|
:auto-start="true"
|
|
@@ -35,13 +36,14 @@
|
|
|
<el-tooltip class="item" effect="dark" content="点击上传图片" placement="top-end">
|
|
<el-tooltip class="item" effect="dark" content="点击上传图片" placement="top-end">
|
|
|
<el-upload
|
|
<el-upload
|
|
|
class="avatar-uploader"
|
|
class="avatar-uploader"
|
|
|
- :action="actionUrl"
|
|
|
|
|
|
|
+ :action="imgOssUrl"
|
|
|
:headers="imgHeaders"
|
|
:headers="imgHeaders"
|
|
|
:data="imgData"
|
|
:data="imgData"
|
|
|
- :with-credentials="true"
|
|
|
|
|
|
|
+ :with-credentials="false"
|
|
|
:show-file-list="false"
|
|
:show-file-list="false"
|
|
|
:before-upload="beforeAvatarUpload"
|
|
:before-upload="beforeAvatarUpload"
|
|
|
:on-success="handleAvatarSuccess"
|
|
:on-success="handleAvatarSuccess"
|
|
|
|
|
+ :on-error="handleAvatarError"
|
|
|
:on-change="handleOnChange"
|
|
:on-change="handleOnChange"
|
|
|
>
|
|
>
|
|
|
<img v-if="coverUrl" :src="coverUrl" class="avatar">
|
|
<img v-if="coverUrl" :src="coverUrl" class="avatar">
|
|
@@ -121,33 +123,33 @@ export default {
|
|
|
name: 'PublishVideo',
|
|
name: 'PublishVideo',
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
- actionUrl: process.env.VUE_APP_OSS_URL,
|
|
|
|
|
// ****************************************************************************************************************
|
|
// ****************************************************************************************************************
|
|
|
- options: {
|
|
|
|
|
- target: process.env.VUE_APP_OSS_URL,
|
|
|
|
|
|
|
+ options: null,
|
|
|
|
|
+ options1: {
|
|
|
|
|
+ target: '',
|
|
|
chunkSize: 1024 * 1024 * 1024 * 10, // 10GiB
|
|
chunkSize: 1024 * 1024 * 1024 * 10, // 10GiB
|
|
|
fileParameterName: 'file',
|
|
fileParameterName: 'file',
|
|
|
testChunks: false,
|
|
testChunks: false,
|
|
|
query: (file, chunk) => {
|
|
query: (file, chunk) => {
|
|
|
return {
|
|
return {
|
|
|
- channelId: 2
|
|
|
|
|
|
|
+ channelId: 104
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
headers: {
|
|
headers: {
|
|
|
Authorization: ''
|
|
Authorization: ''
|
|
|
},
|
|
},
|
|
|
- withCredentials: true
|
|
|
|
|
|
|
+ withCredentials: false
|
|
|
},
|
|
},
|
|
|
attrs: {
|
|
attrs: {
|
|
|
accept: 'video/*'
|
|
accept: 'video/*'
|
|
|
},
|
|
},
|
|
|
// ****************************************************************************************************************
|
|
// ****************************************************************************************************************
|
|
|
- imgOssUrl: null,
|
|
|
|
|
|
|
+ imgOssUrl: '',
|
|
|
imgHeaders: {
|
|
imgHeaders: {
|
|
|
Authorization: ''
|
|
Authorization: ''
|
|
|
},
|
|
},
|
|
|
imgData: {
|
|
imgData: {
|
|
|
- channelId: 5
|
|
|
|
|
|
|
+ channelId: 105
|
|
|
},
|
|
},
|
|
|
coverUrl: null,
|
|
coverUrl: null,
|
|
|
// ****************************************************************************************************************
|
|
// ****************************************************************************************************************
|
|
@@ -164,7 +166,8 @@ export default {
|
|
|
],
|
|
],
|
|
|
form: {
|
|
form: {
|
|
|
videoFileId: null,
|
|
videoFileId: null,
|
|
|
- coverFileId: null,
|
|
|
|
|
|
|
+ channelId: 104,
|
|
|
|
|
+ coverUrl: null,
|
|
|
title: null,
|
|
title: null,
|
|
|
description: null,
|
|
description: null,
|
|
|
categoryPid: null,
|
|
categoryPid: null,
|
|
@@ -176,12 +179,28 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
|
- getServerInfo(2).then(res => {
|
|
|
|
|
|
|
+ getServerInfo(this.form.channelId).then(res => {
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
const resData = res.data
|
|
const resData = res.data
|
|
|
- this.options.target = resData.ossUrl
|
|
|
|
|
|
|
+ this.options = {
|
|
|
|
|
+ target: resData.ossUrl,
|
|
|
|
|
+ chunkSize: resData.maxSize,
|
|
|
|
|
+ fileParameterName: 'file',
|
|
|
|
|
+ testChunks: false,
|
|
|
|
|
+ query: (file, chunk) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ channelId: this.form.channelId
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ Authorization: 'Bearer ' + resData.token
|
|
|
|
|
+ },
|
|
|
|
|
+ withCredentials: false
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*this.options.target = resData.ossUrl
|
|
|
this.options.chunkSize = resData.maxSize
|
|
this.options.chunkSize = resData.maxSize
|
|
|
- this.options.headers.Authorization = 'Bearer ' + resData.token
|
|
|
|
|
|
|
+ this.options.headers.Authorization = 'Bearer ' + resData.token*/
|
|
|
} else {
|
|
} else {
|
|
|
this.$notify({
|
|
this.$notify({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
@@ -193,13 +212,13 @@ export default {
|
|
|
}).catch(error => {
|
|
}).catch(error => {
|
|
|
this.$notify({
|
|
this.$notify({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
- message: error.message,
|
|
|
|
|
|
|
+ message: '获取 OSS 服务器地址失败, 暂时无法上传视频文件',
|
|
|
type: 'warning',
|
|
type: 'warning',
|
|
|
duration: 3000
|
|
duration: 3000
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- getServerInfo(5).then(res => {
|
|
|
|
|
|
|
+ getServerInfo(this.imgData.channelId).then(res => {
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
const resData = res.data
|
|
const resData = res.data
|
|
|
this.imgOssUrl = resData.ossUrl
|
|
this.imgOssUrl = resData.ossUrl
|
|
@@ -207,7 +226,7 @@ export default {
|
|
|
} else {
|
|
} else {
|
|
|
this.$notify({
|
|
this.$notify({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
- message: '获取 OSS 服务器地址失败, 暂时无法上传文件',
|
|
|
|
|
|
|
+ message: '获取 OSS 服务器地址失败, 暂时无法上传视频封面',
|
|
|
type: 'error',
|
|
type: 'error',
|
|
|
duration: 3000
|
|
duration: 3000
|
|
|
})
|
|
})
|
|
@@ -215,7 +234,7 @@ export default {
|
|
|
}).catch(error => {
|
|
}).catch(error => {
|
|
|
this.$notify({
|
|
this.$notify({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
- message: error.message,
|
|
|
|
|
|
|
+ message: '获取 OSS 服务器地址失败, 暂时无法上传视频封面',
|
|
|
type: 'warning',
|
|
type: 'warning',
|
|
|
duration: 3000
|
|
duration: 3000
|
|
|
})
|
|
})
|
|
@@ -264,7 +283,6 @@ export default {
|
|
|
},
|
|
},
|
|
|
onFileError(rootFile, file, response, chunk) {
|
|
onFileError(rootFile, file, response, chunk) {
|
|
|
const res = JSON.parse(response)
|
|
const res = JSON.parse(response)
|
|
|
- console.log(res.msg)
|
|
|
|
|
this.$notify({
|
|
this.$notify({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
message: '视频文件上传错误',
|
|
message: '视频文件上传错误',
|
|
@@ -338,7 +356,7 @@ export default {
|
|
|
|
|
|
|
|
const formData = new FormData()
|
|
const formData = new FormData()
|
|
|
formData.append('file', coverFile)
|
|
formData.append('file', coverFile)
|
|
|
- formData.append('channelId', 5)
|
|
|
|
|
|
|
+ formData.append('channelId', this.imgData.channelId)
|
|
|
fetch(process.env.VUE_APP_OSS_URL, {
|
|
fetch(process.env.VUE_APP_OSS_URL, {
|
|
|
headers: this.imgHeaders,
|
|
headers: this.imgHeaders,
|
|
|
method: 'POST',
|
|
method: 'POST',
|
|
@@ -348,7 +366,7 @@ export default {
|
|
|
if (json.code === 0) {
|
|
if (json.code === 0) {
|
|
|
this.coverUrl = URL.createObjectURL(coverFile)
|
|
this.coverUrl = URL.createObjectURL(coverFile)
|
|
|
const resData = json.data
|
|
const resData = json.data
|
|
|
- this.form.coverFileId = resData.uploadId
|
|
|
|
|
|
|
+ this.form.coverUrl = resData.url
|
|
|
} else {
|
|
} else {
|
|
|
this.$notify({
|
|
this.$notify({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
@@ -381,7 +399,7 @@ export default {
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
const resData = res.data
|
|
const resData = res.data
|
|
|
this.coverUrl = URL.createObjectURL(file.raw)
|
|
this.coverUrl = URL.createObjectURL(file.raw)
|
|
|
- this.form.coverFileId = resData.uploadId
|
|
|
|
|
|
|
+ this.form.coverUrl = resData.url
|
|
|
} else {
|
|
} else {
|
|
|
this.$notify({
|
|
this.$notify({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
@@ -391,6 +409,14 @@ export default {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ handleAvatarError(error, file) {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '视频封面上传失败,请重试!' + error,
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
handleOnChange(file, fileList) {
|
|
handleOnChange(file, fileList) {
|
|
|
},
|
|
},
|
|
|
// ****************************************************************************************************************
|
|
// ****************************************************************************************************************
|
|
@@ -454,7 +480,7 @@ export default {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!this.form.coverFileId) {
|
|
|
|
|
|
|
+ if (!this.form.coverUrl) {
|
|
|
this.$notify({
|
|
this.$notify({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
message: '你还没有上传视频封面',
|
|
message: '你还没有上传视频封面',
|