import { param2Obj } from '@/utils'

const userMap = {
  admin: {
    roles: ['admin'],
    token: 'admin',
    introduction: '管理员',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'admin'
  },
  zhouyuanbin: {
    roles: ['manager'],
    token: 'zhouyuanbin',
    introduction: '周元彬',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'zhouyuanbin'
  },
  limin: {
    roles: ['manager'],
    token: 'limin',
    introduction: '李旻',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'limin'
  },
  wangnaimeng: {
    roles: ['manager'],
    token: 'wangnaimeng',
    introduction: '王乃梦',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'wangnaimeng'
  },
  mia: {
    roles: ['manager'],
    token: 'mia',
    introduction: 'Mia',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'mia'
  },
  liuxiaojing: {
    roles: ['manager'],
    token: 'liuxiaojing',
    introduction: '刘小静',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'liuxiaojing'
  },
  yinyuanyuan: {
    roles: ['manager'],
    token: 'yinyuanyuan',
    introduction: '银园园',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'yinyuanyuan'
  },
  zhangxiaolin: {
    roles: ['manager'],
    token: 'zhangxiaolin',
    introduction: '章晓琳',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'zhangxiaolin'
  },
  guihaiying: {
    roles: ['manager'],
    token: 'guihaiying',
    introduction: '桂海英',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'guihaiying'
  },
  liling: {
    roles: ['manager'],
    token: 'liling',
    introduction: '李玲',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'liling'
  },
  zhengfang: {
    roles: ['consultant'],
    token: 'zhengfang',
    introduction: '郑芳',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'zhengfang'
  },
  liping: {
    roles: ['consultant'],
    token: 'liping',
    introduction: '李萍',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'liping'
  },
  chenlin: {
    roles: ['consultant'],
    token: 'chenlin',
    introduction: '陈霖',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'chenlin'
  },
  Cindy: {
    roles: ['consultant'],
    token: 'Cindy',
    introduction: 'Cindy',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'Cindy'
  }
}

export default {
  loginByUsername: config => {
    const { username } = JSON.parse(config.body)
    return userMap[username]
  },
  getUserInfo: config => {
    const { token } = param2Obj(config.url)
    if (userMap[token]) {
      return userMap[token]
    } else {
      return false
    }
  },
  logout: () => 'success'
}
