Ver código fonte

Merge remote-tracking branch 'origin/master'

459242451@qq.com 3 anos atrás
pai
commit
e115969a6b

+ 3 - 1
index.html

@@ -184,7 +184,9 @@
     </script>
 </head>
 
-<body>
+<body style="position: fixed;background-color: #112692;
+    width: 100%;
+    height: 100%;">
     <div id="app"></div>
     <script type="module" src="/src/main.ts"></script>
 </body>

+ 3 - 1
src/api/resource.ts

@@ -10,16 +10,18 @@ export interface ResourceListItem {
   longitude?: string; // 经度
   latitude?: string; //纬度
   manageUnit?: string; //管理单位
+  carType?: string;
   num?: number; // 数量
   carryGoods?: null; //携带物资(应急时)
   contactName?: string; //联系人
   contactPhone?: string; //联系电话
-  updateTime?:string;
+  updateTime?: string;
 }
 
 export interface GetResourceListParams {
   name?: string;
   manageUnit?: string; // 管理单位
+  carType?: null;
   resourceType: 1 | 2 | 3; // 资源类型。1-仓库。2-队伍.3-车辆
 }
 

BIN
src/assets/card-bg/frame_czfa.png


BIN
src/assets/card-bg/frame_czfa@2x.png


BIN
src/assets/card-bg/frame_sgxc@2x.png


BIN
src/assets/card-bg/frame_sjlb.png


BIN
src/assets/card-bg/frame_sjxx@2x.png


BIN
src/assets/card-bg/frame_skjc@2x.png


BIN
src/assets/card-bg/frame_yjya@2x.png


BIN
src/assets/card-bg/frame_zhtx@2x.png


BIN
src/assets/header@2x.png


+ 5 - 2
src/components/Card/index.scss

@@ -36,11 +36,14 @@
         background-image: url('../../assets/card-bg/frame_information.png');
     }
     &-bg-incident-info {
-        background-image: url('../../assets/card-bg/frame_sjxx.png');
+        height: px2rem(468px * 2);
+        background-image: url('../../assets/card-bg/frame_sjxx@2x.png');
     }
     &-bg-command-chain {
         background-image: url('../../assets/card-bg/frame_zhtx@2x.png');
-        margin-top: px2rem(-63px * 2);
+        // margin-top: px2rem(-63px * 2);
+        height: px2rem(302px * 2);
+        margin-top: px2rem(20px * 2);
     }
     &-bg-incident-plan {
         margin-top: px2rem(20px *2);

+ 6 - 0
src/components/MarkerMap/constants.ts

@@ -163,3 +163,9 @@ export const SINGLE_PAWN = [
     locations: '118.269259,33.974288',
   },
 ];
+
+export const BASE_URL = 'http://61.147.254.211:30876/YJZH-SQ/api';
+export const BASE_USER_URL = 'http://61.147.254.211:30876/tpbd-cas';
+export const BASE_RESOURCE_URL =
+  BASE_URL + '/common/download/resource?resource=';
+export const LOGIN_URL = 'http://61.147.254.211:9999/home/#/login';

+ 1 - 1
src/components/MarkerMap/dialog.ts

@@ -139,7 +139,7 @@ export const GET_VEHICLES_DIALOG_HTML = (item: ResourceItemDetail) => {
       <div class="content">
         <div><span>车牌号:</span><span>${item.name ?? '-'}</span></div>
         <div><span>管理单位:</span><span>${item.manageUnit ?? '-'}</span></div>
-        <div><span>车辆类型:</span><span>-</span></div>
+        <div><span>车辆类型:</span><span>${item.carType ?? '-'}</span></div>
       </div>
       <i class="card-border-bottom-left"></i>
       <i class="card-border-bottom-right"></i>

+ 5 - 0
src/constants/constants.ts

@@ -14,3 +14,8 @@ export const DA_HUA = {
 
 export const DA_HUA_URL_PREFIX =
   DA_HUA.host + '://' + DA_HUA.ip + ':' + DA_HUA.port;
+export const BASE_URL = 'http://61.147.254.211:30876/YJZH-SQ/api';
+export const BASE_USER_URL = 'http://61.147.254.211:30876/tpbd-cas';
+export const BASE_RESOURCE_URL =
+  BASE_URL + '/common/download/resource?resource=';
+export const LOGIN_URL = 'http://61.147.254.211:9999/home/#/login';

+ 45 - 8
src/router/index.ts

@@ -7,7 +7,8 @@ import {
 } from 'vue-router';
 import NProgress from 'nprogress';
 import { BaseLoginUrl } from '@/constants/constants';
-
+import { api_gettokenByTicket } from '@/service/login';
+import { LOGIN_URL } from "@/constants/constants"
 const BaseLayout = () =>
   import(/* webpackChunkName: "BaseLayout" */ '@/layout/BaseLayout');
 
@@ -63,16 +64,52 @@ router.beforeEach(async (to, from) => {
 
   const main = useMainStore();
 
-  if (!to.query.ticket && !window.localStorage.getItem('Authorization')) {
-    window.location.href = BaseLoginUrl;
-    return false;
-  }
+  // if (to.query.ticket) { 
+  //    return await main.getUserInfo(to.query.ticket as string);
+  // }
+  //   if (!to.query.ticket && !window.localStorage.getItem('Authorization')) {
+  //     window.location.href = BaseLoginUrl;
+  //     return false;
+  //   }
 
-  if (to.query.ticket && !window.localStorage.getItem('Authorization')) {
-    return await main.getUserInfo(to.query.ticket as string);
+  // if (to.query.ticket && !window.localStorage.getItem('Authorization')) {
+  //   return await main.getUserInfo(to.query.ticket as string);
+  // }
+  var route = router.currentRoute.value;
+  var islogin = false;
+  // debugger
+  //判断url是否含有ticket
+  if (route.query.ticket != undefined && route.query.ticket != null) {
+    //存在ticket 根据ticket获取token 并保存清除ticket
+    api_gettokenByTicket((route.query.ticket as string) ?? '').then((res) => {
+      console.log(res);
+      window.localStorage.setItem('userdata', JSON.stringify(res.data));
+      let newQuery = JSON.parse(JSON.stringify(route.query)); // 深拷贝
+      delete newQuery.ticket;
+      islogin =true;
+      router.replace({ query: newQuery });
+      setTimeout(() => {
+        location.reload();
+      }, 1000);
+    });
+  } else {
+    let userinfojson = window.localStorage.getItem('userdata');
+    if (userinfojson != undefined || userinfojson != null) {
+      islogin = true;
+    } else { 
+       setTimeout(() => {
+          window.location.href = LOGIN_URL;
+       }, 1000);
+      
+    }
+    // if (!islogin) {
+    //   // debuggerlocation.reload();
+    //   // location.reload();
+      // window.location.href = LOGIN_URL;
+    // }
   }
 
-  main.clearReqToken();
+  // main.clearReqToken();
   return true;
 });
 router.afterEach((to) => {

+ 23 - 0
src/service/login.ts

@@ -0,0 +1,23 @@
+import request from "@/utils/request";
+import { BASE_USER_URL } from "@/constants/constants";
+
+
+
+export const api_gettokenByTicket = (ticket:string) => { 
+   return request<Object>('GET', {
+     url: `${BASE_USER_URL}/user?ticket=${ticket}`
+   });
+}
+
+
+  
+function docheck() { 
+  var token = localStorage.getItem("token");
+  if (token == null || token == undefined || token == "undefined") {
+    if (window.location.href.indexOf("login") == -1) {
+
+    }
+    return false;
+  }
+  return true;
+}

+ 1 - 1
src/store/useMainStore.ts

@@ -47,7 +47,7 @@ export default defineStore<'main', MainStateType, {}, MainActionsType>('main', {
           data: { accessToken, ...userInfo },
         } = await getUserInfo(ticket);
         if (accessToken) {
-          window.localStorage.setItem('Authorization', accessToken);
+          // window.localStorage.setItem('Authorization', accessToken);
         }
         this.userInfo = userInfo;
         return true;

+ 21 - 8
src/utils/request.ts

@@ -4,7 +4,7 @@ import { ElMessage } from 'element-plus';
 import useMainStore from '@/store/useMainStore';
 import { BaseLoginUrl, DA_HUA_URL_PREFIX } from '@/constants/constants';
 import { useDaHuaStore } from '@/store';
-
+import { LOGIN_URL, BASE_URL } from '@/constants/constants';
 // const baseURL =
 //   process.env.NODE_ENV === 'production'
 //     ? 'http://sqpcbg.xt.wenhq.top:8083/api'
@@ -37,12 +37,17 @@ axios.interceptors.response.use(
           // message: `401. 没有权限访问该接口: ${res.config.url}`,
           message: `401. 没有权限访问该接口`,
         });
-        const main = useMainStore();
-        main.clearReqToken();
-        window.localStorage.setItem('Authorization', '');
-        window.location.href = BaseLoginUrl;
+        if (res.data.data.indexOf('Jwt expired') != -1) {
+           debugger
+           window.localStorage.removeItem('userdata');
+           window.location.href = LOGIN_URL;
+         }
+        // const main = useMainStore();
+        // main.clearReqToken();
+        // window.localStorage.setItem('Authorization', '');
+        // window.location.href = BaseLoginUrl;
 
-        throw Error(res.statusText);
+        // throw Error(res.statusText);
       }
       if (res.data?.code === 404) {
         ElMessage.error({ message: '404. 未找到该接口!' });
@@ -65,6 +70,11 @@ axios.interceptors.response.use(
     }
 
     if (res.status >= 500) {
+      if (res.data?.message == 'invalid ticket') {
+        debugger
+        window.localStorage.removeItem('userdata');
+        window.location.href = LOGIN_URL;
+      }
       ElMessage.error({ message: '系统异常, 请稍后重试!' });
       throw Error(res.statusText);
     }
@@ -94,6 +104,10 @@ export default function request<T>(
   method: AxiosRequestConfig['method'] = 'GET',
   confifg: AxiosRequestConfig & {},
 ): Promise<T> {
+   var tokenkjson = window.localStorage.getItem('userdata');
+   tokenkjson = tokenkjson == null ? '{}' : tokenkjson;
+   tokenkjson = tokenkjson == undefined ? '{}' : tokenkjson;
+   tokenkjson = JSON.parse(tokenkjson);
   return axios.request({
     method,
     baseURL,
@@ -102,8 +116,7 @@ export default function request<T>(
       Accept: 'application/json',
       'Content-Type': 'application/json',
       AppId: '3bcb760743ea456faba29a1dfb247bf4',
-      Authorization:
-        'Bearer ' + window.localStorage.getItem('Authorization') ?? '',
+      Authorization: 'Bearer ' + tokenkjson['accessToken'],
       ...confifg.headers,
     },
   });

+ 6 - 1
src/views/IncidentDetail/index.scss

@@ -68,6 +68,11 @@
         }
     }
     
+    .sc {
+        background: url("../../assets/card-bg/frame_sjlb.png");
+        display: none;
+    }
+    
     .event-list-c {
         position: absolute;
         // top: px2rem(76px * 2);
@@ -78,7 +83,7 @@
         height: px2rem(475px * 2);
         background-color: red;
         z-index: 100;
-        background: url("../../assets/card-bg/frame_sjlb@2x.png");
+        background: url("../../assets/card-bg/frame_sjlb.png");
         background-size: 100% 100%;
         .elc-back {
             position: absolute;

+ 4 - 1
src/views/IncidentDetail/index.tsx

@@ -127,6 +127,7 @@ export default defineComponent({
 
     return () => (
       <>
+        <div class="sc"></div>
         <div class="incident-detail-page-container">
           {
             <div class="detail-left">
@@ -151,7 +152,9 @@ export default defineComponent({
                           <span>
                             {idx + 1}、
                             {item.createTime +
-                              ',【'+item.name+'】在' +
+                              ',【' +
+                              item.name +
+                              '】在' +
                               item.addr +
                               '处发生了' +
                               (commonStore.globalDict[