auth.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import store from "@/store"
  2. import config from "@/config"
  3. import tool from "@/utils/tool"
  4. import http from "@/utils/request"
  5. export default {
  6. // 登录获取TOKEN
  7. token: async function (data = {}) {
  8. const query = {
  9. username: data.user,
  10. password: tool.crypto.encrypt(data.password),
  11. code: data.code,
  12. uuid: data.uuid
  13. }
  14. return await http.post(`${config.API_URL}/mes/auth/login`, query)
  15. },
  16. // 获取登录验证码
  17. codeImg: async function () {
  18. return await http.get(`${config.API_URL}/mes/auth/code`)
  19. },
  20. user: {
  21. name: "用户管理",
  22. url: `${config.API_URL}/mes/sysUser`,
  23. get: async function (data = {}) {
  24. if (store.state.tenant.tenantId !== "0") data.tenantId = store.state.tenant.tenantId
  25. return await http.post(`${this.url}/getPage`, data)
  26. },
  27. all: async function (data = {}) {
  28. if (store.state.tenant.tenantId !== "0") data.tenantId = store.state.tenant.tenantId
  29. return await http.post(`${this.url}/getList`, data)
  30. },
  31. add: async function (data = {}) {
  32. return await http.post(`${this.url}/save`, data)
  33. },
  34. edit: async function (data = {}) {
  35. return await http.post(`${this.url}/update`, data)
  36. },
  37. del: async function (data = {}) {
  38. return await http.post(`${this.url}/remove`, data)
  39. },
  40. resetPass: async function (data = {}) {
  41. return await http.post(`${this.url}/resetPass`, data)
  42. },
  43. updatePass: async function (data = {}) {
  44. const query = {
  45. oldPass: tool.crypto.encrypt(data.userPassword),
  46. newPass: tool.crypto.encrypt(data.newPassword)
  47. }
  48. return await http.post(`${this.url}/updatePass`, query)
  49. }
  50. }
  51. }