user.js 697 B

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. common_vendor.defineStore("user", {
  4. state: () => {
  5. return {
  6. token: null,
  7. nickname: null,
  8. avatar: null,
  9. ad: null,
  10. adUnitId: null
  11. };
  12. },
  13. actions: {
  14. /*
  15. 记录token
  16. */
  17. login(info) {
  18. this.$state = info;
  19. this.save();
  20. },
  21. /*
  22. 个人信息
  23. */
  24. setInfo(info) {
  25. this.nickname = info.nickname;
  26. this.avatar = info.avatar;
  27. },
  28. /* 本地保存 */
  29. save() {
  30. common_vendor.index.setStorageSync("userInfo", {
  31. token: this.token,
  32. nickname: this.nickname,
  33. avatar: this.avatar
  34. });
  35. }
  36. }
  37. });