简单验证登录接口
This commit is contained in:
		
							parent
							
								
									2864a04f24
								
							
						
					
					
						commit
						209d318f09
					
				@ -57,6 +57,8 @@
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { validMobile } from '@/utils/validate'
 | 
			
		||||
// 导入登录api
 | 
			
		||||
import { login } from '@/api/user'
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'Login',
 | 
			
		||||
@ -125,19 +127,26 @@ export default {
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    handleLogin() {
 | 
			
		||||
      this.$refs.loginForm.validate(valid => {
 | 
			
		||||
        if (valid) {
 | 
			
		||||
          this.loading = true
 | 
			
		||||
          this.$store.dispatch('user/login', this.loginForm).then(() => {
 | 
			
		||||
            this.$router.push({ path: this.redirect || '/' })
 | 
			
		||||
            this.loading = false
 | 
			
		||||
          }).catch(() => {
 | 
			
		||||
            this.loading = false
 | 
			
		||||
          })
 | 
			
		||||
        } else {
 | 
			
		||||
          console.log('error submit!!')
 | 
			
		||||
          return false
 | 
			
		||||
        }
 | 
			
		||||
      // this.$refs.loginForm.validate(valid => {
 | 
			
		||||
      //   if (valid) {
 | 
			
		||||
      //     this.loading = true
 | 
			
		||||
      //     this.$store.dispatch('user/login', this.loginForm).then(() => {
 | 
			
		||||
      //       this.$router.push({ path: this.redirect || '/' })
 | 
			
		||||
      //       this.loading = false
 | 
			
		||||
      //     }).catch(() => {
 | 
			
		||||
      //       this.loading = false
 | 
			
		||||
      //     })
 | 
			
		||||
      //   } else {
 | 
			
		||||
      //     console.log('error submit!!')
 | 
			
		||||
      //     return false
 | 
			
		||||
      //   }
 | 
			
		||||
      // })
 | 
			
		||||
 | 
			
		||||
      login({
 | 
			
		||||
        mobile: '13800000002',
 | 
			
		||||
        password: '123456'
 | 
			
		||||
      }).then(res => {
 | 
			
		||||
        console.log(res.data)
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user