selectId.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. result.push({
  16. id: `${index}`,
  17. content: '@cparagraph(1, 3)',
  18. createTime: '@datetime',
  19. image: `@image('313x200', '@color', '示例slider')`,
  20. orderNum: '@integer(0,10)',
  21. title: '@ctitle(0,15)',
  22. url: null,
  23. });
  24. }
  25. return result;
  26. })();
  27. export default [
  28. {
  29. url: '/zfb-api/zfb/rotation/selectAll',
  30. timeout: 1000,
  31. method: 'get',
  32. response: ({ query }) => {
  33. const { page = 1, pageSize = 20 } = query;
  34. return resultPageSuccess(page, pageSize, demoList);
  35. },
  36. },
  37. ] as MockMethod[];