/* * @Date: 2022-08-17 16:18:02 * @LastEditors: JinxChen * @LastEditTime: 2023-10-13 14:45:16 * @FilePath: \TelpoH5FrontendWeb\src\store\index.js * @description: */ import Vue from 'vue'; import Vuex from 'vuex'; import prefix from '@/store/prefix'; import { isNotNull } from '@/utils'; Vue.use(Vuex); export default new Vuex.Store({ state: { imei: '', // gatewayToken: '', //gateway接口token token: '', wxAuthCode: '', openId: '', appId: '', isFromWx: null, ssjlToken: '', fromSsjl: '', active: null, //点击左边树形图下标 tabClick: '', //心理监测点击tab appType: '', //应用类型 }, mutations: { imei(state, imei) { state.imei = imei; window.localStorage[ prefix + 'imei' ] = imei; }, gatewayToken(state, gatewayToken) { state.gatewayToken = gatewayToken; window.localStorage[prefix + 'gatewayToken'] = gatewayToken; }, token(state, token) { state.token = token; window.localStorage[prefix + 'token'] = token; }, wxAuthCode(state, wxAuthCode) { state.wxAuthCode = wxAuthCode; window.localStorage[prefix + 'wxAuthCode'] = wxAuthCode; }, openId(state, openId) { state.openId = openId; window.localStorage[prefix + 'openId'] = openId; }, appId(state, appId) { state.appId = appId; window.localStorage[prefix + 'appId'] = appId; }, isFromWx(state, isFromWx) { state.isFromWx = isFromWx; window.localStorage[prefix + 'isFromWx'] = isFromWx; }, ssjlToken(state, ssjlToken) { state.ssjlToken = ssjlToken; window.localStorage[prefix + 'ssjlToken'] = ssjlToken; }, fromSsjl(state, fromSsjl) { state.fromSsjl = fromSsjl; window.localStorage[prefix + 'fromSsjl'] = fromSsjl; }, active(state, active) { state.active = active; window.localStorage[prefix + 'active'] = active; }, tabClick(state, tabClick) { state.tabClick = tabClick; window.localStorage[prefix + 'tabClick'] = tabClick; }, appType(state, appType) { state.appType = appType; window.localStorage[prefix + 'appType'] = appType; }, }, getters: { imei: state => { if (isNotNull(state.imei)) return state.imei; else return window.localStorage[ prefix + 'imei' ] == null ? '' : window.localStorage[ prefix + 'imei' ]; }, gatewayToken: state => { if (state.gatewayToken != '') return state.gatewayToken; return window.localStorage[prefix + 'gatewayToken'] == null ? '' : window.localStorage[prefix + 'gatewayToken']; }, token: state => { if (state.token != '') return state.token; return window.localStorage[prefix + 'token'] == null ? '' : window.localStorage[prefix + 'token']; }, wxAuthCode: state => { if (state.wxAuthCode != '') return state.wxAuthCode; return window.localStorage[prefix + 'wxAuthCode'] == null ? '' : window.localStorage[prefix + 'wxAuthCode']; }, openId: state => { if (state.openId != '') return state.openId; return window.localStorage[prefix + 'openId'] == null ? '' : window.localStorage[prefix + 'openId']; }, appId: state => { if (state.appId != '') return state.appId; return window.localStorage[prefix + 'appId'] == null ? '' : window.localStorage[prefix + 'appId']; }, isFromWx: state => { if (state.isFromWx != '') return state.isFromWx; return window.localStorage[prefix + 'isFromWx'] == null ? '' : window.localStorage[prefix + 'isFromWx']; }, ssjlToken: state => { if (state.ssjlToken != '') return state.ssjlToken; return window.localStorage[prefix + 'ssjlToken'] == null ? '' : window.localStorage[prefix + 'ssjlToken']; }, fromSsjl: state => { if (state.fromSsjl != '') return state.fromSsjl; return window.localStorage[prefix + 'fromSsjl'] == null ? '' : window.localStorage[prefix + 'fromSsjl']; }, active: state => { if (state.active != '') return state.active; return window.localStorage[prefix + 'active'] == null ? '' : window.localStorage[prefix + 'active']; }, tabClick: state => { if (state.tabClick != '') return state.tabClick; return window.localStorage[prefix + 'tabClick'] == null ? '' : window.localStorage[prefix + 'tabClick']; }, appType: state => { if (state.appType != '') return state.appType; return window.localStorage[prefix + 'appType'] == null ? '' : window.localStorage[prefix + 'appType']; }, }, actions: {}, modules: {} });