Commit ee71765f by hank

增加视频类型

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