import { MockMethod } from 'vite-plugin-mock';
import { mock, Random } from 'mockjs';
import { resultPageSuccess } from '../_util';
Random.extend({
  phone: function () {
    const phonePrefixs = ['132', '135', '189']; // 自己写前缀哈
    return this.pick(phonePrefixs) + mock(/\d{8}/); //Number()
  },
});
// console.log(Random.phone());
// 生成 1 - 10 个 随机手机号码

const demoList = (() => {
  const result: any[] = [];
  for (let index = 0; index < 200; index++) {
    // const { phone } = mock({
    //   phone: '@phone',
    // });

    result.push({
      id: `${index}`,
      name: '@ctitle(3,10)',
      desc: '@cparagraph(3, 5)',
      link: `https://zfb.4dkankan.com/smobile.html?m=@string( 'lower/number',5,10)`,
      'productType|1': [0, 1, 2, 3],
      steamRoom: {
        id: 1,
        name: '李嘉琪的直播间',
      },
      'amount|1': '@integer(20,50)',
      'total|1': '@integer(20,50)',
      'marketingUnit|1': '@float(20,50,3,4)',
      'unit|1': '@float(20,50,3,6)',
      isLaunched: '@boolean(1, 9, true)',
      createTime: '@datetime',
    });
  }
  return result;
})();

export default [
  {
    url: '/basic-api/zfb/product/list',
    timeout: 1000,
    method: 'get',
    response: ({ query }) => {
      const { page = 1, pageSize = 20 } = query;
      return resultPageSuccess(page, pageSize, demoList);
    },
  },
] as MockMethod[];
