Преглед на файлове

修改消息为空可发送

YY преди 2 години
родител
ревизия
c983c21ce7
променени са 1 файла, в които са добавени 12 реда и са изтрити 21 реда
  1. 12 21
      src/views/selfShop/message/index.vue

+ 12 - 21
src/views/selfShop/message/index.vue

@@ -169,31 +169,22 @@ export default {
       if (value == 'content') {
         // 文字消息
         form.msg_type = '0';
-        if (this.form.content) {
-          form.content = this.form.content;
-          let res = await this.create(form);
-          if (this.$checkRes(res, '发送成功', '发送失败')) {
-            let data = { _id: res.data.room, customer: this.customer, shop: this.shop };
-            this.toClose();
-            this.search();
-            if (this.customer_id == this.customer._id) this.searchDetail();
-            else this.toView(data);
-          }
-        } else this.$message({ type: `warning`, message: `请输入要发送的消息` });
+        if (this.form.content) form.content = this.form.content;
+        else this.$message({ type: `warning`, message: `请输入要发送的消息` });
       } else if (value == 'file') {
         // 图片消息
         form.msg_type = '1';
         if (this.file.length == 0) this.$message({ type: `warning`, message: `请选择要发送的图片` });
-        else {
-          form.content = this.file[0].url;
-          let res = await this.create(form);
-          if (this.$checkRes(res, '发送成功', '发送失败')) {
-            let data = { _id: res.data.room, customer: this.customer, shop: this.shop };
-            this.toClose();
-            this.search();
-            if (this.customer_id == this.customer._id) this.searchDetail();
-            else this.toView(data);
-          }
+        else form.content = this.file[0].url;
+      }
+      if (form.content) {
+        let res = await this.create(form);
+        if (this.$checkRes(res, '发送成功', '发送失败')) {
+          let data = { _id: res.data.room, customer: this.customer, shop: this.shop };
+          this.toClose();
+          this.search();
+          if (this.customer_id == this.customer._id) this.searchDetail();
+          else this.toView(data);
         }
       }
     },