fe-drone-ci/src/mock/login.js

64 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-04-18 07:09:13 +00:00
const userMap = {
admin: {
role: ['admin'],
token: 'admin',
introduction: '我是超级管理员',
avatar: 'https://wdl.wallstreetcn.com/48a3e1e0-ea2c-4a4e-9928-247645e3428b',
2017-05-11 08:52:38 +00:00
name: '超级管理员小潘',
uid: '001'
2017-04-18 07:09:13 +00:00
},
editor: {
role: ['editor'],
token: 'editor',
introduction: '我是编辑',
avatar: 'https://wdl.wallstreetcn.com/48a3e1e0-ea2c-4a4e-9928-247645e3428b',
2017-05-11 08:52:38 +00:00
name: '普通编辑小张',
uid: '002'
2017-04-18 07:09:13 +00:00
},
developer: {
role: ['develop'],
token: 'develop',
introduction: '我是开发',
avatar: 'https://wdl.wallstreetcn.com/48a3e1e0-ea2c-4a4e-9928-247645e3428b',
2017-05-11 08:52:38 +00:00
name: '工程师小王',
uid: '003'
2017-04-18 07:09:13 +00:00
}
}
2017-04-24 06:15:42 +00:00
export default {
loginByEmail: config => {
2017-05-10 07:47:53 +00:00
const { email } = JSON.parse(config.data);
2017-04-24 09:34:04 +00:00
return new Promise((resolve, reject) => {
if (userMap[email.split('@')[0]]) {
setTimeout(() => {
resolve([200, {
data: userMap[email.split('@')[0]]
}]);
}, 500);
} else {
reject('账号不正确')
}
2017-04-24 06:15:42 +00:00
})
},
getInfo: config => {
const { token } = config.params;
2017-04-24 09:34:04 +00:00
return new Promise((resolve, reject) => {
if (userMap[token]) {
setTimeout(() => {
resolve([200, {
data: userMap[token]
}]);
}, 100);
} else {
reject('获取失败')
}
2017-04-24 06:15:42 +00:00
})
},
logout: () => new Promise(resolve => {
setTimeout(() => {
resolve([200, { data: 'success' }]);
}, 100);
})
};