邃芒智像(Uniapp : WX、TT、H5)
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

68 rader
1.8 KiB

  1. import { defineStore } from "pinia";
  2. import { ref, reactive } from "vue";
  3. // import { request } from "../../utils/request"
  4. /**
  5. * @description:用户信息持久化数据
  6. */
  7. export const userInfoModules = defineStore("userInfoStore", () => {
  8. // state
  9. const userInfo = ref(null)
  10. const openId = ref(null)
  11. const token = ref(null)
  12. const myAvatar = ref('')
  13. const myGlod = ref(0)
  14. const wxappid = "wx75cf14e3a0d45821"
  15. const dyappid = "tt2eba5807b1883f9f01"
  16. const photoPath = ref(null) //自定义相机拍照得到照片路径
  17. /**
  18. * @description:依托平台:(web、mp-weixin、mp-toutiao)
  19. * @example 平台名:"web-H5",枚举值:1
  20. * @example 平台名:"mp-weixin",枚举值:2
  21. * @example 平台名:"mp-toutiao",枚举值:3
  22. */
  23. const platForm = ref(null)
  24. /**
  25. * @description:宿主系统:(windows、ios、android、mac、linux)
  26. * @example 系统名:windows,值:1
  27. * @example 系统名:ios,值:2
  28. * @example 系统名:android,值:3
  29. * @example 系统名:mac,值:4
  30. * @example 系统名:linux,值:5
  31. */
  32. const hostSystem = ref(null)
  33. // 登录获取用户信息
  34. // async function getMyAvatar() {
  35. // }
  36. // 退出清除用户信息
  37. // async function getMyGlod(params) {
  38. // }
  39. function getAppId() {
  40. if (platForm.value == 2) {
  41. return wxappid
  42. } else if (platForm.value == 3) {
  43. return dyappid
  44. }
  45. }
  46. return { userInfo, openId, token, myAvatar, myGlod, platForm, hostSystem, wxappid, dyappid, getAppId };
  47. },
  48. {
  49. // persist: true
  50. unistorage: true,
  51. }
  52. // persist: {
  53. // storage: {
  54. // // getItem: uni.getStorageSync,
  55. // token: uni.getStorageSync,
  56. // setItem: uni.setStorageSync
  57. // }
  58. // },
  59. );