From bb3f41765d5410105b0a45175fc83005c687db5a Mon Sep 17 00:00:00 2001 From: dai <851733175@qq.com> Date: Wed, 2 Nov 2022 16:51:51 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A5=BD=E5=83=8F=E6=98=AF=E5=A5=BD?= =?UTF-8?q?=E4=BA=86=20=E5=9C=B0=E5=9B=BE=E9=A3=9E=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 2 +- src/utils/dai-map.js | 39 +++++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/public/index.html b/public/index.html index e099cd9fc..c6e160baa 100644 --- a/public/index.html +++ b/public/index.html @@ -48,7 +48,7 @@ toLoadJs('https://map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77') } - console.log('============调试版本:1.0.2') + console.log('============调试版本:1.0.3') console.log('nodeEnv', window.SITE_CONFIG['nodeEnv']) diff --git a/src/utils/dai-map.js b/src/utils/dai-map.js index 2f852a730..1d2f4bb07 100644 --- a/src/utils/dai-map.js +++ b/src/utils/dai-map.js @@ -344,31 +344,38 @@ export default function init(ele, position, params) { this.setMarker = function (lat, lng, title = "位置") { lat = parseFloat(lat); lng = parseFloat(lng); + const style = { + externalGraphic: require("@/assets/img/common/map-poi.png"), + graphicWidth: 32, + graphicHeight: 32, + }; if (!this.marker) { //创建矢量图层 - var graphicLayer = new OpenLayers.Layer.Vector("graphicLayer", { + this.markerLayer = new OpenLayers.Layer.Vector("graphicLayer", { style: OpenLayers.Util.extend( {}, OpenLayers.Feature.Vector.style["default"] ), }); - this.map.addLayer(graphicLayer); - let pt = new OpenLayers.Geometry.Point(lng, lat); - var style = { - externalGraphic: require("@/assets/img/common/map-poi.png"), - graphicWidth: 32, - graphicHeight: 32, - }; - var feature = new OpenLayers.Feature.Vector(pt, null, style); - graphicLayer.addFeatures([feature]); - this.marker = feature; - this.markerLayer = graphicLayer; + this.map.addLayer(this.markerLayer); + this.marker = new OpenLayers.Feature.Vector( + new OpenLayers.Geometry.Point(lng, lat), + null, + style + ); + this.markerLayer.addFeatures([this.marker]); } else { console.log("this marker", this.marker); - // this.marker.geometry.x = lng; - // this.marker.geometry.y = lat; - this.marker.geometry = new OpenLayers.Geometry.Point(lng, lat); - + this.marker.geometry.x = 0; + this.marker.geometry.y = 0; + this.marker.geometry.destroy(); + this.markerLayer.removeFeatures([this.marker]); + this.marker = new OpenLayers.Feature.Vector( + new OpenLayers.Geometry.Point(lng, lat), + null, + style + ); + // this.markerLayer.addFeatures([this.marker]); this.markerLayer.redraw(); console.log("redraw", this.marker); } From e8b501dc837437d357a9847251969eb0c297ac03 Mon Sep 17 00:00:00 2001 From: dai <851733175@qq.com> Date: Wed, 2 Nov 2022 17:33:37 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=B1=B1=E4=B8=9C=E9=80=9A=E7=99=BB?= =?UTF-8?q?=E5=BD=95=20=E5=88=9A=E8=BF=9B=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 2 +- src/router/index-yantai-zhengwu.js | 557 +++++++++++++++++++ src/utils/yantai-transit-sdt.js | 17 + src/views/pages/yantai-login-transit-sdt.vue | 93 ++++ src/views/pages/yantai-login-transit.vue | 2 +- 5 files changed, 669 insertions(+), 2 deletions(-) create mode 100644 src/router/index-yantai-zhengwu.js create mode 100644 src/utils/yantai-transit-sdt.js create mode 100644 src/views/pages/yantai-login-transit-sdt.vue diff --git a/src/main.js b/src/main.js index f5f3634b1..83da7bbc3 100644 --- a/src/main.js +++ b/src/main.js @@ -5,7 +5,7 @@ import Element from "element-ui"; import App from "@/App"; import i18n from "@/i18n"; -import router from "@/router"; +import router from "@/router/index-yantai-zhengwu.js"; import "@/icons"; import "@/element-ui/theme/index.css"; import "@/assets/scss/aui.scss"; diff --git a/src/router/index-yantai-zhengwu.js b/src/router/index-yantai-zhengwu.js new file mode 100644 index 000000000..6e65e5e63 --- /dev/null +++ b/src/router/index-yantai-zhengwu.js @@ -0,0 +1,557 @@ +import Vue from "vue"; +import Router from "vue-router"; +import http from "@/utils/request"; +import { isURL } from "@/utils/validate"; +import store from "@/js/store"; + +Vue.use(Router); + +const CUSTOMER = process.env.VUE_APP_CUSTOMER; +// 页面路由(独立页面) +export const pageRoutes = [ + { + path: "/404", + component: () => import("@/views/pages/404"), + name: "404", + meta: { + title: "404未找到", + }, + beforeEnter(to, from, next) { + // 拦截处理特殊业务场景 + // 如果, 重定向路由包含__双下划线, 为临时添加路由 + if (/__.*/.test(to.redirectedFrom)) { + return next(to.redirectedFrom.replace(/__.*/, "")); + } + next(); + }, + }, + { + path: "/login-local", + component: () => { + return CUSTOMER == "yantai" + ? import("@/views/pages/yantai-login") + : import("@/views/pages/login"); + }, + name: "login-local", + meta: { + title: "登录", + }, + }, + { + path: "/login_sdt", + component: () => { + return import("@/views/pages/yantai-login-transit-sdt"); + }, + name: "login_sdt", + meta: { + title: "登录", + }, + }, +// { +// path: "/login_sdt", +// name: "login_sdt2", +// meta: { +// title: "登录", +// }, +// redirect: { +// name: "login_sdt", +// }, +// }, + { + path: "/login/", + component: () => { + return import("@/views/pages/yantai-login-transit"); + }, + name: "login", + meta: { + title: "登录", + }, + }, + { + path: "/login", + name: "login2", + meta: { + title: "登录", + }, + redirect: { + name: "login", + }, + }, + { + path: "/", + name: "index", + component: () => { + return CUSTOMER == "yantai" + ? import("@/views/pages/yantai-index") + : import("@/views/pages/index"); + }, + }, + { + path: "/indexWork", + name: "indexWork", + redirect: { + name: "index", + }, + }, + { + path: "/caiji/:id", + props: true, + name: "caiji", + component: () => import("@/views/pages/caiji"), + meta: { + title: "居民信息填报", + }, + }, + { + path: "/caijisuccess", + props: true, + name: "caijisuccess", + component: () => import("@/views/pages/caijisuccess"), + meta: { + title: "居民信息填报", + }, + }, + { + path: "/staffRegister", + props: true, + name: "staffRegister", + component: () => import("@/views/pages/staffRegister"), + meta: { + title: "员工登记", + }, + }, + { + path: "/staffRegisterSuccess", + props: true, + name: "staffRegisterSuccess", + component: () => import("@/views/pages/staffRegisterSuccess"), + meta: { + title: "员工登记", + }, + }, +]; + +// 模块路由(基于主入口布局页面) +export const moduleRoutes = { + path: "/main", + component: () => import("@/views/main"), + name: "main", + redirect: { + path: "/main/shequ-index", + }, + meta: { + title: "主入口布局", + }, + children: [ + { + path: "/home", + component: () => import("@/views/modules/home"), + name: "home", + meta: { + title: "主页", + isTab: true, + }, + }, + { + path: "unopen", + component: () => import("@/views/modules/unopen"), + name: "unopen", + meta: { + title: "未开放功能", + isTab: true, + }, + }, + { + path: "404", + props: true, + component: () => import("@/views/modules/404"), + name: "main-404", + meta: { + title: "页面未找到或无权访问", + isTab: false, + }, + }, + ], +}; + +// pc端菜单的 如果没有配置 默认的 或者配置了默认的 但没有权限 默认选中第一 +function cookApiDataItem(item) { + function n2one(v) { + let ret = []; + for (let i = 0; i < v.length; i++) { + // console.log("xxxxx", v[i]); + ret.push(v[i]); + if (Array.isArray(v[i].children) && v[i].children.length > 0) { + ret.push(...n2one(v[i].children)); + } + } + // console.log("aaaa", ret); + return ret; + } + + let allChildrenUrl = n2one(item.children) + .filter((i) => i.url != "" && i.showFlag == 1) + .map((i) => i.url); + // console.log("))))))))))))", allChildrenUrl); + + if (item.children.length > 0) { + if (item.url == "" || !allChildrenUrl.find((i) => i.url == item.url)) { + item.url = allChildrenUrl[0]; + } + } + // item.children.forEach((item) => { + // item.color = "#f00"; + // return item; + // }); + return item; +} +// 把按钮都化为页面内部的权限 +function cookApiDataItem2(item) { + let { children } = item; + if (children && Array.isArray(children) && children.length > 0) { + let btns = item.children.filter((item) => item.type == 1); + item.btns = btns; + item.children = item.children + .filter((val) => val.type == 0) + .map((val) => cookApiDataItem2(val)); + } + return item; +} + +// 模块路由(基于主入口布局页面) 可视化数据 +export const moduleShujuRoutes = { + path: "/main-shuju", + component: () => import("@/views/main-shuju/main"), + name: "main-shuju", + redirect: { + path: + CUSTOMER == "yantai" && process.env.VUE_APP_NODE_ENV == "prod" + ? "/main-shuju/i-1536625421829599234" + : "/main-shuju/visual-basicinfo-basicInfoMain", + }, + meta: { + title: "主入口布局", + }, + children: [ + { + path: "/main-shuju/visual-basicinfo-people/:uid", + props: true, + component: () => import("@/views/modules/visual/basicinfo/people"), + name: "visual-basicinfo-people", + meta: { + title: "个人详情", + isTab: false, + }, + }, + { + path: "/main-shuju/visual-basicinfo-people-list", + props: true, + component: () => import("@/views/modules/visual/basicinfo/peopleList"), + name: "visual-basicinfo-people-list", + meta: { + title: "人员列表", + isTab: false, + }, + }, + { + path: "404", + props: true, + component: () => import("@/views/modules/visual/404"), + name: "main-shuju-404", + meta: { + title: "页面未找到或无权访问", + isTab: false, + }, + }, + ], +}; + +export function addDynamicRoute(routeParams, router) { + // 组装路由名称, 并判断是否已添加, 如是: 则直接跳转 + var routeName = routeParams.routeName; + var dynamicRoute = window.SITE_CONFIG["dynamicRoutes"].filter( + (item) => item.name === routeName + )[0]; + if (dynamicRoute) { + return router.push({ + name: routeName, + params: routeParams.params, + }); + } + // 否则: 添加并全局变量保存, 再跳转 + dynamicRoute = { + path: routeName, + component: () => import(`@/views/modules/${routeParams.path}`), + name: routeName, + meta: { + ...window.SITE_CONFIG["contentTabDefault"], + menuId: routeParams.menuId, + title: `${routeParams.title}`, + }, + }; + router.addRoutes([ + { + ...moduleRoutes, + name: `main-dynamic__${dynamicRoute.name}`, + children: [dynamicRoute], + }, + ]); + window.SITE_CONFIG["dynamicRoutes"].push(dynamicRoute); + router.push({ + name: dynamicRoute.name, + params: routeParams.params, + }); +} + +const router = new Router({ + mode: "hash", + scrollBehavior: () => ({ + y: 0, + }), + routes: pageRoutes.concat(moduleRoutes, moduleShujuRoutes), +}); + +router.beforeEach((to, from, next) => { + // 添加动态(菜单)路由 + // 已添加或者当前路由为页面路由, 可直接访问 + if (to.name === "caiji") { + return next(); + } + if ( + window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] || + fnCurrentRouteIsPageRoute(to, pageRoutes) + ) { + return next(); + } + + const customerId = localStorage.getItem("customerId"); + console.log("customerId:", customerId); + + http + .get("gov/access/menu/navDigitalCommunity?tableName=data_menu") + .then(({ data: res }) => { + if (res.code == 10005 || res.code == 10006 || res.code == 10007) { + // 10005 token为空 10006登陆超时 10007别处登录 + console.log("登录失效"); + Vue.prototype.$message.error(res.msg); + return next({ + name: "login", + }); + } + + window.SITE_CONFIG["menuShujuList"] = res.data; + fnAddDynamicMenuRoutes2(window.SITE_CONFIG["menuShujuList"]); + + next({ + ...to, + replace: true, + }); + }) + .catch(() => { + next({ + name: "login", + }); + }); + + http + .get("gov/access/menu/navDigitalCommunity") + .then(({ data: res }) => { + if (res.code == 10005 || res.code == 10006 || res.code == 10007) { + // 10005 token为空 10006登陆超时 10007别处登录 + console.log("登录失效"); + Vue.prototype.$message.error(res.msg); + return next({ + name: "login", + }); + } + window.SITE_CONFIG["menuList"] = res.data + .map((item) => cookApiDataItem2(item)) + .map((item) => cookApiDataItem(item)); + fnAddDynamicMenuRoutes(window.SITE_CONFIG["menuList"]); + // next({ ...to, replace: true }) + next({ + ...to, + replace: true, + }); + }) + .catch(() => { + // next({ + // name: "login", + // }); + }); +}); + +/** + * 判断当前路由是否为页面路由 + * @param {*} route 当前路由 + * @param {*} pageRoutes 页面路由 + */ +function fnCurrentRouteIsPageRoute(route, pageRoutes = []) { + var temp = []; + for (var i = 0; i < pageRoutes.length; i++) { + if (route.path === pageRoutes[i].path) { + return true; + } + if (pageRoutes[i].children && pageRoutes[i].children.length >= 1) { + temp = temp.concat(pageRoutes[i].children); + } + } + return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false; +} + +/** + * 添加动态(菜单)路由 + * @param {*} menuList 菜单列表 + * @param {*} routes 递归创建的动态(菜单)路由 + */ +function fnAddDynamicMenuRoutes(menuList = [], routes = []) { + var temp = []; + for (var i = 0; i < menuList.length; i++) { + if (menuList[i].children && menuList[i].children.length >= 1) { + temp = temp.concat(menuList[i].children); + // continue; + } + // 组装路由 + var route = { + path: "", + component: null, + name: "", + meta: { + ...window.SITE_CONFIG["contentTabDefault"], + menuId: menuList[i].id, + title: menuList[i].name, + btns: menuList[i].btns || [], + }, + }; + // eslint-disable-next-line + let URL = (menuList[i].url || "").replace(/{{([^}}]+)?}}/g, (s1, s2) => + eval(s2) + ); // URL支持{{ window.xxx }}占位符变量 + if (isURL(URL)) { + if (menuList[i].children && menuList[i].children.length >= 1) { + let item = menuList[i].children.find( + (subMenu) => subMenu.url == menuList[i].url + ); + if (item) { + route["path"] = route["name"] = `i-${menuList[i].id}`; + route["redirect"] = `i-${item.id}`; + } else { + route["path"] = route["name"] = `i-${menuList[i].id}`; + route["meta"]["iframeURL"] = URL; + } + } else { + route["path"] = route["name"] = `i-${menuList[i].id}`; + route["meta"]["iframeURL"] = URL; + } + } else { + URL = URL.replace(/^\//, "").replace(/_/g, "-"); + if (URL.startsWith("unopen")) { + route["path"] = route["name"] = URL.replace(/\//g, "-"); + route["component"] = () => import(`@/views/modules/unopen`); + } else if (menuList[i].children && menuList[i].children.length >= 1) { + route["path"] = route["name"] = URL; + route["redirect"] = URL.replace(/\//g, "-"); + } else { + route["path"] = route["name"] = URL.replace(/\//g, "-"); + route["component"] = () => import(`@/views/modules/${URL}`); + } + } + routes.push(route); + } + if (temp.length >= 1) { + return fnAddDynamicMenuRoutes(temp, routes); + } + // routers.reverse(); + // 添加路由 + router.addRoutes([ + { + ...moduleRoutes, + name: "main-dynamic-menu", + children: routes, + }, + { + path: "/main/*", + redirect: { + path: "/main/404", + }, + }, + ]); + window.SITE_CONFIG["dynamicMenuRoutes"] = routes; + window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] = true; +} + +function fnAddDynamicMenuRoutes2(menuList = [], routes = []) { + var temp = []; + for (var i = 0; i < menuList.length; i++) { + if (menuList[i].children && menuList[i].children.length >= 1) { + temp = temp.concat(menuList[i].children); + continue; + } + // 组装路由 + var route = { + path: "", + component: null, + name: "", + meta: { + // ...window.SITE_CONFIG["contentTabDefault"], + menuId: menuList[i].id, + title: menuList[i].name, + }, + }; + // eslint-disable-next-line + let URL = (menuList[i].url || "").replace(/{{([^}}]+)?}}/g, (s1, s2) => + eval(s2) + ); // URL支持{{ window.xxx }}占位符变量 + if (isURL(URL)) { + if (menuList[i].children && menuList[i].children.length >= 1) { + let item = menuList[i].children.find( + (subMenu) => subMenu.url == menuList[i].url + ); + if (item) { + route["path"] = route["name"] = `i-${menuList[i].id}`; + route["redirect"] = `i-${item.id}`; + } else { + route["path"] = route["name"] = `i-${menuList[i].id}`; + route["meta"]["iframeURL"] = URL; + } + } else { + route["path"] = route["name"] = `i-${menuList[i].id}`; + route["meta"]["iframeURL"] = URL; + } + } else { + URL = URL.replace(/^\//, "").replace(/_/g, "-"); + if (URL.startsWith("unopen")) { + route["path"] = route["name"] = URL.replace(/\//g, "-"); + route["component"] = () => import(`@/views/modules/unopen`); + } else if (menuList[i].children && menuList[i].children.length >= 1) { + route["path"] = route["name"] = URL; + route["redirect"] = URL.replace(/\//g, "-"); + } else { + route["path"] = route["name"] = URL.replace(/\//g, "-"); + route["component"] = () => import(`@/views/modules/${URL}`); + } + } + routes.push(route); + } + if (temp.length >= 1) { + return fnAddDynamicMenuRoutes2(temp, routes); + } + // 添加路由 + router.addRoutes([ + { + ...moduleShujuRoutes, + name: "main-dynamic-menu-shuju", + children: routes, + }, + { + path: "/main-shuju/*", + redirect: { + path: "/main-shuju/404", + }, + }, + ]); + window.SITE_CONFIG["dynamicMenuRoutesShuju"] = routes; + window.SITE_CONFIG["dynamicMenuRoutesShujuHasAdded"] = true; +} + +export default router; diff --git a/src/utils/yantai-transit-sdt.js b/src/utils/yantai-transit-sdt.js new file mode 100644 index 000000000..4bc07df14 --- /dev/null +++ b/src/utils/yantai-transit-sdt.js @@ -0,0 +1,17 @@ +export function logout() { + let uriComponent = "http://172.20.46.177/epmet-oper-gov/#/login_sdt"; + let redirect_url = encodeURIComponent(uriComponent); + let url = + "http://59.206.205.195:80/sso/logout?client_id=1000009&redirect_url=" + + redirect_url; + // window.open(url, "_self"); +} + +export function toLoginPage() { + let uriComponent = "http://172.20.46.177/epmet-oper-gov/#/login_sdt"; + let redirect_url = encodeURIComponent(uriComponent); + let url = + "http://59.206.205.195:80/oauth2/authorize?appid=wwafa1a3005a15a672&response_type=code&scope=SCOPE&agentid=1001091&state=STATE&redirect_uri=" + + redirect_url; + window.open(url, "_self"); +} diff --git a/src/views/pages/yantai-login-transit-sdt.vue b/src/views/pages/yantai-login-transit-sdt.vue new file mode 100644 index 000000000..d7e03b62a --- /dev/null +++ b/src/views/pages/yantai-login-transit-sdt.vue @@ -0,0 +1,93 @@ + + + + + + + diff --git a/src/views/pages/yantai-login-transit.vue b/src/views/pages/yantai-login-transit.vue index d9008d41e..0aca5b6d6 100644 --- a/src/views/pages/yantai-login-transit.vue +++ b/src/views/pages/yantai-login-transit.vue @@ -53,7 +53,7 @@ export default { this.status = "success"; localStorage.setItem("customerId", data.customerId); localStorage.setItem("userType", "work"); - //localStorage.setItem("showHeader", "1"); + localStorage.setItem("loginType", "sso"); localStorage.setItem("token", data.token); this.$router.replace({ name: "index" }); } else { From 3e8bc39e8cea192a049206490bcf922eec72b51e Mon Sep 17 00:00:00 2001 From: dai <851733175@qq.com> Date: Wed, 2 Nov 2022 17:49:07 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=B1=B1=E4=B8=9C=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/pages/yantai-login-transit-sdt.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/pages/yantai-login-transit-sdt.vue b/src/views/pages/yantai-login-transit-sdt.vue index d7e03b62a..a09cac376 100644 --- a/src/views/pages/yantai-login-transit-sdt.vue +++ b/src/views/pages/yantai-login-transit-sdt.vue @@ -43,7 +43,7 @@ export default { methods: { //根据社区id获取小区列表 async login(client_code) { - const url = "/auth/thirdlogin/sso-govlogin-yantai/" + client_code; + const url = "/auth/thirdlogin/sso-govlogin-yantai-sdt/" + client_code; let params = {};