|
@@ -201,14 +201,32 @@ export default {
|
201
|
201
|
})
|
202
|
202
|
},
|
203
|
203
|
onRead (file) {
|
|
204
|
+ let that = this
|
204
|
205
|
this.isLoading = true
|
205
|
|
- // this.banner[this.mainIndex - 1].CustomerImgShow = file.content
|
206
|
|
- // this.setBanner({ type: this.$route.query.type, data: JSON.parse(JSON.stringify(this.banner)) })
|
207
|
|
- this.toolClass.upload(file).then((res) => {
|
208
|
|
- this.upload(res.result.url)
|
209
|
|
- }).catch(() => {
|
210
|
|
- this.isLoading = false
|
211
|
|
- })
|
|
206
|
+ let reader = new FileReader();
|
|
207
|
+ reader.readAsDataURL(file.file);
|
|
208
|
+ reader.onload = function (e) {
|
|
209
|
+ let data = e.target.result;
|
|
210
|
+ //加载图片获取图片真实宽度和高度
|
|
211
|
+ let image = new Image();
|
|
212
|
+ image.src = data;
|
|
213
|
+ image.onload = function () {
|
|
214
|
+ let width = image.width;
|
|
215
|
+ let height = image.height;
|
|
216
|
+ if (width / height > 2.5) {
|
|
217
|
+ that.isLoading = false
|
|
218
|
+ that.$toast('该图片长度过长,请重新选择')
|
|
219
|
+ return
|
|
220
|
+ }
|
|
221
|
+ // this.banner[this.mainIndex - 1].CustomerImgShow = file.content
|
|
222
|
+ // this.setBanner({ type: this.$route.query.type, data: JSON.parse(JSON.stringify(this.banner)) })
|
|
223
|
+ that.toolClass.upload(file).then((res) => {
|
|
224
|
+ that.upload(res.result.url)
|
|
225
|
+ }).catch(() => {
|
|
226
|
+ that.isLoading = false
|
|
227
|
+ })
|
|
228
|
+ };
|
|
229
|
+ };
|
212
|
230
|
},
|
213
|
231
|
changeOld () {
|
214
|
232
|
if (!this.banner[this.mainIndex - 1].CustomerImg) {
|