Parcourir la source

feat: 聊天防止重复提交

linwenxin il y a 1 an
Parent
commit
5dc7367134
1 fichiers modifiés avec 11 ajouts et 1 suppressions
  1. 11 1
      src/pages/message/msgView.vue

+ 11 - 1
src/pages/message/msgView.vue

@@ -127,7 +127,8 @@
         message: "",
         userId: this.$store.state.user.userId,
         goodsDetail: {},
-        ids: {}
+        ids: {},
+        sendBool: true
       }
     },
     onLoad(pam) {
@@ -263,6 +264,10 @@
         this.scrollTop = e.detail.scrollTop
       },
       send() {
+        if (!this.sendBool) {
+          return
+        }
+        this.sendBool = false
         if (this.pam.goodsId && this.$store.state.user.userId && this.message) {
           api.postJson('/user/talk/send', {
             message: this.message,
@@ -279,7 +284,12 @@
           }, false).then(res => {
             this.message = ""
             this.getNewList()
+            this.sendBool = true
+          }).catch(() => {
+            this.sendBool = true
           })
+        } else {
+          this.sendBool = true
         }
       },
       goFpzn(item) {