51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
import {
|
|
defineStore
|
|
} from 'pinia';
|
|
|
|
|
|
export const useStore = defineStore('user', {
|
|
state: () => ({
|
|
userinfo: (uni.getStorageSync('user') && JSON.parse(uni.getStorageSync('user'))) || {},
|
|
token: uni.getStorageSync('token') || null,
|
|
role: uni.getStorageSync('role') || null,
|
|
allowPage: uni.getStorageSync('allowPage') || null,
|
|
position: uni.getStorageSync('position') || null,
|
|
positionSwitch: uni.getStorageSync('positionSwitch') || null,
|
|
wendu: uni.getStorageSync('wendu') || null,
|
|
wenduIcon: uni.getStorageSync('wenduIcon') || null,
|
|
isgray: uni.getStorageSync('isgray') || 0 //是否灰化
|
|
}),
|
|
getters: {
|
|
// uid: (state) => state.userinfo?.id
|
|
},
|
|
actions: {
|
|
setUserInfo(val) {
|
|
this.userinfo = val
|
|
},
|
|
setToken(val) {
|
|
this.token = val
|
|
},
|
|
setRole(val) {
|
|
this.role = val
|
|
},
|
|
/**设置定位信息*/
|
|
setPosition(val) {
|
|
this.position = val
|
|
},
|
|
/**设置定位开关*/
|
|
setPositionSwitch(val) {
|
|
this.positionSwitch = val
|
|
},
|
|
/**设置天气*/
|
|
setWeather(wendu, wenduIcon) {
|
|
this.wendu = wendu
|
|
this.wenduIcon = wenduIcon
|
|
},
|
|
setAllowPage(val) {
|
|
this.allowPage = val
|
|
},
|
|
setIsgray(val) {
|
|
this.isgray = val
|
|
}
|
|
},
|
|
}); |