|
@@ -18,7 +18,7 @@
|
|
|
<vueCropper
|
|
|
ref="cropper"
|
|
|
:img="option.img"
|
|
|
- :outputSize="option.size"
|
|
|
+ :outputSize="option.outputSize"
|
|
|
:outputType="option.outputType"
|
|
|
:autoCropWidth="option.autoCropWidth"
|
|
|
:autoCropHeight="option.autoCropHeight"
|
|
@@ -37,9 +37,17 @@
|
|
|
:fixedBox="option.fixedBox">
|
|
|
</vueCropper>
|
|
|
</div>
|
|
|
+ <template v-if="option.autoCropWidth * option.enlarge > preImgOptions.w || option.autoCropHeight * option.enlarge > preImgOptions.h">
|
|
|
+ <div class="su-tips t2">当前上传图片尺寸过小(宽度{{preImgOptions.w}}px,宽度{{preImgOptions.h}}px),最低尺寸(宽度{{option.autoCropWidth * option.enlarge}}px+,宽度{{option.autoCropHeight * option.enlarge}}px+)</div>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <div class="su-tips">原图尺寸(宽度{{preImgOptions.w}}px,宽度{{preImgOptions.h}}px),最低尺寸(宽度{{option.autoCropWidth * option.enlarge}}px+,宽度{{option.autoCropHeight * option.enlarge}}px+)</div>
|
|
|
+ </template>
|
|
|
</div>
|
|
|
<div class="xl-form">
|
|
|
- <div class="xl-form-footer">
|
|
|
+ <div class="xl-form-footer padding20">
|
|
|
+ <el-button class="xl-form-btn t3" @click="rotateLeft">逆90°旋转</el-button>
|
|
|
+ <el-button class="xl-form-btn t3" @click="rotateRight">顺90°旋转</el-button>
|
|
|
<el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
|
|
|
<el-button class="xl-form-btn t1" @click="close('confirm')">确 定</el-button>
|
|
|
</div>
|
|
@@ -61,7 +69,7 @@ export default {
|
|
|
option: {
|
|
|
img: '', //裁剪图片的地址
|
|
|
outputSize: 1, // 裁剪生成图片的质量
|
|
|
- outputType: 'jpg', // 裁剪生成图片的格式
|
|
|
+ outputType: 'jpeg', // 裁剪生成图片的格式
|
|
|
full: false, // 是否输出原图比例的截图
|
|
|
info: true, // 图片大小信息
|
|
|
canScale: true, // 图片是否允许滚轮缩放
|
|
@@ -80,12 +88,23 @@ export default {
|
|
|
// mode: 'cover', // 图片默认渲染方式
|
|
|
maxImgSize: 750 // 限制图片最大宽度和高度
|
|
|
},
|
|
|
+ preImgOptions: {
|
|
|
+ h: 0,
|
|
|
+ w: 0,
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
isShow: function(val) {
|
|
|
if (val) {
|
|
|
this.option.img = this.curObj.url
|
|
|
+ let nImg = new Image()
|
|
|
+ nImg.src = this.curObj.url
|
|
|
+ // console.log(nImg)
|
|
|
+ nImg.onload = () => {
|
|
|
+ this.preImgOptions.h = nImg.height
|
|
|
+ this.preImgOptions.w = nImg.width
|
|
|
+ }
|
|
|
const options = this.curObj.options || {}
|
|
|
if (options.w) this.option.autoCropWidth = options.w
|
|
|
if (options.h) this.option.autoCropHeight = options.h
|
|
@@ -93,6 +112,12 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
+ rotateRight () {
|
|
|
+ this.$refs.cropper.rotateRight()
|
|
|
+ },
|
|
|
+ rotateLeft () {
|
|
|
+ this.$refs.cropper.rotateLeft()
|
|
|
+ },
|
|
|
close(str) {
|
|
|
if (str === 'confirm') {
|
|
|
this.$refs.cropper.getCropBlob((data) => {
|
|
@@ -134,5 +159,13 @@ export default {
|
|
|
width: auto;
|
|
|
height: 500px;
|
|
|
}
|
|
|
+ .su-tips {
|
|
|
+ padding-top: 10px;
|
|
|
+ color: #666;
|
|
|
+ &.t2 {
|
|
|
+ color: #f00;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|