pc-master #232
| @ -34,7 +34,7 @@ | |||||||
|           记住密码 |           记住密码 | ||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
|       <div class="login-btn" @keyup.enter="toLogin" @click="login">登 录</div> |       <div class="login-btn"  @click="login">登 录</div> | ||||||
|     </div> |     </div> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
| @ -47,6 +47,8 @@ export default { | |||||||
|       save: false, |       save: false, | ||||||
|       password: "", |       password: "", | ||||||
|       username: "", |       username: "", | ||||||
|  |       loading:null, | ||||||
|  |       isLoad:false, | ||||||
|     }; |     }; | ||||||
|   }, |   }, | ||||||
|   mounted() { |   mounted() { | ||||||
| @ -61,20 +63,35 @@ export default { | |||||||
|     if (localStorage.getItem("token")) { |     if (localStorage.getItem("token")) { | ||||||
|       this.$router.push({ name: "index" }); |       this.$router.push({ name: "index" }); | ||||||
|     } |     } | ||||||
|     this.toLogin(); |  window.addEventListener('keyup', this.handleKeyUp); | ||||||
|  |   }, | ||||||
|  |     beforeDestroy() { | ||||||
|  |     window.removeEventListener('keyup', this.handleKeyUp); | ||||||
|   }, |   }, | ||||||
|   methods: { |   methods: { | ||||||
|     toLogin() { |      handleKeyUp() { | ||||||
|              document.onkeydown = e =>{ |        if (event.key === 'Enter'&&this.isLoad==false) { | ||||||
|                 if (!e.shiftKey && e.keyCode === 13) { |         this.isLoad=true | ||||||
|                 e.cancelBubble = true; //ie阻止冒泡行为 |                this.loading = this.$loading({ | ||||||
|                 e.stopPropagation();//Firefox阻止冒泡行为 |         lock: true, | ||||||
|                 e.preventDefault(); //取消事件的默认动作*换行 |         text: '登录中', | ||||||
|                 if (e.srcElement.value) { |         spinner: 'el-icon-loading', | ||||||
|                     this.login() |         background: 'rgba(0, 0, 0, 0.7)' | ||||||
|                 } |       }); | ||||||
|             } |            this.login(); | ||||||
|       } |       } | ||||||
|  |       // document.onkeydown = (e) => { | ||||||
|  |       //   if (!e.shiftKey && e.keyCode === 13) { | ||||||
|  |       //     e.cancelBubble = true; //ie阻止冒泡行为 | ||||||
|  |       //     e.stopPropagation(); //Firefox阻止冒泡行为 | ||||||
|  |       //     e.preventDefault(); //取消事件的默认动作*换行 | ||||||
|  |       //     console.log(e,111); | ||||||
|  |       //     if (e.srcElement.value) { | ||||||
|  |       //       console.log(11); | ||||||
|  |           | ||||||
|  |       //     } | ||||||
|  |       //   } | ||||||
|  |       // }; | ||||||
|     }, |     }, | ||||||
|     login() { |     login() { | ||||||
|       var store = this.$store.state; |       var store = this.$store.state; | ||||||
| @ -95,6 +112,8 @@ export default { | |||||||
|         password: this.password, |         password: this.password, | ||||||
|       }; // 替换为你要发送的数据 |       }; // 替换为你要发送的数据 | ||||||
|       this.api.login(data).then((res) => { |       this.api.login(data).then((res) => { | ||||||
|  |           this.loading.close() | ||||||
|  |           this.isLoad=false | ||||||
|         if (this.save) { |         if (this.save) { | ||||||
|           localStorage.setItem("save", 1); |           localStorage.setItem("save", 1); | ||||||
|           localStorage.setItem("username", this.username); |           localStorage.setItem("username", this.username); | ||||||
| @ -119,6 +138,9 @@ export default { | |||||||
|           localStorage.removeItem("token"); |           localStorage.removeItem("token"); | ||||||
|           this.$message.error(res.data.msg); |           this.$message.error(res.data.msg); | ||||||
|         } |         } | ||||||
|  |       }).catch(err=>{ | ||||||
|  |             this.loading.close() | ||||||
|  |               this.isLoad=false | ||||||
|       }); |       }); | ||||||
|     }, |     }, | ||||||
|   }, |   }, | ||||||
|  | |||||||
| @ -724,18 +724,28 @@ this.dataInit(); | |||||||
|         for (let index = 0; index < inputList.length; index++) { |         for (let index = 0; index < inputList.length; index++) { | ||||||
|             inputList[index].onfocus = this.selectValue;//input放入焦点,全选文本 |             inputList[index].onfocus = this.selectValue;//input放入焦点,全选文本 | ||||||
|         } |         } | ||||||
|  |          window.addEventListener('keyup', this.handleKeyUp); | ||||||
|  |     }, | ||||||
|  |        beforeDestroy() { | ||||||
|  |     window.removeEventListener('keyup', this.handleKeyUp); | ||||||
|   }, |   }, | ||||||
|     methods: { |     methods: { | ||||||
|                 modelClose(){ |                 modelClose(){ | ||||||
|             this.$router.go(-1); // 返回前一页 |             this.$router.go(-1); // 返回前一页 | ||||||
|         }, |         }, | ||||||
| modelConfirm(){ |          handleKeyUp() { | ||||||
|  |        if (event.key === 'Enter') { | ||||||
|  |       | ||||||
|  |            this.modelConfirm(); | ||||||
|  |       } | ||||||
|  |       }, | ||||||
|  |             modelConfirm(){ | ||||||
|         if(this.modelPassword=='230509'){ |         if(this.modelPassword=='230509'){ | ||||||
|             this.warnModel=false |             this.warnModel=false | ||||||
|         }else{ |         }else{ | ||||||
|             this.$message('密码错误'); |             this.$message('密码错误'); | ||||||
|         } |         } | ||||||
| }, |             }, | ||||||
|           //失去焦点 计算公式 x/10 |           //失去焦点 计算公式 x/10 | ||||||
|           blurChange10(code, el) { |           blurChange10(code, el) { | ||||||
|             var store = this.$store.state |             var store = this.$store.state | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user