| huibing.xie | 1f1606f | 2018-08-20 15:46:55 +0800 | [diff] [blame^] | 1 | import { param2Obj } from '@/utils' |
| 2 | |
| 3 | const userMap = { |
| 4 | admin: { |
| 5 | data: { |
| 6 | roles: ['admin'], |
| 7 | token: 'admin', |
| 8 | introduction: '我是超级管理员', |
| 9 | avatar: 'https://cn.vuejs.org/images/logo.png', |
| 10 | name: 'Super Admin' |
| 11 | }, |
| 12 | code: 200 |
| 13 | } |
| 14 | } |
| 15 | export default { |
| 16 | loginByUsername: config => { |
| 17 | const { username } = JSON.parse(config.body) |
| 18 | return userMap[username] |
| 19 | }, |
| 20 | getUserInfo: config => { |
| 21 | const { token } = param2Obj(config.url) |
| 22 | if (userMap[token]) { |
| 23 | return userMap[token] |
| 24 | } else { |
| 25 | return false |
| 26 | } |
| 27 | }, |
| 28 | logout: () => { |
| 29 | return { |
| 30 | code: 200 |
| 31 | } |
| 32 | } |
| 33 | } |