remoteSearch.js 560B

12345678910111213141516171819202122232425
  1. import Mock from 'mockjs'
  2. import { param2Obj } from '@/utils'
  3. const NameList = []
  4. const count = 100
  5. for (let i = 0; i < count; i++) {
  6. NameList.push(Mock.mock({
  7. name: '@first'
  8. }))
  9. }
  10. NameList.push({ name: 'mockPan' })
  11. export default {
  12. searchUser: config => {
  13. const { name } = param2Obj(config.url)
  14. const mockNameList = NameList.filter(item => {
  15. const lowerCaseName = item.name.toLowerCase()
  16. if (name && lowerCaseName.indexOf(name.toLowerCase()) < 0) return false
  17. return true
  18. })
  19. return { items: mockNameList }
  20. }
  21. }