/* import Vue from 'vue'; import Vuex from 'vuex'; import getters from './getters'; import app from './modules/app'; Vue.use(Vuex); const store = new Vuex.Store({ modules: { app }, getters }); export default store; */ import Vue from 'vue'; import Vuex from 'vuex'; import prefix from '@/store/prefix'; import { isNotNull } from '@/services/utils-service'; Vue.use(Vuex); export default new Vuex.Store({ state: { authToken: '', userId: '', deviceId: '', code: '', serialNo: '', isAdmin: '', // 绑定时申请人是否管理员/家属 openId: '', bindSerialNo: '', //设备绑定成功时的输入的serialNo loginName: '', //用户登录用的手机号码 fenceNameList: '', //用户所拥有的全部围栏名字 familyNameList: '', //用户所拥有的全部亲情名字 currentAddressAndPostion: '', //导航界面用户当前地址 wxRecAuth: false, //获取微信第一次授权 familyShortKeyList: '', //亲情号码快捷键 isRegister: '', //判断用户是否是第一次进入公众号并且注册成功 isLogin: '', //判断用户是否是已经登录成功 gatewayToken: '', //gateway接口token isFromWx: '', //是否从微信过来的 uniPhone: '', //物联网卡号 roleUser: '', //身份角色, 1 学生; 2 长辈 deviceType: '', //设备类型 1 电子设备 2 手表 uploadinteval: '', //设备-手表采集频率 notJump: null, showLogin: '', //是否显示登录 watchRole: '', iotCardTitle: '', //物联网卡商名字 fromRuoter: null, deviceVersion: '', //设备版本号 ssjlToken: '', //b端接口token tabClick: '', //心理监测点击tab personId: '', //设备列表的personId uid: '' //心理相关用户的uid }, mutations: { authToken(state, token) { state.authToken = token; window.localStorage[prefix + 'authToken'] = token; }, ssjlToken(state, ssjlToken) { state.ssjlToken = ssjlToken; window.localStorage[prefix + 'ssjlToken'] = ssjlToken; }, userId(state, userId) { state.userId = userId; window.localStorage[prefix + 'userId'] = userId; }, deviceId(state, deviceId) { state.deviceId = deviceId; window.localStorage[prefix + 'deviceId'] = deviceId; }, code(state, code) { state.code = code; window.localStorage[prefix + 'code'] = code; }, serialNo(state, serialNo) { state.serialNo = serialNo; window.localStorage[prefix + 'serialNo'] = serialNo; }, isAdmin(state, isAdmin) { const result = isAdmin ? 1 : 0; state.isAdmin = result; window.localStorage[prefix + 'isAdmin'] = result; }, openId(state, openId) { state.openId = openId; window.localStorage[prefix + 'openId'] = openId; }, bindSerialNo(state, bindSerialNo) { state.bindSerialNo = bindSerialNo; window.localStorage[prefix + 'bindSerialNo'] = bindSerialNo; }, // 用户登录用的手机号码 loginName(state, loginName) { state.loginName = loginName; window.localStorage[prefix + 'loginName'] = loginName; }, // 圆形围栏和多边形围栏 fenceNameList(state, fenceNameList) { state.fenceNameList = fenceNameList; window.localStorage[prefix + 'fenceNameList'] = fenceNameList; }, // 亲情号码名字 familyNameList(state, familyNameList) { state.familyNameList = familyNameList; window.localStorage[prefix + 'familyNameList'] = familyNameList; }, // currentAddressAndPostion currentAddressAndPostion(state, currentAddressAndPostion) { state.currentAddressAndPostion = currentAddressAndPostion; window.localStorage[prefix + 'currentAddressAndPostion'] = currentAddressAndPostion; }, wxRecAuth(state, wxRecAuth) { state.wxRecAuth = wxRecAuth; window.localStorage[prefix + 'wxRecAuth'] = wxRecAuth; }, familyShortKeyList(state, familyShortKeyList) { state.familyShortKeyList = familyShortKeyList; window.localStorage[prefix + 'familyShortKeyList'] = familyShortKeyList; }, isRegister(state, isRegister) { state.isRegister = isRegister; window.localStorage[prefix + 'isRegister'] = isRegister; }, isLogin(state, isLogin) { state.isLogin = isLogin; window.localStorage[prefix + 'isLogin'] = isLogin; }, gatewayToken(state, gatewayToken) { state.gatewayToken = gatewayToken; window.localStorage[prefix + 'gatewayToken'] = gatewayToken; }, isFromWx(state, isFromWx) { state.isFromWx = isFromWx; window.localStorage[prefix + 'isFromWx'] = isFromWx; }, uniPhone(state, uniPhone) { state.uniPhone = uniPhone; window.localStorage[prefix + 'uniPhone'] = uniPhone; }, roleUser(state, roleUser) { state.roleUser = roleUser; window.localStorage[prefix + 'roleUser'] = roleUser; }, deviceType(state, deviceType) { state.deviceType = deviceType; window.localStorage[prefix + 'deviceType'] = deviceType; }, uploadinteval(state, uploadinteval) { state.uploadinteval = uploadinteval; window.localStorage[prefix + 'uploadinteval'] = uploadinteval; }, notJump(state, notJump) { state.notJump = notJump; window.localStorage[prefix + 'notJump'] = notJump; }, showLogin(state, showLogin) { state.showLogin = showLogin; window.localStorage[prefix + 'showLogin'] = showLogin; }, watchRole(state, watchRole) { state.watchRole = watchRole; window.localStorage[prefix + 'watchRole'] = watchRole; }, iotCardTitle(state, iotCardTitle) { state.iotCardTitle = iotCardTitle; window.localStorage[prefix + 'iotCardTitle'] = iotCardTitle; }, fromRuoter(state, fromRuoter) { state.fromRuoter = fromRuoter; window.localStorage[prefix + 'fromRuoter'] = fromRuoter; }, deviceVersion(state, deviceVersion) { state.deviceVersion = deviceVersion; window.localStorage[prefix + 'deviceVersion'] = deviceVersion; }, tabClick(state, tabClick) { state.tabClick = tabClick; window.localStorage[prefix + 'tabClick'] = tabClick; }, personId(state, personId) { state.personId = personId; window.localStorage[prefix + 'personId'] = personId; }, uid(state, uid) { state.uid = uid; window.localStorage[prefix + 'uid'] = uid; } }, getters: { authToken: state => { if (state.authToken != '') { return state.authToken; } else { return window.localStorage[prefix + 'authToken'] == null ? '' : window.localStorage[prefix + 'authToken']; } }, ssjlToken: state => { if (state.ssjlToken != '') { return state.ssjlToken; } else { return window.localStorage[prefix + 'ssjlToken'] == null ? '' : window.localStorage[prefix + 'ssjlToken']; } }, userId: state => { if (state.userId != '') return state.userId; return window.localStorage[prefix + 'userId'] == null ? '' : window.localStorage[prefix + 'userId']; }, deviceId: state => { if (state.deviceId != '') return state.deviceId; return window.localStorage[prefix + 'deviceId'] == null ? '' : window.localStorage[prefix + 'deviceId']; }, code: state => { if (state.code != '') return state.code; return window.localStorage[prefix + 'code'] == null ? '' : window.localStorage[prefix + 'code']; }, serialNo: state => { if (state.serialNo != '') return state.serialNo; return window.localStorage[prefix + 'serialNo'] == null ? '' : window.localStorage[prefix + 'serialNo']; }, isAdmin: state => { if (state.isAdmin != '') return state.isAdmin; return window.localStorage[prefix + 'isAdmin'] == null ? '' : window.localStorage[prefix + 'isAdmin']; }, openId: state => { if (state.openId != '') return state.openId; return window.localStorage[prefix + 'openId'] == null ? '' : window.localStorage[prefix + 'openId']; }, bindSerialNo: state => { if (state.bindSerialNo != '') return state.bindSerialNo; return window.localStorage[prefix + 'bindSerialNo'] == null ? '' : window.localStorage[prefix + 'bindSerialNo']; }, loginName: state => { if (state.loginName != '') return state.loginName; return window.localStorage[prefix + 'loginName'] == null ? '' : window.localStorage[prefix + 'loginName']; }, // 圆形围栏和多边形围栏 fenceNameList: state => { if (isNotNull(state.fenceNameList)) return state.fenceNameList; else return window.localStorage[prefix + 'fenceNameList'] == null ? '' : window.localStorage[prefix + 'fenceNameList']; }, familyNameList: state => { if (isNotNull(state.familyNameList)) return state.familyNameList; else return window.localStorage[prefix + 'familyNameList'] == null ? '' : window.localStorage[prefix + 'familyNameList']; }, // currentAddressAndPostion currentAddressAndPostion: state => { if (isNotNull(state.currentAddressAndPostion)) return state.currentAddressAndPostion; else return window.localStorage[prefix + 'currentAddressAndPostion'] == null ? '' : window.localStorage[prefix + 'currentAddressAndPostion']; }, wxRecAuth: state => { if (isNotNull(state.wxRecAuth)) return state.wxRecAuth; else return window.localStorage[prefix + 'wxRecAuth'] == null ? '' : window.localStorage[prefix + 'wxRecAuth']; }, familyShortKeyList: state => { if (state.familyShortKeyList != '') return state.familyShortKeyList; return window.localStorage[prefix + 'familyShortKeyList'] == null ? '' : window.localStorage[prefix + 'familyShortKeyList']; }, isRegister: state => { if (state.isRegister != '') return state.isRegister; return window.localStorage[prefix + 'isRegister'] == null ? '' : window.localStorage[prefix + 'isRegister']; }, isLogin: state => { if (state.isLogin != '') return state.isLogin; return window.localStorage[prefix + 'isLogin'] == null ? '' : window.localStorage[prefix + 'isLogin']; }, gatewayToken: state => { if (state.gatewayToken != '') return state.gatewayToken; return window.localStorage[prefix + 'gatewayToken'] == null ? '' : window.localStorage[prefix + 'gatewayToken']; }, isFromWx: state => { if (state.isFromWx != '') return state.isFromWx; return window.localStorage[prefix + 'isFromWx'] == null ? '' : window.localStorage[prefix + 'isFromWx']; }, uniPhone: state => { if (state.uniPhone != '') return state.uniPhone; return window.localStorage[prefix + 'uniPhone'] == null ? '' : window.localStorage[prefix + 'uniPhone']; }, roleUser: state => { if (state.roleUser != '') return state.roleUser; return window.localStorage[prefix + 'roleUser'] == null ? '' : window.localStorage[prefix + 'roleUser']; }, deviceType: state => { if (state.deviceType != '') return state.deviceType; return window.localStorage[prefix + 'deviceType'] == null ? '' : window.localStorage[prefix + 'deviceType']; }, uploadinteval: state => { if (state.uploadinteval != '') return state.uploadinteval; return window.localStorage[prefix + 'uploadinteval'] == null ? '' : window.localStorage[prefix + 'uploadinteval']; }, notJump: state => { if (state.notJump != '') return state.notJump; return window.localStorage[prefix + 'notJump'] == null ? '' : window.localStorage[prefix + 'notJump']; }, showLogin: state => { if (state.showLogin != '') return state.showLogin; return window.localStorage[prefix + 'showLogin'] == null ? '' : window.localStorage[prefix + 'showLogin']; }, watchRole: state => { if (state.watchRole != '') return state.watchRole; return window.localStorage[prefix + 'watchRole'] == null ? '' : window.localStorage[prefix + 'watchRole']; }, iotCardTitle: state => { if (state.iotCardTitle != '') return state.iotCardTitle; return window.localStorage[prefix + 'iotCardTitle'] == null ? '' : window.localStorage[prefix + 'iotCardTitle']; }, fromRuoter: state => { if (state.fromRuoter != '') return state.fromRuoter; return window.localStorage[prefix + 'fromRuoter'] == null ? '' : window.localStorage[prefix + 'fromRuoter']; }, deviceVersion: state => { if (state.deviceVersion != '') return state.deviceVersion; return window.localStorage[prefix + 'deviceVersion'] == null ? '' : window.localStorage[prefix + 'deviceVersion']; }, tabClick: state => { if (state.tabClick != '') return state.tabClick; return window.localStorage[prefix + 'tabClick'] == null ? '' : window.localStorage[prefix + 'tabClick']; }, personId: state => { if (state.personId != '') return state.personId; return window.localStorage[prefix + 'personId'] == null ? '' : window.localStorage[prefix + 'personId']; }, uid: state => { if (state.uid != '') return state.uid; return window.localStorage[prefix + 'uid'] == null ? '' : window.localStorage[prefix + 'uid']; } }, actions: {}, modules: {} });