|  | @@ -39,10 +39,10 @@
 | 
	
		
			
				|  |  |          <div class="col-md-5">
 | 
	
		
			
				|  |  |              <div class="m-t text-center" style="border: 0px solid #dddee1;">
 | 
	
		
			
				|  |  |                  <div class="form-group has-feedback">
 | 
	
		
			
				|  |  | -                    <i-input class="userinput" v-model="username" @on-enter="login" placeholder="账号" style="width: 250px;" autofocus/>
 | 
	
		
			
				|  |  | +                    <i-input class="userinput" v-model="username" @on-enter="beforeLogin" placeholder="账号" style="width: 250px;" autofocus/>
 | 
	
		
			
				|  |  |                  </div>
 | 
	
		
			
				|  |  |                  <div class="form-group has-feedback">
 | 
	
		
			
				|  |  | -                    <i-input class="userinput"  type="password" v-model="password" @on-enter="login" style="width: 250px;"
 | 
	
		
			
				|  |  | +                    <i-input class="userinput"  type="password" v-model="password" @on-enter="beforeLogin" style="width: 250px;"
 | 
	
		
			
				|  |  |                               placeholder="密码"/>
 | 
	
		
			
				|  |  |                  </div>
 | 
	
		
			
				|  |  |                  <!--<div class="form-group has-feedback" id="authcode">
 | 
	
	
		
			
				|  | @@ -56,7 +56,7 @@
 | 
	
		
			
				|  |  |                      </div>
 | 
	
		
			
				|  |  |                  </div>-->
 | 
	
		
			
				|  |  |                  <div>
 | 
	
		
			
				|  |  | -                    <i-button @click="login" style="width: 125px;height: 45px">登录</i-button>
 | 
	
		
			
				|  |  | +                    <i-button @click="beforeLogin" style="width: 125px;height: 45px">登录</i-button>
 | 
	
		
			
				|  |  |                      <i-button @click="change" style="width: 125px;height: 45px">切换管理端</i-button>
 | 
	
		
			
				|  |  |                  </div>
 | 
	
		
			
				|  |  |              </div>
 | 
	
	
		
			
				|  | @@ -91,20 +91,20 @@
 | 
	
		
			
				|  |  |          beforeMount: function(){
 | 
	
		
			
				|  |  |              // TODO 调用接口获取机器码
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                $.ajax({
 | 
	
		
			
				|  |  | -                    url:"http://127.0.0.1:21600/api/reg/gen",
 | 
	
		
			
				|  |  | -                    success:function(r){
 | 
	
		
			
				|  |  | -                        if(r.code == "0"){
 | 
	
		
			
				|  |  | -                            vm.machineCode = r.rows[0].data.code;
 | 
	
		
			
				|  |  | -                            console.log(vm.machineCode);
 | 
	
		
			
				|  |  | -                            vm.machineCode = vm.machineCode.replace("+","%2B");
 | 
	
		
			
				|  |  | -                            sessionStorage.setItem("machineCode",vm.machineCode);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    },
 | 
	
		
			
				|  |  | -                    error:function(XMLHttpRequest, textStatus, errorThrown){
 | 
	
		
			
				|  |  | -                        alert("获取机器码失败,请联系管理员");
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                })
 | 
	
		
			
				|  |  | +                // $.ajax({
 | 
	
		
			
				|  |  | +                //     url:"http://127.0.0.1:21600/api/reg/gen",
 | 
	
		
			
				|  |  | +                //     success:function(r){
 | 
	
		
			
				|  |  | +                //         if(r.code == "0"){
 | 
	
		
			
				|  |  | +                //             vm.machineCode = r.rows[0].data.code;
 | 
	
		
			
				|  |  | +                //             console.log(vm.machineCode);
 | 
	
		
			
				|  |  | +                //             vm.machineCode = vm.machineCode.replace("+","%2B");
 | 
	
		
			
				|  |  | +                //             sessionStorage.setItem("machineCode",vm.machineCode);
 | 
	
		
			
				|  |  | +                //         }
 | 
	
		
			
				|  |  | +                //     },
 | 
	
		
			
				|  |  | +                //     error:function(XMLHttpRequest, textStatus, errorThrown){
 | 
	
		
			
				|  |  | +                //         alert("获取机器码失败,请联系管理员");
 | 
	
		
			
				|  |  | +                //     }
 | 
	
		
			
				|  |  | +                // })
 | 
	
		
			
				|  |  |                  // 本地调试的时候打开下面的注释代码
 | 
	
		
			
				|  |  |                  // vm.machineCode = "0z4kBPFEve0=";
 | 
	
		
			
				|  |  |                  // sessionStorage.setItem("machineCode","0z4kBPFEve0=");
 | 
	
	
		
			
				|  | @@ -127,6 +127,32 @@
 | 
	
		
			
				|  |  |              refreshCode: function () {
 | 
	
		
			
				|  |  |                  this.src = "captcha.jpg?t=" + $.now();
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | +            beforeLogin:function (){
 | 
	
		
			
				|  |  | +                //登录前 用户在点击登录时再请求机器码
 | 
	
		
			
				|  |  | +                vm.machineCode = sessionStorage.getItem("machineCode");
 | 
	
		
			
				|  |  | +                console.log("登录")
 | 
	
		
			
				|  |  | +                console.log(!vm.machineCode)
 | 
	
		
			
				|  |  | +                if (!vm.machineCode){
 | 
	
		
			
				|  |  | +                    alert("第一次登录比较慢,稍等片刻");
 | 
	
		
			
				|  |  | +                    $.ajax({
 | 
	
		
			
				|  |  | +                        url:"http://127.0.0.1:21600/api/reg/gen",
 | 
	
		
			
				|  |  | +                        success:function(r){
 | 
	
		
			
				|  |  | +                            if(r.code == "0"){
 | 
	
		
			
				|  |  | +                                vm.machineCode = r.rows[0].data.code;
 | 
	
		
			
				|  |  | +                                console.log(vm.machineCode);
 | 
	
		
			
				|  |  | +                                vm.machineCode = vm.machineCode.replace("+","%2B");
 | 
	
		
			
				|  |  | +                                sessionStorage.setItem("machineCode",vm.machineCode);
 | 
	
		
			
				|  |  | +                                vm.login();
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        },
 | 
	
		
			
				|  |  | +                        error:function(XMLHttpRequest, textStatus, errorThrown){
 | 
	
		
			
				|  |  | +                            alert("获取机器码失败,请联系管理员");
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    })
 | 
	
		
			
				|  |  | +                    return
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                this.login();
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  |              login: function (event) {
 | 
	
		
			
				|  |  |                  if (vm.username =='' || vm.password==''){
 | 
	
		
			
				|  |  |                      alert("账号或密码为空,请重新输入");
 | 
	
	
		
			
				|  | @@ -135,17 +161,17 @@
 | 
	
		
			
				|  |  |                  var data = "username=" + vm.username + "&password=" + vm.password + "&captcha=" + vm.captcha + "&machineCode=" + vm.machineCode+"&loginType=2"; //TODO  新增加一个机器码;
 | 
	
		
			
				|  |  |                  // var data = "username=" + vm.username + "&password=" + vm.password + "&captcha=" + vm.captcha + "&machineCode=0z4kBPFEve0=&loginType=2"; //TODO  新增加一个机器码;
 | 
	
		
			
				|  |  |                  sessionStorage.removeItem("permsSet");
 | 
	
		
			
				|  |  | -                var code = sessionStorage.getItem("machineCode");
 | 
	
		
			
				|  |  | -                if(!code){
 | 
	
		
			
				|  |  | -                    alert("正在获取机器码,请稍后登录,大约5s");
 | 
	
		
			
				|  |  | -                    /**
 | 
	
		
			
				|  |  | -                     * 场景:第一次登录会出现问题该机器未录入报错
 | 
	
		
			
				|  |  | -                     * 原因:用户登录过快  请求机器码还没响应
 | 
	
		
			
				|  |  | -                     * 在这响应请求
 | 
	
		
			
				|  |  | -                     */
 | 
	
		
			
				|  |  | -                    this.gen();
 | 
	
		
			
				|  |  | -                    return;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | +                // var code = sessionStorage.getItem("machineCode");
 | 
	
		
			
				|  |  | +                // if(!code){
 | 
	
		
			
				|  |  | +                //     alert("正在获取机器码,请稍后登录,大约5s");
 | 
	
		
			
				|  |  | +                //     /**
 | 
	
		
			
				|  |  | +                //      * 场景:第一次登录会出现问题该机器未录入报错
 | 
	
		
			
				|  |  | +                //      * 原因:用户登录过快  请求机器码还没响应
 | 
	
		
			
				|  |  | +                //      * 在这响应请求
 | 
	
		
			
				|  |  | +                //      */
 | 
	
		
			
				|  |  | +                //     this.gen();
 | 
	
		
			
				|  |  | +                //     return;
 | 
	
		
			
				|  |  | +                // }
 | 
	
		
			
				|  |  |                  $.ajax({
 | 
	
		
			
				|  |  |                      type: "POST",
 | 
	
		
			
				|  |  |                      url: "sys/login",
 |