option.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * 全局设置
  3. */
  4. export const state = {
  5. userAgent: '',
  6. // 是否移动端
  7. isMobile: false,
  8. // 身份token
  9. cookies: '',
  10. // 用户身份SessionId
  11. sessionId: '',
  12. // 正式系统地址
  13. // url: 'http://218.17.158.219:9090/platform-b2c',
  14. // 用户信息
  15. isLogin: {
  16. // 是否登录
  17. logged: false,
  18. fetching: false,
  19. data: []
  20. },
  21. // 获取用户信息
  22. userInfo: {
  23. fetching: false,
  24. data: []
  25. },
  26. // 系统设置
  27. globalOptions: {
  28. fetching: false,
  29. data: {}
  30. }
  31. }
  32. export const mutations = {
  33. SET_USER_AGENT (state, result) {
  34. state.userAgent = result
  35. },
  36. SET_MOBILE_LAYOUT (state, result) {
  37. state.isMobile = result
  38. },
  39. SET_COOKIES (state, result) {
  40. state.cookies = result || ''
  41. },
  42. SET_SESSION_ID (state, result) {
  43. state.sessionId = result || ''
  44. },
  45. UPDATE_URL (state, result) {
  46. state.url = result
  47. },
  48. REQUEST_USER_INFO (state) {
  49. state.userInfo.fetching = true
  50. },
  51. REQUEST_USER_INFO_SUCCESS (state, result) {
  52. state.userInfo.data = result || {}
  53. state.userInfo.fetching = false
  54. },
  55. REQUEST_USER_INFO_FAILURE (state) {
  56. state.userInfo.fetching = true
  57. state.userInfo.data = {}
  58. },
  59. REQUEST_IS_LOGIN (state) {
  60. state.isLogin.fetching = true
  61. },
  62. REQUEST_IS_LOGIN_SUCCESS (state, result) {
  63. state.isLogin.fetching = false
  64. state.isLogin.data = result || {}
  65. state.isLogin.logged = !!(result && result.userName)
  66. },
  67. REQUEST_IS_LOGIN_FAILURE (state) {
  68. state.isLogin.fetching = false
  69. state.isLogin.data = {}
  70. },
  71. REQUEST_LOGOUT_SUCCESS (state) {
  72. state.isLogin.data = {}
  73. state.isLogin.logged = false
  74. },
  75. REQUEST_GLOBAL_OPTIONS (state) {
  76. state.globalOptions.fetching = true
  77. },
  78. REQUEST_GLOBAL_OPTIONS_SUCCESS (state, result) {
  79. state.globalOptions.fetching = false
  80. state.globalOptions.data = result
  81. },
  82. REQUEST_GLOBAL_OPTIONS_FAILURE (state) {
  83. state.globalOptions.fetching = false
  84. }
  85. }