Commit e87ef81b authored by yyh's avatar yyh

功能开发

parent 7f36fd2c
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
<div class="van-hairline--bottom type-two"> <div class="van-hairline--bottom type-two">
<div class="title" style="margin-bottom: 10px;">{{proofSubItem.label}}</div> <div class="title" style="margin-bottom: 10px;">{{proofSubItem.label}}</div>
<div v-for="(file,index) in fileList" :key="index" style="margin-bottom: 10px;"> <div v-for="(file,index) in fileList" :key="index" style="margin-bottom: 10px;">
<video controls :src="file.url" style="margin-bottom: 10px;width: 100%;"> <video controls disablePictureInPicture style="margin-bottom: 10px;width: 100%;">
<source :src="file.url">
你的浏览器不支持Video标签
</video> </video>
<div style="text-align:right;color:#3175FF;" @click="del(index)">删除</div> <div style="text-align:right;color:#3175FF;" @click="del(index)">删除</div>
</div> </div>
<input type="file" @change="handleFileChange" id="uploader2" accept="video/*" :value="file" style="display:none;"> <input type="file" @change="handleFileChange" id="uploader2" accept="video/*" style="display:none;">
<label for="uploader2" class="uploader"> <label for="uploader2" class="uploader">
<common-svg name="shipin" width="32px" height="32px"></common-svg> <common-svg name="shipin" width="32px" height="32px"></common-svg>
<div class="title">上传视频</div> <div class="title">上传视频</div>
...@@ -31,7 +33,6 @@ export default class TypeEight extends Vue { ...@@ -31,7 +33,6 @@ export default class TypeEight extends Vue {
@Prop() @Prop()
private value!: []; private value!: [];
private fileList: any[] = []; private fileList: any[] = [];
private file: any = '';
private loaded: number = 0; private loaded: number = 0;
private total: number = 0; private total: number = 0;
@Watch('valHash', { immediate: true, deep: true }) @Watch('valHash', { immediate: true, deep: true })
...@@ -58,15 +59,19 @@ export default class TypeEight extends Vue { ...@@ -58,15 +59,19 @@ export default class TypeEight extends Vue {
this.$emit('update:value', value); this.$emit('update:value', value);
} }
private handleFileChange(e: any) { private handleFileChange(e: any) {
const input = e.target; const [ file ] = e.target.files;
const files = input.files; if (!file) { return; }
console.log(file.size);
if(file.size > 10 * 1024 * 1024) {
this.$toast('文件太大');
return;
}
const toast = this.$toast({ const toast = this.$toast({
message: '0%', message: '0%',
duration: 0, // 持续展示 toast duration: 0, // 持续展示 toast
forbidClick: true, forbidClick: true,
}); });
if (files && files[0]) { this.$api.file.upload(file, (process: any) => {
this.$api.file.upload(files[0], (process: any) => {
const { loaded, total } = process; const { loaded, total } = process;
const percent = Math.floor(loaded / total * 100); const percent = Math.floor(loaded / total * 100);
toast.message = `${ percent }%`; toast.message = `${ percent }%`;
...@@ -75,16 +80,16 @@ export default class TypeEight extends Vue { ...@@ -75,16 +80,16 @@ export default class TypeEight extends Vue {
} }
}).then((res: any) => { }).then((res: any) => {
e.target.value = ''; e.target.value = '';
this.file = '';
const temp: any = Array.isArray(this.value) ? this.value : []; const temp: any = Array.isArray(this.value) ? this.value : [];
this.$emit('update:value', [...temp, { this.$emit('update:value', [...temp, {
type: 'media', type: 'media',
format: 'hash', format: 'hash',
value: res.hash, value: res.hash,
}]); }]);
}).catch((err: any) => {
toast.clear();
}); });
} }
}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -56,10 +56,21 @@ export default class TypeNine extends Vue { ...@@ -56,10 +56,21 @@ export default class TypeNine extends Vue {
this.$emit('update:value', value); this.$emit('update:value', value);
} }
private handleFileChange(e: any) { private handleFileChange(e: any) {
const input = e.target; const [ file ] = e.target.files;
const files = input.files; if (!file) { return; }
if (files && files[0]) { const toast = this.$toast({
this.$api.file.upload(files[0]).then((res: any) => { message: '0%',
duration: 0, // 持续展示 toast
forbidClick: true,
});
this.$api.file.upload(file, (process: any) => {
const { loaded, total } = process;
const percent = Math.floor(loaded / total * 100);
toast.message = `${ percent }%`;
if (percent === 100) {
toast.clear();
}
}).then((res: any) => {
e.target.value = ''; e.target.value = '';
this.file = ''; this.file = '';
const temp: any = Array.isArray(this.value) ? this.value : []; const temp: any = Array.isArray(this.value) ? this.value : [];
...@@ -68,9 +79,10 @@ export default class TypeNine extends Vue { ...@@ -68,9 +79,10 @@ export default class TypeNine extends Vue {
format: 'hash', format: 'hash',
value: res.hash, value: res.hash,
}]); }]);
}).catch((err: any) => {
toast.clear();
}); });
} }
}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -258,12 +258,12 @@ export default class SelectTemplate extends Vue { ...@@ -258,12 +258,12 @@ export default class SelectTemplate extends Vue {
place-items: center; place-items: center;
} }
.btn-group{ .btn-group{
position: fixed; // position: fixed;
left: 0; // left: 0;
right: 0; // right: 0;
bottom: 0; // bottom: 0;
display: flex; // display: flex;
padding: 10px 17px; // padding: 10px 17px;
.left,.right{ .left,.right{
border-radius: 4px; border-radius: 4px;
height: 40px; height: 40px;
......
...@@ -21,19 +21,14 @@ ...@@ -21,19 +21,14 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'; import { Component, Prop, Vue } from 'vue-property-decorator';
import { Cell, Form, Field, CellGroup, Button, Image, RadioGroup, Radio } from 'vant'; import { Button, Image } from 'vant';
import { State, Getter, Action, Mutation } from 'vuex-class'; import { State, Getter, Action, Mutation } from 'vuex-class';
import { Route } from 'vue-router'; import { Route } from 'vue-router';
import H5Cropper from 'vue-cropper-h5'; import H5Cropper from 'vue-cropper-h5';
@Component({ @Component({
components: { components: {
[Form.name]: Form,
[Field.name]: Field,
[Button.name]: Button, [Button.name]: Button,
[Image.name]: Image, [Image.name]: Image,
[Cell.name]: Cell,
[RadioGroup.name]: RadioGroup,
[Radio.name]: Radio,
H5Cropper, H5Cropper,
}, },
}) })
......
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 to comment