Commit 180e3cbd authored by yyh's avatar yyh

fix banner 数据结构不一致

parent 31105cba
...@@ -77,7 +77,8 @@ export default class AddBanner extends Vue { ...@@ -77,7 +77,8 @@ export default class AddBanner extends Vue {
this.imgs = []; this.imgs = [];
return; return;
} }
this.$api.file.getFiles(newVal).then((res: any) => { const imghashs = newVal.map(({hash}) => hash );
this.$api.file.getFiles(imghashs).then((res: any) => {
this.imgs = res.files; this.imgs = res.files;
}); });
} }
...@@ -85,14 +86,18 @@ export default class AddBanner extends Vue { ...@@ -85,14 +86,18 @@ export default class AddBanner extends Vue {
this.imgs.splice(index, 1); this.imgs.splice(index, 1);
const value = [...this.hashs]; const value = [...this.hashs];
value.splice(index, 1); value.splice(index, 1);
this.$emit('update:banners', value); this.emitBanners(value);
} }
private getFile(file: any) { private getFile(file: any) {
this.$api.file.upload(file).then((res: any) => { this.$api.file.upload(file).then((res: any) => {
this.imgs.push(res); this.imgs.push(res);
this.$emit('update:banners', this.hashs); this.emitBanners(this.hashs);
}); });
} }
private emitBanners(hashs: any[]) {
const temp = hashs.map((item: any) => ({ hash: item, target: '' }));
this.$emit('update:banners', temp);
}
private change(e: any) { private change(e: any) {
if (this.imgs.length >= 4) { if (this.imgs.length >= 4) {
this.$toast('最多上传4张banner图'); this.$toast('最多上传4张banner图');
......
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