login.vue 20 KB

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