import BaseAPI from './base_api'
import _ from 'lodash'

export default class OtherAPI extends BaseAPI {
  /**
  * 当前登录用户，检测是否该系统有权限
  */
 getInfo = () => this.post('/user/getinfo', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
  /**
   * 获取我的消息信息
   */
  getMyMsg = () => this.get('/v2/education/message/my', {})
  /* 支持三方登录 */
  examAutoLogin = (obj) => this.post('/util/kaosx', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
  /**
   * 调用退出登录
   */
  outLogin = () => this.get('/user_center/logout', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
  /**
   * 文件提交
   * @param {[object]} obj
   */
  uploadFile = (obj = {}) => this.post('/util/upload-file', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
  /**
   * 个人信息 - 修改密码
   * @param {[string]} obj.old_password 验证码
   * @param {[string]} obj.new_password 新的密码
   * @param {[string]} obj.service 这里 一直是定值 h5.ezijing.com
   */
  updatePwd = (obj = {}) => this.post('/user_center/change_password', _.assignIn(obj, { service: 'h5.ezijing.com' }), { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
  /**
   * 个人信息 - 上传头像
   */
  updatePic = (obj = {}) => this.post('/v3/storage/upload/avatar', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
}
