Login copy.vue 5.7 KB

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