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}`,

      // 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,

      buildingId: '@integer(1,20)',
      buildingNum: null,
      companyName: '@ctitle(10,20)',
      coveredArea: null,
      createTime: '@datetime',
      decorate: null,
      elevator: null,
      endTime: null,
      floor: null,
      head: null,
      homepic: null,
      houseNum: null,
      latitude: null,
      longitude: null,
      name: '@ctitle(10,20)',
      nickName: null,
      orientation: null,
      parlourNum: null,
      phone: phone,
      power: null,
      price: null,
      purpose: null,
      roomNum: null,
      sellTime: null,
      startTime: null,
      'state|1': ['0', '1'],
      title: '@ctitle(10,15)',
      toiletNum: null,
      total: null,
      type: null,
      unitNum: null,
      userName: phone,
      userType: null,
      utilizationArea: null,
      website: null,
    });
  }
  return result;
})();

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