diff --git a/src/components/img-upload/Cropper.vue b/src/components/img-upload/Cropper.vue index 1ec7578..b64defa 100644 --- a/src/components/img-upload/Cropper.vue +++ b/src/components/img-upload/Cropper.vue @@ -3,31 +3,31 @@
- +
-
-
- +
+
+
@@ -41,11 +41,10 @@
-->
- + 上传
@@ -57,7 +56,7 @@ import { VueCropper } from 'vue-cropper' -import {compress, compressAccurately} from 'image-conversion' +import { compress, compressAccurately } from 'image-conversion' export default { components: { VueCropper @@ -86,9 +85,19 @@ export default { fixed: { type: Boolean, default: true + }, + // 默认生成截图框宽度 (默认:80%) + autoCropWidth: { + type: Number, + default: 480 + }, + // 默认生成截图框高度 (默认:80%) + autoCropHeight: { + type: Number, + default: 124 } }, - data() { + data () { return { previews: {}, // 预览数据 option: { @@ -100,8 +109,6 @@ export default { original: false, // 上传图片按照原始比例渲染 (默认:false) canMoveBox: true, // 截图框能否拖动 (默认:true) autoCrop: true, // 是否默认生成截图框 (默认:false) - autoCropWidth: 480, // 默认生成截图框宽度 (默认:80%) - autoCropHeight: 124, // 默认生成截图框高度 (默认:80%) fixedBox: false, // 固定截图框大小 不允许改变 (默认:false) fixed: true, // 是否开启截图框宽高固定比例 (默认:true) fixedNumber: [1, 0.26], // 截图框比例 (默认:[1:1]) @@ -111,30 +118,30 @@ export default { } }, methods: { - changeScale(num) { + changeScale (num) { // 图片缩放 num = num || 1 this.$refs.cropper.changeScale(num) }, - rotateLeft() { + rotateLeft () { // 向左旋转 this.$refs.cropper.rotateLeft() }, - rotateRight() { + rotateRight () { // 向右旋转 this.$refs.cropper.rotateRight() }, - updateImg(file) { + updateImg (file) { this.option.img = file.url this.option.size = file.size / 1024 > 200 ? 0.9 : 0.95 }, - realTime(data) { + realTime (data) { // 实时预览 this.previews = data }, - close() { + close () { }, - uploadImg(type) { + uploadImg (type) { this.isDisabled = true // 将剪裁好的图片回传给父组件 const that = this @@ -155,81 +162,81 @@ export default { diff --git a/src/components/modules/content.vue b/src/components/modules/content.vue index cf528e7..09695bd 100644 --- a/src/components/modules/content.vue +++ b/src/components/modules/content.vue @@ -10,7 +10,7 @@ + :label-width="data.labelWidth"> = 0) { - byteString = atob(base64Data.split(',')[1]) - } else { - byteString = unescape(base64Data.split(',')[1]) - } - const mimeString = base64Data - .split(',')[0] - .split(':')[1] - .split(';')[0] - const ia = new Uint8Array(byteString.length) - for (let i = 0; i < byteString.length; i++) { - ia[i] = byteString.charCodeAt(i) - } - return new Blob([ia], { - type: mimeString - }) - }, // 图片上传到服务器 imgUpload (formData) { this.isUpload = true diff --git a/src/components/modules/module.vue b/src/components/modules/module.vue index d23cfb0..117ea87 100644 --- a/src/components/modules/module.vue +++ b/src/components/modules/module.vue @@ -1,7 +1,7 @@