This commit is contained in:
parent
2cd8209171
commit
496057ae5c
|
@ -1,6 +1,7 @@
|
|||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
import { createRouter, createWebHashHistory } from "vue-router";
|
||||
import http from "@/utils/request.js";
|
||||
import tools from '@/utils/tools'
|
||||
import tools from "@/utils/tools";
|
||||
import { namespaceContextKey } from "element-plus";
|
||||
|
||||
const routerHistory = createWebHashHistory();
|
||||
|
||||
|
@ -8,83 +9,88 @@ const router = createRouter({
|
|||
history: routerHistory,
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
redirect: '/guide'
|
||||
path: "/",
|
||||
redirect: "/guide",
|
||||
},
|
||||
{
|
||||
name: '引导页',
|
||||
path: '/guide',
|
||||
component: () => import('../view/guide.vue'),
|
||||
name: "引导页",
|
||||
path: "/guide",
|
||||
component: () => import("../view/guide.vue"),
|
||||
},
|
||||
{
|
||||
path: '/home',
|
||||
component: () => import('../view/home.vue'),
|
||||
path: "/home",
|
||||
component: () => import("../view/home.vue"),
|
||||
children: [
|
||||
// {
|
||||
// name: '登录',
|
||||
// path: '/login/index',
|
||||
// component: () => import('../view/login/LoginZZD.vue'),
|
||||
// },
|
||||
{
|
||||
name: '首页',
|
||||
path: '/home/index',
|
||||
component: () => import('../view/sy.vue'),
|
||||
name: "首页",
|
||||
path: "/home/index",
|
||||
component: () => import("../view/sy.vue"),
|
||||
},
|
||||
{
|
||||
name: '养老',
|
||||
path: '/home/yl',
|
||||
component: () => import('../view/yl.vue'),
|
||||
name: "养老",
|
||||
path: "/home/yl",
|
||||
component: () => import("../view/yl.vue"),
|
||||
},
|
||||
{
|
||||
name: '卫生',
|
||||
path: '/home/hygiene',
|
||||
component: () => import('../view/hygiene.vue'),
|
||||
name: "卫生",
|
||||
path: "/home/hygiene",
|
||||
component: () => import("../view/hygiene.vue"),
|
||||
},
|
||||
{
|
||||
name: '教育',
|
||||
path: '/home/education',
|
||||
component: () => import('../view/education.vue'),
|
||||
name: "教育",
|
||||
path: "/home/education",
|
||||
component: () => import("../view/education.vue"),
|
||||
},
|
||||
{
|
||||
name: '就业补助',
|
||||
path: '/home/work',
|
||||
component: () => import('../view/work.vue'),
|
||||
name: "就业补助",
|
||||
path: "/home/work",
|
||||
component: () => import("../view/work.vue"),
|
||||
},
|
||||
{
|
||||
name: '智能分析',
|
||||
path: '/home/analyze',
|
||||
component: () => import('../view/analyze.vue'),
|
||||
name: "智能分析",
|
||||
path: "/home/analyze",
|
||||
component: () => import("../view/analyze.vue"),
|
||||
},
|
||||
{
|
||||
name: '首页地图',
|
||||
path: '/home/index/map',
|
||||
component: () => import('../view/sy_map.vue'),
|
||||
name: "首页地图",
|
||||
path: "/home/index/map",
|
||||
component: () => import("../view/sy_map.vue"),
|
||||
},
|
||||
{
|
||||
name: '首页表格',
|
||||
path: '/home/index/table',
|
||||
component: () => import('../view/sy_table.vue'),
|
||||
name: "首页表格",
|
||||
path: "/home/index/table",
|
||||
component: () => import("../view/sy_table.vue"),
|
||||
},
|
||||
{
|
||||
name: '首页表格详情',
|
||||
path: '/home/index/table/details',
|
||||
component: () => import('../view/sy_details.vue'),
|
||||
name: "首页表格详情",
|
||||
path: "/home/index/table/details",
|
||||
component: () => import("../view/sy_details.vue"),
|
||||
},
|
||||
{
|
||||
name: '人物图',
|
||||
path: '/home/index/person',
|
||||
component: () => import('../view/person/index.vue'),
|
||||
name: "人物图",
|
||||
path: "/home/index/person",
|
||||
component: () => import("../view/person/index.vue"),
|
||||
},
|
||||
// {
|
||||
// name: '地图编辑',
|
||||
// path: '/home/index/mapEdit',
|
||||
// component: () => import('../view/sy_map_fb.vue'),
|
||||
// },
|
||||
]
|
||||
],
|
||||
},
|
||||
]
|
||||
})
|
||||
],
|
||||
});
|
||||
|
||||
function getCookie(cname) {
|
||||
var cn = cname
|
||||
const cookies = document.cookie.split('; ');
|
||||
var cn = cname;
|
||||
const cookies = document.cookie.split("; ");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
const [name, value] = cookies[i].split('=');
|
||||
const [name, value] = cookies[i].split("=");
|
||||
if (name === cn) {
|
||||
return value;
|
||||
}
|
||||
|
@ -100,26 +106,35 @@ function getCookie(cname) {
|
|||
}
|
||||
|
||||
router.beforeEach((to, form, next) => {
|
||||
var token = getCookie('lytoken')
|
||||
// console.log('token', token)
|
||||
if (token == '') {
|
||||
window.location.href =
|
||||
'http://220.191.238.50:996/api/login?returnURL=' +
|
||||
window.location.href
|
||||
// var token = getCookie('lytoken')
|
||||
// // console.log('token', token)
|
||||
// if (token == '') {
|
||||
// window.location.href =
|
||||
// 'http://220.191.238.50:996/api/login?returnURL=' +
|
||||
// window.location.href
|
||||
// } else {
|
||||
// // http.get("/api/zzdn_event/auditToken?token=" + token).then((res) => {
|
||||
// // if (res.code == '500') {
|
||||
// // window.location.href =
|
||||
// // 'http://220.191.238.50:996/api/login?returnURL=' +
|
||||
// // window.location.href
|
||||
// // } else {
|
||||
// // tools.data.set('token',token)
|
||||
// next();
|
||||
// // }
|
||||
// // });
|
||||
// tools.data.set('token', token)
|
||||
// next();
|
||||
// }
|
||||
let type = tools.data.get("type");
|
||||
if (type) {
|
||||
console.log(1111);
|
||||
|
||||
next();
|
||||
} else {
|
||||
// http.get("/api/zzdn_event/auditToken?token=" + token).then((res) => {
|
||||
// if (res.code == '500') {
|
||||
// window.location.href =
|
||||
// 'http://220.191.238.50:996/api/login?returnURL=' +
|
||||
// window.location.href
|
||||
// } else {
|
||||
// tools.data.set('token',token)
|
||||
// next();
|
||||
// }
|
||||
// });
|
||||
tools.data.set('token', token)
|
||||
window.location.href = "http://localhost:8080/#/guide";
|
||||
next();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
export default router
|
||||
export default router;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import axios from "axios";
|
||||
import { ElMessage } from "element-plus";
|
||||
import tools from "@/utils/tools";
|
||||
|
||||
import dd from "gdt-jsapi";
|
||||
import router from "../router";
|
||||
// axios.defaults.baseURL = '/api'
|
||||
axios.defaults.timeout = 120000;
|
||||
|
|
|
@ -61,6 +61,9 @@
|
|||
<script setup>
|
||||
import { ref, onMounted, onUnmounted, reactive } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import http from "@/utils/request.js";
|
||||
import dd from "gdt-jsapi";
|
||||
|
||||
import tab1 from "@/assets/guide/tab1.png";
|
||||
import tab2 from "@/assets/guide/tab2.png";
|
||||
import tab3 from "@/assets/guide/tab3.png";
|
||||
|
@ -123,6 +126,79 @@ const stopDrag = () => {
|
|||
document.removeEventListener("mousemove", doDrag); // 销毁监听器
|
||||
document.removeEventListener("mouseup", stopDrag);
|
||||
};
|
||||
const getCookie = (cname) => {
|
||||
var cn = cname;
|
||||
const cookies = document.cookie.split("; ");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
const [name, value] = cookies[i].split("=");
|
||||
if (name === cn) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
// 登录
|
||||
const login = () => {
|
||||
// this.loading = true;
|
||||
// let ua = navigator.userAgent.toLowerCase();
|
||||
// let env = "pc";
|
||||
// const isMobile =
|
||||
// /ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/i.test(
|
||||
// ua
|
||||
// );
|
||||
// env = isMobile ? "move" : "pc";
|
||||
// console.log(ua, env, 333);
|
||||
console.log(111, dd.getAuthCode);
|
||||
dd.getAuthCode()
|
||||
.then((res) => {
|
||||
// let auth__code = env == "pc" ? res.auth_code : res.code;
|
||||
// console.log( 555,res, auth__code);
|
||||
http
|
||||
.post(`/api/sign_in/one_click_login?authCode=${res.auth_code}`)
|
||||
.then((response) => {
|
||||
if (response.code == 200) {
|
||||
console.log(1111, response);
|
||||
tools.data.set("token", response.data.token);
|
||||
// this.loading = false;
|
||||
// // 登录成功
|
||||
// if (!response.data.is_bind) {
|
||||
// this.isShowBind = true;
|
||||
// this.tenantUserId = response.data.tenant_user_id;
|
||||
// } else {
|
||||
// var user = {
|
||||
// token: response.data.token,
|
||||
// name: response.data.name,
|
||||
// id: response.data.id,
|
||||
// };
|
||||
// tools.data.set("user", user);
|
||||
// this.$message.success("登录成功");
|
||||
// this.$router.replace("/home");
|
||||
// }
|
||||
tools.data.set("type", 1);
|
||||
} else {
|
||||
// 前往绑定
|
||||
this.loading = false;
|
||||
ElMessage.error({
|
||||
message: "请重新登录!",
|
||||
offset: 100,
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
var token = getCookie("lytoken");
|
||||
// console.log('token', token)
|
||||
if (!token) {
|
||||
window.location.href =
|
||||
"http://220.191.238.50:996/api/login?returnURL=" +
|
||||
window.location.href;
|
||||
} else {
|
||||
tools.data.set("token", token);
|
||||
tools.data.set("type", 2);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onUnmounted(() => {
|
||||
// 清理事件监听器
|
||||
|
@ -137,16 +213,17 @@ const reset_font = () => {
|
|||
"scale(" + width / 1920 + "," + height / 1080 + ")";
|
||||
};
|
||||
onMounted(() => {
|
||||
let token = tools.data.get("token");
|
||||
login();
|
||||
// let token = tools.data.get("token");
|
||||
// console.log(token, "token");
|
||||
if (token == null) {
|
||||
ElMessage.error({
|
||||
message: "请重新登录!",
|
||||
offset: 100,
|
||||
});
|
||||
window.location.href =
|
||||
"http://220.191.238.50:996/api/login?returnURL=" + window.location.href;
|
||||
}
|
||||
// if (token == null) {
|
||||
// ElMessage.error({
|
||||
// message: "请重新登录!",
|
||||
// offset: 100,
|
||||
// });
|
||||
// window.location.href =
|
||||
// "http://220.191.238.50:996/api/login?returnURL=" + window.location.href;
|
||||
// }
|
||||
reset_font();
|
||||
reset_font();
|
||||
});
|
||||
|
@ -161,16 +238,16 @@ const tabData = reactive({
|
|||
PageUrl: "/home/index/table",
|
||||
tabList: [
|
||||
{
|
||||
name: "总体概况",
|
||||
name: "全局概览",
|
||||
img: tab1,
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
name: "要素一张图",
|
||||
name: "要素图谱",
|
||||
img: tab7,
|
||||
},
|
||||
{
|
||||
name: "评估模型",
|
||||
name: "评估体系",
|
||||
img: tab8,
|
||||
},
|
||||
// {
|
||||
|
@ -199,7 +276,7 @@ const tabData = reactive({
|
|||
img: png3,
|
||||
url: "/home/index",
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
img: png2,
|
||||
url: "/home/index/map",
|
||||
|
|
Loading…
Reference in New Issue