login.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <div class="login">
  3. <div class="bg" v-if="erp"><img :src="bg" alt="" style="width:100%;height:100%"></div>
  4. <div class="logoImg" v-if="erp">
  5. <img :src="logo" alt="">
  6. <span class="logoTxt">东信中控管理系统</span>
  7. </div>
  8. <div class="main" v-if="erp">
  9. <!-- <img src="@/assets/logo/logo.png" alt="" class="img1"> -->
  10. <img src="@/assets/image/img_bg.png" alt="" class="img2">
  11. <h3>中控系统管理</h3>
  12. <!-- <h4>OA SYSTEM MANAGEMENT</h4> -->
  13. <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
  14. <h2 class="title">欢迎登录</h2>
  15. <el-form-item prop="username">
  16. <el-input v-model="loginForm.username" type="text" auto-complete="off" @focus="isUsername=true"
  17. @blur="isUsername=false" placeholder="用户名">
  18. <svg-icon slot="prefix" icon-class="user" v-bind:class="{'color-class':isUsername}" class=" input-icon " />
  19. </el-input>
  20. </el-form-item>
  21. <el-form-item prop="password">
  22. <el-input
  23. v-model="loginForm.password"
  24. type="password"
  25. auto-complete="off"
  26. placeholder="密码"
  27. @focus="isPassword=true"
  28. @blur="isPassword=false"
  29. @keyup.enter.native="handleLogin"
  30. >
  31. <svg-icon slot="prefix" icon-class="password" v-bind:class="{'color-class':isPassword}" class="el-input__icon input-icon " />
  32. </el-input>
  33. </el-form-item>
  34. <el-form-item prop="code">
  35. <el-input
  36. v-model="loginForm.code"
  37. auto-complete="off"
  38. placeholder="验证码"
  39. @focus="isValidCode=true"
  40. @blur="isValidCode=false"
  41. @keyup.enter.native="handleLogin"
  42. >
  43. <svg-icon slot="prefix" icon-class="validCode" v-bind:class="{'color-class':isValidCode}" class="el-input__icon input-icon " />
  44. </el-input>
  45. <div class="login-code">
  46. <img :src="codeUrl" @click="getCode" />
  47. </div>
  48. </el-form-item>
  49. <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
  50. <el-form-item style="width:100%;">
  51. <el-button
  52. :loading="loading"
  53. size="medium"
  54. type="primary"
  55. style="width:100%;"
  56. @click.native.prevent="handleLogin"
  57. >
  58. <span v-if="!loading">登 录</span>
  59. <span v-else>登 录 中...</span>
  60. </el-button>
  61. </el-form-item>
  62. </el-form>
  63. </div>
  64. <div id="loader-wrapper" v-if="ERPloading">
  65. <div id="loader"></div>
  66. <div class="loader-section section-left"></div>
  67. <div class="loader-section section-right"></div>
  68. <div class="load_title">正在加载系统资源,请耐心等待</div>
  69. </div>
  70. <!-- 底部 -->
  71. <!-- <div class="el-login-footer">
  72. <span>© 2020 All Rights Reserved. ruoyichina.com<br> 蒙ICP备2020003903号 <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAMAAAC3SZ14AAACBFBMVEVHcEzknkbrvFL04pfow2v//9apiXD/5K3ks1Pq0o736ajt3I3w5MDRq3bn0o7t7bfoxmTy56Tw26b256jqy3vbo1HgrV/v4LH0u1HpwHm+lnP36cv05admSVDcqV+WcVFsW2KIgHjZol/48cPfo1DOkEXdp0/MilTpwGzlrVLpwFjjr1zqzIbduX3msVjTmmXltFLr2HzkvmDt2YHw3HbjuGTz3HjgsFJfPEHqxXHisHOldFrPsYn10WfXvJfw4oh0cXVcRVmFeG/bwZulgWmsjGGmbkHNrH1SOVjywWLfs27vqkndr3Hxy5yMgXXrvlnouFQhI3MbHHjhpkrsx1/enUfVHBXXjD7ttlPTJRl3dnrIRSXXLBfosk3pwV7lvGP10mH0ylzZRiTXZy3ghz/npEEXC2LXVCjrbzLhTyLnu1vs0Wrpx2bzw1boqk+pkmTzyGi7qnaRZUTWlVGzHhcoD1mdCBn3NRPbeTvjkz5tYmnWOB+xo3vPBwS6VSvLVCTQFg7Xr2RseosiFGceKYotQozuezTalUbtwVmTWDPr22zgMxq3llZgHkuKemeFiI1EAEBuJ0rhfDPZEQ3Xu3DZbjjUXDBVV3RcAz2+Lh+il3WpCh21Li7FYT/pZi/dbjCzn2m9pm3kol5pV1rrXB/aBwgTDXO/sIaVhHqxl3aggFekcEYg5SEkAAAAc3RSTlMA/PqN3gbRBP4VKVE9xiQO53lZZuL+2078sKIuQ/vj/v395zXYqst0wuT0z5xi4zrsytiM7OPw+vnN0tuk8IWv+vjqgN7w76/6sX/trDbr///////////////////////////////////////////////+NgsVowAAAXJJREFUGNNjYAACdk4eZzY2Ox5OVgYoYBeXsnYrknd1kRKHiUmzWXTWpc8vzpdlkwYLsCq7yxYlh1UnxaTMUrDhAqlT5vVYPKk7LLK6IWZRlCMvF9Agbr8g+SWTI8PCImvnzQp04mZn8PVUDFqduTQyKSmmNnNhoIM9D4OX94qgVW0N0eHBFTFtCwIVbZkZfBhXtiik1kcnV0xN8a8KqpGQZFCqbGxtrstIj56WnjG3uXVKqhiDUnhE07Ky8sz65Izy2WlN/oxiDLyMictbJpSVlMyMnjMjsLCAQ5LBKjSvoD8wrbR3YmlaUFRIBIclg4hoMWN8YV9Ufk/V9KjG1FAOEQZBFtHwFImExNyIkK6OynZzFmEGfmEBjvBQoIh/QkJeaDyLECsDuxBLSBaHf1xcSEAwR06OKdBDnMxm2fFZAQH+AcHBAXHZJsycDOxcxkYGTEyxsbEB/loChoJ87MDQ4dRXV1VT0dTT1tDR5eNnYAAAHI5j3PTE3yIAAAAASUVORK5CYII=" alt=""></span>
  73. </div> -->
  74. </div>
  75. </template>
  76. <script>
  77. import bgImg from "@/assets/image/bg.png";
  78. import logoImg from "@/assets/logo/logo-b.png";
  79. import { getCodeImg } from "@/api/login";
  80. import Cookies from "js-cookie";
  81. import { encrypt, decrypt } from '@/utils/jsencrypt'
  82. export default {
  83. name: "Login",
  84. data() {
  85. return {
  86. isUsername:false,
  87. isPassword:false,
  88. isValidCode:false,
  89. codeUrl: "",
  90. cookiePassword: "",
  91. loginForm: {
  92. username: "",
  93. password: "",
  94. rememberMe: false,
  95. code: "",
  96. uuid: ""
  97. },
  98. loginRules: {
  99. username: [
  100. { required: true, trigger: "blur", message: "用户名不能为空" }
  101. ],
  102. password: [
  103. { required: true, trigger: "blur", message: "密码不能为空" }
  104. ],
  105. code: [{ required: true, trigger: "change", message: "验证码不能为空" }]
  106. },
  107. loading: false,
  108. redirect: undefined,
  109. bg:bgImg,
  110. logo:logoImg,
  111. erp:false,
  112. ERPloading:true,
  113. };
  114. },
  115. watch: {
  116. $route: {
  117. handler: function(route) {
  118. this.redirect = route.query && route.query.redirect;
  119. },
  120. immediate: true
  121. }
  122. },
  123. created() {
  124. this.getUrl()
  125. },
  126. methods: {
  127. getUrl(){
  128. let url = this.$route.query
  129. if(url.username && url.password){
  130. let data = {username:url.username,password:url.password}
  131. if(url.path){
  132. if(url.path == "subsystem"){
  133. Cookies.set("path","subsystem")
  134. }
  135. if(url.path == "hostEquipment"){
  136. Cookies.set("path","hostEquipment")
  137. }
  138. if(url.path == "functionalInterface"){
  139. Cookies.set("path","functionalInterface")
  140. }
  141. }
  142. this.handleLoginERP(url)
  143. }else{
  144. this.getCode();
  145. this.getCookie();
  146. }
  147. },
  148. handleLoginERP(data) {//erp登录
  149. this.$store.dispatch("LoginERP", data).then((res) => {
  150. if(Cookies.get("path") === "subsystem"){
  151. this.$router.push({ path: "/business/Middleware/subsystem" });
  152. }
  153. if(Cookies.get("path") === "hostEquipment"){
  154. this.$router.push({ path: "/business/Middleware/hostEquipment" });
  155. }
  156. if(Cookies.get("path") === "functionalInterface"){
  157. this.$router.push({ path: "/business/Middleware/functionalInterface" });
  158. }
  159. }).catch((err) => {
  160. location.href = '/deviceManager/#/';
  161. });
  162. },
  163. getCode() {
  164. getCodeImg().then(res => {
  165. this.codeUrl = "data:image/gif;base64," + res.data.img;
  166. this.loginForm.uuid = res.data.uuid;
  167. this.erp = true
  168. setTimeout(()=>{
  169. this.ERPloading = false
  170. },1)
  171. });
  172. },
  173. getCookie() {
  174. const username = Cookies.get("username");
  175. const password = Cookies.get("password");
  176. const rememberMe = Cookies.get('rememberMe')
  177. this.loginForm = {
  178. username: username === undefined ? this.loginForm.username : username,
  179. password: password === undefined ? this.loginForm.password : decrypt(password),
  180. rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
  181. };
  182. },
  183. handleLogin() {
  184. this.$refs.loginForm.validate(valid => {
  185. if (valid) {
  186. this.loading = true;
  187. if (this.loginForm.rememberMe) {
  188. Cookies.set("username", this.loginForm.username, { expires: 30 });
  189. Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 });
  190. Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 });
  191. } else {
  192. Cookies.remove("username");
  193. Cookies.remove("password");
  194. Cookies.remove('rememberMe');
  195. }
  196. this.$store
  197. .dispatch("Login", this.loginForm)
  198. .then(() => {
  199. this.$router.push({ path: "/Middleware/bpmn/index" });
  200. //this.$router.push({ path: this.redirect || "/" });
  201. })
  202. .catch(() => {
  203. this.loading = false;
  204. this.getCode();
  205. });
  206. }
  207. });
  208. }
  209. }
  210. };
  211. </script>
  212. <style rel="stylesheet/scss" lang="scss">
  213. .bg{
  214. width:100%;
  215. height:100%;
  216. overflow: hidden;
  217. position: fixed;
  218. top:0;
  219. left:0;
  220. z-index: -1;
  221. .bgimg{
  222. width:100%;
  223. height:100%;
  224. position: absolute;
  225. top:0;
  226. left:0;
  227. z-index: -1;
  228. }
  229. }
  230. .logoImg{
  231. width:100%;
  232. position: fixed;
  233. top:0;
  234. z-index: 1;
  235. img{
  236. width:152px;
  237. margin:10px 2rem 0 20px;
  238. vertical-align: middle;
  239. }
  240. .logoTxt{
  241. font-size: 1.5rem;
  242. color:#fff;
  243. vertical-align: middle;
  244. letter-spacing: 4px;
  245. }
  246. }
  247. .login {
  248. display: flex;
  249. justify-content: center;
  250. align-items: center;
  251. height: 100%;
  252. // background-color: #0D1D30;
  253. position: relative;
  254. }
  255. .main{
  256. position: relative;
  257. width: 940px;
  258. height: 495px;
  259. background:rgba(25,41,59,1);
  260. border-radius:12px;
  261. box-shadow:0px 2px 12px 0px rgba(9,23,39,1);
  262. color:rgba(255,255,255,1);
  263. .img1{
  264. position:absolute;
  265. top: 46px;
  266. left: 53px;
  267. width: 110px;
  268. }
  269. .img2{
  270. position:absolute;
  271. top: 63px;
  272. left: 132px;
  273. width: 348px;
  274. height: 299px;
  275. }
  276. h3{
  277. margin-left: 52px;
  278. margin-top: 383px;
  279. margin-bottom: 0;
  280. font-size:32px;
  281. }
  282. h4{
  283. margin-left: 52px;
  284. font-size:24px;
  285. margin-top: 16px;
  286. }
  287. .login-form {
  288. position:absolute;
  289. right: 0;
  290. top: 0;
  291. border-radius: 6px;
  292. background: #ffffff;
  293. width: 299px;
  294. height: 495px;
  295. padding: 58px 33px 33px 33px;
  296. .title {
  297. width:85px;
  298. font-size:20px;
  299. margin: 0px auto 62px auto;
  300. border-bottom: 3px rgba(27,74,127,1) ridge;
  301. text-align: center;
  302. color: #333333;
  303. padding-bottom: 8px;
  304. }
  305. .el-input {
  306. height: 32px;
  307. input:focus {
  308. color:rgba(6,104,185,1);
  309. }
  310. input {
  311. outline:none;
  312. height: 38px;
  313. border-top: 0;
  314. border-left: 0;
  315. border-right: 0;
  316. border-radius:0;
  317. }
  318. }
  319. .color-class{
  320. color:rgba(6,104,185,1);
  321. }
  322. .input-icon {
  323. height: 39px;
  324. width: 19px;
  325. margin-left: 2px;
  326. }
  327. }
  328. }
  329. .login-code {
  330. position:absolute;
  331. width: 88px;
  332. height: 32px;
  333. right: 0;
  334. bottom: 8px;
  335. img {
  336. width: 88px;
  337. height: 32px;
  338. cursor: pointer;
  339. vertical-align: middle;
  340. }
  341. }
  342. .el-login-footer {
  343. height: 40px;
  344. line-height: 40px;
  345. position: absolute;
  346. transform: translateY(273px);
  347. width: 100%;
  348. text-align: center;
  349. color: #fff;
  350. font-family: Arial;
  351. font-size: 12px;
  352. letter-spacing: 1px;
  353. span{
  354. img{
  355. height: 12px;
  356. }
  357. }
  358. }
  359. </style>