Login.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <div class="login">
  3. <div class="tab">
  4. <div style="width: 100%;text-align: center">
  5. <div class="tab-wrapper">
  6. <img :class="flag1? 'active1':'active2'" alt=""
  7. src="./img/img_2.png" style="display: inline-block;position: absolute;top:50px;">
  8. <div :class="flag1? 'active':''" class="tab1" @click="handleChange">账号登录</div>
  9. <img alt="" src="./img/split.png" style="display: inline-block;position: absolute;top:-12px;">
  10. <div :class="flag2? 'active':''" class="tab2" @click="handleChange1">人脸识别</div>
  11. </div>
  12. <div v-if="flag1">
  13. <div class="input-div">
  14. <img alt="" class="phone-img" src="./img/phone.png">
  15. <el-input v-model="input" class="phone" placeholder="请输入手机号/邮箱"></el-input>
  16. </div>
  17. <div class="input-div">
  18. <img alt="" class="password-img" src="./img/password.png">
  19. <el-input v-model="password" class="password" placeholder="请输入登录密码"
  20. show-password></el-input>
  21. </div>
  22. <div style="text-align: left">
  23. <el-checkbox v-model="checked" class="rememberMe">记住密码</el-checkbox>
  24. </div>
  25. </div>
  26. <div v-if="flag2">
  27. <div class="code">
  28. 人脸扫描
  29. </div>
  30. </div>
  31. </div>
  32. <div v-if="activeName === 'first'" class="button-div">
  33. <el-button type="primary" @click="loginSubmit">登录</el-button>
  34. <el-button @click="cancel">取消</el-button>
  35. </div>
  36. <a class="left" href="">下载浏览器</a>
  37. <a class="right" href="">立即注册</a>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import {Base64} from "js-base64";
  43. export default {
  44. name: 'HelloWorld',
  45. props: {
  46. msg: String
  47. },
  48. data() {
  49. return {
  50. activeName: 'first',
  51. input: '',
  52. password: '',
  53. checked: false,
  54. flag1: true,
  55. flag2: false,
  56. Base64: '',
  57. };
  58. },
  59. mounted() {
  60. let username = localStorage.getItem("input");
  61. if (username) {
  62. this.input = localStorage.getItem("input");
  63. this.password = Base64.decode(localStorage.getItem("password"));// base64解密
  64. this.checked = true;
  65. }
  66. },
  67. methods: {
  68. loginSubmit() {
  69. if (this.input !== 'admin') {
  70. this.$message.error("用户不存在")
  71. } else {
  72. if (this.password !== '123456') {
  73. this.$message.error("密码错误")
  74. } else {
  75. if (this.checked) {
  76. let password = Base64.encode(this.password); // base64加密
  77. localStorage.setItem("input", this.input);
  78. localStorage.setItem("password", password);
  79. } else {
  80. localStorage.removeItem("input");
  81. localStorage.removeItem("password");
  82. }
  83. this.$message.success("登录成功")
  84. setTimeout(() => {
  85. this.$router.push('/xndc');
  86. }, 400);
  87. }
  88. }
  89. },
  90. cancel() {
  91. this.input = ''
  92. this.password = ''
  93. },
  94. handleClick(tab, event) {
  95. console.log(tab, event);
  96. },
  97. handleChange() {
  98. this.flag1 = true
  99. this.flag2 = false
  100. },
  101. handleChange1() {
  102. this.flag1 = false
  103. this.flag2 = true
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="less" scoped>
  109. .login {
  110. position: fixed;
  111. left: 0;
  112. top: 0;
  113. right: 0;
  114. bottom: 0;
  115. background: url("./img/login.png") no-repeat;
  116. background-size: 100% 100%;
  117. }
  118. /deep/ .el-tabs__nav {
  119. float: none;
  120. }
  121. /deep/ .el-tabs__active-bar {
  122. display: none;
  123. }
  124. /deep/ .el-tabs__item {
  125. }
  126. .tab-wrapper {
  127. width: 100%;
  128. height: 100%;
  129. text-align: center;
  130. .tab2 {
  131. margin-left: 33px;
  132. }
  133. .tab1 {
  134. margin-right: 33px;
  135. }
  136. .tab1, .tab2 {
  137. width: 100%;
  138. font-size: 24px !important;
  139. font-weight: 1000;
  140. height: 100%;
  141. color: #c4c4c4;
  142. display: inline;
  143. &:hover {
  144. cursor: pointer
  145. }
  146. }
  147. .active {
  148. color: white;
  149. }
  150. .active1 {
  151. left: 28%;
  152. }
  153. .active2 {
  154. left: 62%;
  155. }
  156. .line {
  157. width: 2px;
  158. height: 20px;
  159. background-color: #000;
  160. }
  161. }
  162. .tab {
  163. width: 27%;
  164. height: 60%;
  165. position: absolute;
  166. top: 26%;
  167. left: 12%;
  168. .phone-img {
  169. position: absolute;
  170. width: 22px;
  171. height: 28px;
  172. top: 18%;
  173. }
  174. .password-img {
  175. width: 21px;
  176. height: 21px;
  177. position: absolute;
  178. top: 40%;
  179. }
  180. }
  181. .button-div {
  182. text-align: left;
  183. }
  184. .code {
  185. width: 100px;
  186. height: 100px;
  187. background-color: #fff;
  188. }
  189. .left, .right {
  190. position: absolute;
  191. color: #fff;
  192. bottom: 10%;
  193. font-size: 20px;
  194. color: rgb(0, 255, 231);
  195. }
  196. .left {
  197. left: -10px;
  198. }
  199. .right {
  200. right: -10px;
  201. }
  202. /deep/ .el-input__inner {
  203. background-color: rgba(0, 0, 0, 0);
  204. border: none;
  205. border-bottom: 2px solid #fff;
  206. border-radius: 0;
  207. height: 100%;
  208. padding-bottom: 4%;
  209. margin-top: 15%;
  210. padding-left: 11% !important;
  211. font-size: 19px;
  212. font-weight: 1000;
  213. color: #fff;
  214. }
  215. /deep/ .el-tabs__content {
  216. text-align: left;
  217. }
  218. /deep/ .el-checkbox {
  219. margin-top: 5%;
  220. font-size: 20px;
  221. }
  222. /deep/ .el-checkbox__label {
  223. font-size: 20px;
  224. font-weight: 1000;
  225. color: white;
  226. }
  227. /deep/ .el-checkbox__inner {
  228. width: 25px;
  229. height: 25px;
  230. font-size: 20px;
  231. border-radius: 5px;
  232. background-image: url("./img/img2.png")
  233. }
  234. /deep/ .el-input__clear {
  235. height: 160%;
  236. font-size: 20px;
  237. }
  238. /deep/ .el-icon-view:before {
  239. content: "\e6ce";
  240. font-size: 25px;
  241. }
  242. /deep/ .el-button {
  243. height: 32%;
  244. width: 32%;
  245. font-weight: bold;
  246. font-size: 23px;
  247. margin-top: 8%;
  248. }
  249. /deep/ .el-button--default {
  250. margin-left: 15% !important;
  251. border: 0px solid rgb(23, 73, 146);
  252. background: url("./img/img_1.png") no-repeat;
  253. background-size: 100% 100%;
  254. }
  255. /deep/ .el-button--primary {
  256. margin-left: 10%;
  257. border: 0;
  258. background: url("./img/img.png") no-repeat;
  259. background-size: 100% 100%;
  260. }
  261. /deep/ .el-checkbox__inner::after {
  262. box-sizing: content-box;
  263. content: "";
  264. border: 1px solid #FFF;
  265. border-left: 0;
  266. border-top: 0;
  267. height: 10px;
  268. left: 10px;
  269. position: absolute;
  270. top: 5px;
  271. transform: rotate(45deg) scaleY(0);
  272. width: 4px;
  273. transition: transform .15s ease-in .05s;
  274. transform-origin: center;
  275. }
  276. </style>