ZZJ
2021-12-13 10727876994cffcd1fc74af114223740fc8825b6
src/pages/index/App.vue
@@ -90,11 +90,60 @@
        const res1 = await savePassword(data);
        console.log(data);
      }
      if (this.active == 1) {
        const data = this.$refs[`form${this.active}`].getFormData();
        await initNetwork(data);
        console.log(data);
    },
    systemLogin() {
      this.nullRule = this.rules
      this.$nextTick(() => {
        this.$refs['ruleForm'].validate(valid => {
          if (valid) {
            this.loading = this.$loading({
              lock: true,
              text: 'Loading',
              spinner: 'el-icon-loading',
              background: 'rgba(0, 0, 0, 0.7)'
            })
            this.testLogin()
          } else {
            this.nullRule = {}
          }
        })
        this.nullRule = {}
      })
    },
    async testLogin() {
      // location.assign("/view/desktop/")
      tologin({ username: this.user.loginName, password: this.user.password })
        .then(json => {
          const loginedInfo = {
            access_token: json.token_type + ' ' + json.access_token,
            refresh_token: json.refresh_token
          }
          sessionStorage.setItem('expires_in', json.expires_in)
          sessionStorage.setItem('loginedInfo', JSON.stringify(loginedInfo))
          this.loading.close()
          this.getLoginUserData()
        })
        .catch(err => {
          this.loading.close()
          this.$notify({
            title: '提示',
            type: 'error',
            message: err.msg
          })
          this.$refs.pwd.focus()
        })
    },
    async getLoginUserData() {
      let res = await getLoginUserData()
      if (res.success) {
        sessionStorage.setItem('userInfo', JSON.stringify(res.data))
        this.$notify.success("登录成功!")
        // 获取权限
        await this.getMenuList()
        location.assign("/view/desktop/")
        return res.data
      } else {
        this.$notify.error("登录失败!")
      }
      this.active++;