码迷,mamicode.com
首页 > 其他好文 > 详细

2020-03-30

时间:2020-03-30 23:33:36      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:ext   技术   oca   token   bind   cat   简单   vue   account   

庚子鼠年 己卯月 壬申日

描述

继续完善项目

随笔

强智登录模块

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

2020-03-30

标签:ext   技术   oca   token   bind   cat   简单   vue   account   

原文地址:https://www.cnblogs.com/chang1024/p/12601887.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!