Login.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="login_container">
  3. <div class="login_box">
  4. <div class="tit-box">
  5. <div class="tit-con">
  6. <p class="txt">
  7. 欢迎来到
  8. <span class="arrow">
  9. <i class="el-icon-arrow-right"></i>
  10. </span>
  11. </p>
  12. <p class="tit">智慧农业大数据平台</p>
  13. </div>
  14. </div>
  15. <div class="f-box">
  16. <ul class="loginItems">
  17. <li>
  18. <i class="iconfont icon-yonghu1"></i>
  19. <input
  20. type="text"
  21. @keyup="fillPass()"
  22. id="username"
  23. v-model="username"
  24. placeholder="请输入用户名"
  25. />
  26. </li>
  27. <li>
  28. <i class="iconfont icon-mima1"></i>
  29. <input
  30. type="password"
  31. id="password"
  32. v-model="pass"
  33. placeholder="请输入密码"
  34. />
  35. </li>
  36. <li>
  37. <div class="pass">
  38. <input type="checkbox" id="brand" v-model="cState" />
  39. <label for="brand">
  40. <span>
  41. <i class="el-icon-check"></i>
  42. </span>
  43. 记住密码
  44. </label>
  45. <a>忘记密码?</a>
  46. </div>
  47. </li>
  48. <li>
  49. <button class="logon-btn" @click="submit()">登录</button>
  50. </li>
  51. </ul>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. username: '',
  61. pass: '',
  62. cState: true
  63. }
  64. },
  65. methods: {
  66. submit() {
  67. if (this.username == '' || this.pass == '') {
  68. this.$message.error('请输入用户名和密码!')
  69. return
  70. }
  71. this.$axios({
  72. method: 'POST',
  73. url: 'login',
  74. data: this.qs.stringify({
  75. username: this.username,
  76. password: this.pass
  77. })
  78. }).then((res) => {
  79. if (res.data.message == '') {
  80. if (this.cState == true) {
  81. //是否记住密码
  82. localStorage.setItem('username', this.username)
  83. localStorage.setItem('password', this.pass)
  84. } else {
  85. localStorage.removeItem(username, password)
  86. }
  87. localStorage.setItem('isLogin', true)
  88. let selHome = sessionStorage.getItem('selHome')
  89. if (selHome) {
  90. this.$router.push(selHome) //登录后默认选择首页
  91. } else {
  92. this.$router.push('/index/home')
  93. }
  94. } else {
  95. this.$message.error(res.data.message)
  96. }
  97. })
  98. },
  99. fillPass() {
  100. let username = localStorage.getItem('username')
  101. if (username == this.username) {
  102. this.pass = localStorage.getItem('password')
  103. }
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang='less' scoped>
  109. .login_container {
  110. height: 100%;
  111. // background: url(../../static/images/login/1.gif) no-repeat center;
  112. background-size: 100% 100%;
  113. .login_box {
  114. width: 900px;
  115. height: 450px;
  116. position: absolute;
  117. left: 50%;
  118. top: 50%;
  119. transform: translate(-50%, -50%);
  120. display: flex;
  121. .tit-box {
  122. position: relative;
  123. flex: 1;
  124. background: rgba(0, 0, 0, 0.6);
  125. color: #fff;
  126. letter-spacing: 5px;
  127. .tit-con {
  128. display: block;
  129. padding: 180px 50px;
  130. .txt {
  131. font-size: 24px;
  132. padding-bottom: 15px;
  133. border-bottom: 1px solid #fff;
  134. position: relative;
  135. .arrow {
  136. position: absolute;
  137. top: 4px;
  138. margin-left: 10px;
  139. background: #fff;
  140. width: 25px;
  141. height: 25px;
  142. border-radius: 50%;
  143. i {
  144. color: #000;
  145. font-size: 18px;
  146. position: absolute;
  147. left: 4px;
  148. top: 4px;
  149. }
  150. i:before {
  151. font-weight: 800;
  152. }
  153. }
  154. }
  155. .tit {
  156. font-size: 32px;
  157. padding-top: 10px;
  158. }
  159. }
  160. }
  161. .f-box {
  162. flex: 1;
  163. background: #fff;
  164. .loginItems {
  165. padding: 80px 50px 0 50px;
  166. li {
  167. width: 100%;
  168. margin-bottom: 45px;
  169. position: relative;
  170. i.iconfont {
  171. position: absolute;
  172. font-size: 22px;
  173. left: 0;
  174. top: 5px;
  175. color: #b5b5b5;
  176. }
  177. }
  178. input::-webkit-input-placeholder {
  179. /* WebKit browsers 适配谷歌 */
  180. color: #b5b5b5;
  181. }
  182. input:-moz-placeholder {
  183. /* Mozilla Firefox 4 to 18 适配火狐 */
  184. color: #b5b5b5;
  185. }
  186. input::-moz-placeholder {
  187. /* Mozilla Firefox 19+ 适配火狐 */
  188. color: #b5b5b5;
  189. }
  190. input:-ms-input-placeholder {
  191. /* Internet Explorer 10+ 适配ie*/
  192. color: #b5b5b5;
  193. }
  194. input[type='text'],
  195. input[type='password'] {
  196. border: none;
  197. padding: 10px 20px 10px 30px;
  198. box-sizing: border-box;
  199. border-bottom: 1px solid #b5b5b5;
  200. width: 100%;
  201. font-size: 15px;
  202. outline: none;
  203. box-shadow: 0 0 0px 1000px white inset !important;
  204. -webkit-box-shadow: 0 0 0px 1000px white inset !important;
  205. }
  206. input[type='checkbox'] {
  207. display: none;
  208. }
  209. input[type='checkbox'] + label span {
  210. display: inline-block;
  211. width: 16px;
  212. height: 16px;
  213. border-radius: 3px;
  214. border: 1px solid #b5b5b5;
  215. float: left;
  216. margin-right: 10px;
  217. i {
  218. display: none;
  219. }
  220. }
  221. input[type='checkbox']:checked + label span {
  222. background: #2f3945;
  223. i {
  224. display: block;
  225. font-size: 15px;
  226. color: #fff;
  227. }
  228. i:before {
  229. font-weight: 800;
  230. }
  231. }
  232. .pass {
  233. display: flex;
  234. justify-content: space-between;
  235. font-size: 14px;
  236. label {
  237. color: #b5b5b5;
  238. }
  239. a {
  240. color: red;
  241. }
  242. }
  243. button {
  244. width: 100%;
  245. border: none;
  246. background: #3d4c5a;
  247. border-radius: 30px;
  248. color: #fff;
  249. line-height: 40px;
  250. height: 40px;
  251. cursor: pointer;
  252. outline: none;
  253. }
  254. button:hover {
  255. background: #4b647b;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. </style>