You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.1 KiB

4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
4 months ago
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const store = common_vendor.createPinia();
  4. const userStore = common_vendor.defineStore({
  5. id: "userStore",
  6. state: () => ({
  7. token: common_vendor.index.getStorageSync("token") ? common_vendor.index.getStorageSync("token") : "",
  8. loginInfo: common_vendor.index.getStorageSync("loginInfo") ? common_vendor.index.getStorageSync("loginInfo") : {},
  9. userInfo: {
  10. idCard: "",
  11. name: "",
  12. myHouse: null
  13. },
  14. chooseHouse: {
  15. "roomNum": "",
  16. "houseType": "",
  17. "houseTypeName": "",
  18. "communityId": "",
  19. "communityName": "",
  20. "userName": "",
  21. "idNo": "",
  22. "houseId": ""
  23. },
  24. timer: null
  25. }),
  26. actions: {
  27. upDateToken(token) {
  28. console.log("没到storeToken么?");
  29. this.token = token;
  30. console.log(this.token);
  31. common_vendor.index.setStorageSync("token", token);
  32. },
  33. upDateLoginInfo(info) {
  34. this.loginInfo = info;
  35. common_vendor.index.setStorageSync("loginInfo", info);
  36. },
  37. upDateHouse(key, value) {
  38. this.chooseHouse[key] = value;
  39. console.log(this.chooseHouse);
  40. },
  41. upDateUseInfo(key, value) {
  42. this.userInfo[key] = value;
  43. console.log(this.userInfo);
  44. },
  45. goLogin() {
  46. this.openid = "";
  47. this.token = "";
  48. this.loginInfo = {};
  49. for (let key in this.loginInfo) {
  50. this.chooseHouse[key] = "";
  51. }
  52. common_vendor.index.clearStorage();
  53. const pages = getCurrentPages();
  54. const page = pages[pages.length - 1].$page.fullPath;
  55. let url = "/pages/subPage/login/login";
  56. if (page != url) {
  57. console.log("当前页面");
  58. console.log(page);
  59. if (this.timer)
  60. clearTimeout(this.timer);
  61. this.timer = setTimeout(() => {
  62. common_vendor.index.navigateTo({
  63. url: url + "?redirect=" + page
  64. });
  65. this.timer = null;
  66. }, 1e3);
  67. }
  68. }
  69. }
  70. });
  71. function useUserStoreHook() {
  72. return userStore(store);
  73. }
  74. exports.useUserStoreHook = useUserStoreHook;
  75. exports.userStore = userStore;