page.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <div class="page-login">
  3. <div class="page-login--layer page-login--layer-area">
  4. <ul class="circles">
  5. <li v-for="n in 10" :key="n"></li>
  6. </ul>
  7. </div>
  8. <div class="page-login--layer">
  9. <div
  10. class="page-login--content"
  11. flex="dir:top main:justify cross:stretch box:justify">
  12. <div class="page-login--content-header">
  13. </div>
  14. <div
  15. class="page-login--content-main"
  16. flex="dir:top main:center cross:center">
  17. <!-- logo -->
  18. <img class="page-login--logo" src="./image/logo.png">
  19. <!-- form -->
  20. <div class="page-login--form">
  21. <el-card shadow="never">
  22. <el-form
  23. ref="loginForm"
  24. label-position="top"
  25. :rules="rules"
  26. :model="formLogin"
  27. size="default">
  28. <div style="font-size:30px;text-align:center;color:#fff;margin-bottom:30px">用户登录</div>
  29. <el-form-item prop="username">
  30. <el-input
  31. type="text"
  32. v-model="formLogin.username"
  33. placeholder="用户名">
  34. <i slot="prepend" class="fa fa-user"></i>
  35. </el-input>
  36. </el-form-item>
  37. <el-form-item prop="password">
  38. <el-input
  39. type="password"
  40. v-model="formLogin.password"
  41. placeholder="密码">
  42. <i slot="prepend" class="fa fa-lock"></i>
  43. </el-input>
  44. </el-form-item>
  45. <el-button
  46. size="default"
  47. @click="submit"
  48. type="primary"
  49. class="button-login">
  50. 登录
  51. </el-button>
  52. </el-form>
  53. </el-card>
  54. </div>
  55. </div>
  56. <div class="page-login--content-footer">
  57. <Foot></Foot>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. import util from '@/libs/util.js'
  65. import Foot from "../../../layout/header-aside/components/footer";
  66. import api from '@/api'
  67. import { mapActions } from 'vuex'
  68. import localeMixin from '@/locales/mixin.js'
  69. export default {
  70. components: {Foot},
  71. mixins: [
  72. localeMixin
  73. ],
  74. data () {
  75. return {
  76. // 快速选择用户
  77. dialogVisible: false,
  78. users: [
  79. {
  80. name: 'Admin',
  81. username: 'admin',
  82. password: 'admin'
  83. },
  84. {
  85. name: 'Editor',
  86. username: 'editor',
  87. password: 'editor'
  88. },
  89. {
  90. name: 'User1',
  91. username: 'user1',
  92. password: 'user1'
  93. }
  94. ],
  95. // 表单
  96. formLogin: {
  97. username: '',
  98. password: '',
  99. code: 'v9am'
  100. },
  101. // 表单校验
  102. rules: {
  103. username: [
  104. {
  105. required: true,
  106. message: '请输入用户名',
  107. trigger: 'blur'
  108. }
  109. ],
  110. password: [
  111. {
  112. required: true,
  113. message: '请输入密码',
  114. trigger: 'blur'
  115. }
  116. ],
  117. code: [
  118. {
  119. required: true,
  120. message: '请输入验证码',
  121. trigger: 'blur'
  122. }
  123. ]
  124. },
  125. }
  126. },
  127. mounted () {
  128. },
  129. created(){
  130. //开启监听键盘按下事件
  131. window.addEventListener("keydown",this.handleKeyDown,true);
  132. },
  133. beforeDestroy () {
  134. },
  135. methods: {
  136. ...mapActions('d2admin/account', [
  137. 'login'
  138. ]),
  139. handleKeyDown(e){
  140. let key=null;
  141. if(window.event===undefined){
  142. key=e.keyCode;
  143. }else{
  144. key=window.event.keyCode;
  145. }
  146. if(key===13){
  147. this.submit();
  148. }
  149. },
  150. loginBtn(){
  151. let data={
  152. userName:this.formLogin.username,
  153. userPassword:this.formLogin.password
  154. }
  155. api.login(data)
  156. .then(res=>{
  157. if(res.code==200){
  158. console.log(res,"loginRes")
  159. //移除键盘事件
  160. window.removeEventListener('keydow',this.handleKeyDown,true)
  161. // util.cookies.set('uuid', "admin-uuid")
  162. // util.cookies.set('token', "afe08f93-c46b-47d9-ac3b-43e9ad0c55ba")
  163. // util.cookies.set('uuid', "admin-uuid")
  164. console.log( res.data.token," res.data.token")
  165. util.cookies.set('token', res.data.token)
  166. // 重定向对象不存在则返回顶层路径
  167. this.$router.replace(this.$route.query.redirect || '/')
  168. localStorage.setItem("userName",this.formLogin.username);
  169. localStorage.setItem("manageStore",res.data.object.manageStore);
  170. localStorage.setItem("orgId",res.data.object.orgId);
  171. localStorage.setItem("orgCode",res.data.object.orgCode);
  172. localStorage.setItem("orgName",res.data.object.orgName);
  173. }else if(res.code==600){
  174. this.$message.error('账号或密码错误');
  175. }
  176. })
  177. },
  178. // 提交登录信息
  179. submit () {
  180. this.$refs.loginForm.validate((valid) => {
  181. if (valid) {
  182. // 登录
  183. // 注意 这里的演示没有传验证码
  184. // 具体需要传递的数据请自行修改代码
  185. // this.login({
  186. // username: this.formLogin.username,
  187. // password: this.formLogin.password
  188. // })
  189. // .then(() => {
  190. // // 重定向对象不存在则返回顶层路径
  191. // this.$router.replace(this.$route.query.redirect || '/')
  192. // localStorage.setItem("userName",this.formLogin.username)
  193. // })
  194. this.loginBtn();
  195. } else {
  196. // 登录表单校验失败
  197. this.$message.error('表单校验失败,请检查')
  198. }
  199. })
  200. },
  201. // 随机语录
  202. tipsrandom () {
  203. var index
  204. index = Math.floor(Math.random() * this.tipsarr.length)
  205. this.tips = this.tipsarr[index]
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="scss">
  211. .page-login {
  212. @extend %unable-select;
  213. $backgroundColor: #F0F2F5;
  214. // ---
  215. background-color: $backgroundColor;
  216. background: url('./image/bg.jpg') center no-repeat ;
  217. background-size:100% 100%;
  218. height: 100%;
  219. position: relative;
  220. // 层
  221. .page-login--layer {
  222. @extend %full;
  223. overflow: auto;
  224. }
  225. .page-login--layer-area {
  226. overflow: hidden;
  227. }
  228. // 时间
  229. .page-login--layer-time {
  230. font-size: 24em;
  231. font-weight: bold;
  232. color: rgba(0, 0, 0, 0.03);
  233. overflow: hidden;
  234. }
  235. // 登陆页面控件的容器
  236. .page-login--content {
  237. height: 100%;
  238. min-height: 500px;
  239. }
  240. // header
  241. .page-login--content-header {
  242. padding: 1em 0;
  243. .page-login--content-header-motto {
  244. margin: 0px;
  245. padding: 0px;
  246. color: $color-text-normal;
  247. text-align: center;
  248. font-size: 12px;
  249. }
  250. }
  251. // main
  252. .page-login--logo {
  253. width: 240px;
  254. margin-bottom: 2em;
  255. margin-top: -2em;
  256. }
  257. // 登录表单
  258. .page-login--form {
  259. width: 28em;
  260. height: 26em;
  261. background-image: url("./image/dengluk.png");
  262. background-repeat: no-repeat;
  263. background-size: 100% 100%;
  264. // 卡片
  265. .el-card {
  266. margin-bottom: 15px;
  267. background: none !important;
  268. border: none !important;
  269. }
  270. // 登录按钮
  271. .button-login {
  272. width: 100%;
  273. height: 56px;
  274. background: linear-gradient(0deg, #01E9BD, #00D6B9);
  275. border-radius: 6px;
  276. }
  277. .el-input{
  278. width: 100%;
  279. background: rgba(255,255,255,0.1100);
  280. border: 1px solid #6DF6E4;
  281. box-shadow: 0px 0px 9px 0px rgba(0,87,75,0.3100);
  282. border-radius: 6px;
  283. color: #fff;
  284. height: 57px;
  285. }
  286. // 输入框左边的图表区域缩窄
  287. .el-input-group__prepend {
  288. padding: 0px 14px;
  289. }
  290. .login-code {
  291. height: 40px - 2px;
  292. display: block;
  293. margin: 0px -20px;
  294. border-top-right-radius: 2px;
  295. border-bottom-right-radius: 2px;
  296. }
  297. // 登陆选项
  298. .page-login--options {
  299. margin: 0px;
  300. padding: 0px;
  301. font-size: 14px;
  302. color: $color-primary;
  303. margin-bottom: 15px;
  304. font-weight: bold;
  305. }
  306. .page-login--quick {
  307. width: 100%;
  308. }
  309. }
  310. // 快速选择用户面板
  311. .page-login--quick-user {
  312. @extend %flex-center-col;
  313. padding: 10px 0px;
  314. border-radius: 4px;
  315. &:hover {
  316. background-color: $color-bg;
  317. i {
  318. color: $color-text-normal;
  319. }
  320. span {
  321. color: $color-text-normal;
  322. }
  323. }
  324. i {
  325. font-size: 36px;
  326. color: $color-text-sub;
  327. }
  328. span {
  329. font-size: 12px;
  330. margin-top: 10px;
  331. color: $color-text-sub;
  332. }
  333. }
  334. // footer
  335. .page-login--content-footer {
  336. // padding: 1em 0;
  337. .page-login--content-footer-locales {
  338. padding: 0px;
  339. margin: 0px;
  340. margin-bottom: 15px;
  341. font-size: 12px;
  342. line-height: 12px;
  343. text-align: center;
  344. color: $color-text-normal;
  345. a {
  346. color: $color-text-normal;
  347. margin: 0 .5em;
  348. &:hover {
  349. color: $color-text-main;
  350. }
  351. }
  352. }
  353. .page-login--content-footer-copyright {
  354. padding: 0px;
  355. margin: 0px;
  356. margin-bottom: 10px;
  357. font-size: 12px;
  358. line-height: 12px;
  359. text-align: center;
  360. color: $color-text-normal;
  361. a {
  362. color: $color-text-normal;
  363. }
  364. }
  365. .page-login--content-footer-options {
  366. padding: 0px;
  367. margin: 0px;
  368. font-size: 12px;
  369. line-height: 12px;
  370. text-align: center;
  371. a {
  372. color: $color-text-normal;
  373. margin: 0 1em;
  374. }
  375. }
  376. }
  377. // 背景
  378. .circles {
  379. position: absolute;
  380. top: 0;
  381. left: 0;
  382. width: 100%;
  383. height: 100%;
  384. overflow: hidden;
  385. margin: 0px;
  386. padding: 0px;
  387. // li {
  388. // position: absolute;
  389. // display: block;
  390. // list-style: none;
  391. // width: 20px;
  392. // height: 20px;
  393. // background: #FFF;
  394. // animation: animate 25s linear infinite;
  395. // bottom: -200px;
  396. // @keyframes animate {
  397. // 0%{
  398. // transform: translateY(0) rotate(0deg);
  399. // opacity: 1;
  400. // border-radius: 0;
  401. // }
  402. // 100%{
  403. // transform: translateY(-1000px) rotate(720deg);
  404. // opacity: 0;
  405. // border-radius: 50%;
  406. // }
  407. // }
  408. // &:nth-child(1) {
  409. // left: 15%;
  410. // width: 80px;
  411. // height: 80px;
  412. // animation-delay: 0s;
  413. // }
  414. // &:nth-child(2) {
  415. // left: 5%;
  416. // width: 20px;
  417. // height: 20px;
  418. // animation-delay: 2s;
  419. // animation-duration: 12s;
  420. // }
  421. // &:nth-child(3) {
  422. // left: 70%;
  423. // width: 20px;
  424. // height: 20px;
  425. // animation-delay: 4s;
  426. // }
  427. // &:nth-child(4) {
  428. // left: 40%;
  429. // width: 60px;
  430. // height: 60px;
  431. // animation-delay: 0s;
  432. // animation-duration: 18s;
  433. // }
  434. // &:nth-child(5) {
  435. // left: 65%;
  436. // width: 20px;
  437. // height: 20px;
  438. // animation-delay: 0s;
  439. // }
  440. // &:nth-child(6) {
  441. // left: 75%;
  442. // width: 150px;
  443. // height: 150px;
  444. // animation-delay: 3s;
  445. // }
  446. // &:nth-child(7) {
  447. // left: 35%;
  448. // width: 200px;
  449. // height: 200px;
  450. // animation-delay: 7s;
  451. // }
  452. // &:nth-child(8) {
  453. // left: 50%;
  454. // width: 25px;
  455. // height: 25px;
  456. // animation-delay: 15s;
  457. // animation-duration: 45s;
  458. // }
  459. // &:nth-child(9) {
  460. // left: 20%;
  461. // width: 15px;
  462. // height: 15px;
  463. // animation-delay: 2s;
  464. // animation-duration: 35s;
  465. // }
  466. // &:nth-child(10) {
  467. // left: 85%;
  468. // width: 150px;
  469. // height: 150px;
  470. // animation-delay: 0s;
  471. // animation-duration: 11s;
  472. // }
  473. // }
  474. }
  475. .el-input__inner{
  476. border: none;
  477. height: 57px;
  478. line-height: 57px;
  479. padding-left: 10px;
  480. padding-right: 0;
  481. background: transparent;
  482. color:#fff
  483. }
  484. .el-input__inner:-webkit-autofill,
  485. .el-input__inner:-webkit-autofill:hover,
  486. .el-input__inner:-webkit-autofill:focus,
  487. .el-input__inner:-webkit-autofill:active {
  488. -webkit-transition-delay: 99999s;
  489. -webkit-transition: color 99999s ease-out, background-color 99999s ease-out;
  490. }
  491. .el-input-group__append, .el-input-group__prepend{
  492. background: none !important;
  493. border:none !important;
  494. color: rgba(255, 255, 255, 0.8) !important;
  495. font-size: 22px;
  496. }
  497. .el-form-item__error{
  498. color:#fff
  499. }
  500. input::-webkit-input-placeholder{
  501. color:#fff;
  502. }
  503. input::-moz-placeholder{ /* Mozilla Firefox 19+ */
  504. color:#fff;
  505. }
  506. input:-moz-placeholder{ /* Mozilla Firefox 4 to 18 */
  507. color:#fff;
  508. }
  509. input:-ms-input-placeholder{ /* Internet Explorer 10-11 */
  510. color:#fff;
  511. }
  512. }
  513. </style>