存入用户的account

master
吕天方 6 months ago
parent 141f0f504e
commit fcc9e2eb19

@ -4,7 +4,7 @@
* @Author: JC9527
* @Date: 2024-01-09 23:11:58
* @LastEditors: JC9527
* @LastEditTime: 2024-03-06 18:56:29
* @LastEditTime: 2024-09-03 20:12:27
*/
import request from "@/utils/request2"
@ -19,10 +19,11 @@ export function getTrend(params) {
// 事件概况统计
export function summarystat() {
export function summarystat(params) {
return request({
url: "/event/summary/stat",
method:'get',
params
})
}

@ -4,7 +4,7 @@
* @Author: JC9527
* @Date: 2024-01-09 23:08:15
* @LastEditors: JC9527
* @LastEditTime: 2024-05-16 11:20:06
* @LastEditTime: 2024-09-03 20:23:09
*/
import router from './router'
import store from './store'
@ -22,74 +22,53 @@ const whiteList = ['/login', '/register', '/bigScreen']
router.beforeEach((to, from, next) => {
NProgress.start()
// console.log('tototo',to.path);
if(localStorage.getItem('accessToken')) {
if(localStorage.getItem('accessToken') && localStorage.getItem('account')) {
next()
NProgress.done()
} else {
if (window.location.href.includes("code=")) {
var reg = new RegExp(/[?&]code=([^&#]+)/);
var c = window.location.href.match(reg);
const code = c && c[1];
getAccesstoken({code:code}).then(res=>{
// console.log(res,"res")
// setAccessToken(res.data.accessToken)
localStorage.setItem('accessToken',res.data.accessToken)
let url = window.location.href;
var modifiedUrl = url.replace(/[\?&](code)=.*?(#\/|$)/g, '');
// console.log(modifiedUrl,'modifiedUrl');
window.location.href = modifiedUrl;
// next()
NProgress.done()
// return getUserinfo({accessToken:res.data.accessToken})
})
// .then(res=>{
// localStorage.setItem('AuserInfo', JSON.stringify(el.data))
// })
} else {
location.href = "http://10.236.2.28:54567/bjh-admin/"
}
} else if (window.location.href.includes("code=")) {
var reg = new RegExp(/[?&]code=([^&#]+)/);
var c = window.location.href.match(reg);
const code = c && c[1];
getAccesstoken({code:code}).then(res=>{
// console.log(res,"res")
// setAccessToken(res.data.accessToken)
localStorage.setItem('accessToken',res.data.accessToken)
return getUserinfo({ accessToken: res.data.accessToken })
}).then(el=>{
// setToken(el.data.token)
localStorage.setItem('account',el.data.account)
let url = window.location.href;
var modifiedUrl = url.replace(/[\?&](code)=.*?(#\/|$)/g, '');
// console.log(modifiedUrl,'modifiedUrl');
window.location.href = modifiedUrl;
// next()
NProgress.done()
})
// .then(res=>{
// localStorage.setItem('AuserInfo', JSON.stringify(el.data))
// })
}
// next()
// if (getToken()) {
// else if(getToken()) {
// to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
// /* has token*/
// if (to.path === '/login') {
// next({ path: '/' })
// NProgress.done()
// } else {
// console.log('store.getters.roles',store.getters.roles)
// if (store.getters.roles.length === 0) {
// isRelogin.show = true
// // 判断当前用户是否已拉取完user_info信息
// store.dispatch('GetInfo').then(() => {
// isRelogin.show = false
// store.dispatch('GenerateRoutes').then(accessRoutes => {
// // 根据roles权限生成可访问的路由表
// router.addRoutes(accessRoutes) // 动态添加可访问路由表
// next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
// })
// }).catch(err => {
// store.dispatch('LogOut').then(() => {
// Message.error(err)
// next({ path: '/' })
// })
// })
// } else {
// if (store.getters.roles.length === 0) {
// // isRelogin.show = true
// // 判断当前用户是否已拉取完user_info信息
// store.dispatch('GetInfo').then(() => {
// isRelogin.show = false
// next()
// }
// }
// } else {
// // 没有token
// if (whiteList.indexOf(to.path) !== -1) {
// // 在免登录白名单,直接进入
// next()
// NProgress.done()
// }).catch(err => {
// })
// } else {
// next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
// next()
// NProgress.done()
// }
// }
// }
else {
location.href = "http://10.236.2.28:54567/bjh-admin/"
}
})
router.afterEach(() => {

@ -4,7 +4,7 @@
* @Author: JC9527
* @Date: 2023-08-15 09:44:13
* @LastEditors: JC9527
* @LastEditTime: 2024-09-02 18:56:45
* @LastEditTime: 2024-09-03 20:10:39
-->
<template>
<div class="left-wai-box">
@ -208,6 +208,7 @@ export default {
mapLoading:false,
personLoading:false,
isBreadcrumb:true,
account:"",
}
},
props: ['personLine', 'carLine'],
@ -300,11 +301,11 @@ export default {
MYsummarystat() {
//
summarystat().then(res => {
summarystat({account:this.account}).then(res => {
if (res.code == 200) this.MYsummarystatdata = res.data
})
//
tasksummarystat().then(res => {
tasksummarystat({account:this.account}).then(res => {
if (res.code == 200) this.tasksummarystatdata = res.data
})
},
@ -439,11 +440,9 @@ export default {
this.getDomHeight();
this.getEvent();
this.getOnline();
},
created() {
this.account = localStorage.getItem('account')
this.MYsummarystat()
}
},
}
</script>
<style lang="scss" scoped>

Loading…
Cancel
Save