fe-drone-ci/mock/remoteSearch.js

52 lines
1.0 KiB
JavaScript
Raw Normal View History

2017-08-22 07:43:34 +00:00
import Mock from 'mockjs'
2017-04-23 11:50:32 +00:00
2017-08-22 07:43:34 +00:00
const NameList = []
const count = 100
2017-04-23 11:50:32 +00:00
for (let i = 0; i < count; i++) {
NameList.push(Mock.mock({
name: '@first'
2017-08-22 07:43:34 +00:00
}))
2017-04-23 11:50:32 +00:00
}
2019-03-18 10:07:55 +00:00
NameList.push({ name: 'mock-Pan' })
2017-04-23 11:50:32 +00:00
2019-03-18 07:51:48 +00:00
export default [
2019-03-18 10:07:55 +00:00
// username search
2019-03-18 07:51:48 +00:00
{
url: '/search/user',
type: 'get',
response: config => {
const { name } = config.query
const mockNameList = NameList.filter(item => {
const lowerCaseName = item.name.toLowerCase()
return !(name && lowerCaseName.indexOf(name.toLowerCase()) < 0)
})
2019-03-19 10:46:30 +00:00
return {
code: '20000',
data: { items: mockNameList }
}
2019-03-18 07:51:48 +00:00
}
},
2019-03-18 10:07:55 +00:00
// transaction list
2019-03-18 07:51:48 +00:00
{
url: '/transaction/list',
type: 'get',
response: _ => {
return {
2019-03-19 10:46:30 +00:00
code: '20000',
data: {
total: 20,
'items|20': [{
order_no: '@guid()',
timestamp: +Mock.Random.date('T'),
username: '@name()',
price: '@float(1000, 15000, 0, 2)',
'status|1': ['success', 'pending']
}]
}
2019-03-18 07:51:48 +00:00
}
}
2017-04-23 11:50:32 +00:00
}
2019-03-18 07:51:48 +00:00
]