option.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. user: {
  16. // 是否登录
  17. logged: false,
  18. fetching: false,
  19. data: {}
  20. },
  21. // 系统设置
  22. globalOptions: {
  23. fetching: false,
  24. data: {}
  25. }
  26. })
  27. export const mutations = {
  28. SET_USER_AGENT (state, result) {
  29. state.userAgent = result
  30. },
  31. SET_MOBILE_LAYOUT (state, result) {
  32. state.isMobile = result
  33. },
  34. SET_COOKIES (state, result) {
  35. state.cookies = result || ''
  36. },
  37. SET_SESSION_ID (state, result) {
  38. state.sessionId = result || ''
  39. },
  40. UPDATE_URL (state, result) {
  41. state.url = result
  42. },
  43. REQUEST_USER_INFO (state) {
  44. state.user.fetching = true
  45. },
  46. REQUEST_USER_INFO_SUCCESS (state, result) {
  47. state.user.fetching = false
  48. state.user.data = result || {}
  49. state.user.logged = !!(result && result.userName)
  50. },
  51. REQUEST_USER_INFO_FAILURE (state) {
  52. state.user.fetching = false
  53. state.user.data = {}
  54. },
  55. REQUEST_LOGOUT_SUCCESS (state) {
  56. state.user.data = {}
  57. state.user.logged = false
  58. },
  59. REQUEST_GLOBAL_OPTIONS (state) {
  60. state.globalOptions.fetching = true
  61. },
  62. REQUEST_GLOBAL_OPTIONS_SUCCESS (state, result) {
  63. state.globalOptions.fetching = false
  64. state.globalOptions.data = result
  65. },
  66. REQUEST_GLOBAL_OPTIONS_FAILURE (state) {
  67. state.globalOptions.fetching = false
  68. }
  69. }