فهرست منبع

修改一键登录

plg 2 هفته پیش
والد
کامیت
22060a0efd
1فایلهای تغییر یافته به همراه158 افزوده شده و 20 حذف شده
  1. 158 20
      src/views/loginNew.vue

+ 158 - 20
src/views/loginNew.vue

@@ -8,18 +8,36 @@
         <img class="ye2" src="../assets/img/login/ye2.png" />
       </div>
       <div class="cpdm_right">
-        <el-form class="login-left-middle-new" :model="ruleForm" :rules="rules" ref="ruleForm" :label-position="'left'"
-          label-width="10px" size="mini">
+        <el-form
+          class="login-left-middle-new"
+          :model="ruleForm"
+          :rules="rules"
+          ref="ruleForm"
+          :label-position="'left'"
+          label-width="10px"
+          size="mini"
+        >
           <div class="cpdm_right_top">
             <div class="cpdm_right_top_des">欢迎登录</div>
-            <img class="cpdm_right_top_img" src="../assets/img/login/login-left-top.png" />
+            <img
+              class="cpdm_right_top_img"
+              src="../assets/img/login/login-left-top.png"
+            />
           </div>
           <el-form-item label="" prop="account" class="account-new">
-            <el-input class="input-account-new" type="text" v-model="ruleForm.account" placeholder="请输入账号"
-              autocomplete="off">
+            <el-input
+              class="input-account-new"
+              type="text"
+              v-model="ruleForm.account"
+              placeholder="请输入账号"
+              autocomplete="off"
+            >
               <template slot="prefix">
                 <div class="account-inner">
-                  <img style="height: 20px; margin-left: 10px" src="../assets/img/login/persion1.png" />
+                  <img
+                    style="height: 20px; margin-left: 10px"
+                    src="../assets/img/login/persion1.png"
+                  />
                   <div class="account-inner-line"></div>
                 </div>
               </template>
@@ -27,11 +45,21 @@
             <!-- <img src="../assets/img/login/persion.png" /> -->
           </el-form-item>
           <el-form-item label="" class="account-two-new" prop="pass">
-            <el-input class="input-password-new" type="password" placeholder="请输入密码" show-password v-model="ruleForm.pass"
-              autocomplete="off" @keyup.enter.native="submitForm('ruleForm')">
+            <el-input
+              class="input-password-new"
+              type="password"
+              placeholder="请输入密码"
+              show-password
+              v-model="ruleForm.pass"
+              autocomplete="off"
+              @keyup.enter.native="submitForm('ruleForm')"
+            >
               <template slot="prefix">
                 <div class="account-inner">
-                  <img style="height: 20px; margin-left: 10px" src="../assets/img/login/password1.png" />
+                  <img
+                    style="height: 20px; margin-left: 10px"
+                    src="../assets/img/login/password1.png"
+                  />
                   <div class="account-inner-line"></div>
                 </div>
               </template>
@@ -45,6 +73,11 @@
             <div class="button-new" @click="submitForm('ruleForm')">登录</div>
           </el-form-item>
         </el-form>
+        <div v-show="isTest">  <el-divider style="width: 80%">演示账号一键登录</el-divider></div>
+      
+        <div style="text-align: center" v-show="isTest">
+          <el-button size="mini" @click="loginTest">演示账号登录</el-button>
+        </div>
       </div>
     </div>
   </div>
@@ -116,12 +149,111 @@ export default {
         type: [{ validator: validateType, trigger: "change" }],
         imgText: [{ validator: validateImgText, trigger: "blur" }],
       },
+      isTest: false,
     };
   },
   mounted() {
     // this.getCode();
+    //调用接口
+    //调用接口查看返回值
+    this.viewStaus()
   },
   methods: {
+    viewStaus() {
+      this.$http.get(
+        `/system/getVersion`,
+        //"/v1/system/login",
+        {
+          // userNo: this.ruleForm.account,
+          // password: md5(this.ruleForm.pass),
+          // imgText: this.ruleForm.imgText,
+          // type: 0,
+        },
+        (res) => {
+          if (res && res.code == 200) {
+            //
+           
+            if( res.msg=='test'){
+              this.isTest=true;
+            }else{
+              this.isTest=false;
+            }
+          } else if (res && res.code == 2001) {
+            //调用刷新的方法
+            // this.getCode();
+            this.$message({
+              message: res.msg,
+              type: "error",
+            });
+          } else {
+            this.$message({
+              message: res.msg,
+              type: "error",
+            });
+          }
+        }
+      );
+    },
+
+    loginTest() {
+      this.$http.get(
+        `/system/login?userNo=sjcc&password=${md5("123456")}`,
+        //"/v1/system/login",
+        {
+          // userNo: this.ruleForm.account,
+          // password: md5(this.ruleForm.pass),
+          // imgText: this.ruleForm.imgText,
+          // type: 0,
+        },
+        (res) => {
+          if (res && res.code == 200) {
+            // type等于3  超级管理员
+            // type等于2  普通管理员
+            // type等于1  普通用户等不能登录
+            oSessionStorage.setItem("userInfo", JSON.stringify(res.data.user));
+            oSessionStorage.setItem("token", res.data.token);
+            // oSessionStorage.setItem("invitationCode", res.data.user.invitationCode);
+            //如果类型返回的是0则为普通用户
+            //如果类型返回的是1则为管理员用户
+            // this.$router.push({ path: "/manage/adminHome" });
+            if (res.data.user.roleType == "5") {
+              this.$router.push({ path: "/manage/generalSituation" });
+              // this.$router.push({ path: "/manage/userManage" });
+            } else if (res.data.user.roleType == "4") {
+              // this.$router.push({ path: "/manage/userManage" });
+              this.$router.push({ path: "/manage/generalSituation" });
+            } else if (res.data.user.roleType == "3") {
+              this.$router.push({ path: "/manage/userManage" });
+            } else {
+              this.$message({
+                message: "请使用管理账号登录",
+                type: "error",
+              });
+            }
+
+            // if (res.data.user.roleType === "0") {
+            //   this.$message.warning("账号密码错误");
+            //   // this.$router.push({ path: "/home" });
+            //   // this.$router.push({ path: "/manageMain" });
+            // } else {
+            //   this.$router.push({ path: "/manage/adminHome" });
+            // }
+          } else if (res && res.code == 2001) {
+            //调用刷新的方法
+            // this.getCode();
+            this.$message({
+              message: res.msg,
+              type: "error",
+            });
+          } else {
+            this.$message({
+              message: res.msg,
+              type: "error",
+            });
+          }
+        }
+      );
+    },
     getCode() {
       this.$http.getImg(`/user/getCode`, {}, (res) => {
         let blob = new Blob([res.data], { type: "image/jpeg" });
@@ -144,9 +276,7 @@ export default {
               // type: 0,
             },
             (res) => {
-
               if (res && res.code == 200) {
-
                 // type等于3  超级管理员
                 // type等于2  普通管理员
                 // type等于1  普通用户等不能登录
@@ -206,12 +336,19 @@ export default {
 };
 </script>
 <style scoped>
+.el-divider--horizontal {
+  display: block;
+  height: 1px;
+  width: 80% !important;
+  margin: 24px 0;
+  margin-left: 10%;
+}
 /* @font-face {
   font-family: "Electronic";
   src: url("../../assets/font/sjxk.ttf") format("truetype");
 } */
 
-.input-account-new>>>.el-input__inner {
+.input-account-new >>> .el-input__inner {
   background-color: #f7f7f7 !important;
   background-image: none;
   border-radius: 30px;
@@ -233,26 +370,26 @@ export default {
   width: 100%;
 }
 
-.account-new>>>.el-input {
+.account-new >>> .el-input {
   display: table !important;
 }
 
-.input-account-new>>>.el-input__inner::placeholder {
+.input-account-new >>> .el-input__inner::placeholder {
   /*color: #f9f9f9;*/
   color: #9a9a9a;
 }
 
-.input-password-new>>>.el-input__inner::placeholder {
+.input-password-new >>> .el-input__inner::placeholder {
   /*color: #f9f9f9;*/
   color: #9a9a9a !important;
 }
 
-.input-password-new>>>.el-input__icon {
+.input-password-new >>> .el-input__icon {
   /*color: #f9f9f9;*/
- line-height: 46px !important;
+  line-height: 46px !important;
 }
 
-.input-password-new>>>.el-input__inner {
+.input-password-new >>> .el-input__inner {
   background-color: #f7f7f7 !important;
   background-image: none;
   border-radius: 30px;
@@ -270,7 +407,8 @@ export default {
   width: 100%;
 }
 
-.button-new-parent>>>.el-form-item__content {}
+.button-new-parent >>> .el-form-item__content {
+}
 </style>
 
 <style lang="less" scoped>
@@ -458,7 +596,7 @@ export default {
 
 .account-inner-line {
   width: 1px;
-  background-color: #E9E9E9;
+  background-color: #e9e9e9;
   height: 30px;
   margin-left: 10px;
 }