import BaseACTION from './base_action'
import { Login } from '@api'

export default class LoginAction extends BaseACTION {
  /* get传输方式 */
  getSendCode (obj) {
    return Login.getSendCode(obj).then(res => {
      return res || { test: this.getVueInstance().$t('action.interface') }
    }).catch(res => {
      return res || { test: this.getVueInstance().$t('action.interface') }
    })
  }

  register (obj) {
    return Login.register(obj).then(res => {
      return res || { test: 'OK' }
    }).catch(res => {
      return res || { test: 'OK' }
    })
  }

  login (obj, param) {
    return Login.login(obj, param).then(res => {
      return res || { test: 'OK' }
    }).catch(res => {
      return res || { test: 'OK' }
    })
  }

  getUserInfo () {
    return Login.getUserInfo().then(res => {
      return res || { test: 'OK' }
    }).catch(res => {
      return res || { test: 'OK' }
    })
  }

  loginOut () {
    return Login.loginOut().then(res => {
      return res || { test: 'OK' }
    }).catch(res => {
      return res || { test: 'OK' }
    })
  }

  /* post传输方式 */
  postTest (obj = {}) {
    return Login.postTest(obj).then(res => {
      return res || { test: 'OK' }
    }).catch(res => {
      return res || { test: 'OK' }
    })
  }

  /* 当前登录用户，检测是否该系统有权限 */
  getInfo () {
    return Login.getInfo().then(res => {
      return res || { test: 'OK' }
    }).catch(res => {
      return res || { test: 'OK' }
    })
  }
}
