Browse Source

留言板提交留言,图片数据不提交bug处理

yangc 8 years ago
parent
commit
341cde04c6
2 changed files with 17 additions and 7 deletions
  1. 5 1
      components/common/upload/upload.vue
  2. 12 6
      components/default/MessageBoard.vue

+ 5 - 1
components/common/upload/upload.vue

@@ -41,7 +41,10 @@
         this.$http.post('/api/images', param, config)
           .then(response => {
             this.qualifications.url = response.data[0].path
-            this.$emit('uploadAction', response.data[0].path)
+            this.$emit('uploadAction', this.qualifications.url)
+          }, err => {
+            console.log(err)
+            this.$message.error('图片上传失败,请重试')
           })
       },
       showImg (imgUrl) {
@@ -50,6 +53,7 @@
       },
       deleteImg () {
         this.qualifications.url = ''
+        this.$emit('uploadAction', this.qualifications.url)
       }
     }
   }

+ 12 - 6
components/default/MessageBoard.vue

@@ -55,19 +55,19 @@
           <p>&nbsp;&nbsp;&nbsp;添加图片:</p>
           <div class="img-warp">
             <div class="img-item">
-              <upload/>
+              <upload @uploadAction="listenUpload($event, 0)"/>
             </div>
             <div class="img-item">
-              <upload/>
+              <upload @uploadAction="listenUpload($event, 1)"/>
             </div>
             <div class="img-item">
-              <upload/>
+              <upload @uploadAction="listenUpload($event, 2)"/>
             </div>
             <div class="img-item">
-              <upload/>
+              <upload @uploadAction="listenUpload($event, 3)"/>
             </div>
             <div class="img-item">
-              <upload/>
+              <upload @uploadAction="listenUpload($event, 4)"/>
             </div>
           </div>
           <p class="tip clearfix">提示:最多可上传五张图片,每张大小不超过500KB,仅支持JPG、PNG、GIF格式.</p>
@@ -142,7 +142,8 @@
         txtVal: 0,
         isMobile: true,
         isEmail: true,
-        messageBoard: {}
+        messageBoard: {},
+        dialogImageUrl: ['', '', '', '', '']
       }
     },
     components: {
@@ -173,6 +174,9 @@
       }
     },
     methods: {
+      listenUpload: function (url, index) {
+        this.dialogImageUrl[index] = url
+      },
       listenPage (page) {
         this.pageParams.page = page
         this.$emit('pageEvent', page)
@@ -227,6 +231,7 @@
               this.isOpendMessage()
               this.$message.info('感谢您的宝贵意见')
               this.messageBoard = {}
+              this.dialogImageUrl = ['', '', '', '', '']
             }
           }
         } else {
@@ -248,6 +253,7 @@
             this.isOpendMessage()
             this.$message.info('感谢您的宝贵意见')
             this.messageBoard = {}
+            this.dialogImageUrl = ['', '', '', '', '']
           }
         }
       }