yuantianjiao 6 gadus atpakaļ
vecāks
revīzija
1b3c3c3f0b
2 mainītis faili ar 28 papildinājumiem un 8 dzēšanām
  1. 3
    1
      public/index.html
  2. 25
    7
      src/pages/user/calendar/making.vue

+ 3
- 1
public/index.html Parādīt failu

@@ -8,7 +8,9 @@
8 8
     charset="utf-8" />
9 9
   <link rel="stylesheet" href="//at.alicdn.com/t/font_775069_clu263vfyod.css">
10 10
   <link rel="icon" href="<%= BASE_URL %>favicon.ico">
11
-  <script src="https://jsconsole.com/js/remote.js?34f890f2-39c4-46f7-9d9e-7a8cb29a6007"></script>
11
+  <!-- <script src="https://jsconsole.com/js/remote.js?34f890f2-39c4-46f7-9d9e-7a8cb29a6007"></script> -->
12
+  <script src="//cdn.bootcss.com/eruda/1.5.2/eruda.min.js"></script>
13
+  <script>eruda.init();</script>
12 14
   <title>
13 15
     <%= htmlWebpackPlugin.options.title %>
14 16
   </title>

+ 25
- 7
src/pages/user/calendar/making.vue Parādīt failu

@@ -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) {