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 个 随机手机号码

// bgMusic: ""
// cameraNum: 2
// childName: null
// expirationDate: null
// expirationTime: 1622217599000
// floorLogo: "http://zfb-4dkankan.oss-cn-shenzhen.aliyuncs.com/companyLogo/1629431551712_00000010_2021-08-16.zip"
// id: 1107
// name: "南山居"
// num: 6
// point: 99
// sceneLogo: "http://zfb-4dkankan.oss-cn-shenzhen.aliyuncs.com/companyLogo/1629354038921_20210817162925_0_STITCH.jpg"
// sceneNum: 0
// subNum: 10
// userName: "13112310255"

const demoList = (() => {
  const result: any[] = [];
  for (let index = 0; index < 1200; index++) {
    const { phone } = mock({
      phone: '@phone',
    });
    result.push({
      id: `${index}`,

      bgMusic: '@url()',
      cameraNum: '@integer(1,20)',
      childName: '@ctitle(10,20)',
      expirationDate: '@datetime',
      expirationTime: '@datetime',
      floorLogo: '@image()',
      name: '@ctitle(10,15)',
      num: '@integer(1,20)',
      point: '@integer(1,100)',
      sceneLogo: '@image()',
      sceneNum: '@integer(1,10)',
      subNum: '@integer(1,20)',
      userName: phone,
      // userName: phone,
      // subNum: '@integer(1,20)',
      // sceneNum: '@integer(1,10)',
      // num: '@integer(1,10)',
      // floorLogo: '@image()',
      // sceneLogo: '@image()',
      // beginTime: '@datetime',
      // endTime: '@datetime',
      // address: '@city()',
      // name: '@cname()',
      // 'no|100000-10000000': 100000,
      // 'status|1': ['正常', '启用', '停用'],
    });
  }
  return result;
})();

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