pageList.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { MockMethod } from 'vite-plugin-mock';
  2. import { mock, Random } from 'mockjs';
  3. import { resultPageSuccess } from '../_util';
  4. Random.extend({
  5. phone: function () {
  6. const phonePrefixs = ['132', '135', '189']; // 自己写前缀哈
  7. return this.pick(phonePrefixs) + mock(/\d{8}/); //Number()
  8. },
  9. });
  10. // console.log(Random.phone());
  11. // 生成 1 - 10 个 随机手机号码
  12. const demoList = (() => {
  13. const result: any[] = [];
  14. for (let index = 0; index < 1200; index++) {
  15. const { phone } = mock({
  16. phone: '@phone',
  17. });
  18. result.push({
  19. id: `${index}`,
  20. activatedTime: '@datetime',
  21. address: '@city(true)',
  22. agentFrameworkId: null,
  23. agentFrameworkName: null,
  24. agentName: null,
  25. balance: 'THETAYP41136787.OSC',
  26. 'cameraType|1': [1, 4, 9, 10, 6],
  27. childName: 'THETAYP41136787.OSC',
  28. companyId: null,
  29. companyName: '@ctitle',
  30. cooperationUser: null,
  31. cooperationUserName: null,
  32. country: 0,
  33. createTime: null,
  34. goodsId: null,
  35. goodsName: null,
  36. imageUrl: null,
  37. inTime: null,
  38. isExpire: null,
  39. lastTime: null,
  40. nickName: null,
  41. orderSn: null,
  42. outTime: null,
  43. 'own|1': [0, 1, 2, 3],
  44. pic: null,
  45. recStatus: 'A',
  46. responseUserIncrement: null,
  47. sceneNum: null,
  48. 'snCode|8': '@integer(1,20)',
  49. space: null,
  50. spaceContent: null,
  51. spaceEndStr: null,
  52. spaceEndTime: null,
  53. spaceId: null,
  54. spaceStr: null,
  55. surplusDate: null,
  56. totalSpace: 0,
  57. totalSpaceStr: null,
  58. type: null,
  59. usedSpace: 0,
  60. usedSpaceStr: null,
  61. userId: '@integer(1,20)',
  62. userIncrementId: null,
  63. userName: phone,
  64. wifiName: 'THETAYP41136787.OSC',
  65. });
  66. }
  67. return result;
  68. })();
  69. export default [
  70. {
  71. url: '/zfb-api/zfb/camera/pageList',
  72. timeout: 1000,
  73. method: 'get',
  74. response: ({ query }) => {
  75. const { page = 1, pageSize = 20 } = query;
  76. return resultPageSuccess(page, pageSize, demoList);
  77. },
  78. },
  79. ] as MockMethod[];