vue2- store.js

齐起运
2023-12-01
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
state: {
LOADING: false,
scrollHeight: 800,
inputFlag: false,
user: {
username: "",
companyName: "",
phone: "",
code: "",
adress: "",
demand: ""
},
codeFlag: false, //h5获取更多
info: { //h5获取更多
username: "",
companyName: "",
phone: "",
code: "",
adress: "",
demand: ""
},
enterFlag: 1, //点击空白区区域菜单弹窗是否可关闭
dialogFlag: false, //菜单弹窗是否显示
personIcon: '', //营业厅顶部菜单头像地址
userName: '',//营业厅顶部菜单用户名
protalInfo: {}, //营业厅用户信息 头像
token: '', //token令牌
roleType: {}, //售电用户的默认信息 roleType
userInfo: {}, // getCompanyId()方法设置localStorage的用户信息 userId memberId memberName
moduleId:'', ///埋点的模块 必须传 energy_trading solution
isRefresh:false, //是否正在刷新token true请求延迟500m秒
},
mutations: {
SET_MODULEID(state, info) {
state.moduleId = info
},
SET_ISREFRESH(state, info) {
state.isRefresh = info
},
// isRefresh
SET_USERINFO(state, info) {
state.userInfo = info
window.localStorage.setItem('user_info', info)
},
SET_PROTAINFO(state, info) {
state.protalInfo = info
window.localStorage.setItem('protal_info', info)
},
SET_TOKEN(state, info) {
state.token = info
window.localStorage.setItem('access_token', info)
},
SET_ROLETYPE(state, info) {
state.roleType = info
window.localStorage.setItem('default_user', info)
},
showLoading(state) {
state.LOADING = true
},
hideLoading(state) {
state.LOADING = false
},
SET_HEIGHT: (state, scrollHeight) => {
state.scrollHeight = scrollHeight
},
SET_DISABLED: (state, flag) => {
state.inputFlag = flag
},
SET_CODE: (state, flag) => {
state.codeFlag = flag
},
SET_USER: (state, user) => {
state.user = user
},

},
actions: {
setIsRefresh({ commit }, info) {
commit('SET_ISREFRESH', info)
},
setModuleId({ commit }, info) {
commit('SET_MODULEID', info)
},
setUserinfo({ commit }, info) {
commit('SET_USERINFO', info)
},
setProtalinfo({ commit }, info) {
commit('SET_PROTAINFO', info)
},
setToken({ commit }, info) {
commit('SET_TOKEN', info)
},
setRoleType({ commit }, info) {
commit('SET_ROLETYPE', info)
}

},
getters: {
getInfo: (state) => {
if (window.localStorage.getItem('protal_info')) {
state.protalInfo= JSON.parse(window.localStorage.getItem('protal_info'));
}
return state.protalInfo;
}

}


})

转载于:https://www.cnblogs.com/dmwcq/p/11180872.html

 类似资料: