其他分享
首页 > 其他分享> > vue login.js登录逻辑

vue login.js登录逻辑

作者:互联网

    // 验证码
    changeImg() {
        this.imgurl = '/api/changeCode?' + Math.random()
      },
      login() {
        this.$refs.loginForm.validate(valid => {
          if (valid) {
            this.username = this.loginForm.username
            this.password = this.loginForm.password
            this.$http.post('/api/user/frontCheckLogin/' + this.username + '/' + this.password)
              .then(res => {
                // console.log(res.data)
                if (res.data.code == 200) {
                  this.$store.commit('SET_TOKEN', this.loginForm.username)
                  this.$store.commit('GET_USER', this.loginForm)
                  // console.log(this.$store)
                  this.$http.get('/api/perm/2/')
                    .then(res => {
                      this.$store.commit('BTNS', res.data.data)
                    })
                  this.getSelection()
                  this.$message({
                    message: '登陆成功',
                    type: 'success',
                    customClass: 'zZindex',
                    duration: 1000
                  })
                } else {
                  this.$message({
                    message: res.data.message,
                    type: 'error',
                    customClass: 'zZindex'
                  })
                }
              })
              .catch(err => {
                console.log(err)
              })
          } else {
            console.log("error submit!!")
            return false
          }
        })
      }

标签:vue,log,res,js,loginForm,login,data,message,store
来源: https://www.cnblogs.com/knuzy/p/11374606.html