index.js 1014 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { createStore } from 'vuex';
  2. import storage from '@/utils/storage';
  3. const store = createStore({
  4. state: () => ({
  5. isShowToast: false, // 是否在展示Toast中
  6. remark: [], // 填写订单备注
  7. shareLink: "", // 分享链接
  8. verificationKey: "", // 获取key表示验证通过
  9. distributionId: "", // 分销员Id
  10. hasLogin: storage.getHasLogin(),
  11. userInfo: storage.getUserInfo(),
  12. uuid: storage.getUuid(),
  13. token: "",
  14. userName: "",
  15. }),
  16. mutations: {
  17. login(state, userInfo) {
  18. state.userInfo = userInfo || {};
  19. state.userName =
  20. userInfo.Name || userInfo.Nickname || userInfo.Username || "匿名用户";
  21. state.hasLogin = true;
  22. },
  23. logout(state) {
  24. state.userName = "";
  25. state.hasLogin = false;
  26. state.userInfo = {};
  27. },
  28. // 设置填写订单中备注
  29. setRemark(state, remark) {
  30. state.remark = remark;
  31. },
  32. },
  33. actions: {
  34. // 可在此添加异步登录逻辑
  35. },
  36. });
  37. export default store;