Ver Fonte

添加登陆页注释

Zhengy há 6 anos atrás
pai
commit
c0a3fcc039
2 ficheiros alterados com 21 adições e 16 exclusões
  1. 2 1
      src/App.vue
  2. 19 15
      src/components/Login.vue

+ 2 - 1
src/App.vue

@@ -18,6 +18,7 @@ export default {
   -moz-osx-font-smoothing: grayscale;
   text-align: center;
   color: #2c3e50;
-  margin-top: 50px;
+  min-width: 570px;
+  margin: 50px auto 0;
 }
 </style>

+ 19 - 15
src/components/Login.vue

@@ -45,7 +45,7 @@ export default {
     
   },
   methods:{
-    judegAccount(){
+    judegAccount(){//检测用户名和角色是否匹配
       if(this.form.name==""){
         return;
       }
@@ -64,29 +64,33 @@ export default {
         this.form.name = '';
       }
     },
-    resetForm(formName) {
+    resetForm(formName) {//重置
       this.$refs[formName].resetFields();
     },
-    submitForm(){
+    submitForm(){//点击登陆验证用户名和密码
+      if(this.form.name==""||this.form.password==""){
+        this.showText('请输入用户名和密码');
+        return;
+      }
       let accountArr = [];
       var type = "";
       switch(this.form.radio){
-          case "1":accountArr=this.$store.state.adminAccount;type="admin";break;
-          case "2":accountArr=this.$store.state.shopAccount;type="shop";break;
-          default:accountArr=this.$store.state.buyerAccount;type="buyer";
+        case "1":accountArr=this.$store.state.adminAccount;type="admin";break;
+        case "2":accountArr=this.$store.state.shopAccount;type="shop";break;
+        default:accountArr=this.$store.state.buyerAccount;type="buyer";
       }
       for(var i=0,arrLength=accountArr.length;i<arrLength;i++){
-          if(this.form.name==accountArr[i].name&&this.form.password!=accountArr[i].password){
-            this.showText('密码输入错误,请重新输入');
-            this.form.password = '';
-            return;
-          }else if(this.form.name==accountArr[i].name&&this.form.password==accountArr[i].password){
-            this.$store.commit('login',{userMess:accountArr[i].mess,loginState:this.form.radio})
-            this.$router.push({path:`/${type}`});
-          }
+        if(this.form.name==accountArr[i].name&&this.form.password!=accountArr[i].password){
+          this.showText('密码输入错误,请重新输入');
+          this.form.password = '';
+          return;
+        }else if(this.form.name==accountArr[i].name&&this.form.password==accountArr[i].password){
+          this.$store.commit('login',{userMess:accountArr[i].mess,loginState:this.form.radio})
+          this.$router.push({path:`/${type}`});
+        }
       }
     },
-    showText(mess){
+    showText(mess){//错误提示
       this.$alert(mess, '错了哦', {
         confirmButtonText: '确定'
       });