|
|
// stores/counterStore.js
import { defineStore, createPinia } from 'pinia'; const store = createPinia();
export const userStore = defineStore({ id: 'userStore', state: () => ({ token: uni.getStorageSync('token')?uni.getStorageSync('token'):'2f58eb3901ec4396a33cc015b9b1c28c', loginInfo: uni.getStorageSync('loginInfo')?uni.getStorageSync('loginInfo'):{}, userInfo: { idCard: '', name: '' }, chooseHouse: { "roomNum": "", "houseType": '', "houseTypeName": '', "communityId": '', "communityName": '', "userName": 0, "idNo": "用户身份证号", "houseId": '', } }), actions: { upDateToken(token) { this.token = token uni.setStorageSync('token', token) }, upDateLoginInfo(info) { console.log('没来这里么?') this.loginInfo = info uni.setStorageSync('loginInfo', info) }, upDateHouse(key, value) { this.chooseHouse[key] = value console.log(this.chooseHouse) }, upDateUseInfo(key, value) { this.userInfo[key] = value console.log(this.userInfo) } }, });
export function useUserStoreHook() { return userStore(store); }
|