wangJJ hace 5 años
padre
commit
3636f550b9

+ 4 - 2
src/pages/UserCenter/BindingMail.vue

@@ -68,8 +68,10 @@
           verifyCode: this.mailBindingForm.verifyCode
         };
         Http.put('/api/user/email',params).then(res=>{
-          if(res.code === 20000){
-            notify('success', '绑定成功');
+          if(res.msg == "ERROR"){
+            notify('error', '重新绑定失败:' + res.data);
+          }else{
+            notify('success', '重新绑定成功');
             this.$router.push({path:'/personal/mailBinding'});
           }
         }).catch(err=> {

+ 5 - 3
src/pages/UserCenter/BindingMobile.vue

@@ -68,10 +68,12 @@
           verifyCode: this.phoneBindingForm.verifyCode
         };
         Http.put('/api/user/mobile',params).then(res=>{
-          if(res.code === 20000){
-            notify('success', '绑定成功');
+          if(res.msg == "ERROR"){
+            notify('error', '重新绑定失败:' + res.data);
+          }else{
+            notify('success', '重新绑定成功');
             this.$router.push({path:'/personal/phoneBinding'});
-         }
+          }
         }).catch(err=> {
           notify('error', err.data);
         })

+ 9 - 5
src/pages/UserCenter/MailBinding.vue

@@ -1,13 +1,13 @@
 <template>
   <div>
     <div class="right-modifyPsw">
-      <div >
+      <div>
         <div class="right-modifyPsw-title">
           <span style="font-size: 18px;font-weight: bold">邮箱绑定</span>
         </div>
         <div>
           <div v-if="!user.email">
-            <div style="background-color: rgba(233,239,249,1);padding: 10px;margin-bottom: 30px" v-if="showBindWranning">
+            <div style="background-color: rgba(233,239,249,1);padding: 10px;margin-bottom: 30px">
               <img src="../../assets/img/phoneUnbinding.png"></img>
               <span style="font-size: 16px">您还未绑定邮箱,为保护您帐号,建议您</span>
               <el-button type="primary" plain size="mini" @click="handleBindingEmail">立即绑定
@@ -43,7 +43,6 @@
     name: "MailBinding",
     data() {
       return {
-        // showBindWranning: true,
         hasVerifyCode: false,
         bindingEmail: false,
         codeTime: 10,
@@ -59,7 +58,6 @@
         let userId = storageGet('user')&&storageGet('user').userVO.id;
         Http.get(`/api/user/${userId}`).then(res=>{
           this.user = res.userVO
-          this.showBindWranning = !!this.user.email;
         })
       },
       handleBindingEmail(){
@@ -96,8 +94,14 @@
       }
     },
     mounted() {
-      console.log('aaa');
       this.setUserInfo();
+    },
+    watch:{
+      '$route' (to, from) {
+        if(to.path==='/personal/mailBinding'){
+          this.$router.go(0);
+        }
+      }
     }
   }
 </script>

+ 24 - 3
src/pages/UserCenter/Mine.vue

@@ -5,7 +5,7 @@
       <el-button v-if="!isModifyMode" type="primary" size="mini" class="pull-right" @click="isModifyMode = true">编辑</el-button>
     </div>
     <div style="margin-bottom: 15px;width: 60%">
-      <el-form :model="userForm" status-icon ref="userForm" label-width="100px" class="demo-ruleForm">
+      <el-form :model="userForm" :rules="rules" status-icon ref="userForm" label-width="100px" class="demo-ruleForm">
         <el-form-item label="头像" prop="avator">
           <el-upload
             class="avatar-uploader"
@@ -18,8 +18,8 @@
             <i v-else class="el-icon-plus avatar-uploader-icon"></i>
           </el-upload>
         </el-form-item>
-        <el-form-item label="用户名" prop="username">
-          <el-input v-model="userForm.userName" autocomplete="off" :disabled="!isModifyMode"></el-input>
+        <el-form-item label="用户名" prop="userName">
+          <el-input v-model="userForm.userName" autocomplete="off" :disabled="true"></el-input>
         </el-form-item>
         <el-form-item label="企业简称" prop="enterprise">
           <el-input v-model="userForm.unit" autocomplete="off" :disabled="!isModifyMode"></el-input>
@@ -78,6 +78,27 @@
           personalCompetence:[],
           province:'',
           city:''
+        },
+        rules: {
+          photoUrl: [
+            { required: true, message: '请输入活动名称', trigger: 'blur' },
+            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
+          ],
+          userName: [
+            { required: true, message: '请设置用户名', trigger: 'change' }
+          ],
+          province: [
+            { required: true, message: '请选择省份', trigger: 'change' }
+          ],
+          city: [
+            { required: true, message: '请选择城市', trigger: 'change' }
+          ],
+          gender: [
+            { required: true, message: '请选择性别', trigger: 'change' }
+          ],
+          address:[
+            {required: true},
+          ]
         }
       }
     },

+ 9 - 4
src/pages/UserCenter/PhoneBinding.vue

@@ -45,15 +45,13 @@
     },
     methods: {
       changePhoneNumber(){
-        this.showBingWranning = false;
         this.$router.push({
-          path: '/personal/mailBinding/rebinding',
+          path: '/personal/phoneBinding/rebinding',
         });
       },
       bindPhoneNumber(){
-        this.showBingWranning = false;
         this.$router.push({
-          path: '/personal/mailBinding/binding',
+          path: '/personal/phoneBinding/binding',
         });
       },
       setUserInfo(){
@@ -65,6 +63,13 @@
     },
     mounted() {
       this.setUserInfo();
+    },
+    watch:{
+      '$route' (to, from) {
+        if(to.path==='/personal/phoneBinding'){
+          this.$router.go(0);
+        }
+      }
     }
   }
 </script>

+ 10 - 19
src/pages/UserCenter/ReBindingMail.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <el-form label-width="80px" style="with:400px;">
+    <el-form label-width="80px" style="width:400px;">
       <el-form-item label="新邮箱号">
         <el-input v-model="emailBindingForm.email"></el-input>
       </el-form-item>
@@ -48,26 +48,17 @@
           "email": this.emailBindingForm.email,
           "verifyCode": this.emailBindingForm.verifyCode
         };
-        // Http.put('/api/user/email', params).then(res => {
-        //   if (res.msg !== 'ERROR') {
-        //     notify('success', '重新绑定成功');
-        //     // this.$router.push({path: '/personal/mailBinding'});
-        //     window.location.href({path: '/personal/mailBinding'});
-        //   }
-        // }).catch(err => {
-        //   notify('error', '重新绑定失败:' + err.data);
-        // })
-
-        if(this.emailBindingForm.email == this.user.email){
-            notify('error', '请使用其他邮箱,此邮箱您已绑定!');
+        if (this.emailBindingForm.email == this.user.email) {
+          notify('error', '请使用其他邮箱,此邮箱您已绑定!');
         }
         Http.put('/api/user/email', params).then((res) => {
-            if(res.msg == "ERROR"){
-                notify('error', '重新绑定失败:' + res.data);
-            }else{
-                notify('success', '重新绑定成功');
-                window.location.href({path: '/personal/mine'});
-            }
+
+          if (res.msg == "ERROR") {
+            notify('error', '重新绑定失败:' + res.data);
+          } else {
+            notify('success', '重新绑定成功');
+            this.$router.push({path: '/personal/mailBinding'});
+          }
         })
       },
       getVerifyCode() {

+ 71 - 66
src/pages/UserCenter/ReBindingMobile.vue

@@ -1,25 +1,27 @@
 <template>
   <div>
-          <el-steps :active="active" process-status="finish" style="margin: 20px">
-            <el-step title="验证原手机"></el-step>
-            <el-step title="绑定新手机"></el-step>
-          </el-steps>
+    <el-steps :active="active" process-status="finish" style="margin: 20px">
+      <el-step title="验证原手机"></el-step>
+      <el-step title="绑定新手机"></el-step>
+    </el-steps>
 
-          <el-form label-width="80px"  style="with:400px;">
-            <el-form-item label="原手机号" v-if="active===0">
-              <span v-model="phoneBindingForm.phone">{{this.user.mobile}}</span>
-            </el-form-item>
-            <el-form-item label="新手机号" v-if="active===1">
-              <el-input v-model="phoneBindingForm.phone"></el-input>
-            </el-form-item>
-            <el-form-item label="验证码">
-              <el-input placeholder="验证码内容" v-model="phoneBindingForm.verifyCode" class="input-with-select">
-                <el-button slot="append" @click="getVerifyCode">{{hasVerifyCode ? codeTime : '获取验证码'}}</el-button>
-              </el-input>
-              <span v-if="hasVerifyCode">验证码已发送到您手机上</span>
-            </el-form-item>
-          </el-form>
-    <el-button type="primary" plain style="margin-left: 80px" @click="reBindingMobile">{{this.active===0  ? '下一步':'完成绑定'}}</el-button>
+    <el-form label-width="80px" style="width:400px;">
+      <el-form-item label="原手机号" v-if="active===0">
+        <span v-model="phoneBindingForm.phone">{{this.user.mobile}}</span>
+      </el-form-item>
+      <el-form-item label="新手机号" v-if="active===1">
+        <el-input v-model="phoneBindingForm.phone"></el-input>
+      </el-form-item>
+      <el-form-item label="验证码">
+        <el-input placeholder="验证码内容" v-model="phoneBindingForm.verifyCode" class="input-with-select">
+          <el-button slot="append" @click="getVerifyCode">{{hasVerifyCode ? codeTime : '获取验证码'}}</el-button>
+        </el-input>
+        <span v-if="hasVerifyCode">验证码已发送到您手机上</span>
+      </el-form-item>
+    </el-form>
+    <el-button type="primary" plain style="margin-left: 80px" @click="reBindingMobile">{{this.active===0 ?
+      '下一步':'完成绑定'}}
+    </el-button>
 
   </div>
 
@@ -29,79 +31,82 @@
   import Http from '@/js/http.js'
   import {storageGet} from '@/js/index'
   import {notify} from '@/constants/index'
+
   export default {
     name: "ReBindingMobile",
-    data(){
-      return{
+    data() {
+      return {
         active: 0,
-        user:{},
+        user: {},
         phoneBindingForm: {
           phone: '',
           verifyCode: ''
         },
-        hasVerifyCode:false,
-        codeTime:10,
+        hasVerifyCode: false,
+        codeTime: 10,
       }
     },
-    methods:{
+    methods: {
       setUserInfo() {
-        let userId = storageGet('user')&&storageGet('user').userVO.id;
-        Http.get(`/api/user/${userId}`).then(res=>{
+        let userId = storageGet('user') && storageGet('user').userVO.id;
+        Http.get(`/api/user/${userId}`).then(res => {
           this.user = res.userVO
         })
       },
-      reBindingMobile(){
-          if(this.active === 0){
-            //1.验证原手机
-            let params = {
-              "id": this.user.id,
-              "mobile": this.user.mobile,
-              "verifyCode":this.phoneBindingForm.verifyCode
-            }
-            Http.put('/api/verify/old/mobile',params).then(res=>{
-              if(res.code === 20000){
-                notify('success', '验证成功');
-                this.active = 0;
-                this.setUserInfo();
-              }
-            }).catch(err=> {
-              notify('error', '验证原手机失败:' + err.data);
-            })
-          }else{
-            let params = {
-              "id": this.user.id,
-              "mobile": this.phoneBindingForm.phone,
-              "verifyCode": this.phoneBindingForm.verifyCode
-            };
-            Http.put('/api/user/mobile',params).then(res=>{
-              if(res.code === 20000){
-                notify('success', '重新绑定成功');
-                this.$router.push({path:'/personal/phoneBinding'});
-              }
-            }).catch(err=> {
-              notify('error', '重新绑定失败:' + err.data);
-            })
+      reBindingMobile() {
+        if (this.active === 0) {
+          //1.验证原手机
+          let params = {
+            "id": this.user.id,
+            "mobile": this.user.mobile,
+            "verifyCode": this.phoneBindingForm.verifyCode
           }
+          Http.put('/api/verify/old/mobile', params).then(res => {
+            if (res.code === 20000) {
+              notify('success', '验证成功');
+              this.active = 0;
+              this.setUserInfo();
+            }
+          }).catch(err => {
+            notify('error', '验证原手机失败:' + err.data);
+          })
+        } else {
+          let params = {
+            "id": this.user.id,
+            "mobile": this.phoneBindingForm.phone,
+            "verifyCode": this.phoneBindingForm.verifyCode
+          };
+          Http.put('/api/user/mobile', params).then(res => {
+            if (res.msg == "ERROR") {
+              notify('error', '重新绑定失败:' + res.data);
+            } else {
+              notify('success', '重新绑定成功');
+              this.$router.push({path: '/personal/phoneBinding'});
+            }
+          }).catch(err => {
+            notify('error', '重新绑定失败:' + err.data);
+          })
+        }
 
       },
-      getVerifyCode(){
+      getVerifyCode() {
         let params = {
-          id:this.user.id,
-          mobile:this.phoneBindingForm.phone
+          id: this.user.id,
+          mobile: this.phoneBindingForm.phone
         }
-        Http.put('/api/verify/mobile',params).then((res)=>{
+        Http.put('/api/verify/mobile', params).then((res) => {
           this.hasVerifyCode = true;
           let _this = this;
           let codeTimer = setInterval(function () {
-            if(_this.codeTime > 0 ){
+            if (_this.codeTime > 0) {
               _this.codeTime--;
-            }else{
+            } else {
               clearInterval(codeTimer);
               _this.hasVerifyCode = false;
               this.codeTime = 10;
             }
-          },1000)
-        }).catch(err=> {
+          }, 1000)
+        }).catch(err => {
           notify('error', '获取验证码失败:' + err.data);
         })
       }