提交 75451580 编写于 作者: zhaosheng.zhang's avatar zhaosheng.zhang

feat: 音频上传七牛

上级 4b151987
......@@ -7,7 +7,7 @@
class="upload-demo"
:disabled="isDisable"
:before-upload="beforeMusicUpload"
:action="actionurl"
action="#"
:headers="headers"
:on-remove="handleRemove"
:on-success="sucess"
......@@ -48,7 +48,9 @@
</template>
<script>
import { getBaseUrl } from '@/utils/index';
import { doUpload, getFilePath } from '@/utils/qiniu-util';
import { openLoading, closeLoading } from '@/utils/utils';
let _this = null;
export default {
props: {
isDisable: {
......@@ -67,7 +69,6 @@
dialogImageUrl: '',
dialogVisible: false,
musicArr: [],
actionUrl: '',
headers: {
token: localStorage.getItem('token'),
},
......@@ -78,13 +79,18 @@
watch: {
musicList(newv) {
console.log(newv);
this.musicArr = newv || [];
const newVideoList = newv?.filter(item => {
const suffixUrl = item?.url.substring(item?.url.lastIndexOf('/') + 1); // 接口不返回name,上传数据列表名称展示为截取url最后“/”后面的内容
item.name = suffixUrl;
return item;
});
this.musicArr = newVideoList || [];
},
},
created() {
_this = this;
this.musicArr = this.musicList;
console.log(console.log('this.musicList', this.musicArr));
this.actionurl = getBaseUrl('/diagnose/illness/audio/upload');
},
methods: {
musicUrl(item) {
......@@ -114,14 +120,32 @@
this.loading = false;
},
// 上传mp3
beforeMusicUpload() {},
beforeMusicUpload(file) {
openLoading(_this);
doUpload(
_this,
file,
getFilePath(file, null),
null,
null,
''
).then(function(res) {
closeLoading(_this);
const fileItem = {
name: res.name ? res.name : res.fullPath,
size: res.size,
status: 'success',
url: res.fullPath
};
_this.musicArr.push(fileItem);
_this.$message.success('上传成功');
});
},
setNewArr() {
const newArr = [];
if (this.musicArr && this.musicArr.length) {
this.musicArr.forEach((item) => {
if (item.data) {
newArr.push(item.data.domainPath + item.data.path);
} else if (item.url && item.from) {
if (item.url && item.status === 'success') {
newArr.push(item.url);
}
});
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册