|
7 | 7 | <div class="g-core-image-corp-container" v-bind:id="'vciu-modal-' + formID" v-show="hasImage">
|
8 | 8 | <crop ref="cropBox" :is-resize="resize && !crop" :ratio="cropRatio"></crop>
|
9 | 9 | <div class="info-aside">
|
| 10 | + <p class="btn-groups rotate-groups" v-if="crop"> |
| 11 | + <button type="button" v-on:click="doRotate" class="btn btn-rotate">↺</button> |
| 12 | + <button type="button" v-on:click="doReverseRotate" class="btn btn-reverserotate">↻</button> |
| 13 | + </p> |
10 | 14 | <p class="btn-groups" v-if="crop">
|
11 | 15 | <button type="button" v-on:click="doCrop" class="btn btn-upload">{{cropBtn.ok}}</button>
|
12 | 16 | <button type="button" v-on:click="cancel" class="btn btn-cancel">{{cropBtn.cancel}}</button>
|
|
78 | 82 | if(extensionsArr.length>1) {
|
79 | 83 | var reg = new RegExp('^[' + extensionsArr.join('|') + ']+$','i');
|
80 | 84 | if (!reg.test(fileExt)) {
|
81 |
| - return this.__dispatch('errorhandle','TYPE ERROR'); |
| 85 | + return this.__dispatch('errorhandle','图片格式错误!'); |
82 | 86 | }
|
83 | 87 | }
|
84 | 88 | if (e.target.files[0].size > this.maxFileSize) {
|
|
91 | 95 | formatSize = options.maxFileSize.toFixed(2) + 'Byte';
|
92 | 96 | }
|
93 | 97 | console.warn('FILE IS TOO LARGER MAX FILE IS ' + formatSize);
|
94 |
| - return this.__dispatch('errorhandle','FILE IS TOO LARGER MAX FILE IS ' + formatSize); |
| 98 | + return this.__dispatch('errorhandle','图片不能大于' + formatSize); |
95 | 99 | }
|
96 | 100 |
|
97 | 101 | this.files = e.target.files;
|
|
133 | 137 | const cropBox = this.$refs.cropBox;
|
134 | 138 | pic.onload= function() {
|
135 | 139 | self.image.minProgress = self.minWidth / pic.naturalWidth;
|
136 |
| - self.imgChangeRatio = cropBox.setImage(src, pic.naturalWidth, pic.naturalHeight); |
| 140 | + canvasHelper.init(src, (src) => { |
| 141 | + self.imgChangeRatio = cropBox.setImage(src, pic.naturalWidth, pic.naturalHeight); |
| 142 | + }); |
137 | 143 | }
|
138 | 144 | },
|
139 | 145 |
|
|
142 | 148 | cropBox.resizeImage(progress);
|
143 | 149 | },
|
144 | 150 |
|
| 151 | + doRotate(e) { |
| 152 | + let self = this; |
| 153 | + const cropBox = this.$refs.cropBox; |
| 154 | + const targetImage = cropBox.getCropImage(); |
| 155 | + this.data.comprose = 100 - this.compress; |
| 156 | + return canvasHelper.rotate(targetImage, 1, (src) => { |
| 157 | + self.__initImage(src) |
| 158 | + }) |
| 159 | + }, |
| 160 | +
|
| 161 | + doReverseRotate(e) { |
| 162 | + let self = this; |
| 163 | + const cropBox = this.$refs.cropBox; |
| 164 | + const targetImage = cropBox.getCropImage(); |
| 165 | + this.data.comprose = 100 - this.compress; |
| 166 | + return canvasHelper.rotate(targetImage, -1, (src) => { |
| 167 | + self.__initImage(src) |
| 168 | + }) |
| 169 | + }, |
| 170 | +
|
145 | 171 | doCrop(e) {
|
146 | 172 | this.__setData('crop');
|
147 | 173 | const cropBox = this.$refs.cropBox;
|
|
159 | 185 | },
|
160 | 186 |
|
161 | 187 | doResize(e) {
|
162 |
| - this.__setData('reszie'); |
| 188 | + this.__setData('resize'); |
163 | 189 | const cropBox = this.$refs.cropBox;
|
164 | 190 | const upload = this.__setUpload(e.target);
|
165 | 191 | if (this.resize === 'local') {
|
|
258 | 284 | }
|
259 | 285 | }
|
260 | 286 | }
|
| 287 | + console.log(data); |
261 | 288 | xhr('POST',this.url, this.headers, data, done, errorUpload, isBinary);
|
262 | 289 | },
|
263 | 290 | },
|
|
0 commit comments