|
@@ -43,16 +43,61 @@ const router = new VueRouter({
|
|
|
routes
|
|
|
})
|
|
|
|
|
|
-
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
if (to.path == '/login') {
|
|
|
sessionStorage.clear();
|
|
|
}
|
|
|
|
|
|
let user = JSON.parse(sessionStorage.getItem('user'));
|
|
|
- if (!user && to.path != '/login') {
|
|
|
+ if (!user && to.path != '/login' && to.path != '/404') {
|
|
|
+ console.log(11123)
|
|
|
next({ path: '/login' })
|
|
|
} else {
|
|
|
+ if(to.path == '/login'){
|
|
|
+ var url = location.hash;
|
|
|
+ var theRequest = new Object();
|
|
|
+ if (url.indexOf("?") != -1) {
|
|
|
+ var str = url.split("?")[1].substr(1);
|
|
|
+ var strs = str.split("&");
|
|
|
+ for(var i = 0; i < strs.length; i ++) {
|
|
|
+ theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
|
|
|
+ }
|
|
|
+ Vue.prototype.$indicator.open();
|
|
|
+ Vue.prototype.http.post(Vue.prototype.port.manage.login, {
|
|
|
+ "loginName": theRequest.sername,
|
|
|
+ "password": theRequest.password,
|
|
|
+ } , res => {
|
|
|
+ Vue.prototype.$indicator.close();
|
|
|
+ if (res.code == "ok") {
|
|
|
+ sessionStorage.setItem('user', JSON.stringify(res.data));
|
|
|
+ var str = '';
|
|
|
+ for(var i in res.data.functions) {
|
|
|
+ str += res.data.functions[i].code + ",";
|
|
|
+ }
|
|
|
+ sessionStorage.setItem('power',str);
|
|
|
+ sessionStorage.setItem('assetsTab',-1);
|
|
|
+ next({ path: '/assets' });
|
|
|
+ } else {
|
|
|
+ Vue.prototype.$toast({
|
|
|
+ message: res.msg,
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ next({ path: '/404' });
|
|
|
+ }
|
|
|
+ }, error => {
|
|
|
+ Vue.prototype.$indicator.close();
|
|
|
+ Vue.prototype.$toast({
|
|
|
+ message: error,
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ next({ path: '/404' });
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ next();
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
if(to.path == '/assets' || to.path == '/data' || to.path == '/my') {
|
|
|
$(".tabber").show();
|
|
|
} else {
|