Login.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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: 'admin',
  61. pass: 'hyl123456',
  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 == 0) {
  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/farmBaseManger')
  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/login_bg.jpg) no-repeat center;
  112. // background: url(../../static/images/login/1.gif) no-repeat center;
  113. background-size: 100% 100%;
  114. .login_box {
  115. width: 900px;
  116. height: 450px;
  117. position: absolute;
  118. left: 50%;
  119. top: 50%;
  120. transform: translate(-50%, -50%);
  121. display: flex;
  122. .tit-box {
  123. position: relative;
  124. flex: 1;
  125. background: rgba(0, 0, 0, 0.6);
  126. color: #fff;
  127. letter-spacing: 5px;
  128. .tit-con {
  129. display: block;
  130. padding: 180px 50px;
  131. .txt {
  132. font-size: 24px;
  133. padding-bottom: 15px;
  134. border-bottom: 1px solid #fff;
  135. position: relative;
  136. .arrow {
  137. position: absolute;
  138. top: 4px;
  139. margin-left: 10px;
  140. background: #fff;
  141. width: 25px;
  142. height: 25px;
  143. border-radius: 50%;
  144. i {
  145. color: #000;
  146. font-size: 18px;
  147. position: absolute;
  148. left: 4px;
  149. top: 4px;
  150. }
  151. i:before {
  152. font-weight: 800;
  153. }
  154. }
  155. }
  156. .tit {
  157. font-size: 32px;
  158. padding-top: 10px;
  159. }
  160. }
  161. }
  162. .f-box {
  163. flex: 1;
  164. background: #fff;
  165. .loginItems {
  166. padding: 80px 50px 0 50px;
  167. li {
  168. width: 100%;
  169. margin-bottom: 45px;
  170. position: relative;
  171. i.iconfont {
  172. position: absolute;
  173. font-size: 22px;
  174. left: 0;
  175. top: 5px;
  176. color: #b5b5b5;
  177. }
  178. }
  179. input::-webkit-input-placeholder {
  180. /* WebKit browsers 适配谷歌 */
  181. color: #b5b5b5;
  182. }
  183. input:-moz-placeholder {
  184. /* Mozilla Firefox 4 to 18 适配火狐 */
  185. color: #b5b5b5;
  186. }
  187. input::-moz-placeholder {
  188. /* Mozilla Firefox 19+ 适配火狐 */
  189. color: #b5b5b5;
  190. }
  191. input:-ms-input-placeholder {
  192. /* Internet Explorer 10+ 适配ie*/
  193. color: #b5b5b5;
  194. }
  195. input[type='text'],
  196. input[type='password'] {
  197. border: none;
  198. padding: 10px 20px 10px 30px;
  199. box-sizing: border-box;
  200. border-bottom: 1px solid #b5b5b5;
  201. width: 100%;
  202. font-size: 15px;
  203. outline: none;
  204. box-shadow: 0 0 0px 1000px white inset !important;
  205. -webkit-box-shadow: 0 0 0px 1000px white inset !important;
  206. }
  207. input[type='checkbox'] {
  208. display: none;
  209. }
  210. input[type='checkbox'] + label span {
  211. display: inline-block;
  212. width: 16px;
  213. height: 16px;
  214. border-radius: 3px;
  215. border: 1px solid #b5b5b5;
  216. float: left;
  217. margin-right: 10px;
  218. i {
  219. display: none;
  220. }
  221. }
  222. input[type='checkbox']:checked + label span {
  223. background: #2f3945;
  224. i {
  225. display: block;
  226. font-size: 15px;
  227. color: #fff;
  228. }
  229. i:before {
  230. font-weight: 800;
  231. }
  232. }
  233. .pass {
  234. display: flex;
  235. justify-content: space-between;
  236. font-size: 14px;
  237. label {
  238. color: #b5b5b5;
  239. }
  240. a {
  241. color: red;
  242. }
  243. }
  244. button {
  245. width: 100%;
  246. border: none;
  247. background: #3d4c5a;
  248. border-radius: 30px;
  249. color: #fff;
  250. line-height: 40px;
  251. height: 40px;
  252. cursor: pointer;
  253. outline: none;
  254. }
  255. button:hover {
  256. background: #4b647b;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. </style>