Commit ee71765f by hank

增加视频类型

parent 95f56fdc
......@@ -141,7 +141,6 @@ export function upload(file) {
formData.append('resource', file)
console.log(formData.get('resource').size)
alert(formData.get('resource').size)
return post(`/common/upload/resource`,formData, {
'Content-Type': 'multipart/form-data'
} )
......
......@@ -46,14 +46,17 @@
v-model="item2[index3]"
@keyup="valueChange2()"
/>
<div>
<div>
<img
v-if="item.modelSchema[isSchemaIndex(item2)][index3].type === 'image'"
:src="getHostUrl(item2[index3])"
class="edit-input"
/>
<video :src="getHostUrl(item2[index3])" v-if="item.modelSchema[isSchemaIndex(item2)][index3].type === 'video'"></video>
<van-uploader
result-type="dataUrl"
v-if="item.modelSchema[isSchemaIndex(item2)][index3].type == 'image' || item.modelSchema[isSchemaIndex(item2)][index3].type == 'video'"
:accept="item.modelSchema[isSchemaIndex(item2)][index3].type == 'image' ? 'image/*' : 'video/*'"
@click.native="uploadListItem(item.dataKey,index2, index3)"
:after-read="uploadAfter"
>
......@@ -69,7 +72,8 @@
</div>
<van-uploader
result-type="dataUrl"
v-if="item.type == 'image'"
v-if="item.type == 'image' || item.type == 'video'"
:accept="item.type == 'image' ? 'image/*' : 'video/*'"
@click.native="uploadItem(item.dataKey)"
:after-read="uploadAfter"
>
......@@ -83,7 +87,7 @@
<script>
import { upload } from "@/api/api";
import { getHostUrl } from '@/utils/index'
import { getHostUrl } from "@/utils/index";
export default {
name: "editMenu",
props: {
......@@ -93,7 +97,7 @@ export default {
},
frameUrl: {
type: String,
default: ''
default: ""
},
schemaData: {
type: Object,
......@@ -118,8 +122,7 @@ export default {
},
uploadItem(key) {
// alert(key);
this.itemKey = '',
this.dataKey = key;
(this.itemKey = ""), (this.dataKey = key);
},
uploadListItem(key, index, itemKey) {
this.dataKey = key;
......@@ -128,7 +131,7 @@ export default {
console.log(key, index, itemKey, "dsadadsa");
},
isSchemaIndex(item) {
console.log(item)
console.log(item);
return item["schemaIndex"] ? item["schemaIndex"] : 0;
},
toObj(obj) {
......@@ -148,10 +151,15 @@ export default {
}
console.log(item);
},
getHostUrl( dataUrl) {
return getHostUrl(this.frameUrl, dataUrl)
getHostUrl(dataUrl) {
return getHostUrl(this.frameUrl, dataUrl);
},
uploadAfter(file) {
this.$toast.loading({
mask: true,
duration: 0,
message: "上传中..."
});
upload(file.file)
.then(res => {
// this.schemaData[this.dataKey].value = res.data.data;
......@@ -160,9 +168,11 @@ export default {
} else {
this.setSchemaData(res.data.data);
}
this.$toast.clear();
})
.catch(e => {
console.log(e);
this.$toast.clear();
this.$toast("上传失败");
});
},
......@@ -173,7 +183,7 @@ export default {
setSchemaListData(value) {
this.schemaData[this.dataKey][this.listIndex][this.itemKey] = value;
this.valueChange2();
this.itemKey = ''
this.itemKey = "";
},
deleteItem(index, arr) {
arr.splice(index, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment