ssoLogin.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <template>
  2. <div class="sso-login-page scrollbar-box">
  3. <!--<img class="logo-img" :src="rectangleLogo">-->
  4. <!--<div class="title-img-box">-->
  5. <!--<div>-->
  6. <!--<img class="title-img" src="@/assets/ZDimages/login/title_icon.png">-->
  7. <!--</div>-->
  8. <!--</div>-->
  9. <!--<p class="introduction-p">技术支持:江苏忠江智能科技有限公司</p>-->
  10. </div>
  11. </template>
  12. <script>
  13. import { decrypt } from '@/utils/jsencrypt'
  14. import { Decrypt } from '@/utils/secret.js'
  15. import store from '@/store'
  16. import Cookies from 'js-cookie'
  17. import { setToken } from '@/utils/auth'
  18. import { getLogoInfo, getUrlConfig } from '@/api/system/publicConfig'
  19. import { ssoGetLoginUser,initPage,getInfo } from '@/api/login'
  20. export default {
  21. name: 'Login',
  22. data() {
  23. return {
  24. codeUrl: '',
  25. cookiePassword: '',
  26. type: 1,
  27. loginForm: {
  28. // username: "admin",
  29. // password: "admin123",
  30. username: '',
  31. password: '',
  32. rememberMe: false,
  33. code: '',
  34. uuid: ''
  35. // userType:""
  36. },
  37. loginRules: {
  38. // username: [
  39. // { required: true, trigger: "blur", message: "请输入您的账号" }
  40. // ],
  41. // password: [
  42. // { required: true, trigger: "blur", message: "请输入您的密码" }
  43. // ],
  44. // code: [{ required: true, trigger: "change", message: "请输入验证码" }]
  45. },
  46. loading: false,
  47. // 验证码开关
  48. captchaOnOff: true,
  49. // 注册开关
  50. register: false,
  51. redirect: undefined,
  52. text: '',
  53. userTypeCode: '',
  54. rectangleLogo: localStorage.getItem('rectangleLogo')
  55. }
  56. },
  57. watch: {
  58. $route: {
  59. handler: function(route) {
  60. this.redirect = route.query && route.query.redirect
  61. },
  62. immediate: true
  63. }
  64. },
  65. created() {
  66. let url = window.location.href
  67. debugger
  68. if (url.indexOf('token') != -1) {
  69. console.log('找到了====>')
  70. setToken(url.split('=')[1])
  71. this.getInfo();
  72. } else {
  73. console.log('没找到---->')
  74. this.ssoGetLoginUser()
  75. }
  76. localStorage.setItem('windowHref', window.location.href)
  77. },
  78. mounted() {
  79. },
  80. methods: {
  81. getInfo(type) {
  82. getInfo().then(response => {
  83. console.log('response', response)
  84. localStorage.setItem('userType',response.user.userType);
  85. localStorage.setItem('userId',response.user.userId);
  86. localStorage.setItem('tenantId',response.user.tenantId);
  87. localStorage.setItem('identity',response.screen_token);
  88. localStorage.setItem('identityType',response.screen_type);
  89. //等待配置与字段获取到后跳转
  90. Promise.all([
  91. this.initPage(),
  92. this.getLogoInfo(),
  93. this.getUrlConfig()
  94. ]).then((result)=>{
  95. this.fullScreen();
  96. this.$router.push({ path: this.redirect || "/home" }).catch(()=>{});
  97. }).catch((error) => {})
  98. })
  99. },
  100. //获取身份标识
  101. ssoGetLoginUser() {
  102. ssoGetLoginUser(response => {
  103. // window.open('https://icas.jnu.edu.cn/cas/login?service=http://localhost:8081/sso/getLoginUser','_self')
  104. })
  105. },
  106. //获取首页配置
  107. initPage(){
  108. initPage().then(response => {
  109. if(response.data){
  110. localStorage.setItem('initPage',true);
  111. }else{
  112. localStorage.setItem('initPage',false);
  113. }
  114. });
  115. },
  116. getLogoInfo(){
  117. getLogoInfo().then(response => {
  118. console.log('公共配置', response.data)
  119. store.dispatch('settings/setSmartAlarmType', response.data.smartLock)
  120. localStorage.setItem('setSmartAlarmType', response.data.smartLock)
  121. this.rectangleLogo = response.data.rectangleLogo
  122. localStorage.setItem('circularLogo', response.data.circularLogo)
  123. localStorage.setItem('rectangleLogo', response.data.rectangleLogo)
  124. localStorage.setItem('videoCover', response.data.videoCover)
  125. })
  126. },
  127. getUrlConfig() {
  128. getUrlConfig().then(response => {
  129. console.log('开发配置', response.data)
  130. //判定http或者https
  131. let urlText = window.location.href.split('://')[0] + '://'
  132. let outerNet = window.location.href.indexOf(response.data.ipIdentify) == -1//true外网 false 内网
  133. if (outerNet) {//外网
  134. //文件预览地址
  135. localStorage.setItem('filePreviewUrl', urlText + response.data.fileExtranetUrl)
  136. //摄像头代理访问地址
  137. localStorage.setItem('cameraExtranetAgent', urlText + response.data.cameraExtranetAgent)
  138. //摄像头地址ip段
  139. localStorage.setItem('ipIdentify', response.data.ipIdentify)
  140. //摄像头访问地址
  141. localStorage.setItem('cameraUrl', 'wss://' + response.data.cameraExtranetUrl)
  142. //MQTT地址
  143. localStorage.setItem('mqttUrl', 'wss://' + Decrypt(response.data.mqttExtranetUrl))
  144. //MQTT账号
  145. localStorage.setItem('mqttUser', Decrypt(response.data.mqttExtranetUser))
  146. //MQTT密码
  147. localStorage.setItem('mqttPassword', Decrypt(response.data.mqttExtranetPassword))
  148. //可视化大屏访问地址
  149. localStorage.setItem('screenUrl', urlText + response.data.screenExtranetUrl)
  150. } else {
  151. //文件预览地址
  152. localStorage.setItem('filePreviewUrl', urlText + response.data.fileIntranetUrl)
  153. //摄像头代理访问地址
  154. localStorage.setItem('cameraExtranetAgent', urlText + response.data.cameraIntranetAgent)
  155. //摄像头地址ip段
  156. localStorage.setItem('ipIdentify', response.data.ipIdentify)
  157. //摄像头访问地址
  158. localStorage.setItem('cameraUrl', 'wss://' + response.data.cameraIntranetUrl)
  159. //MQTT地址
  160. localStorage.setItem('mqttUrl', 'ws://' + Decrypt(response.data.mqttIntranetUrl))
  161. //MQTT账号
  162. localStorage.setItem('mqttUser', Decrypt(response.data.mqttIntranetUser))
  163. //MQTT密码
  164. localStorage.setItem('mqttPassword', Decrypt(response.data.mqttIntranetPassword))
  165. //可视化大屏访问地址
  166. localStorage.setItem('screenUrl', urlText + response.data.screenIntranetUrl)
  167. }
  168. })
  169. },
  170. //全屏
  171. fullScreen() {
  172. var element = document.documentElement
  173. if (element.requestFullscreen) {
  174. element.requestFullscreen()
  175. } else if (element.msRequestFullscreen) {
  176. element.msRequestFullscreen()
  177. } else if (element.mozRequestFullScreen) {
  178. element.mozRequestFullScreen()
  179. } else if (element.webkitRequestFullscreen) {
  180. element.webkitRequestFullscreen()
  181. }
  182. },
  183. //退出全屏
  184. exitFullscreen() {
  185. if (document.exitFullscreen) {
  186. document.exitFullscreen()
  187. } else if (document.msExitFullscreen) {
  188. document.msExitFullscreen()
  189. } else if (document.mozCancelFullScreen) {
  190. document.mozCancelFullScreen()
  191. } else if (document.webkitExitFullscreen) {
  192. document.webkitExitFullscreen()
  193. }
  194. }
  195. }
  196. }
  197. </script>
  198. <style rel="stylesheet/scss" lang="scss">
  199. .sso-login-page {
  200. height: 100%;
  201. width: 100%;
  202. background-image: url("../assets/ZDimages/login/icon_dl_bbg.png");
  203. background-repeat: no-repeat;
  204. background-size: cover;
  205. -webkit-background-size: cover;
  206. -o-background-size: cover;
  207. position: relative;
  208. * {
  209. margin: 0;
  210. }
  211. .logo-img {
  212. position: absolute;
  213. top: 29px;
  214. left: 52px;
  215. width: 250px;
  216. height: 55px;
  217. }
  218. .title-img-box {
  219. position: absolute;
  220. top: 74px;
  221. left: 50%;
  222. margin-left: -580px;
  223. width: 1180px;
  224. height: 230px;
  225. div {
  226. position: relative;
  227. img {
  228. width: 1180px;
  229. height: 230px;
  230. }
  231. p {
  232. position: absolute;
  233. top: 72px;
  234. right: 300px;
  235. width: 50px;
  236. height: 26px;
  237. line-height: 26px;
  238. text-align: center;
  239. background: #0045AF;
  240. color: #fff;
  241. font-size: 14px;
  242. border-radius: 70px;
  243. }
  244. }
  245. }
  246. .form-box {
  247. width: 680px;
  248. height: 520px;
  249. background-image: url("../assets/ZDimages/login/img_dlk_bg.png");
  250. position: absolute;
  251. top: 290px;
  252. left: 50%;
  253. margin-left: -340px;
  254. .form-title-p {
  255. line-height: 52px;
  256. font-size: 24px;
  257. text-align: center;
  258. color: #fff;
  259. font-weight: 700;
  260. }
  261. .username-input-box-code:hover {
  262. box-shadow: 0 0 4px 1px rgba(255, 39, 39, 1) !important;
  263. }
  264. .username-input-box-code {
  265. border: 1px solid #FF6A6A !important;
  266. }
  267. .username-input-box:hover {
  268. box-shadow: 0 0 4px 1px rgba(0, 255, 252, 1);
  269. }
  270. .username-input-box {
  271. width: 480px;
  272. height: 60px;
  273. border: 1px solid #00FFFC;
  274. border-radius: 10px;
  275. background: rgba(0, 13, 41, 0.2);
  276. margin: 40px auto 32px;
  277. display: flex;
  278. overflow: hidden;
  279. img {
  280. height: 20px;
  281. width: 20px;
  282. margin: 20px;
  283. }
  284. input:-webkit-autofill {
  285. //input 背景色 #0C2034根据自己需要替换
  286. -webkit-box-shadow: 0 0 0px 1000px rgba(1, 25, 67, 1) inset !important;
  287. //input字体颜色 颜色根据自己要求替换
  288. -webkit-text-fill-color: #FFFFFF !important;
  289. }
  290. input {
  291. flex: 1;
  292. border: none;
  293. outline: none;
  294. background-color: transparent !important;
  295. color: #dedede;
  296. font-size: 16px;
  297. }
  298. ::placeholder {
  299. color: #999999;
  300. font-size: 16px;
  301. }
  302. }
  303. .password-input-box:hover {
  304. box-shadow: 0 0 4px 1px rgba(0, 255, 252, 1);
  305. }
  306. .password-input-box {
  307. width: 480px;
  308. height: 60px;
  309. border: 1px solid #00FFFC;
  310. border-radius: 10px;
  311. background: rgba(0, 13, 41, 0.2);
  312. margin: 0 auto;
  313. display: flex;
  314. overflow: hidden;
  315. img {
  316. height: 20px;
  317. width: 20px;
  318. margin: 20px;
  319. }
  320. input:-webkit-autofill {
  321. //input 背景色 #0C2034根据自己需要替换
  322. -webkit-box-shadow: 0 0 0px 1000px rgba(1, 25, 67, 1) inset !important;
  323. //input字体颜色 颜色根据自己要求替换
  324. -webkit-text-fill-color: #FFFFFF !important;
  325. }
  326. input {
  327. flex: 1;
  328. border: none;
  329. outline: none;
  330. background-color: transparent !important;
  331. color: #dedede;
  332. font-size: 16px;
  333. }
  334. ::placeholder {
  335. color: #999999;
  336. font-size: 16px;
  337. }
  338. }
  339. .text-p {
  340. width: 480px;
  341. height: 59px;
  342. line-height: 59px;
  343. margin: 0 auto;
  344. font-size: 14px;
  345. font-family: Microsoft YaHei;
  346. color: #DC1616;
  347. }
  348. .code-input-box {
  349. width: 480px;
  350. height: 60px;
  351. display: flex;
  352. margin: 0 auto;
  353. .code-input-left-box:hover {
  354. box-shadow: 0 0 4px 1px rgba(0, 255, 252, 1);
  355. }
  356. .code-input-left-box {
  357. width: 330px;
  358. height: 60px;
  359. border: 1px solid #00FFFC;
  360. border-radius: 10px;
  361. background: rgba(0, 13, 41, 0.2);
  362. display: flex;
  363. overflow: hidden;
  364. img {
  365. height: 20px;
  366. width: 20px;
  367. margin: 20px;
  368. }
  369. input:-webkit-autofill {
  370. -webkit-box-shadow: 0 0 0 1000px white inset !important;
  371. }
  372. input {
  373. flex: 1;
  374. border: none;
  375. outline: none;
  376. background-color: transparent !important;
  377. color: #dedede;
  378. font-size: 16px;
  379. }
  380. ::placeholder {
  381. color: #999999;
  382. font-size: 16px;
  383. }
  384. }
  385. .login-code {
  386. width: 124px;
  387. height: 50px;
  388. margin: 6px 0 0 25px;
  389. img {
  390. width: 124px;
  391. height: 50px;
  392. cursor: pointer;
  393. vertical-align: middle;
  394. }
  395. }
  396. }
  397. .form-button-p {
  398. font-size: 16px;
  399. display: block;
  400. width: 480px;
  401. height: 60px;
  402. background: #0045AF;
  403. color: #fff;
  404. border: none;
  405. border-radius: 10px;
  406. margin: 34px auto 0;
  407. }
  408. }
  409. .introduction-p {
  410. width: 100%;
  411. text-align: center;
  412. color: #fff;
  413. font-size: 16px;
  414. line-height: 44px;
  415. position: absolute;
  416. left: 0;
  417. bottom: 0;
  418. }
  419. }
  420. .login {
  421. /*display: flex;*/
  422. /*justify-content: right;*/
  423. /*padding-right:220px;*/
  424. /*align-items: center;*/
  425. height: 100%;
  426. width: 100%;
  427. background-image: url("../assets/ZDimages/img_dl_bg.png");
  428. background-size: 100%;
  429. position: relative;
  430. .login-max-box {
  431. position: absolute;
  432. height: 800px;
  433. width: 1600px;
  434. background: #FFFFFF;
  435. border-radius: 30px;
  436. top: 50%;
  437. left: 50%;
  438. margin-top: -400px;
  439. margin-left: -800px;
  440. display: flex;
  441. .left-box {
  442. width: 591px;
  443. height: 500px;
  444. background-image: url("../assets/ZDimages/img_dl_sy.png");
  445. background-size: 100%;
  446. margin: 172px 0 178px 140px;
  447. }
  448. .right-box {
  449. flex: 1;
  450. .title {
  451. margin: 91px 0 40px 0;
  452. text-align: center;
  453. padding: 0;
  454. font-size: 50px;
  455. font-family: Microsoft YaHei;
  456. font-weight: bold;
  457. color: #0045AF;
  458. /*
  459. position: absolute;
  460. margin:0;
  461. top: -100px;
  462. right:-120px;
  463. font-size:60px;
  464. width:770px;
  465. text-align: center;
  466. font-weight:700;
  467. */
  468. -webkit-touch-callout: none; /* iOS Safari */
  469. -webkit-user-select: none; /* Chrome/Safari/Opera */
  470. -khtml-user-select: none; /* Konqueror */
  471. -moz-user-select: none; /* Firefox */
  472. -ms-user-select: none; /* Internet Explorer/Edge */
  473. user-select: none; /* Non-prefixed version, currently not supported by any browser */
  474. }
  475. .login-form {
  476. border-radius: 6px;
  477. background: #ffffff;
  478. width: 500px;
  479. margin: 0 auto;
  480. padding: 25px 25px 5px 25px;
  481. .el-input {
  482. height: 38px;
  483. input {
  484. height: 38px;
  485. }
  486. }
  487. .input-icon {
  488. height: 39px;
  489. width: 14px;
  490. margin-left: 2px;
  491. }
  492. .username-input-box {
  493. width: 448px;
  494. height: 48px;
  495. background: #f8f8f8;
  496. border: 1px solid #E0E0E0;
  497. border-radius: 10px;
  498. display: flex;
  499. margin-bottom: 30px;
  500. img {
  501. width: 20px;
  502. height: 20px;
  503. margin: 14px 16px 0 16px;
  504. }
  505. input {
  506. height: 46px;
  507. flex: 1;
  508. background: #f8f8f8;
  509. outline: none;
  510. border: none;
  511. margin-right: 20px;
  512. color: #333;
  513. }
  514. input::placeholder {
  515. color: #ccc;
  516. }
  517. }
  518. .password-input-box {
  519. width: 448px;
  520. height: 48px;
  521. background: #f8f8f8;
  522. border: 1px solid #E0E0E0;
  523. border-radius: 10px;
  524. display: flex;
  525. img {
  526. width: 20px;
  527. height: 20px;
  528. margin: 14px 16px 0 16px;
  529. }
  530. input {
  531. height: 46px;
  532. flex: 1;
  533. background: #f8f8f8;
  534. outline: none;
  535. border: none;
  536. margin-right: 20px;
  537. color: #333;
  538. }
  539. input::placeholder {
  540. color: #ccc;
  541. }
  542. }
  543. .code-input-box {
  544. width: 450px;
  545. height: 50px;
  546. display: flex;
  547. margin-bottom: 60px;
  548. .code-input-left-box {
  549. width: 274px;
  550. height: 48px;
  551. background: #f8f8f8;
  552. border: 1px solid #E0E0E0;
  553. border-radius: 10px;
  554. img {
  555. width: 20px;
  556. height: 20px;
  557. margin: 14px 16px 0 16px;
  558. }
  559. input {
  560. height: 46px;
  561. flex: 1;
  562. background: #f8f8f8;
  563. outline: none;
  564. border: none;
  565. margin-right: 20px;
  566. color: #333;
  567. }
  568. input::placeholder {
  569. color: #ccc;
  570. }
  571. display: flex;
  572. }
  573. .login-code {
  574. margin-left: 24px;
  575. width: 150px;
  576. height: 48px;
  577. img {
  578. width: 150px;
  579. height: 48px;
  580. cursor: pointer;
  581. vertical-align: middle;
  582. }
  583. }
  584. }
  585. }
  586. .login-tip {
  587. font-size: 13px;
  588. text-align: center;
  589. color: #bfbfbf;
  590. }
  591. .el-login-footer {
  592. height: 40px;
  593. line-height: 40px;
  594. position: fixed;
  595. bottom: 0;
  596. width: 100%;
  597. text-align: center;
  598. color: #fff;
  599. font-family: Arial;
  600. font-size: 12px;
  601. letter-spacing: 1px;
  602. }
  603. .login-code-img {
  604. height: 38px;
  605. }
  606. .type-max-box {
  607. display: flex;
  608. margin-bottom: 58px;
  609. width: 450px;
  610. /*border-bottom:1px solid #e0e0e0;*/
  611. p {
  612. font-size: 18px;
  613. text-align: center;
  614. line-height: 56px;
  615. margin: 0;
  616. color: #666666;
  617. cursor: pointer;
  618. }
  619. p:nth-child(1) {
  620. width: 90px;
  621. margin-right: 30px;
  622. }
  623. p:nth-child(2) {
  624. width: 126px;
  625. }
  626. .typeColorA {
  627. color: #0045af;
  628. border-bottom: 2px solid #0045af;
  629. }
  630. }
  631. .text-p {
  632. margin: 0;
  633. width: 172px;
  634. height: 50px;
  635. font-size: 14px;
  636. font-family: Microsoft YaHei;
  637. color: #DC1616;
  638. line-height: 50px;
  639. }
  640. }
  641. .logo-img {
  642. position: absolute;
  643. left: 20px;
  644. top: 20px;
  645. width: 267px;
  646. height: 66px;
  647. }
  648. }
  649. .position-p {
  650. position: absolute;
  651. right: 0;
  652. bottom: 20px;
  653. width: 638px;
  654. height: 15px;
  655. font-size: 14px;
  656. color: #AAE1FF;
  657. line-height: 15px;
  658. padding: 0;
  659. margin: 0;
  660. }
  661. }
  662. </style>