login.js 966 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. let app = new Vue({
  2. el: '#app',
  3. data () {
  4. return {
  5. accounts:'',
  6. password:'',
  7. userList:[
  8. {accounts:'123',password:'123'},
  9. {accounts:'admin',password:'123456'}
  10. ]
  11. }
  12. },
  13. created () {
  14. },
  15. beforeDestroy () {
  16. },
  17. mounted () {
  18. },
  19. methods: {
  20. goIndex(){
  21. let that = this
  22. for(let a = 0;a<this.userList.length;a++){
  23. if(this.userList[a].accounts == this.accounts){
  24. if(this.userList[a].password == this.password){
  25. this.$message({
  26. message: '登录成功',
  27. type: 'success'
  28. });
  29. sessionStorage.setItem('accounts',this.accounts);
  30. sessionStorage.setItem('password',this.password);
  31. setTimeout(()=>{
  32. window.location.href = '../index.html'
  33. },1000)
  34. return
  35. }
  36. }
  37. }
  38. this.$message.error('用户名不存在或密码错误');
  39. }
  40. },
  41. })