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 < 1200; index++) {
    const { phone } = mock({
      phone: '@phone',
    });
    result.push({
      id: `${index}`,

      address: '@city(true)',
      area: '@region',
      areaNum: '@integer(1,20)',
      code: '@integer(1,20)',
      contacts: '',
      createTime: '@datetime',
      endTime: '@datetime',
      expirationTime: '@datetime',
      introduce: '@csentence(50,100)',
      logo: '@url',
      memoName: '@ctitle(10,20)',
      name: '@ctitle(10,20)',
      phone: phone,
      point: '@integer(1,20)',
      qualification: null,
      sceneLogo: null,
      startTime: '@datetime',
      state: 0,
      subNum: '@integer(1,20)',
      subUsers: '',
      type: null,
      userId: '@integer(1000,50000)',
      userName: phone,
      website: '@url',
    });
  }
  return result;
})();

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