import { createNamespace } from '../../utils';
import Icon from '../../icon';
import Loading from '../../loading';
import Uploader from '../../uploader';
const [createComponent, bem] = createNamespace('sku-img-uploader');
export default createComponent({
props: {
value: String,
uploadImg: Function,
maxSize: {
type: Number,
default: 6
}
},
data() {
return {
// 正在上传的图片 base64
paddingImg: '',
uploadFail: false
};
},
methods: {
afterReadFile(file) {
// 上传文件
this.paddingImg = file.content;
this.uploadFail = false;
this.uploadImg(file.file, file.content)
.then(img => {
this.$emit('input', img);
this.$nextTick(() => {
this.paddingImg = '';
});
})
.catch(() => {
this.uploadFail = true;
});
},
onOversize() {
this.$toast(`最大可上传图片为${this.maxSize}MB,请尝试压缩图片尺寸`);
},
renderUploader(content, disabled = false) {
return (