index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <template>
  2. <div class="login-container">
  3. <div class="login-left">
  4. <div class="login-header">
  5. <div class="logo">
  6. <img src="@/assets/images/base/login-logo.png" alt="">
  7. </div>
  8. <i class="line"></i>
  9. <div class="logo-name">乐团管理系统</div>
  10. </div>
  11. <div class="footer">
  12. <!-- @copyright@Daya Webucation co.、Ltd2019 -->
  13. Copyright © 2022 管乐迷, Inc.ALL Rights Reserved
  14. </div>
  15. </div>
  16. <div class="login-section">
  17. <!-- <div class="left-header">
  18. <div class="login-project-name">
  19. <span>欢迎登录</span>管乐迷乐团运管系统
  20. </div>
  21. </div> -->
  22. <el-form ref="loginForm"
  23. :model="loginForm"
  24. :rules="loginRules"
  25. class="login-form"
  26. auto-complete="on"
  27. label-position="left">
  28. <div class="title-container">登录</div>
  29. <el-form-item prop="username"
  30. class='logitem'>
  31. <span class="svg-container">
  32. <svg-icon icon-class="user" />
  33. </span>
  34. <el-input ref="username"
  35. @keyup.enter.native="handleLogin"
  36. v-model.trim="loginForm.username"
  37. placeholder="请输入用户名"
  38. class='login-input'
  39. name="username"
  40. type="text"
  41. tabindex="1"
  42. auto-complete="off" />
  43. </el-form-item>
  44. <el-form-item prop="password"
  45. class='logitem'>
  46. <span class="svg-container">
  47. <svg-icon icon-class="password" />
  48. </span>
  49. <el-input :key="passwordType"
  50. ref="password"
  51. class='login-input'
  52. v-model.trim="loginForm.password"
  53. :type="passwordType"
  54. placeholder="请输入密码"
  55. name="password"
  56. tabindex="2"
  57. auto-complete="off"
  58. @keyup.enter.native="handleLogin" />
  59. <span class="show-pwd"
  60. @click="showPwd">
  61. <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
  62. </span>
  63. </el-form-item>
  64. <div class='remberBox' @click="isSaveUserInfo = !isSaveUserInfo">
  65. <div class="dotWrap" :class="[isSaveUserInfo ? 'checked' : '']"></div>
  66. 记住密码
  67. <!-- <el-checkbox v-model="isSaveUserInfo">记住密码</el-checkbox> -->
  68. </div>
  69. <div class="loginBtn"
  70. :class="!loginForm.username || !loginForm.password?'disabled':''"
  71. @click="handleLogin">登录</div>
  72. </el-form>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import { validUsername } from "@/utils/validate";
  78. import { Searchs } from '@/helpers'
  79. export default {
  80. name: "Login",
  81. data () {
  82. const validateUsername = (rule, value, callback) => {
  83. // validUsername
  84. if (!value) {
  85. callback(new Error("请输入用户名"));
  86. } else {
  87. callback();
  88. }
  89. }
  90. const validatePassword = (rule, value, callback) => {
  91. if (value.length < 6) {
  92. callback(new Error("密码必须大于六位"));
  93. } else {
  94. callback();
  95. }
  96. }
  97. return {
  98. loginForm: {
  99. username: "",
  100. password: ""
  101. },
  102. loginRules: {
  103. username: [
  104. { required: true, trigger: "blur", validator: validateUsername }
  105. ],
  106. password: [
  107. { required: true, trigger: "blur", validator: validatePassword }
  108. ]
  109. },
  110. passwordType: "password",
  111. redirect: undefined,
  112. isSaveUserInfo: true
  113. }
  114. },
  115. mounted () {
  116. this.loginForm.username = localStorage.getItem('username');
  117. this.loginForm.password = localStorage.getItem('password');
  118. },
  119. watch: {
  120. $route: {
  121. handler: function (route) {
  122. this.redirect = route.query && route.query.redirect;
  123. },
  124. immediate: true
  125. }
  126. },
  127. methods: {
  128. showPwd () {
  129. if (this.passwordType === "password") {
  130. this.passwordType = "";
  131. } else {
  132. this.passwordType = "password";
  133. }
  134. this.$nextTick(() => {
  135. this.$refs.password.focus();
  136. });
  137. },
  138. handleLogin () {
  139. // 清除所有savekey
  140. const s = new Searchs();
  141. s.removeAll()
  142. // 判断是否点击了记住密码 => 存储密码
  143. if (this.isSaveUserInfo) {
  144. localStorage.setItem('username', this.loginForm.username);
  145. localStorage.setItem('password', this.loginForm.password);
  146. } else {
  147. localStorage.setItem('username', '');
  148. localStorage.setItem('password', '');
  149. }
  150. this.$refs.loginForm.validate(valid => {
  151. if (valid) {
  152. this.$store
  153. .dispatch("user/login", this.loginForm)
  154. .then(() => {
  155. this.$nextTick(res => {
  156. // 这里清空 tab
  157. this.$store
  158. .dispatch("delAllViews")
  159. this.$router.push({ path: "/main/main" });
  160. })
  161. })
  162. .catch(() => {
  163. });
  164. } else {
  165. return false;
  166. }
  167. });
  168. },
  169. saveUserInfo () {
  170. this.isSaveUserInfo = !this.isSaveUserInfo;
  171. }
  172. }
  173. };
  174. </script>
  175. <style lang="scss" rel="stylesheet/scss" scoped>
  176. body {
  177. background: #fff !important;
  178. }
  179. /deep/.el-input__inner{
  180. background-color:transparent!important;
  181. border:1px solid transparent!important
  182. }
  183. .login-container .el-input input:-webkit-autofill{
  184. background-color:transparent!important;
  185. }
  186. .login-input {
  187. background-color:transparent!important;
  188. }
  189. /* 修复input 背景不协调 和光标变色 */
  190. /* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
  191. .loginBtn {
  192. background-color: #22B4A9;
  193. text-align: center;
  194. margin: 0 auto;
  195. width: 85%;
  196. height: 50px;
  197. line-height: 50px;
  198. color: #fff;
  199. border-radius: 5px;
  200. cursor: pointer;
  201. }
  202. .loginBtn.disabled {
  203. background-color: rgba(34, 180, 169, .5);
  204. }
  205. ::-webkit-input-placeholder {
  206. /* WebKit browsers */
  207. color: #444;
  208. font-size: 14px;
  209. }
  210. ::-moz-placeholder {
  211. /* Mozilla Firefox 19+ */
  212. color: #444;
  213. font-size: 14px;
  214. }
  215. :-ms-input-placeholder {
  216. /* Internet Explorer 10+ */
  217. color: #444;
  218. font-size: 14px;
  219. }
  220. .login-container .el-input input {
  221. color: #444 !important;
  222. caret-color: #444 !important;
  223. }
  224. .remberBox {
  225. display: flex;
  226. flex-direction: row;
  227. justify-content: flex-start;
  228. margin-bottom: 30px;
  229. padding-top: 10px;
  230. align-items: center;
  231. cursor: pointer;
  232. color: #6D7278;
  233. font-size: 16px;
  234. .dotWrap {
  235. width: 21px;
  236. height: 21px;
  237. background: url('../../assets/images/icon_checkbox_default.png') no-repeat center;
  238. background-size: contain;
  239. margin-right: 8px;
  240. position: relative;
  241. overflow: hidden;
  242. &.checked {
  243. background: url('../../assets/images/icon_checkbox.png') no-repeat center;
  244. background-size: contain;
  245. }
  246. }
  247. }
  248. $bg: #fff;
  249. $light_gray: #000;
  250. $cursor: #000;
  251. @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  252. .login-container .el-input input {
  253. color: $cursor;
  254. &::first-line {
  255. color: $light_gray;
  256. }
  257. }
  258. }
  259. @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  260. .login-container .el-input input {
  261. color: $cursor;
  262. }
  263. }
  264. /* reset element-ui css */
  265. .login-container {
  266. .el-input {
  267. display: inline-block;
  268. height: 47px;
  269. width: 85%;
  270. input {
  271. background: transparent!important;
  272. border: 0px;
  273. -webkit-appearance: none;
  274. border-radius: 0px;
  275. padding: 12px 5px 12px 15px;
  276. color: $light_gray;
  277. height: 47px;
  278. caret-color: $cursor;
  279. &:-webkit-autofill {
  280. box-shadow: 0 0 0px 1000px $bg inset !important;
  281. -webkit-text-fill-color: $cursor !important;
  282. }
  283. }
  284. }
  285. .el-form-item {
  286. border: 1px solid #E5E6E8;
  287. border-radius: 8px;
  288. color: #454545;
  289. }
  290. }
  291. </style>
  292. <style lang="scss" scoped>
  293. $bg: #fff;
  294. $dark_gray: #000;
  295. $light_gray: #eee;
  296. .login-container {
  297. // min-height: 100%;
  298. // width: 100%;
  299. // background: url("../../assets/images/base/login-bg-1.png") no-repeat 100% 100%;
  300. // background-size: cover;
  301. // overflow: hidden;
  302. height: 100vh;
  303. // background-image: url("../../assets/images/base/login-bg.png");
  304. display: flex;
  305. align-items: center;
  306. justify-content: space-between;
  307. background: url("../../assets/images/base/login-bg.png") no-repeat center left #fff;
  308. background-size: cover;
  309. .login-form {
  310. // position: absolute;
  311. // left: 180px;
  312. // top: 240px;
  313. width: 500px;
  314. border-radius: 15px;
  315. padding: 50px 60px 70px;
  316. background-color: #fff;
  317. box-shadow: 0px 0px 16px 1px #ebf6f5;
  318. }
  319. .tips {
  320. font-size: 14px;
  321. color: #fff;
  322. margin-bottom: 10px;
  323. span {
  324. &:first-of-type {
  325. margin-right: 16px;
  326. }
  327. }
  328. }
  329. .svg-container {
  330. padding: 6px 5px 6px 15px;
  331. color: #999999;
  332. vertical-align: middle;
  333. width: 30px;
  334. display: inline-block;
  335. }
  336. .title-container {
  337. position: relative;
  338. display: flex;
  339. flex-direction: column;
  340. align-items: flex-start;
  341. font-size: 26px;
  342. color: #333;
  343. font-weight: 600;
  344. margin-bottom: 30px;
  345. border-bottom: 1px solid #E5E6E8;
  346. &::after {
  347. margin-top: 12px;
  348. display: inline-block;
  349. content: ' ';
  350. width: 25px;
  351. height: 4px;
  352. background: #22B4A9;
  353. margin-bottom: -2px;
  354. margin-left: 13px;
  355. }
  356. }
  357. .show-pwd {
  358. position: absolute;
  359. right: 10px;
  360. top: 7px;
  361. font-size: 14px;
  362. color: #6D7278;
  363. cursor: pointer;
  364. user-select: none;
  365. }
  366. .login-header {
  367. margin-top: 80px;
  368. font-size: 18px;
  369. color: #333333;
  370. display: flex;
  371. align-items: center;
  372. justify-content: flex-start;
  373. margin-bottom: 30px;
  374. .logo {
  375. img {
  376. height: 40px;
  377. }
  378. }
  379. .line {
  380. display: inline-block;
  381. width: 1px;
  382. height: 20px;
  383. background: #979797;
  384. margin: 0 20px;
  385. }
  386. }
  387. .login-left {
  388. display: flex;
  389. flex-direction: column;
  390. justify-content: space-between;
  391. height: 100%;
  392. margin-left: 170px;
  393. .footer {
  394. margin-bottom: 30px;
  395. font-size: 14px;
  396. position: absolute;
  397. color: #B2B2B2;
  398. bottom: 0;
  399. width: 100%;
  400. left: 0;
  401. text-align: center;
  402. }
  403. }
  404. // .login-project-name {
  405. // margin-top: 100px;
  406. // font-size: 24px;
  407. // color: #333333;
  408. // font-weight: 100;
  409. // span {
  410. // font-size: 34px;
  411. // color: #000;
  412. // font-weight: 600;
  413. // padding-right: 15px;
  414. // }
  415. // }
  416. }
  417. .login-section {
  418. margin-right: 250px;
  419. }
  420. /* 大屏幕(大桌面显示器,大于等于 1200px) */
  421. @media screen and (max-width: 1600px) {
  422. .login-section {
  423. margin-right: 200px;
  424. }
  425. .login-container .login-left {
  426. margin-left: 100px;
  427. }
  428. // .login-container .login-left .footer {
  429. // margin-left: 120px;
  430. // }
  431. }
  432. /* 大屏幕(大桌面显示器,大于等于 1200px) */
  433. @media screen and (max-width: 1200px) {
  434. .login-section {
  435. margin-right: 100px;
  436. }
  437. .login-container .login-left {
  438. margin-left: 50px;
  439. }
  440. // .login-container .login-left .footer {
  441. // margin-left: 100px;
  442. // }
  443. }
  444. /* 中等屏幕(桌面显示器,大于等于 992px) */
  445. @media screen and (max-width: 992px) {
  446. .login-section {
  447. margin-right: 100px;
  448. }
  449. .login-container .login-left {
  450. margin-left: 20px;
  451. }
  452. // .login-container .login-left .footer {
  453. // margin-left: 50px;
  454. // }
  455. }
  456. /* 小屏幕(平板,大于等于 768px) */
  457. @media screen and (max-width: 768px) {
  458. .login-section {
  459. margin-right: 50px;
  460. }
  461. .login-container .login-left {
  462. margin-left: 10px;
  463. display: none;
  464. }
  465. // .login-container .login-left .footer {
  466. // margin-left: 20px;
  467. // }
  468. }
  469. </style>