user.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * 用户状态管理
  3. */
  4. import {
  5. defineStore
  6. } from 'pinia'
  7. import {
  8. getCardInfo,
  9. getCardQrcode,
  10. getCompanyInfo
  11. } from '@/api/card.js'
  12. export const useUserStore = defineStore('user', {
  13. state: () => ({
  14. cardInfo: {
  15. "userId": "",
  16. "nickName": "",
  17. "phonenumber": "",
  18. "postName": "",
  19. "companyName": "",
  20. "companyAddress": "",
  21. "email": "",
  22. "sex": null,
  23. "avatar": ""
  24. },
  25. companyInfo: {
  26. "name": "",
  27. "email": "",
  28. "address": "",
  29. "introduce": ""
  30. },
  31. qrInfo: {
  32. }
  33. }),
  34. actions: {
  35. // 获取用户卡片信息
  36. queryCardInfo(userId = null) {
  37. return new Promise(async (resolve, reject) => {
  38. let parmas = userId ? {
  39. userId
  40. } : {}
  41. let res = await getCardInfo(parmas)
  42. console.log(res, "resresresresresres");
  43. this.cardInfo = res.data
  44. resolve(res.data)
  45. })
  46. },
  47. queryCompanyInfo(userId = null) {
  48. return new Promise(async (resolve, reject) => {
  49. let parmas = userId ? {
  50. userId
  51. } : {}
  52. let res = await getCompanyInfo(parmas)
  53. this.companyInfo = res.data
  54. resolve(res.data)
  55. })
  56. },
  57. queryCardQrcode(userId = null) {
  58. return new Promise(async (resolve, reject) => {
  59. let parmas = userId ? {
  60. userId
  61. } : {
  62. userId: this.cardInfo.userId
  63. }
  64. let res = await getCardQrcode(parmas)
  65. this.qrInfo = res.data
  66. resolve(res.data)
  67. })
  68. },
  69. }
  70. })