Ver código fonte

fix binding mobile

wangJJ 5 anos atrás
pai
commit
c8433aa093
1 arquivos alterados com 55 adições e 53 exclusões
  1. 55 53
      src/pages/UserCenter/ReBindingMobile.vue

+ 55 - 53
src/pages/UserCenter/ReBindingMobile.vue

@@ -15,12 +15,14 @@
       </el-form-item>
       <el-form-item label="验证码" prop="verifyCode">
         <el-input placeholder="验证码内容" v-model="phoneBindingForm.verifyCode" class="input-with-select">
-          <el-button slot="append" @click="getVerifyCode" :disabled="hasVerifyCode">{{hasVerifyCode ? codeTime : '获取验证码'}}</el-button>
+          <el-button slot="append" @click="getVerifyCode" :disabled="hasVerifyCode">{{hasVerifyCode ? codeTime :
+            '获取验证码'}}
+          </el-button>
         </el-input>
         <span v-if="hasVerifyCode">验证码已发送到您手机上</span>
       </el-form-item>
       <el-form-item>
-        <el-button type="primary" plain  @click="reBindingMobile">{{this.active===0 ?
+        <el-button type="primary" plain @click="reBindingMobile">{{this.active===0 ?
           '下一步':'完成绑定'}}
         </el-button>
       </el-form-item>
@@ -43,21 +45,21 @@
         phoneBindingForm: {
           phone: '',
           verifyCode: '',
-          newPhone:'',
+          newPhone: '',
         },
         hasVerifyCode: false,
         codeTime: 60,
         rules: {
           verifyCode: [
             {required: true, message: '请输入验证码', trigger: 'blur'},
-              {min: 6, max: 6, message: '验证码长度为6个字符', trigger: 'blur'}
+            {min: 6, max: 6, message: '验证码长度为6个字符', trigger: 'blur'}
           ],
           phone: [
             {required: true, message: '请输入手机号', trigger: 'blur'},
           ],
-          newPhone:  [
-              {required: true, message: '请输入手机号', trigger: 'blur'},
-              {min: 11, max: 11, message: '手机号不合法', trigger: 'blur'}
+          newPhone: [
+            {required: true, message: '请输入手机号', trigger: 'blur'},
+            {min: 11, max: 11, message: '手机号不合法', trigger: 'blur'}
           ],
         }
       }
@@ -84,9 +86,11 @@
               this.active = 1;
               this.phoneBindingForm.phone = '';
               this.phoneBindingForm.verifyCode = '';
+              this.hasVerifyCode = false;
+              this.codeTime = 60;
               this.setUserInfo();
-            }else{
-                notify('error', '验证原手机失败:' + res.data);
+            } else {
+              notify('error', '验证原手机失败:' + res.data);
               this.codeTime = 60;
               this.hasVerifyCode = false;
             }
@@ -108,7 +112,7 @@
               notify('error', '重新绑定失败:' + res.data);
             } else {
               notify('success', '重新绑定成功');
-              if(confirm('重新绑定成功,即将跳转至手机绑定页面...')){
+              if (confirm('重新绑定成功,即将跳转至手机绑定页面...')) {
                 this.$router.push({path: '/personal/mailBinding'});
               }
             }
@@ -119,51 +123,49 @@
 
       },
       getVerifyCode() {
-          if (this.active === 0) {
-              //1.验证原手机
-              let params = {
-                  id: this.user.id,
-                  mobile: this.phoneBindingForm.phone
-              }
-              Http.put('/api/verify/mobile', params).then((res) => {
-                  this.hasVerifyCode = true;
-                  let _this = this;
-                  let codeTimer = setInterval(function () {
-                      if (_this.codeTime > 0) {
-                          _this.codeTime--;
-                      } else {
-                          clearInterval(codeTimer);
-                          _this.hasVerifyCode = false;
-                          this.codeTime = 10;
-                      }
-                  }, 1000)
-              }).catch(err => {
-                  notify('error', '获取验证码失败:' + err.data);
-              })
-          }else{
-              //2.验证新手机
-              let params = {
-                  id: this.user.id,
-                  mobile: this.phoneBindingForm.newPhone
+        if (this.active === 0) {
+          //1.验证原手机
+          let params = {
+            id: this.user.id,
+            mobile: this.phoneBindingForm.phone
+          }
+          Http.put('/api/verify/mobile', params).then((res) => {
+            this.hasVerifyCode = true;
+            let _this = this;
+            let codeTimer = setInterval(function () {
+              if (_this.codeTime > 0) {
+                _this.codeTime--;
+              } else {
+                clearInterval(codeTimer);
+                _this.hasVerifyCode = false;
+                this.codeTime = 10;
               }
-              console.log("手机号:" + this.phoneBindingForm.newPhone);
-              notify("手机号:" + this.phoneBindingForm.newPhone);
-              Http.put('/api/verify/mobile', params).then((res) => {
-                  this.hasVerifyCode = true;
-                  let _this = this;
-                  let codeTimer = setInterval(function () {
-                      if (_this.codeTime > 0) {
-                          _this.codeTime--;
-                      } else {
-                          clearInterval(codeTimer);
-                          _this.hasVerifyCode = false;
-                          this.codeTime = 10;
-                      }
-                  }, 1000)
-              }).catch(err => {
-                  notify('error', '获取验证码失败:' + err.data);
-              })
+            }, 1000)
+          }).catch(err => {
+            notify('error', '获取验证码失败:' + err.data);
+          })
+        } else {
+          //2.验证新手机
+          let params = {
+            id: this.user.id,
+            mobile: this.phoneBindingForm.newPhone
           }
+          Http.put('/api/verify/mobile', params).then((res) => {
+            this.hasVerifyCode = true;
+            let _this = this;
+            let codeTimer = setInterval(function () {
+              if (_this.codeTime > 0) {
+                _this.codeTime--;
+              } else {
+                clearInterval(codeTimer);
+                _this.hasVerifyCode = false;
+                this.codeTime = 10;
+              }
+            }, 1000)
+          }).catch(err => {
+            notify('error', '获取验证码失败:' + err.data);
+          })
+        }
       }
 
     },