system.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import flyio from "../flyio";
  2. import { ApiCaptchaResponse, ApiResponse, DictItem, ConfigItem } from "@/types";
  3. import { SmsRequestDTO } from "@/types/user";
  4. /**
  5. * 获取配置属性
  6. * @returns
  7. */
  8. export function getConfig() {
  9. return flyio.get('/front/comm/config') as Promise<ApiResponse<ConfigItem[]>>;
  10. }
  11. /**
  12. * 获取字典数据
  13. * @param dictTypes 字典类型列表,逗号分隔
  14. * @returns
  15. */
  16. export function getDictData(dictTypes: string) {
  17. return flyio.get(`/front/comm/dict/${dictTypes}`) as Promise<ApiResponse<Record<string, DictItem[]>>>;
  18. }
  19. /**
  20. * 发送短信验证码, 发送验证码(不验重,验证码,不登陆), 适用于账号登录
  21. * @param params 包含手机号等参数的对象
  22. * @returns
  23. */
  24. export function sendSmsNoValidationNoToken(params: SmsRequestDTO) {
  25. // 使用POST方法,参数通过URL查询字符串传递
  26. return flyio.post('/front/comm/sendSmsNoValidationNoToken', null, { params }) as Promise<ApiResponse<any>>;
  27. }
  28. /**
  29. * 发送短信验证码, 发送验证码(验重,验证码,不登陆), 适用于账号注册
  30. * @param params 包含手机号等参数的对象
  31. * @returns
  32. */
  33. export function sendSmsNoToken(params: SmsRequestDTO, showToast = true) {
  34. return flyio.post('/front/comm/sendSmsNoToken', null, { params }, {
  35. showToast
  36. }) as Promise<ApiResponse<any>>;
  37. }
  38. /**
  39. * 发送短信验证码, 发送验证码(不验重,无验证码,需登陆), 适用于登录后的校验
  40. * @param params 包含手机号等参数的对象
  41. * @returns
  42. */
  43. export function sendSms(params: SmsRequestDTO) {
  44. return flyio.post('/front/comm/sendSms', null, { params }) as Promise<ApiResponse<any>>;
  45. }
  46. /**
  47. * 获取省份列表
  48. * @returns
  49. */
  50. export function getProvinces() {
  51. return flyio.get('/front/user/provinces') as Promise<ApiResponse<DictItem[]>>;
  52. }
  53. /**
  54. * 获取考生类别
  55. * @returns
  56. */
  57. export function getExamTypes(location: string) {
  58. return flyio.get('/front/user/examTypes', { location }) as Promise<ApiResponse<DictItem[]>>;
  59. }
  60. /**
  61. * 获取专业列表
  62. * @returns
  63. */
  64. export function getExamMajors(location: string, examType: string) {
  65. return flyio.get('/front/user/examMajors', { location, examType }) as Promise<ApiResponse<DictItem[]>>;
  66. }
  67. /**
  68. * 获取毕业年份列表
  69. * @returns
  70. */
  71. export function getGraduateYears(location: string, examType: string) {
  72. return flyio.get('/front/user/graduateYears', { location, examType }) as Promise<ApiResponse<DictItem[]>>;
  73. }
  74. /**
  75. * 获取验证码图片
  76. * @returns
  77. */
  78. export function getCaptchaImage() {
  79. return flyio.get('/captchaImage') as Promise<ApiCaptchaResponse>;
  80. }
  81. /**
  82. * 验证短信验证码
  83. * @param params 包含手机号等参数的对象
  84. * @returns
  85. */
  86. export function validateSms(params: SmsRequestDTO) {
  87. return flyio.post('/front/comm/validateSms', null, { params }) as Promise<ApiResponse<any>>;
  88. }