| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- import Vue from 'vue'
- import vuex from 'vuex'
- import Element from 'element-ui'
- import fabric from 'fabric'
- import 'element-ui/lib/theme-chalk/index.css';
- import "babel-polyfill"
- import router from '../router/index'
- import store from '../store/storeIndex'
- import App from '../App.vue'
- import {getAllDictByProject} from '../utils/gw_dictionary.js'
- import VueVideoPlayer from 'vue-video-player'
- import ol from 'openlayers'
- import Viewer from 'v-viewer'
- import 'viewerjs/dist/viewer.css'
- import 'video.js/dist/video-js.css'
- import {hasPriv,isProvince,hasMenu} from '../utils/gw_hasPriv.js'
- import {projTransform,geometryTransform} from '../views/zongHeXinXiOl/js/projTransform' // 坐标系转换
- import request from '@util/gw_ajax_request'
- import vRegion from 'v-region';
- import orgStatus from '../store/orgChange.js'
- import {getCookie,setCookie} from '../utils/gw_cookie.js'
- Vue.use(vRegion);
- Vue.use(VueVideoPlayer, /* {
- options: global default options,
- events: global videojs events
- } */)
- // 图片预览插件
- Vue.use(Viewer);
- Vue.use(fabric);
- Viewer.setDefaults({
- Options: {
- "inline": true,
- "button": true,
- "navbar": true,
- "title": true,
- "toolbar": true,
- "tooltip": true,
- "movable": true,
- "zoomable": true,
- "rotatable": true,
- "scalable": true,
- "transition": true,
- "fullscreen": true,
- "keyboard": true,
- "url": "data-source"
- }
- })
- getAllDictByProject();
- Vue.use(vuex);
- Vue.use(Element, {size: 'mini'})
- let token = GetQueryString('token');
- if (token) {
- } else {
- token = "";
- }
- console.log(token);
- localStorage.setItem('token', token);
- var url = window.location.href;
- if(url.indexOf("hncas")>-1){
- if(!GetQueryString('code')){
- window.location.href="http://zhsw.swt.hainan.gov.cn:9001/auth/oauth/authorize?response_type=code&client_id=vvye44ip9xi6tmz42v5dnr0w&redirect_uri=http://zhsw.swt.hainan.gov.cn:9000/"
- }else{
- window.location.href="http://zhsw.swt.hainan.gov.cn:9000/src/pages/gwDdIndex.html?code="+GetQueryString('code')
- }
- }
- function GetQueryString(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) return unescape(r[2]);
- return null;
- }
- function getParams(name) {
- var search = window.location.search.substring(1);
- if (!search) {
- search = window.location.hash.split("?")[1];
- }
- if (search) {
- var obj = JSON.parse(
- '{"' +
- decodeURIComponent(search)
- .replace(/"/g, '\\"')
- .replace(/&/g, '","')
- .replace(/=/g, '":"') +
- '"}'
- );
- return name ? obj[name] : obj;
- }
- }
- // if(url.indexOf("61.187.56.146")>-1){
- // import("./hnsljdxt_monitor");
- // }
- var v = new Vue({
- el: '#gwHzzApp',
- store,
- router,
- render: h => h(App),
- mounted: async function () {
- // //debugger
- let isUrl = "";
- let ticket = "";
- localStorage.setItem("sdUrl","");
- setCookie("sdUrl","")
- if ((url.indexOf("221.237.107.122")>-1) && GetQueryString('token')) {
- isUrl = "5101"
- ticket = GetQueryString('token');
- }
- // if ((url.indexOf("221.237.107.122")>-1) && !GetQueryString('token')) {
- // window.location.href="http://10.1.228.132:9969/wui/index.html?checkoutTo=e996a8fe-1660-4bc6-8e14-d367e4735a65"
- // }
- if (url.indexOf("fjcas") > -1) {
- window.location.href = "http://10.135.6.214:9170/oauth2.0/authorize?response_type=code&client_id=b8f102503faa451f95a6ecf4df17c5c3&redirect_uri=https://27.156.118.74:19901/src/pages/gwDdIndex.html";
- }
- if (url.indexOf("27.156.118.74") > -1 && GetQueryString('code')) {
- isUrl = "034"
- ticket = GetQueryString('code');
- }
- if (GetQueryString('ticket')) {
- isUrl = "036"
- ticket = GetQueryString('ticket');
- }
- if (GetQueryString('accessId')) {
- isUrl = "063"
- ticket = GetQueryString('accessId');
- }
- if (GetQueryString('ssophone')) {
- isUrl = "066"
- ticket = GetQueryString('ssophone');
- }
- if (url.indexOf("zhsw.swt.hainan.gov.cn") > -1 && GetQueryString('code')) {
- isUrl = "055"
- ticket = GetQueryString('code');
- }
- if (url.indexOf("60.208.113.79") > -1 && getParams('ticketKey')) {
- isUrl = "037"
- ticket = getParams('ticketKey');
- }
- if (ticket) {
- if (localStorage && (!localStorage.getItem('userid'))) {
- window.localStorage.clear();
- this.loginOut();
- await this.loginWithsso(ticket, isUrl);
- }else{
- if(window.location.href.indexOf("planCheckYear")>-1){
- localStorage.setItem("sdUrl","/planCheckYear");
- setCookie("sdUrl","/planCheckYear")
- }
- if(window.location.href.indexOf("home")>-1){
- localStorage.setItem("sdUrl","/home");
- setCookie("sdUrl","/home")
- }
- }
- } else {
- if (localStorage && (!localStorage.getItem('userid')) || !sessionStorage.getItem('privCollect')) {
- window.localStorage.clear();
- this.loginOut();
- if(window.location.href.indexOf("/sldchome")>-1){
- this.$router.push('/logindc');
- }
- else if(window.location.href.indexOf("/sljchome")>-1){
- this.$router.push('/loginjc');
- }else{
- this.$router.push('/login');
- }
- }
- }
- },
- methods: {
- loginOut() {
- if (localStorage.getItem('accessToken')) {
- request.get(`/bis/insp/logOut`)
- .then(res => {
- if (res.success) {
- } else {
- this.$message.warning(res.message);
- return;
- }
- })
- }
- },
- async loginWithsso(ticket,isP) {
- window.localStorage.clear();
- let url = "";
- let _self = this;
- if(isP=="034"){
- url = "/cas/fj/"
- }
- if(isP=="036"){
- url = "/sso/validateTicket/"
- }
- if(isP=="063"){
- url = "/sso/validateQhUser/"
- }
- if(isP=="066"){
- url = "/sso/validateXjbtUser/"
- }
- if(isP=="055"){
- url = "/cas/hn/"
- }
- if(isP=="037"){
- url = "/cas/sd/validateTicketKey"
- if(window.location.href.indexOf("planCheckYear")>-1){
- localStorage.setItem("sdUrl","/planCheckYear");
- setCookie("sdUrl","/planCheckYear")
- }
- if(window.location.href.indexOf("home")>-1){
- localStorage.setItem("sdUrl","/home");
- setCookie("sdUrl","/home")
- }
- }
- if(isP=="5101"){
- url = "/cas/cd/validateTicketKey"
- }
- try {
- // //debugger
- await request.get(url,{params:{'ticket': ticket}}).then(res => {
- console.log(ticket);
- if (res.success == true) {
- let token = res.data.token;
- let userid = res.data.guid;
- let loginName = res.data.persName;
- let guid = res.data.orgId;
- let orgNm = res.data.orgNm;
- let accessToken = res.accessToken; //token是否过期
- localStorage.setItem('token', token);
- localStorage.setItem('userid', userid);
- localStorage.setItem('account', loginName);
- localStorage.setItem('guid', guid);
- localStorage.setItem('orgNm', orgNm);
- localStorage.setItem('accessToken', accessToken);
- let persType = res.data.persType;
- let isAdmin = res.data.permission;
- localStorage.setItem('persType', persType);
- let allNode = JSON.stringify(res.data.allNode);//当前用户所在组信息
- let allOrg = JSON.stringify(res.data.allOrg);
- localStorage.setItem('isAdmin', isAdmin);
- let orgId = res.data.orgId;
- localStorage.setItem('orgId', orgId);
- localStorage.setItem('allOrg', allOrg);
- localStorage.setItem("currentOrgId", res.data.defaultOrg.orgId); //省级当前的机构id
- localStorage.setItem("currentRlcode", res.data.defaultOrg.rlcode); //省级当前的行政区划编码
- localStorage.setItem("departId", res.data.departId); //人员所属责任处室id-浙江
- localStorage.setItem("departNm", res.data.departNm); //人员所属责任处室名称-浙江
- // 改变全局adcode状态
- _self.$store.commit('changeAdCode', res.data.defaultOrg.rlcode);
- localStorage.setItem("currentOrgNm", res.data.defaultOrg.orgNm); //省级当前的机构名称
- localStorage.setItem('allNode', allNode);
- // _self.$message.success({
- // message: '登录成功',
- // duration: 700
- // });
- // window.location.reload();
- if(localStorage.getItem("sdUrl")){
- localStorage.setItem('ownApp','1')
- orgStatus.commit('changeSystem', '1')
- _self.$router.push(localStorage.getItem("sdUrl"))
- }else{
- _self.$router.push('/refresh')
- }
- }else {
- _self.$message(res.message);
- _self.loginOut();
- _self.$router.push('/login')
- }
- },(err)=>{
- _self.$message.error({
- message: '系统检查异常,请联系管理员',
- duration: 700
- });
- _self.loginOut();
- _self.$router.push('/login')
- })
- } catch (e) {
- }
- }
- },
- watch: {
- $route(to, from) {
- const flag = hasMenu(to)
- if(!flag && to.path!="/login" && to.path!="/loginjc" && to.path!="/"){
- this.$router.push(from.path)
- return false
- }
- console.log('路由变化' + to.path);
- if (to.path != '/login' || to.path != '/sldchome' || to.path != '/sljchome') {
- if (localStorage && localStorage.getItem('userid') && localStorage.getItem('accessToken')) {
- let hasPrivUri = false
- let privCollect = JSON.parse(sessionStorage.getItem('privCollect'))
- // if( from.path != '/' ){
- privCollect.forEach(ele => {
- if (ele.flagLeaf == '1' && to.path == ele.privUri) {
- hasPrivUri = true
- sessionStorage.setItem('privItem', JSON.stringify(ele))
- } else {
- ele.privList.forEach(element => {
- if (element.flagLeaf == '1' && to.path == element.privUri) {
- hasPrivUri = true
- sessionStorage.setItem('privItem', JSON.stringify(element))
- } else {
- element.privList.forEach(elem => {
- if (elem.flagLeaf == '1' && to.path == elem.privUri) {
- hasPrivUri = true
- sessionStorage.setItem('privItem', JSON.stringify(elem))
- }
- })
- }
- })
- }
- });
- console.log(privCollect, 'privCollect')
- console.log(hasPrivUri, 'hasPrivUri')
- if(privCollect && !hasPrivUri) {
- if(from.path=='/' && to.path=='/refresh'){
- this.$router.push(to.path);
- }else if(from.path == '/refresh' && to.path == '/'){
- this.$router.push(to.path);
- }else if(from.path != '/login' && (to.path != '/zhxx' || to.path != '/home' || from.path != '/')) {
- if(to.path == '/yearSdPlanD' || to.path == '/detailYearSdPlanD'){
- next();
- }else{
- this.$router.push(to.path)
- }
- }
- }
- } else {
- if (to.path == '/login') {
- this.$router.push('/login');
- }
- if (to.path == '/sldchome') {
- this.$router.push('/logindc');
- }
- if (to.path == '/sljchome') {
- this.$router.push('/loginjc');
- }
- }
- }else{
- this.loginOut();
- }
- }
- },
- });
- window.v = v;
- Vue.prototype.ownPriv = hasPriv
- Vue.prototype.ownAdName = localStorage.getItem('currentRlcode')=='660000000000'?'师':"市"
- Vue.prototype.isXj = localStorage.getItem('currentRlcode')=='660000000000'?false:true
- Vue.prototype.projTransform = projTransform //点线面坐标系转换
- Vue.prototype.geometryTransform = geometryTransform //geometry转换
- Vue.prototype.$ol = ol;
|