Blame view

mock/prod/list.js 3.08 KB
b58b17e1e   Adam   auto commit the c...
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  import Mock from 'mockjs'
  // import logoPath from "~@/assets/img/yp_logo.jpeg"
  
  const List = []
  const count = 20
  
  const baseContent = '<p>I am testing data, I am testing data.</p><p></p>'
  // const image_uri = logoPath
  const image_uri = 'https://wpimg.wallstcn.com/360e4842-4db5-42d0-b078-f9a84a825546.gif'
  
  for (let i = 0; i < count; i++) {
    List.push(Mock.mock({
      pid: '@increment',
      pname: '@title(5,10)',
      timestamp: +Mock.Random.date('T'),
      shoper: '@first', //所属工厂
      salescount: '@first', //购买次数
      importance: '@integer(1, 3)', //排序权重
      prod_info_weight: '@integer(1, 3)', //重量
      prod_info_leg_long: '@integer(1, 3)', //腿长
      prod_info_glass_width: '@integer(1, 3)', //镜宽
      prod_info_glass_height: '@integer(1, 3)', //镜高
      prod_info_frame_width: '@integer(1, 3)', //框宽
      prod_info_frame_height: '@integer(1, 3)', //框高
      prod_info_norse_width: '@integer(1, 3)', //鼻宽
      prod_info_window_pic: [], //鼻宽
      image_uri: image_uri
    }))
  }
  
  export default [{
      url: '/yp/prod/list',
      type: 'post',
      response: config => {
        const {
          importance,
          type,
          title,
          page = 1,
          limit = 20,
          sort
        } = config.query
  
        // let mockList = List.filter(item => {
        //   if (importance && item.importance !== +importance) return false
        //   if (type && item.type !== type) return false
        //   if (title && item.title.indexOf(title) < 0) return false
        //   return true
        // })
  
        if (sort === '-id') {
          mockList = mockList.reverse()
        }
  
        const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
  
        return {
          code: 20000,
          data: {
            total: mockList.length,
            items: pageList
          }
        }
      }
    },
  
    // {
    //   url: '/yp/prod/detail',
    //   type: 'get',
    //   response: config => {
    //     const {
    //       id
    //     } = config.query
    //     for (const article of List) {
    //       if (article.id === +id) {
    //         return {
    //           code: 20000,
    //           data: article
    //         }
    //       }
    //     }
    //   }
    // },
  
    // {
    //   url: '/yp/article/pv',
    //   type: 'get',
    //   response: _ => {
    //     return {
    //       code: 20000,
    //       data: {
    //         pvData: [{
    //             key: 'PC',
    //             pv: 1024
    //           },
    //           {
    //             key: 'mobile',
    //             pv: 1024
    //           },
    //           {
    //             key: 'ios',
    //             pv: 1024
    //           },
    //           {
    //             key: 'android',
    //             pv: 1024
    //           }
    //         ]
    //       }
    //     }
    //   }
    // },
  
    // {
    //   url: '/yp/article/create',
    //   type: 'post',
    //   response: _ => {
    //     return {
    //       code: 20000,
    //       data: 'success'
    //     }
    //   }
    // },
  
    // {
    //   url: '/yp/article/update',
    //   type: 'post',
    //   response: _ => {
    //     return {
    //       code: 20000,
    //       data: 'success'
    //     }
    //   }
    // }
  ]