Commit 0bd81688e70cfa47108fdccf3f9a0f1510f029dc

Authored by Adam
1 parent 04e55fcfe1
Exists in master

auto commit the code by alias command

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