class.member.js 786 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {service as dibootApi} from '@/utils/dibootApi.js'
  2. export default class Member {
  3. constructor(){
  4. this.$vue = null
  5. this.$tip = null
  6. }
  7. /**
  8. * 设置tip对象
  9. * @param {Object} $tip
  10. */
  11. setTip($tip) {
  12. this.$tip = $tip
  13. return this
  14. }
  15. /**
  16. * 设置vue对象
  17. * @param {Object} $vue
  18. */
  19. setVue($vue) {
  20. this.$vue = $vue
  21. return this
  22. }
  23. /**
  24. * 获取用户信息
  25. */
  26. async getMemberInfo() {
  27. const res = await dibootApi.get('/h5/userInfo')
  28. if (res.code === 0) {
  29. uni.setStorageSync("userInfo", JSON.stringify(res.data))
  30. } else {
  31. console.log('加载用户错误:', res)
  32. uni.clearStorageSync()
  33. let timer = setTimeout(() => {
  34. clearTimeout(timer)
  35. uni.redirectTo({
  36. url: 'pages/login/login'
  37. })
  38. }, 0)
  39. }
  40. }
  41. }