system.ts 717 B

12345678910111213141516171819202122232425262728
  1. import { axios, userLogin, uploadFile as uploadFileUrl } from "@/request";
  2. import { encodePwd } from "@/util";
  3. import { user } from "./user";
  4. import { refreshRole } from "./role";
  5. import { appConstant } from "@/app";
  6. export type LoginProps = {
  7. phoneNum: string;
  8. code: string;
  9. password: string;
  10. };
  11. export const login = async (props: LoginProps) => {
  12. const res = await axios.post(userLogin, {
  13. ...props,
  14. deptId: appConstant.deptId,
  15. password: encodePwd(props.password),
  16. });
  17. user.value.token = res.data.token;
  18. user.value.info = res.data.tmUser;
  19. await refreshRole();
  20. };
  21. export const uploadFile = async (file: File) => {
  22. return (await axios.post<string>(uploadFileUrl, { file })).data;
  23. };