| | |
| | | ...mapMutations([SET_APP_LOADING]), |
| | | //删除照片 |
| | | deletPhoto(item, i) { |
| | | //console.log(item); |
| | | this.picList.splice(i, 1); |
| | | }, |
| | | // 处理图片上传的事件(deleteIndex---删除图片的索引) |
| | |
| | | } |
| | | // 图片的路径获取成功后 |
| | | function callback() { |
| | | console.log(img.width,img.height) |
| | | // 压缩后的图片的base64字符串 |
| | | let data = that.compress(img); |
| | | console.log(that.getFile(data)) |
| | | |
| | | // 调取接口上传图片 |
| | | that.submitUploadImg(that.fileType, data, that.deleteIndex); |
| | |
| | | let maxWidthOrHeight = 1024; |
| | | let drawWidth = this.naturalWidth; |
| | | let drawHeight = this.naturalHeight; |
| | | console.log(drawWidth,drawHeight) |
| | | // 以下改变图片大小,控制最大宽度为1024 |
| | | var maxSide = Math.max(drawWidth, drawHeight); |
| | | if (maxSide > maxWidthOrHeight) { |
| | |
| | | ctx.drawImage(this, 0, 0, resultWidth, resultHeight); |
| | | // 返回校正图片 |
| | | next(canvas.toDataURL("image/jpg", 0.8)); |
| | | |
| | | console.log(image.width,image.height) |
| | | }; |
| | | image.src = img; |
| | | |