82efcaee46960383a45d9714179c3ffc7e9b6ebd.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. import Vue from 'vue'
  2. import vuex from 'vuex'
  3. import Element from 'element-ui'
  4. import fabric from 'fabric'
  5. import 'element-ui/lib/theme-chalk/index.css';
  6. import "babel-polyfill"
  7. import router from '../router/index'
  8. import store from '../store/storeIndex'
  9. import App from '../App.vue'
  10. import {getAllDictByProject} from '../utils/gw_dictionary.js'
  11. import VueVideoPlayer from 'vue-video-player'
  12. import ol from 'openlayers'
  13. import Viewer from 'v-viewer'
  14. import 'viewerjs/dist/viewer.css'
  15. import 'video.js/dist/video-js.css'
  16. import {hasPriv,isProvince,hasMenu} from '../utils/gw_hasPriv.js'
  17. import {projTransform,geometryTransform} from '../views/zongHeXinXiOl/js/projTransform' // 坐标系转换
  18. import request from '@util/gw_ajax_request'
  19. import vRegion from 'v-region';
  20. import orgStatus from '../store/orgChange.js'
  21. import {getCookie,setCookie} from '../utils/gw_cookie.js'
  22. Vue.use(vRegion);
  23. Vue.use(VueVideoPlayer, /* {
  24. options: global default options,
  25. events: global videojs events
  26. } */)
  27. // 图片预览插件
  28. Vue.use(Viewer);
  29. Vue.use(fabric);
  30. Viewer.setDefaults({
  31. Options: {
  32. "inline": true,
  33. "button": true,
  34. "navbar": true,
  35. "title": true,
  36. "toolbar": true,
  37. "tooltip": true,
  38. "movable": true,
  39. "zoomable": true,
  40. "rotatable": true,
  41. "scalable": true,
  42. "transition": true,
  43. "fullscreen": true,
  44. "keyboard": true,
  45. "url": "data-source"
  46. }
  47. })
  48. getAllDictByProject();
  49. Vue.use(vuex);
  50. Vue.use(Element, {size: 'mini'})
  51. let token = GetQueryString('token');
  52. if (token) {
  53. } else {
  54. token = "";
  55. }
  56. console.log(token);
  57. localStorage.setItem('token', token);
  58. var url = window.location.href;
  59. if(url.indexOf("hncas")>-1){
  60. if(!GetQueryString('code')){
  61. 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/"
  62. }else{
  63. window.location.href="http://zhsw.swt.hainan.gov.cn:9000/src/pages/gwDdIndex.html?code="+GetQueryString('code')
  64. }
  65. }
  66. function GetQueryString(name) {
  67. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  68. var r = window.location.search.substr(1).match(reg);
  69. if (r != null) return unescape(r[2]);
  70. return null;
  71. }
  72. function getParams(name) {
  73. var search = window.location.search.substring(1);
  74. if (!search) {
  75. search = window.location.hash.split("?")[1];
  76. }
  77. if (search) {
  78. var obj = JSON.parse(
  79. '{"' +
  80. decodeURIComponent(search)
  81. .replace(/"/g, '\\"')
  82. .replace(/&/g, '","')
  83. .replace(/=/g, '":"') +
  84. '"}'
  85. );
  86. return name ? obj[name] : obj;
  87. }
  88. }
  89. // if(url.indexOf("61.187.56.146")>-1){
  90. // import("./hnsljdxt_monitor");
  91. // }
  92. var v = new Vue({
  93. el: '#gwHzzApp',
  94. store,
  95. router,
  96. render: h => h(App),
  97. mounted: async function () {
  98. // //debugger
  99. let isUrl = "";
  100. let ticket = "";
  101. localStorage.setItem("sdUrl","");
  102. setCookie("sdUrl","")
  103. if ((url.indexOf("221.237.107.122")>-1) && GetQueryString('token')) {
  104. isUrl = "5101"
  105. ticket = GetQueryString('token');
  106. }
  107. // if ((url.indexOf("221.237.107.122")>-1) && !GetQueryString('token')) {
  108. // window.location.href="http://10.1.228.132:9969/wui/index.html?checkoutTo=e996a8fe-1660-4bc6-8e14-d367e4735a65"
  109. // }
  110. if (url.indexOf("fjcas") > -1) {
  111. 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";
  112. }
  113. if (url.indexOf("27.156.118.74") > -1 && GetQueryString('code')) {
  114. isUrl = "034"
  115. ticket = GetQueryString('code');
  116. }
  117. if (GetQueryString('ticket')) {
  118. isUrl = "036"
  119. ticket = GetQueryString('ticket');
  120. }
  121. if (GetQueryString('accessId')) {
  122. isUrl = "063"
  123. ticket = GetQueryString('accessId');
  124. }
  125. if (GetQueryString('ssophone')) {
  126. isUrl = "066"
  127. ticket = GetQueryString('ssophone');
  128. }
  129. if (url.indexOf("zhsw.swt.hainan.gov.cn") > -1 && GetQueryString('code')) {
  130. isUrl = "055"
  131. ticket = GetQueryString('code');
  132. }
  133. if (url.indexOf("60.208.113.79") > -1 && getParams('ticketKey')) {
  134. isUrl = "037"
  135. ticket = getParams('ticketKey');
  136. }
  137. if (ticket) {
  138. if (localStorage && (!localStorage.getItem('userid'))) {
  139. window.localStorage.clear();
  140. this.loginOut();
  141. await this.loginWithsso(ticket, isUrl);
  142. }else{
  143. if(window.location.href.indexOf("planCheckYear")>-1){
  144. localStorage.setItem("sdUrl","/planCheckYear");
  145. setCookie("sdUrl","/planCheckYear")
  146. }
  147. if(window.location.href.indexOf("home")>-1){
  148. localStorage.setItem("sdUrl","/home");
  149. setCookie("sdUrl","/home")
  150. }
  151. }
  152. } else {
  153. if (localStorage && (!localStorage.getItem('userid')) || !sessionStorage.getItem('privCollect')) {
  154. window.localStorage.clear();
  155. this.loginOut();
  156. if(window.location.href.indexOf("/sldchome")>-1){
  157. this.$router.push('/logindc');
  158. }
  159. else if(window.location.href.indexOf("/sljchome")>-1){
  160. this.$router.push('/loginjc');
  161. }else{
  162. this.$router.push('/login');
  163. }
  164. }
  165. }
  166. },
  167. methods: {
  168. loginOut() {
  169. if (localStorage.getItem('accessToken')) {
  170. request.get(`/bis/insp/logOut`)
  171. .then(res => {
  172. if (res.success) {
  173. } else {
  174. this.$message.warning(res.message);
  175. return;
  176. }
  177. })
  178. }
  179. },
  180. async loginWithsso(ticket,isP) {
  181. window.localStorage.clear();
  182. let url = "";
  183. let _self = this;
  184. if(isP=="034"){
  185. url = "/cas/fj/"
  186. }
  187. if(isP=="036"){
  188. url = "/sso/validateTicket/"
  189. }
  190. if(isP=="063"){
  191. url = "/sso/validateQhUser/"
  192. }
  193. if(isP=="066"){
  194. url = "/sso/validateXjbtUser/"
  195. }
  196. if(isP=="055"){
  197. url = "/cas/hn/"
  198. }
  199. if(isP=="037"){
  200. url = "/cas/sd/validateTicketKey"
  201. if(window.location.href.indexOf("planCheckYear")>-1){
  202. localStorage.setItem("sdUrl","/planCheckYear");
  203. setCookie("sdUrl","/planCheckYear")
  204. }
  205. if(window.location.href.indexOf("home")>-1){
  206. localStorage.setItem("sdUrl","/home");
  207. setCookie("sdUrl","/home")
  208. }
  209. }
  210. if(isP=="5101"){
  211. url = "/cas/cd/validateTicketKey"
  212. }
  213. try {
  214. // //debugger
  215. await request.get(url,{params:{'ticket': ticket}}).then(res => {
  216. console.log(ticket);
  217. if (res.success == true) {
  218. let token = res.data.token;
  219. let userid = res.data.guid;
  220. let loginName = res.data.persName;
  221. let guid = res.data.orgId;
  222. let orgNm = res.data.orgNm;
  223. let accessToken = res.accessToken; //token是否过期
  224. localStorage.setItem('token', token);
  225. localStorage.setItem('userid', userid);
  226. localStorage.setItem('account', loginName);
  227. localStorage.setItem('guid', guid);
  228. localStorage.setItem('orgNm', orgNm);
  229. localStorage.setItem('accessToken', accessToken);
  230. let persType = res.data.persType;
  231. let isAdmin = res.data.permission;
  232. localStorage.setItem('persType', persType);
  233. let allNode = JSON.stringify(res.data.allNode);//当前用户所在组信息
  234. let allOrg = JSON.stringify(res.data.allOrg);
  235. localStorage.setItem('isAdmin', isAdmin);
  236. let orgId = res.data.orgId;
  237. localStorage.setItem('orgId', orgId);
  238. localStorage.setItem('allOrg', allOrg);
  239. localStorage.setItem("currentOrgId", res.data.defaultOrg.orgId); //省级当前的机构id
  240. localStorage.setItem("currentRlcode", res.data.defaultOrg.rlcode); //省级当前的行政区划编码
  241. localStorage.setItem("departId", res.data.departId); //人员所属责任处室id-浙江
  242. localStorage.setItem("departNm", res.data.departNm); //人员所属责任处室名称-浙江
  243. // 改变全局adcode状态
  244. _self.$store.commit('changeAdCode', res.data.defaultOrg.rlcode);
  245. localStorage.setItem("currentOrgNm", res.data.defaultOrg.orgNm); //省级当前的机构名称
  246. localStorage.setItem('allNode', allNode);
  247. // _self.$message.success({
  248. // message: '登录成功',
  249. // duration: 700
  250. // });
  251. // window.location.reload();
  252. if(localStorage.getItem("sdUrl")){
  253. localStorage.setItem('ownApp','1')
  254. orgStatus.commit('changeSystem', '1')
  255. _self.$router.push(localStorage.getItem("sdUrl"))
  256. }else{
  257. _self.$router.push('/refresh')
  258. }
  259. }else {
  260. _self.$message(res.message);
  261. _self.loginOut();
  262. _self.$router.push('/login')
  263. }
  264. },(err)=>{
  265. _self.$message.error({
  266. message: '系统检查异常,请联系管理员',
  267. duration: 700
  268. });
  269. _self.loginOut();
  270. _self.$router.push('/login')
  271. })
  272. } catch (e) {
  273. }
  274. }
  275. },
  276. watch: {
  277. $route(to, from) {
  278. const flag = hasMenu(to)
  279. if(!flag && to.path!="/login" && to.path!="/loginjc" && to.path!="/"){
  280. this.$router.push(from.path)
  281. return false
  282. }
  283. console.log('路由变化' + to.path);
  284. if (to.path != '/login' || to.path != '/sldchome' || to.path != '/sljchome') {
  285. if (localStorage && localStorage.getItem('userid') && localStorage.getItem('accessToken')) {
  286. let hasPrivUri = false
  287. let privCollect = JSON.parse(sessionStorage.getItem('privCollect'))
  288. // if( from.path != '/' ){
  289. privCollect.forEach(ele => {
  290. if (ele.flagLeaf == '1' && to.path == ele.privUri) {
  291. hasPrivUri = true
  292. sessionStorage.setItem('privItem', JSON.stringify(ele))
  293. } else {
  294. ele.privList.forEach(element => {
  295. if (element.flagLeaf == '1' && to.path == element.privUri) {
  296. hasPrivUri = true
  297. sessionStorage.setItem('privItem', JSON.stringify(element))
  298. } else {
  299. element.privList.forEach(elem => {
  300. if (elem.flagLeaf == '1' && to.path == elem.privUri) {
  301. hasPrivUri = true
  302. sessionStorage.setItem('privItem', JSON.stringify(elem))
  303. }
  304. })
  305. }
  306. })
  307. }
  308. });
  309. console.log(privCollect, 'privCollect')
  310. console.log(hasPrivUri, 'hasPrivUri')
  311. if(privCollect && !hasPrivUri) {
  312. if(from.path=='/' && to.path=='/refresh'){
  313. this.$router.push(to.path);
  314. }else if(from.path == '/refresh' && to.path == '/'){
  315. this.$router.push(to.path);
  316. }else if(from.path != '/login' && (to.path != '/zhxx' || to.path != '/home' || from.path != '/')) {
  317. if(to.path == '/yearSdPlanD' || to.path == '/detailYearSdPlanD'){
  318. next();
  319. }else{
  320. this.$router.push(to.path)
  321. }
  322. }
  323. }
  324. } else {
  325. if (to.path == '/login') {
  326. this.$router.push('/login');
  327. }
  328. if (to.path == '/sldchome') {
  329. this.$router.push('/logindc');
  330. }
  331. if (to.path == '/sljchome') {
  332. this.$router.push('/loginjc');
  333. }
  334. }
  335. }else{
  336. this.loginOut();
  337. }
  338. }
  339. },
  340. });
  341. window.v = v;
  342. Vue.prototype.ownPriv = hasPriv
  343. Vue.prototype.ownAdName = localStorage.getItem('currentRlcode')=='660000000000'?'师':"市"
  344. Vue.prototype.isXj = localStorage.getItem('currentRlcode')=='660000000000'?false:true
  345. Vue.prototype.projTransform = projTransform //点线面坐标系转换
  346. Vue.prototype.geometryTransform = geometryTransform //geometry转换
  347. Vue.prototype.$ol = ol;