rewrite axios && mock data

This commit is contained in:
Pan
2017-05-15 17:56:45 +08:00
parent 1d05d661bc
commit 5aa22731c8
17 changed files with 137 additions and 204 deletions

View File

@@ -1,4 +1,5 @@
import Mock from 'mockjs';
import { param2Obj } from 'utils';
const NameList = [];
const count = 100;
@@ -12,18 +13,12 @@ NameList.push({ name: 'mockPan' })
export default {
searchUser: config => {
const { name } = config.params;
const { name } = param2Obj(config.url);
const mockNameList = NameList.filter(item => {
const lowerCaseName = item.name.toLowerCase()
if (name && lowerCaseName.indexOf(name.toLowerCase()) < 0) return false;
return true;
});
return new Promise(resolve => {
setTimeout(() => {
resolve([200, {
items: mockNameList
}]);
}, 100);
})
return { items: mockNameList }
}
};