mock.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { http } from "@/utils/http";
  2. import { faker } from "@faker-js/faker/locale/zh_CN";
  3. type Result = {
  4. success: boolean;
  5. data: Array<any>;
  6. };
  7. type mapType = {
  8. plateNumber: string;
  9. driver: string;
  10. orientation: number;
  11. lng: number;
  12. lat: number;
  13. };
  14. const mapList = (): Array<mapType> => {
  15. const result: Array<mapType> = [];
  16. for (let index = 0; index < 10; index++) {
  17. result.push({
  18. plateNumber: `豫A${faker.string.numeric({
  19. length: 5
  20. })}${faker.string.alphanumeric({
  21. casing: "upper"
  22. })}`,
  23. driver: faker.person.firstName(),
  24. orientation: faker.number.int({ min: 1, max: 360 }),
  25. lng: faker.location.latitude({ max: 114.1, min: 113 }),
  26. lat: faker.location.latitude({ max: 35.1, min: 34 })
  27. });
  28. }
  29. return result;
  30. };
  31. /** 地图数据 */
  32. // export const mapJson = (params?: object) => {
  33. // return http.request<Result>("get", "/get-map-info", { params });
  34. // };
  35. /** 地图数据 */
  36. export const mapJson = (params?: object) => {
  37. return {
  38. success: true,
  39. data: mapList()
  40. };
  41. };
  42. /** 文件上传 */
  43. export const formUpload = data => {
  44. return http.request<Result>(
  45. "post",
  46. "https://run.mocky.io/v3/3aa761d7-b0b3-4a03-96b3-6168d4f7467b",
  47. { data },
  48. {
  49. headers: {
  50. "Content-Type": "multipart/form-data"
  51. }
  52. }
  53. );
  54. };