login.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // 导入总仓库和自己声明的 AppDispatch
  2. // import store, { AppDispatch } from ".."
  3. import { DictListTypeAPI, DictListTypeObj } from "@/types";
  4. import http from "@/utils/http";
  5. import { AppDispatch } from "..";
  6. /**
  7. * 用户登录接口
  8. */
  9. export const userLoginAPI = (data: any) => {
  10. return http.post("admin/login", { ...data });
  11. };
  12. /**
  13. * 修改密码接口
  14. */
  15. export const passWordEditAPI = (data: any) => {
  16. return http.post("sys/user/updatePwd", { ...data });
  17. };
  18. /**
  19. * 获取下拉框数据
  20. */
  21. export const getDictListAPI = () => {
  22. return async (dispatch: AppDispatch) => {
  23. const res = await http.get("cms/dict/getList");
  24. const list: DictListTypeAPI[] = res.data;
  25. const obj = {
  26. age: [{ label: "全部", value: "", type: "age" }],
  27. texture: [{ label: "全部", value: "", type: "texture" }],
  28. level: [{ label: "全部", value: "", type: "level" }],
  29. source: [{ label: "全部", value: "", type: "source" }],
  30. } as DictListTypeObj;
  31. list.forEach((v) => {
  32. obj[v.type].push({ label: v.name, value: v.name, type: v.type });
  33. });
  34. dispatch({ type: "login/getDictList", payload: obj });
  35. };
  36. };