prod.js 3.53 KB
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', //产品id
    pname: '01-8701志平防蓝光-防辐射电脑网课眼镜,TR90弹性漆,近视镜,青春潮流', //产品名移交
    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,
    prod_memo: '',
    // 'type|1': ['CN', 'US', 'JP', 'EU'],
    // 'status|1': ['published', 'draft'],
    'type|1': ['CN', 'US', 'JP', 'EU'], //本产品销售区域
    'prod_status|1': ['published', 'draft'], //状态,上线-下线
    judge_list: [], //评论管理
    sku_list: [], //sku清单
    sku_attr: [], //sku属性
  }))
}

export default [{
    url: '/yp/prod/list',
    type: 'post',
    response: config => {
      const {
        importance,
        type,
        pname,
        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 (pname && item.pname.indexOf(pname) < 0) return false
        return true
      })

      //   if (sort === '-pid') {
      //     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 {
        pid
      } = config.query
      for (const prod of List) {
        if (prod.pid === +pid) {
          return {
            code: 20000,
            data: prod
          }
        }
      }
    }
  },

  //   {
  //     url: '/yp/prod/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/prod/create',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  },

  {
    url: '/yp/prod/update',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  }
]