| | |
| | | //在页面加载时读取sessionStorage里的状态信息 |
| | | if (sessionStorage.getItem("store") ) { |
| | | this.$store.replaceState(Object.assign({}, this.$store.state,JSON.parse(sessionStorage.getItem("store")))) |
| | | } |
| | | } |
| | | |
| | | // 判断是否已经登录 |
| | | if(!this.$store.state.login) { |
| | | this.$router.push('/'); |
| | | } |
| | | |
| | | //在页面刷新时将vuex里的信息保存到sessionStorage里 |
| | | window.addEventListener("beforeunload",()=>{ |
| | |
| | | |
| | | router.beforeEach((to, from, next) => { |
| | | iView.LoadingBar.start(); |
| | | if(store.state.login || to.path=='/') { // 判断是否登录 |
| | | // console.log(to.meta); |
| | | Util.title(to.meta.title); |
| | | next(); |
| | | }else{ |
| | | next('/'); |
| | | } |
| | | // console.log(to.meta); |
| | | Util.title(to.meta.title); |
| | | next(); |
| | | |
| | | }); |
| | | |
| | |
| | | |
| | | const store = new Vuex.Store({ |
| | | state: { |
| | | login: true, |
| | | login: false, |
| | | userName: '', |
| | | topNav: { |
| | | actionName: '/' |
| | |
| | | tbl:[] |
| | | } |
| | | }, |
| | | created: function() { |
| | | // 设置主导航 |
| | | this.$store.commit('setActiveName', 'control'); |
| | | |
| | | this.$bus.$emit('changePageState', 'control'); |
| | | }, |
| | | methods: { |
| | | setAutoComplete: function() { |
| | | this.autocomplete.data = []; // 初始化可搜索内容 |
| | |
| | | deep: true |
| | | } |
| | | }, |
| | | created: function() { |
| | | // 设置主导航 |
| | | this.$store.commit('setActiveName', 'history'); |
| | | |
| | | this.$bus.$emit('changePageState', 'history'); |
| | | }, |
| | | methods: { |
| | | showAlarmsSetting: function() { |
| | | this.alarmsModal = true; |
| | |
| | | county: item.county.trim(), |
| | | device_name: item.device_name.trim() |
| | | }); |
| | | //console.log(url); |
| | | // console.log(url); |
| | | _self.$router.replace ('/index/data/'+url+pageState+'/'); |
| | | } |
| | | } |
| | |
| | | imgs: mapImgSrc |
| | | } |
| | | }, |
| | | created: function() { |
| | | // 设置主导航 |
| | | this.$store.commit('setActiveName', 'home'); |
| | | }, |
| | | methods: { |
| | | // 查询地图中的坐标点 |
| | | searchMapDot: function() { |
| | |
| | | } |
| | | } |
| | | }, |
| | | created: function() { |
| | | sessionStorage.removeItem('store'); |
| | | }, |
| | | methods: { |
| | | handleSubmit(name) { |
| | | this.$refs[name].validate((valid) => { |
| | | if (valid) { |
| | | this.$store.commit('setLogin', true); |
| | | this.$store.commit('setUserName', this.user.name); |
| | | sessionStorage.setItem("store",JSON.stringify(this.$store.state)) |
| | | this.$router.push('/index'); |
| | | } else { |
| | | this.$Message.error('登录失败!用户名/密码错误'); |