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

feat: 音频上传七牛

上级 4b151987
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
class="upload-demo" class="upload-demo"
:disabled="isDisable" :disabled="isDisable"
:before-upload="beforeMusicUpload" :before-upload="beforeMusicUpload"
:action="actionurl" action="#"
:headers="headers" :headers="headers"
:on-remove="handleRemove" :on-remove="handleRemove"
:on-success="sucess" :on-success="sucess"
...@@ -48,7 +48,9 @@ ...@@ -48,7 +48,9 @@
</template> </template>
<script> <script>
import { getBaseUrl } from '@/utils/index'; import { doUpload, getFilePath } from '@/utils/qiniu-util';
import { openLoading, closeLoading } from '@/utils/utils';
let _this = null;
export default { export default {
props: { props: {
isDisable: { isDisable: {
...@@ -67,7 +69,6 @@ ...@@ -67,7 +69,6 @@
dialogImageUrl: '', dialogImageUrl: '',
dialogVisible: false, dialogVisible: false,
musicArr: [], musicArr: [],
actionUrl: '',
headers: { headers: {
token: localStorage.getItem('token'), token: localStorage.getItem('token'),
}, },
...@@ -78,13 +79,18 @@ ...@@ -78,13 +79,18 @@
watch: { watch: {
musicList(newv) { musicList(newv) {
console.log(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() { created() {
_this = this;
this.musicArr = this.musicList; this.musicArr = this.musicList;
console.log(console.log('this.musicList', this.musicArr)); console.log(console.log('this.musicList', this.musicArr));
this.actionurl = getBaseUrl('/diagnose/illness/audio/upload');
}, },
methods: { methods: {
musicUrl(item) { musicUrl(item) {
...@@ -114,14 +120,32 @@ ...@@ -114,14 +120,32 @@
this.loading = false; this.loading = false;
}, },
// 上传mp3 // 上传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() { setNewArr() {
const newArr = []; const newArr = [];
if (this.musicArr && this.musicArr.length) { if (this.musicArr && this.musicArr.length) {
this.musicArr.forEach((item) => { this.musicArr.forEach((item) => {
if (item.data) { if (item.url && item.status === 'success') {
newArr.push(item.data.domainPath + item.data.path);
} else if (item.url && item.from) {
newArr.push(item.url); newArr.push(item.url);
} }
}); });
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册