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.

49 lines
1.1 KiB

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
4 months ago
4 months ago
  1. // stores/counterStore.js
  2. import { defineStore, createPinia } from 'pinia';
  3. const store = createPinia();
  4. export const userStore = defineStore({
  5. id: 'userStore',
  6. state: () => ({
  7. token: uni.getStorageSync('token')?uni.getStorageSync('token'):'2f58eb3901ec4396a33cc015b9b1c28c',
  8. loginInfo: uni.getStorageSync('loginInfo')?uni.getStorageSync('loginInfo'):{},
  9. userInfo: {
  10. idCard: '',
  11. name: ''
  12. },
  13. chooseHouse: {
  14. "roomNum": "",
  15. "houseType": '',
  16. "houseTypeName": '',
  17. "communityId": '',
  18. "communityName": '',
  19. "userName": 0,
  20. "idNo": "用户身份证号",
  21. "houseId": '',
  22. }
  23. }),
  24. actions: {
  25. upDateToken(token) {
  26. this.token = token
  27. uni.setStorageSync('token', token)
  28. },
  29. upDateLoginInfo(info) {
  30. console.log('没来这里么?')
  31. this.loginInfo = info
  32. uni.setStorageSync('loginInfo', info)
  33. },
  34. upDateHouse(key, value) {
  35. this.chooseHouse[key] = value
  36. console.log(this.chooseHouse)
  37. },
  38. upDateUseInfo(key, value) {
  39. this.userInfo[key] = value
  40. console.log(this.userInfo)
  41. }
  42. },
  43. });
  44. export function useUserStoreHook() {
  45. return userStore(store);
  46. }