feat: add avatar payments and finance management
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useUserStore = defineStore('user', {
|
||||
state: () => ({ token: '', userId: '', nickname: '', avatarUrl: '', initialized: false }),
|
||||
getters: { isLogin: state => Boolean(state.token) },
|
||||
actions: {
|
||||
init() {
|
||||
this.$patch({
|
||||
token: uni.getStorageSync('hh_token') || '',
|
||||
userId: uni.getStorageSync('hh_userId') || '',
|
||||
nickname: uni.getStorageSync('hh_nickname') || '',
|
||||
avatarUrl: uni.getStorageSync('hh_avatarUrl') || '',
|
||||
initialized: true
|
||||
})
|
||||
},
|
||||
applySession(session) {
|
||||
this.$patch(session)
|
||||
uni.setStorageSync('hh_token', this.token)
|
||||
uni.setStorageSync('hh_userId', this.userId)
|
||||
uni.setStorageSync('hh_nickname', this.nickname)
|
||||
uni.setStorageSync('hh_avatarUrl', this.avatarUrl)
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user