|
1 | 1 | <template> |
2 | | - <div class="g-core-image-upload-btn"> |
| 2 | + <div class="g-core-image-upload-btn" ref="container"> |
3 | 3 | <slot>{{text}}</slot> |
4 | 4 | <form class="g-core-image-upload-form" v-show="!hasImage" method="post" enctype="multipart/form-data" action="/api2/common_user/cropHeadUrl" style="display: block; cursor: pointer; position: absolute; left: 0px; top: 0px; width: 1242px; height: 61px; opacity: 0; margin: 0px; padding: 0px; overflow: hidden;"> |
5 | | - <input v-bind:disabled="uploading" v-bind:id="'g-core-upload-input-' + formID" v-bind:name="name" v-bind:multiple="multiple" type="file" v-bind:accept="inputAccept" v-on:change="change" style="width: 100%; height: 100%;"> |
| 5 | + <input v-bind:disabled="uploading" v-bind:id="'g-core-upload-input-' + formID" v-bind:name="name" v-bind:multiple="multiple" type="file" v-bind:accept="inputAccept" v-on:change="change" v-on:dragover="dragover" v-on:dragenter="dragover" v-on:dragleave="dragleave" v-on:dragend="dragleave" v-on:drop="dragleave" style="width: 100%; height: 100%;"> |
6 | 6 | </form> |
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" :is-rotate="rotate"></crop> |
|
75 | 75 | let dq = document.querySelector('#vciu-modal-' + this.formID); |
76 | 76 | return dq.querySelector(str); |
77 | 77 | }, |
| 78 | + dragover() { |
| 79 | + let element = this.$refs.container; |
| 80 | + element.classList.add('is-dragover'); |
| 81 | + }, |
| 82 | + dragleave() { |
| 83 | + let element = this.$refs.container; |
| 84 | + element.classList.remove('is-dragover'); |
| 85 | + }, |
78 | 86 | change(e) { |
79 | 87 | let fileVal = document.querySelector('#g-core-upload-input-' + this.formID).value.replace(/C:\\fakepath\\/i, ""); |
80 | 88 | let fileExt = fileVal.substring(fileVal.lastIndexOf(".") + 1); |
|
152 | 160 | let self = this; |
153 | 161 | const cropBox = this.$refs.cropBox; |
154 | 162 | const targetImage = cropBox.getCropImage(); |
155 | | - this.data.comprose = 100 - this.compress; |
| 163 | + this.data.compress = 100 - this.compress; |
156 | 164 | return canvasHelper.rotate(targetImage, 1, (src) => { |
157 | 165 | self.__initImage(src) |
158 | 166 | }) |
|
162 | 170 | let self = this; |
163 | 171 | const cropBox = this.$refs.cropBox; |
164 | 172 | const targetImage = cropBox.getCropImage(); |
165 | | - this.data.comprose = 100 - this.compress; |
| 173 | + this.data.compress = 100 - this.compress; |
166 | 174 | return canvasHelper.rotate(targetImage, -1, (src) => { |
167 | 175 | self.__initImage(src) |
168 | 176 | }) |
|
174 | 182 | const upload = this.__setUpload(e.target); |
175 | 183 | if (this.crop === 'local') { |
176 | 184 | const targetImage = cropBox.getCropImage(); |
177 | | - this.data.comprose = 100 - this.compress; |
| 185 | + this.data.compress = 100 - this.compress; |
178 | 186 | return canvasHelper.crop(targetImage, this.data, (code) => { |
179 | 187 | upload(code); |
180 | 188 | this.__dispatch('imagechanged', code); |
|
189 | 197 | const upload = this.__setUpload(e.target); |
190 | 198 | if (this.resize === 'local') { |
191 | 199 | const targetImage = cropBox.getCropImage(); |
192 | | - this.data.comprose = 100 - this.compress; |
| 200 | + this.data.compress = 100 - this.compress; |
193 | 201 | return canvasHelper.resize(targetImage, this.data, (code) => { |
194 | 202 | upload(code); |
195 | 203 | this.__dispatch('imagechanged', code); |
|
265 | 273 | if (isBinary) { |
266 | 274 | data = { |
267 | 275 | type: this.files[0]['type'], |
268 | | - filename: encodeURI(this.files[0]['name']), |
| 276 | + filename: this.files[0]['name'], |
269 | 277 | filed: this.inputOfFile, |
270 | 278 | base64Code: base64Code |
271 | 279 | }; |
|
0 commit comments