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
          }
        })
      }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM