Commit 98fa2fc9 by zhangquan

设置首帧图

1 parent 82047178
...@@ -36,8 +36,10 @@ ...@@ -36,8 +36,10 @@
import upload from '@/api/uploadApi' import upload from '@/api/uploadApi'
import util from '@/utils/util' import util from '@/utils/util'
import bigView from '@/components/big-view' import bigView from '@/components/big-view'
import uploadMixin from '@/mixins/upload'
export default { export default {
name: 'Upload', name: 'Upload',
mixins: [uploadMixin],
components: { components: {
bigView bigView
}, },
...@@ -66,6 +68,10 @@ export default { ...@@ -66,6 +68,10 @@ export default {
type: String, type: String,
default: '' default: ''
}, },
coverAttr: {
type: String,
default: ''
},
name: { name: {
type: String, type: String,
default: '' default: ''
...@@ -140,12 +146,12 @@ export default { ...@@ -140,12 +146,12 @@ export default {
return this.$message.error('请上传格式为jpg、jpeg、png、webp、gif的图片') return this.$message.error('请上传格式为jpg、jpeg、png、webp、gif的图片')
} }
if(file.type?.indexOf('image')>-1){ if(file.type?.indexOf('image')>-1){
this.uploadImg(e) this.uploadImgFn(e)
}else{ }else{
this.uploadVideo(e) this.uploadVideo(e)
} }
}, },
uploadImg(e) { uploadImgFn(e) {
const loading = this.$loading({ const loading = this.$loading({
lock: true, lock: true,
text: 'Loading', text: 'Loading',
...@@ -193,12 +199,24 @@ export default { ...@@ -193,12 +199,24 @@ export default {
if(url && url.indexOf('https')<0){ if(url && url.indexOf('https')<0){
url = url.replace('http','https') url = url.replace('http','https')
} }
self.formObj[this.attr] = url self.formObj[self.attr] = url
self.$emit('uploadSuccess', {attr : this.attr, url}) if(this.coverAttr) {
}) self.$nextTick(()=>[
.finally(end => { self.getImgUrl(url).then(resp => {
self.$set(self.formObj, self.coverAttr, resp)
loading.close()
}).catch(err=>{
loading.close()
})
])
}else{
loading.close()
}
self.$refs.fileRef && (self.$refs.fileRef.value = '')
self.$emit('uploadSuccess', {attr : self.attr, url})
}).catch(end => {
loading.close() loading.close()
self.$refs.fileRef.value = '' self.$refs.fileRef && (self.$refs.fileRef.value = '')
}) })
upload.uploadEvent('', res => { upload.uploadEvent('', res => {
console.log(res, '视频上传完成') console.log(res, '视频上传完成')
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<span class="module active">{{contentType[contentObj.type]}}</span> <span class="module active">{{contentType[contentObj.type]}}</span>
</div> </div>
<div slot="mainVideoSlot" class="main-video-slot"> <div slot="mainVideoSlot" class="main-video-slot">
<Upload fileType="video" :formObj="formObj" btnName="上传视频" attr="vedioUrl"></Upload> <Upload fileType="video" :formObj="formObj" btnName="上传视频" attr="vedioUrl" coverAttr="prodImg"></Upload>
<Upload tip="建议尺寸:最大5M,138*84px" :formObj="formObj" btnName="上传视频封面" attr="prodImg"></Upload> <Upload tip="建议尺寸:最大5M,138*84px" :formObj="formObj" btnName="上传视频封面" attr="prodImg"></Upload>
</div> </div>
<div slot="viewSlot" class="view-slot"> <div slot="viewSlot" class="view-slot">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!