work_order/store/modules/app.js

28 lines
664 B
JavaScript

const state = {
userInfo: JSON.parse(uni.getStorageSync('user_info') || '{}') || {},
token: uni.getStorageSync('token') || ''
};
const mutations = {
SET_USERINFO(state, data) {
state.userInfo = data;
uni.setStorageSync('user_info', JSON.stringify(data));
},
LOGOUT(state) {
state.userInfo = {};
state.token = '';
uni.removeStorageSync('user_info');
uni.removeStorageSync('token');
uni.removeStorageSync('query');
},
SET_TOKEN(state, data) {
state.token = data.token;
uni.setStorageSync('token', data.token);
uni.setStorageSync('token_time', data.token_time);
},
};
export default {
state,
mutations,
};