app.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import authorize from '@/common/authorize.js'
  2. import { formatDate } from '@/common/utilsTools.js'
  3. const state = {
  4. isIphoneX: false,
  5. isIphone: false,
  6. isActivity: false
  7. }
  8. const mutations = {
  9. login(state, provider) { //用户身份 1、协销 2、会员机构 3、供应商 4.普通机构
  10. state.hasLogin = true
  11. state.userInfo = provider
  12. uni.setStorage({ //缓存用户登陆状态
  13. key: 'userInfo',
  14. data: provider
  15. })
  16. },
  17. logout(state) {
  18. state.hasLogin = false
  19. state.userInfo = {}
  20. uni.removeStorage({
  21. key: 'userInfo'
  22. })
  23. uni.removeStorage({
  24. key: 'token'
  25. })
  26. },
  27. wxLogin(state, provider) {
  28. state.isWxAuthorize = true
  29. // console.log(state.isWxAuthorize)
  30. state.wechatUserInfo = provider
  31. uni.setStorageSync('_WX_State', true)
  32. uni.setStorage({ //缓存用户微信授权信息
  33. key: 'wechatUserInfo',
  34. data: provider
  35. })
  36. },
  37. updateStatus(state, provider) {
  38. let TIME = formatDate()
  39. console.log(`${TIME}`, provider)
  40. state.userInfo = provider
  41. uni.setStorage({ //缓存用户登陆状态
  42. key: 'userInfo',
  43. data: provider
  44. })
  45. },
  46. setActivity(state, variable) {
  47. state.isActivity = variable
  48. },
  49. setChangeVar(state, variable) {
  50. //获取设备信息是否为IphoneX
  51. state.isIphoneX = variable
  52. },
  53. setIsIphone(state, variable) {
  54. //获取设备信息是否为IphoneX
  55. state.isIphone = variable
  56. },
  57. setLoginType(state, variable) {
  58. //获取设备信息是否为IphoneX
  59. state.isLoginType = variable
  60. console.log(state.isLoginType)
  61. },
  62. setLoginProductId(state, variable) {
  63. //获取设备信息是否为IphoneX
  64. state.isLoginProductId = variable
  65. console.log(state.isLoginProductId)
  66. },
  67. setLoginOrderId(state, variable) {
  68. //获取设备信息是否为IphoneX
  69. state.isLoginOrderId = variable
  70. console.log(state.isLoginOrderId)
  71. },
  72. setWindowHeight(state, height) {
  73. state.windowHeight = height
  74. console.log(state.windowHeight)
  75. }
  76. }
  77. const actions = {
  78. setVariableFun: function(context, vData) {
  79. context.commit('setChangeVar', vData)
  80. },
  81. setIsIphoneFun: function(context, vData) {
  82. context.commit('setIsIphone', vData)
  83. },
  84. setActivityFn: function(context, vData) {
  85. context.commit('setActivity', vData)
  86. },
  87. }
  88. export default {
  89. namespaced: true,
  90. state,
  91. mutations,
  92. actions
  93. }