|
|
@@ -0,0 +1,285 @@
|
|
|
+<template>
|
|
|
+ <el-row class="movie-list">
|
|
|
+ <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
|
|
|
+ <el-col :md="24" style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div class="text item">
|
|
|
+ <el-button style="float: left; padding: 3px 0" type="text" @click="onReturnArticle">返回文章稿件列表</el-button>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
|
|
|
+ <el-col :md="8" style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <span>更新音频稿件信息</span>
|
|
|
+ <el-button style="float: right; padding: 3px 0" type="text" @click="onUpdateVideoInfo">更新</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="text item">
|
|
|
+ <el-form ref="form" :model="form" label-width="80px">
|
|
|
+ <el-form-item label="标题">
|
|
|
+ <el-input v-model="form.title" style="width: 70%; padding-right: 2px" placeholder="标题不能超过 50 个字符" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="描述">
|
|
|
+ <el-input v-model="form.description" type="textarea" style="width: 70%; padding-right: 2px" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ <el-col :md="12" style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <span>更新音频文件</span>
|
|
|
+ <el-button style="float: right; padding: 3px 0" type="text" @click="onUpdateVideoFile">更新</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="text item">
|
|
|
+ <uploader
|
|
|
+ class="uploader-example"
|
|
|
+ :options="options"
|
|
|
+ :auto-start="true"
|
|
|
+ @file-added="onFileAdded"
|
|
|
+ @file-success="onFileSuccess"
|
|
|
+ @file-progress="onFileProgress"
|
|
|
+ @file-error="onFileError"
|
|
|
+ >
|
|
|
+ <uploader-unsupport />
|
|
|
+ <uploader-drop>
|
|
|
+ <p>拖动音频文件到此处或</p>
|
|
|
+ <uploader-btn :attrs="attrs">选择音频文件</uploader-btn>
|
|
|
+ </uploader-drop>
|
|
|
+ <uploader-list />
|
|
|
+ </uploader>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-row>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getAudioPost, } from '@/api/audio'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'EditArticle',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ /***********************************************************************/
|
|
|
+ options: {
|
|
|
+ target: '//oss.reghao.cn/',
|
|
|
+ chunkSize: 1024 * 1024 * 1024, // 1GiB
|
|
|
+ fileParameterName: 'file',
|
|
|
+ testChunks: false,
|
|
|
+ query: (file, chunk) => {
|
|
|
+ return {
|
|
|
+ channelId: 2
|
|
|
+ }
|
|
|
+ },
|
|
|
+ headers: {
|
|
|
+ Authorization: '1234567890'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ attrs: {
|
|
|
+ accept: 'audio/*'
|
|
|
+ },
|
|
|
+ imgHeaders: {
|
|
|
+ Authorization: '1234567890'
|
|
|
+ },
|
|
|
+ imgData: {
|
|
|
+ channelId: 3
|
|
|
+ },
|
|
|
+ /***********************************************************************/
|
|
|
+ coverUrl: null,
|
|
|
+ coverFile: null,
|
|
|
+ imageList: [],
|
|
|
+ imageUrl: '',
|
|
|
+ // 提交给后端的数据
|
|
|
+ tagsStr: null,
|
|
|
+ form: {
|
|
|
+ videoFileId: null,
|
|
|
+ coverUrl: null,
|
|
|
+ title: null,
|
|
|
+ description: null,
|
|
|
+ categoryId: 0,
|
|
|
+ tags: [],
|
|
|
+ scope: null,
|
|
|
+ width: 0,
|
|
|
+ height: 0,
|
|
|
+ duration: 0
|
|
|
+ },
|
|
|
+ videoInfo: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ document.title = '编辑音频'
|
|
|
+
|
|
|
+ const audioId = this.$route.params.audioId
|
|
|
+ getAudioPost(audioId).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ const audioInfo = res.data
|
|
|
+ this.imageUrl = audioInfo.coverUrl
|
|
|
+ this.form.title = audioInfo.title
|
|
|
+ this.form.description = audioInfo.description
|
|
|
+ this.form.scope = audioInfo.scope
|
|
|
+ } else {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ /***********************************************************************/
|
|
|
+ onFileAdded(file) {
|
|
|
+ if (file.file.size > 1024*1024*1024) {
|
|
|
+ file.cancel()
|
|
|
+ this.$notify(
|
|
|
+ {
|
|
|
+ title: '提示',
|
|
|
+ message: '音频文件应小于 1GiB',
|
|
|
+ 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) {
|
|
|
+ const resData = res.data
|
|
|
+ this.form.audioFileId = resData.uploadId
|
|
|
+
|
|
|
+ this.$notify(
|
|
|
+ {
|
|
|
+ title: '提示',
|
|
|
+ message: '音频已上传',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onFileError(rootFile, file, response, chunk) {
|
|
|
+ this.$notify(
|
|
|
+ {
|
|
|
+ title: '提示',
|
|
|
+ message: '文件上传错误',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /***********************************************************************/
|
|
|
+ beforeAvatarUpload(file) {
|
|
|
+ const isJPG = file.type === 'image/jpeg'
|
|
|
+ const isLt2M = file.size / 1024 / 1024 < 2
|
|
|
+ if (!isJPG) {
|
|
|
+ this.$message.error('上传头像图片只能是 JPG 格式!')
|
|
|
+ }
|
|
|
+ if (!isLt2M) {
|
|
|
+ this.$message.error('上传头像图片大小不能超过 2MB!')
|
|
|
+ }
|
|
|
+ return isJPG && isLt2M
|
|
|
+ },
|
|
|
+ handleAvatarSuccess(res, file) {
|
|
|
+ this.imageList.push(file)
|
|
|
+ this.imageUrl = URL.createObjectURL(file.raw)
|
|
|
+ if (res.code === 0) {
|
|
|
+ const resData = res.data
|
|
|
+ const uploadId = resData.uploadId
|
|
|
+ const url = resData.url
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setTitle(title) {
|
|
|
+ if (title.length > 50) {
|
|
|
+ this.form.title = title.substring(0, 50)
|
|
|
+ this.form.description = title
|
|
|
+ } else {
|
|
|
+ this.form.title = title
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onReturnArticle() {
|
|
|
+ this.$router.push('/post/article')
|
|
|
+ },
|
|
|
+ onUpdateVideoFile() {
|
|
|
+ console.log('更新文章文件')
|
|
|
+ },
|
|
|
+ onUpdateVideoCover() {
|
|
|
+ console.log('更新音频封面')
|
|
|
+ },
|
|
|
+ onUpdateVideoInfo() {
|
|
|
+ console.log('更新音频信息')
|
|
|
+ },
|
|
|
+ onUpdateVideoScope() {
|
|
|
+ console.log('更新音频作用域')
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+/*处于手机屏幕时*/
|
|
|
+@media screen and (max-width: 768px){
|
|
|
+ .movie-list {
|
|
|
+ padding-top: 8px;
|
|
|
+ padding-left: 0.5%;
|
|
|
+ padding-right: 0.5%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .coverImg {
|
|
|
+ height: 120px !important;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.movie-list {
|
|
|
+ padding-top: 15px;
|
|
|
+ padding-left: 6%;
|
|
|
+ padding-right: 6%;
|
|
|
+}
|
|
|
+
|
|
|
+.uploader-example {
|
|
|
+ width: 500px;
|
|
|
+ padding: 15px;
|
|
|
+ margin: 40px auto 0;
|
|
|
+ font-size: 12px;
|
|
|
+ box-shadow: 0 0 10px rgba(0, 0, 0, .4);
|
|
|
+}
|
|
|
+.uploader-example .uploader-btn {
|
|
|
+ margin-right: 4px;
|
|
|
+}
|
|
|
+.uploader-example .uploader-list {
|
|
|
+ max-height: 440px;
|
|
|
+ overflow: auto;
|
|
|
+ overflow-x: hidden;
|
|
|
+ overflow-y: auto;
|
|
|
+}
|
|
|
+
|
|
|
+.avatar-uploader .el-upload {
|
|
|
+ border: 1px dashed #d9d9d9;
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+.avatar-uploader .el-upload:hover {
|
|
|
+ border-color: #409EFF;
|
|
|
+}
|
|
|
+.avatar-uploader-icon {
|
|
|
+ font-size: 28px;
|
|
|
+ color: #8c939d;
|
|
|
+ width: 320px;
|
|
|
+ height: 240px;
|
|
|
+ line-height: 178px;
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
+.avatar {
|
|
|
+ width: 320px;
|
|
|
+ height: 240px;
|
|
|
+ display: block;
|
|
|
+}
|
|
|
+</style>
|