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}`,
      activatedTime: '@datetime',
      address: '@city(true)',
      agentFrameworkId: null,
      agentFrameworkName: null,
      agentName: null,
      balance: 'THETAYP41136787.OSC',
      'cameraType|1': [1, 4, 9, 10, 6],
      childName: 'THETAYP41136787.OSC',
      companyId: null,
      companyName: '@ctitle',
      cooperationUser: null,
      cooperationUserName: null,
      country: 0,
      createTime: null,
      goodsId: null,
      goodsName: null,
      imageUrl: null,
      inTime: null,
      isExpire: null,
      lastTime: null,
      nickName: null,
      orderSn: null,
      outTime: null,
      'own|1': [0, 1, 2, 3],
      pic: null,
      recStatus: 'A',
      responseUserIncrement: null,
      sceneNum: null,
      'snCode|8': '@integer(1,20)',
      space: null,
      spaceContent: null,
      spaceEndStr: null,
      spaceEndTime: null,
      spaceId: null,
      spaceStr: null,
      surplusDate: null,
      totalSpace: 0,
      totalSpaceStr: null,
      type: null,
      usedSpace: 0,
      usedSpaceStr: null,
      userId: '@integer(1,20)',
      userIncrementId: null,
      userName: phone,
      wifiName: 'THETAYP41136787.OSC',
    });
  }
  return result;
})();

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