2020-03-30

庚子鼠年 己卯月 壬申日

描述

继续完善项目

随笔

强智登录模块

  1. 从cookie中获取,没有就不做操作,有就存入store
  2. 进入需要强智token的页面才去检测token,先简单检测(姓名,学号那些可以复用,没必要请求后台),然后获取数据的时候检测
  3. 如果不满足条件或者token过期,调用store中的异步方法updataQzInfo刷新数据
  4. 如果学号或者密码错误,则重定向到学号绑定页面

相关代码

mutations: {
    setQz (state, qz) {
      state.qz = qz
    }
  },
  actions: {
    // 通过cookie的数据 异步刷新用户的强智基本信息
    updataQzInfo (context) {
      // 通过保存的cook来给params赋值
      const params = {
        xh: this.state.qz.user.useraccount,
        pwd: this.state.qz.user.userpasswd,
        method: 'authUser'
      }
      qz.getQzInfo(params).then(res => {
        if (res.token === '-1') {
          console.log('密码错误或学号错误:' + res.token)
          // this.$router.push('/xhbind') 报错当前的url
          VueCookies.set('re_url', window.location.href)
          window.location.href = '/xhbind'
        } else {
          context.commit('setQz', res)
        }
      })
    }
  }
posted @ 2020-03-30 22:41  chang1024  阅读(109)  评论(0编辑  收藏  举报