Browse Source

修复重复点击

wangxin 5 years ago
parent
commit
16aaa5bda4
1 changed files with 35 additions and 24 deletions
  1. 35 24
      src/view/talent_exchange/Index.vue

+ 35 - 24
src/view/talent_exchange/Index.vue

@@ -169,42 +169,53 @@
             nameRule(val) {
                 const status = Boolean(val);
                 this.disabled = !(status && isMobile(this.phone));
-                !status && this.$toast('请填写姓名');
+                !status && this.$toast({icon: 'close', message: '请填写姓名'});
                 return status
             },
             phoneRule(val) {
                 const status = isMobile(val);
                 this.disabled = !(status && Boolean(this.name));
-                !status && this.$toast('请输入正确的手机号');
+                !status && this.$toast({icon: 'close', message: '请输入正确的手机号'});
                 return status
             },
             onSubmit(data) {
                 delete data.undefined
-                for (let key in message) {
-                    if (!data[key]) {
-                        this.$toast(message[key]);
-                        return
-                    }
-                }
-                if (!isMobile(data.phone)) {
-                    this.$toast.fail('手机号格式错误');
-                    return
-                }
-                this.loading = true
-                data.intent_company = data.intent_company.join(',')
-                data.user_id = this.user_id
-                data.user_token = this.user_token
-                data.member_id = this.member_id
-                postAction(checkIns, data).then(() => {
-                    this.$toast.success({
-                        message: '提交成功',
-                        onClose: () => {
-                            document.title = '提交成功'
+                if (!this.loading && !this.disabled) {
+                    this.loading = true
+                    this.disabled = true
+                    for (let key in message) {
+                        if (!data[key]) {
                             this.loading = false
-                            this.isRegister = true
+                            this.disabled = false
+                            this.$toast(message[key]);
+                            return
                         }
+                    }
+                    if (!isMobile(data.phone)) {
+                        this.loading = false
+                        this.disabled = false
+                        this.$toast.fail({icon: 'close', message: '手机号格式错误'});
+                        return
+                    }
+                    data.intent_company = data.intent_company.join(',')
+                    data.user_id = this.user_id
+                    data.user_token = this.user_token
+                    data.member_id = this.member_id
+                    postAction(checkIns, data).then(() => {
+                        this.$toast.success({
+                            message: '提交成功',
+                            onClose: () => {
+                                document.title = '提交成功'
+                                this.isRegister = true
+                            }
+                        })
                     })
-                })
+                } else {
+                    this.$toast.fail({
+                        message: '请勿重复点击'
+                    })
+                }
+
             },
             backToIndex() {
                 if (miniProgram) {