login.js 845 B

12345678910111213141516171819202122232425
  1. import { defineStore } from 'pinia'
  2. import { get, omit } from 'lodash-es'
  3. import { AxiosWrapper } from '@/utils/axios-wrapper'
  4. const axios = new AxiosWrapper()
  5. export const LoginStore = defineStore('login', () => {
  6. const login = async (payload) => {
  7. const type = get(payload, 'type')
  8. const np = omit(payload, 'type')
  9. const res = await axios.$post(`/login/${type}`, np)
  10. return res
  11. }
  12. const rp = async (payload) => {
  13. const type = get(payload, 'type')
  14. const np = omit(payload, 'type')
  15. const res = await axios.$post(`/login/updatePwd/${type}`, np)
  16. return res
  17. }
  18. const rpNoNewPassword = async (payload) => {
  19. const type = get(payload, 'type')
  20. const np = omit(payload, 'type')
  21. const res = await axios.$post(`/login/resetPwd/${type}`, np)
  22. return res
  23. }
  24. return { login, rp, rpNoNewPassword }
  25. })