You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
881 B

  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. Vue.use(Vuex)
  4. const store = new Vuex.Store({
  5. state: {
  6. hasLogin: false,
  7. userInfo: {
  8. token: ''
  9. },
  10. lang: 'zh-cn',
  11. cookie: ''
  12. },
  13. mutations: {
  14. login(state, provider) {
  15. state.hasLogin = true;
  16. state.userInfo = provider;
  17. uni.setStorage({ //缓存用户信息
  18. key: 'userInfo',
  19. data: provider
  20. });
  21. },
  22. logout(state) {
  23. state.hasLogin = false;
  24. state.userInfo = {};
  25. uni.removeStorage({
  26. key: 'userInfo'
  27. });
  28. },
  29. setUserInfo(state, provider) {
  30. state.userInfo = provider;
  31. uni.setStorage({//缓存用户信息
  32. key: 'userInfo',
  33. data: provider
  34. });
  35. },
  36. setCookie(state, provider) {
  37. state.cookie = provider;
  38. uni.setStorage({
  39. key: 'cookieKey',
  40. data: provider
  41. });
  42. }
  43. },
  44. actions: {
  45. }
  46. })
  47. export default store