1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| const { mock } = require('mockjs')
|
| const List = []
| const count = 999
| let num = 0
| for (let i = 0; i < count; i++) {
| List.push(
| mock({
| uuid: '@uuid',
| image: `https://picsum.photos/300/600?random=${num++}`,
| title: '@ctitle',
| description: '@csentence',
| link: 'https://www.baidu.com',
| price: '@integer(100, 500)',
| 'status|1': [1, 0],
| 'isRecommend|1': [1, 0],
| })
| )
| }
|
| module.exports = [
| {
| url: '/goodsList/getList',
| type: 'post',
| response(config) {
| const { title = '', pageNo = 1, pageSize = 20 } = config.body
| let mockList = List.filter((item) => {
| if (title && item.title.indexOf(title) < 0) return false
| return true
| })
| const pageList = mockList.filter(
| (item, index) =>
| index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
| )
| return {
| code: 200,
| msg: 'success',
| totalCount: count,
| data: pageList,
| }
| },
| },
| ]
|
|