App.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. <template>
  2. <div id="app">
  3. <Header v-if="headersShow"></Header>
  4. <div class="scrollbar_style" :class="{'padding':headersShow}">
  5. <router-view></router-view>
  6. </div>
  7. </div>
  8. </template>
  9. <script>
  10. Date.prototype.format = function(fmt) {
  11. let ret;
  12. const opt = {
  13. "Y+": this.getFullYear().toString(), // 年
  14. "m+": (this.getMonth() + 1).toString(), // 月
  15. "d+": this.getDate().toString(), // 日
  16. "H+": this.getHours().toString(), // 时
  17. "M+": this.getMinutes().toString(), // 分
  18. "S+": this.getSeconds().toString() // 秒
  19. // 有其他格式化字符需求可以继续添加,必须转化成字符串
  20. };
  21. for (let k in opt) {
  22. ret = new RegExp("(" + k + ")").exec(fmt);
  23. if (ret) {
  24. fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
  25. }
  26. }
  27. return fmt;
  28. }
  29. Number.prototype.formatNumberRgx = function() {
  30. var parts = this.toString().split(".");
  31. parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  32. return parts.join(".");
  33. };
  34. import Header from './components/header.vue'
  35. import { mapGetters } from 'vuex'
  36. import allUel from './api/allUel.js'
  37. import base from './api/base.js'
  38. import jqueryK from './api/jqueryK.js'
  39. export default {
  40. name: 'App',
  41. data(){
  42. return{
  43. headersShow:false,
  44. password:'654321'
  45. }
  46. },
  47. computed:{
  48. ...mapGetters({
  49. token:'token',
  50. client_key:'client_key',
  51. username:'username',
  52. version:'version',
  53. routerStr:'routerStr',
  54. avatar:'avatar',
  55. browserLanguage:'browserLanguage',
  56. }),
  57. },
  58. components: {
  59. Header
  60. },
  61. created(){
  62. let data = {};
  63. var storage = window.localStorage;
  64. var street = window.location.href.split("/")[2];
  65. let protocolStr = document.location.protocol;
  66. let subStrW = protocolStr=='https:'?'wss:':'ws:';
  67. let subStrT = new RegExp('https:');//创建正则表达式对象
  68. if(street == 'localhost:8080' || street == '127.0.0.1:8080'){
  69. street = '120.77.179.55'
  70. protocolStr = 'http:';
  71. data = {
  72. avatar: "http://120.77.179.55/upload/image/73e766a761584c547ce785af826a4e6d.jpg",
  73. client_key: "23be0e4c9a2e91b330bfeb7d20229e71",
  74. id: "1",
  75. name: "admin",
  76. privilege: "",
  77. role: 1,
  78. token: "27cc9eaa89c63c65df47901692a70bc7",
  79. username: "admin",
  80. version: "0",
  81. }
  82. // data = {
  83. // token:"41b3914983146b748c636d0f46cd1103",
  84. // username:"plmpo",
  85. // id:"92",
  86. // role:4,
  87. // name:"123",
  88. // privilege:"2,3,4,5,6,7,9,10,12,13,14,15,16,17,34,51,53,55,60,19,20,21,22,23,24,25,26,27,28,29,31,52,54,56,63,33,35,36,37,40,41,42,43,62",
  89. // avatar:"",
  90. // client_key:"23be0e4c9a2e91b330bfeb7d20229e71",
  91. // version:"0"
  92. // }
  93. storage.setItem('userData',JSON.stringify(data))
  94. }
  95. for(let i in allUel){
  96. for(let key in allUel[i]){
  97. if(i == 'websocket'){
  98. allUel[i][key]=allUel[i][key].replace(new RegExp('ws:'),subStrW);
  99. }else{
  100. allUel[i][key]=allUel[i][key].replace(subStrT,protocolStr);
  101. }
  102. }
  103. }
  104. let subStr=new RegExp('120.77.179.55');//创建正则表达式对象
  105. for(let i in allUel){
  106. for(let key in allUel[i]){
  107. allUel[i][key]=allUel[i][key].replace(subStr,street);
  108. }
  109. }
  110. let linkTypeArr = window.location.href.split("/");
  111. let linkType = linkTypeArr[linkTypeArr.length-1].split("?")[0];
  112. if(storage.getItem('userData')){
  113. data = JSON.parse(storage.getItem('userData'))
  114. this.$store.commit('USERDATAFUN',{
  115. username:data.username,
  116. id:data.id,
  117. role:data.role,
  118. lastLoginTime:data.lastLoginTime,
  119. client_key:data.client_key,
  120. privilege:data.privilege,
  121. token:data.token,
  122. number:data.number,
  123. avatar:data.avatar,
  124. version:data.version,
  125. })
  126. if(linkType == '' || linkType == 'login'){
  127. linkType = 'dashboard'
  128. this.$router.push({path:'/dashboard'})
  129. document.title = 'IDCOL-dashboard'
  130. }
  131. this.$store.commit('ROUTERSTRFUN',{
  132. routerStr:'/'+linkType
  133. })
  134. document.title = 'IDCOL-'+linkType
  135. if(linkType == 'login'||linkType == 'retrievePassword'){
  136. this.headersShow = false
  137. }else{
  138. this.headersShow = true
  139. }
  140. }else{
  141. if(linkType != 'retrievePassword'){
  142. storage.setItem('userData','')
  143. this.$store.commit('ROUTERSTRFUN',{
  144. routerStr:'/login',
  145. })
  146. this.$router.push({path:'/login'});
  147. }
  148. }
  149. this.$router.beforeEach((to, from, next) => {
  150. console.log(to.path,'--------')
  151. if(to.path == '/login'||to.path == '/retrievePassword'){
  152. this.headersShow = false
  153. }else{
  154. this.headersShow = true
  155. }
  156. this.$store.commit('ROUTERSTRFUN',{
  157. routerStr:to.path
  158. })
  159. next();
  160. })
  161. },
  162. mounted(){
  163. let this_ = this;
  164. let width = document.body.offsetWidth;
  165. if(width >= 1920){
  166. $('html').css({'font-size':'95.01%'})
  167. this.$store.commit('REMRATIOFUN',{
  168. remRatio:0.9501*16,
  169. })
  170. }else{
  171. $('html').css({'font-size':width*62.5/1200+'%'})
  172. this.$store.commit('REMRATIOFUN',{
  173. remRatio:width*62.5/1200/100*16,
  174. })
  175. }
  176. window.onresize = function(){
  177. width = document.body.offsetWidth;
  178. // console.log(width)
  179. if(width >= 1920){
  180. $('html').css({'font-size':'95.01%'})
  181. this_.$store.commit('REMRATIOFUN',{
  182. remRatio:0.9501*16,
  183. })
  184. }else{
  185. $('html').css({'font-size':width*62.5/1200+'%'})
  186. this_.$store.commit('REMRATIOFUN',{
  187. remRatio:width*62.5/1200/100*16,
  188. })
  189. }
  190. this_.$store.commit('UPDATEREMRATIOFUN',{
  191. updateRemRatio:this_.updateRemRatio+1,
  192. })
  193. }
  194. //ie
  195. if (navigator.browserLanguage != "undefined" && navigator.browserLanguage != null) {
  196. if (navigator.systemLanguage == "zh-CN") {
  197. this_.$store.commit('BROWSERLANGUAGE',{
  198. browserLanguage:'bd',
  199. })
  200. // this_.loadJS('https://webapi.amap.com/maps?v=1.4.6&key=192cfd61cc0fbe8c2cf8d5c314f43bb3&plugin=AMap.MarkerClusterer,AMap.ToolBar,AMap.Autocomplete,AMap.PlaceSearch,AMap.Geocoder',function(){})
  201. }else{
  202. this_.$store.commit('BROWSERLANGUAGE',{
  203. browserLanguage:'google',
  204. })
  205. this_.loadJS('https://maps.googleapis.com/maps/api/js?key=AIzaSyD_FHQc9qTI5SPvTBV0SQ-aPS2HJHm8H9U&language=en',function(){
  206. this_.loadJS('./js/richmarker.js',function(){})
  207. })
  208. }
  209. }
  210. //firefox、chrome,360
  211. else {
  212. if (navigator.language == "zh-CN") {
  213. // this_.loadJS('https://webapi.amap.com/maps?v=1.4.6&key=192cfd61cc0fbe8c2cf8d5c314f43bb3&plugin=AMap.MarkerClusterer,AMap.ToolBar,AMap.Autocomplete,AMap.PlaceSearch,AMap.Geocoder',function(){})
  214. this_.$store.commit('BROWSERLANGUAGE',{
  215. browserLanguage:'bd',
  216. })
  217. }else{
  218. this_.$store.commit('BROWSERLANGUAGE',{
  219. browserLanguage:'google',
  220. })
  221. this_.loadJS('https://maps.googleapis.com/maps/api/js?key=AIzaSyD_FHQc9qTI5SPvTBV0SQ-aPS2HJHm8H9U&language=en',function(){
  222. this_.loadJS('./js/richmarker.js',function(){})
  223. })
  224. }
  225. }
  226. console.log(this.browserLanguage,'================')
  227. },
  228. methods:{
  229. loadJS( url, callback ){
  230. let script = document.createElement('script'),
  231. fn = callback || function(){};
  232. script.type = 'text/javascript';
  233. //IE
  234. if(script.readyState){
  235. script.onreadystatechange = function(){
  236. if( script.readyState == 'loaded' || script.readyState == 'complete' ){
  237. script.onreadystatechange = null;
  238. fn();
  239. }
  240. };
  241. }else{
  242. //其他浏览器
  243. script.onload = function(){
  244. fn();
  245. };
  246. }
  247. script.src = url;
  248. document.getElementsByTagName('head')[0].appendChild(script);
  249. },
  250. login(){
  251. var storage = window.localStorage;
  252. let client_key = jqueryK.md5(navigator.userAgent);
  253. base.ajax_post(
  254. allUel.common.login,
  255. {
  256. // username:this.username,
  257. // password:this.password,
  258. username:'admin',
  259. password:'654321',
  260. client_key:client_key,
  261. },
  262. {},
  263. data => {
  264. // this.$message({
  265. // showClose: true,
  266. // message: 'Login successfully',
  267. // type: 'success'
  268. // });
  269. console.log(data)
  270. data.data.client_key = client_key;
  271. data.data.version = this.version;
  272. this.$store.commit('USERDATAFUN',{
  273. username:data.data.username,
  274. id:data.data.id,
  275. role:data.data.role,
  276. lastLoginTime:data.data.lastLoginTime,
  277. client_key:data.data.client_key,
  278. privilege:data.data.privilege,
  279. token:data.data.token,
  280. number:data.data.number,
  281. avatar:data.data.avatar,
  282. version:data.data.version,
  283. })
  284. // this.$router.push({path:'/dashboard'})
  285. // this.$store.commit('ROUTERSTRFUN',{
  286. // routerStr:'/dashboard',
  287. // })
  288. storage.setItem('userData',JSON.stringify(data.data))
  289. if(this.checkboxRememberPassword){
  290. storage.setItem('rememberPassword','true');
  291. storage.setItem('udfn',this.username);
  292. storage.setItem('udfp',jqueryK.base64Encode(this.password));
  293. }
  294. this.$store.commit('HEADERIDFUN',{
  295. headerUpdate: this.headerUpdate+1,
  296. })
  297. },
  298. this
  299. )
  300. },
  301. }
  302. }
  303. </script>
  304. <style type="text/css" lang="less">
  305. @font-face {
  306. font-family: 'PingFang-SC-Heavy';
  307. src: url('./style/font-pf/PingFangHeavy.eot');
  308. src:
  309. url('./style/font-pf/PingFangHeavy.eot?#font-spider') format('embedded-opentype'),
  310. url('./style/font-pf/PingFangHeavy.woff') format('woff'),
  311. url('./style/font-pf/PingFangHeavy.ttf') format('truetype'),
  312. url('./style/font-pf/PingFangHeavy.svg') format('svg');
  313. font-weight: normal;
  314. font-style: normal;
  315. }
  316. @font-face {
  317. font-family: 'PingFangSC-Medium';
  318. src: url('./style/font-pf/PingFangMedium.ttf');
  319. font-weight: normal;
  320. font-style: normal;
  321. }
  322. @font-face {
  323. font-family: 'AlibabaPuHuiTiR';
  324. src: url('./style/font-al/Alibaba-PuHuiTi-Regular.eot');
  325. src:
  326. url('./style/font-al/Alibaba-PuHuiTi-Regular.eot?#font-spider') format('embedded-opentype'),
  327. url('./style/font-al/Alibaba-PuHuiTi-Regular.woff') format('woff'),
  328. url('./style/font-al/Alibaba-PuHuiTi-Regular.ttf') format('truetype'),
  329. url('./style/font-al/Alibaba-PuHuiTi-Regular.svg') format('svg');
  330. font-weight: normal;
  331. font-style: normal;
  332. }
  333. @font-face {
  334. font-family: 'AlibabaPuHuiTiH';
  335. src: url('./style/font-al/Alibaba-PuHuiTi-Heavy.ttf');
  336. src:
  337. url('./style/font-al/Alibaba-PuHuiTi-Heavy.eot?#font-spider') format('embedded-opentype'),
  338. url('./style/font-al/Alibaba-PuHuiTi-Heavy.woff') format('woff'),
  339. url('./style/font-al/Alibaba-PuHuiTi-Heavy.ttf') format('truetype'),
  340. url('./style/font-al/Alibaba-PuHuiTi-Heavy.svg') format('svg');
  341. font-weight: normal;
  342. font-style: normal;
  343. }
  344. @font-face {
  345. font-family: 'AlibabaPuHuiTiB';
  346. src: url('./style/font-al/Alibaba-PuHuiTi-Bold.ttf');
  347. src:
  348. url('./style/font-al/Alibaba-PuHuiTi-Bold.eot?#font-spider') format('embedded-opentype'),
  349. url('./style/font-al/Alibaba-PuHuiTi-Bold.woff') format('woff'),
  350. url('./style/font-al/Alibaba-PuHuiTi-Bold.ttf') format('truetype'),
  351. url('./style/font-al/Alibaba-PuHuiTi-Bold.svg') format('svg');
  352. font-weight: normal;
  353. font-style: normal;
  354. }
  355. @font-face {
  356. font-family: 'AlibabaPuHuiTiL';
  357. src: url('./style/font-al/Alibaba-PuHuiTi-Light.ttf');
  358. src:
  359. url('./style/font-al/Alibaba-PuHuiTi-Light.eot?#font-spider') format('embedded-opentype'),
  360. url('./style/font-al/Alibaba-PuHuiTi-Light.woff') format('woff'),
  361. url('./style/font-al/Alibaba-PuHuiTi-Light.ttf') format('truetype'),
  362. url('./style/font-al/Alibaba-PuHuiTi-Light.svg') format('svg');
  363. font-weight: normal;
  364. font-style: normal;
  365. }
  366. @font-face {
  367. font-family: 'AlibabaPuHuiTiM';
  368. src: url('./style/font-al/Alibaba-PuHuiTi-Medium.ttf');
  369. src:
  370. url('./style/font-al/Alibaba-PuHuiTi-Medium.eot?#font-spider') format('embedded-opentype'),
  371. url('./style/font-al/Alibaba-PuHuiTi-Medium.woff') format('woff'),
  372. url('./style/font-al/Alibaba-PuHuiTi-Medium.ttf') format('truetype'),
  373. url('./style/font-al/Alibaba-PuHuiTi-Medium.svg') format('svg');
  374. font-weight: normal;
  375. font-style: normal;
  376. }
  377. // @font-face {
  378. // font-family: 'bodoni-MT';
  379. // src: url('./style/bodoniMT/bodoniMT.ttf');
  380. // }
  381. html,body,p,h1,h2,h3,h4,h5,ul,li{
  382. margin: 0px;
  383. padding: 0px;
  384. }
  385. html,body,#app{
  386. height: 100%;
  387. width:100%;
  388. }
  389. li{
  390. list-style:none;/*li去点*/
  391. box-sizing: border-box;
  392. }
  393. a{
  394. text-decoration: none;
  395. box-sizing: border-box;
  396. }
  397. i{
  398. font-style: inherit;
  399. }
  400. input{
  401. padding:0;
  402. outline-style: none;
  403. box-sizing: border-box;
  404. }
  405. div{
  406. box-sizing: border-box; //border、padding并入宽度。
  407. }
  408. /*滚动条样式*/
  409. .el-table__body-wrapper::-webkit-scrollbar {/*滚动条整体样式*/
  410. width: 3px; /*高宽分别对应横竖滚动条的尺寸*/
  411. height: 8px;
  412. }
  413. .el-table__body-wrapper::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
  414. border-radius: 3px;
  415. background: #DAE6E0;
  416. }
  417. .el-table__body-wrapper::-webkit-scrollbar-track {/*滚动条里面轨道*/
  418. background: #F6F8F7;
  419. }
  420. .el-table{
  421. th>.cell,td>.cell{
  422. padding: 0;
  423. }
  424. .el-table__body-wrapper{
  425. width: calc(100% - 1.5rem);
  426. margin-right: 1.5rem;
  427. }
  428. }
  429. .scrollbar_style{
  430. // margin-right: 8px;
  431. overflow: auto;
  432. }
  433. /*.scrollbar_style::-webkit-scrollbar-button{
  434. width: 10px;
  435. height: 10px;
  436. }*/
  437. .scrollbar_style::-webkit-scrollbar {/*滚动条整体样式*/
  438. width: 3px; /*高宽分别对应横竖滚动条的尺寸*/
  439. height: 5px;
  440. }
  441. .scrollbar_style::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
  442. border-radius: 3px;
  443. background: #DAE6E0;
  444. }
  445. .scrollbar_style::-webkit-scrollbar-track {/*滚动条里面轨道*/
  446. background: #F6F8F7;
  447. }
  448. /*弹框样式*/
  449. .el-dialog__header{
  450. border-bottom: 1px solid #E8E8E8;
  451. span{
  452. color: #444444;
  453. }
  454. }
  455. .el-dialog__headerbtn {
  456. top: 13px;
  457. font-size: 30px;
  458. }
  459. .el-dialog__body{
  460. .dialog_foot{
  461. text-align:center;padding: 60px 0 20px 0;
  462. .el-button{
  463. width:320px;
  464. height:60px;
  465. border-radius: 6px;
  466. font-size:16px;
  467. }
  468. }
  469. }
  470. #app{
  471. >.scrollbar_style{
  472. // width: calc(100% - 8px);
  473. width: calc(100%);
  474. height: calc(100%);
  475. &.padding{
  476. height: calc(100% - 4.1rem);
  477. }
  478. }
  479. }
  480. .el-dropdown-menu__item:focus, .el-dropdown-menu__item:not(.is-disabled):hover{
  481. color: initial;
  482. background-color: #f5f7fa;
  483. }
  484. .el-dropdown-menu{
  485. max-height: 360px;
  486. .el-dropdown-menu__item{
  487. &.select{
  488. color: #409eff;
  489. font-weight: 700;
  490. }
  491. }
  492. }
  493. /*弹框样式*/
  494. .solar_dialig{
  495. .el-dialog__header{
  496. border-bottom: 1px solid #E8E8E8;
  497. span{
  498. color: #444444;
  499. }
  500. }
  501. .el-dialog__headerbtn {
  502. top: 13px;
  503. font-size: 30px;
  504. }
  505. .el-dialog__body{
  506. .dialog_foot{
  507. text-align:center;padding: 60px 0 20px 0;
  508. .el-button{
  509. width:320px;
  510. height:60px;
  511. border-radius: 6px;
  512. font-size:16px;
  513. }
  514. }
  515. }
  516. }
  517. </style>