• 根据 vuex 的 this.$store.dispatch() 返回值 处理逻辑


    1. App.vue

    •         const ret = await this.$store.dispatch('userLogin', {
                username: this.curUserName,
                password: this.curPassword
              })
              if (ret && ret.info) {
                this.$message.success(ret.info)
                await this.$store.dispatch('controlLoginDialog', false)
              } else {
                this.$message.warning(ret)
              }

    2. vuex/store/action.js

    •   async userLogin ({commit}, account) {
          let userInfo = {}
          return new Promise((resolve, reject) => {
            requestUserLogin(account).then(response => {
              if (response.status === 200) {
                if (response.data.data) {
                  userInfo = response.data.data
                  userInfo.userName = userInfo.name
                  userInfo.isLogin = true
                  resolve({
                    info: userInfo.userName + ' 登录成功,欢迎进入百度云智学院实验平台'
                  })
                } else if (response.data.fail) {
                  userInfo.userName = ''
                  userInfo.isLogin = false
                  myConsole('response.data.fail')
                  resolve(response.data.fail)
                }
              } else {
                userInfo.userName = ''
                userInfo.isLogin = false
              }
      
              commit(USER_LOGIN, {userInfo})
            }).catch(err => {
              myConsole(err)
              reject(err)
            })
          })
        },

    3. 

    --------小尾巴 ________一个人欣赏-最后一朵颜色的消逝-忠诚于我的是·一颗叫做野的心.决不受人奴役.怒火中生的那一刻·终将结束...
  • 相关阅读:
    OpenStack Paste.ini详解(二)
    OpenStack Paste.ini详解(一)
    PDB调试python代码常用命令
    Devstack 安装OpenStack Pike版本(单机环境)
    Openstack Pycharm 的远程调试
    django Forbidden
    Python 常用命令
    OSI模型和TCP/IP协议族(一)
    ubuntu 下关闭MySql server
    安装ubuntu时的注意事项----个人小总结
  • 原文地址:https://www.cnblogs.com/tianxiaxuange/p/10940222.html
Copyright © 2020-2023  润新知