login.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <div id="login">
  3. <div class="loginPopple">
  4. <div class="leftImgs">
  5. <img
  6. class="img1"
  7. src="@/assets/images/loginPage/kc@2x.png"
  8. alt=""
  9. /><img
  10. class="img2"
  11. src="@/assets/images/loginPage/qz@2x.png"
  12. alt=""
  13. /><img
  14. class="img3"
  15. src="@/assets/images/loginPage/ks@2x.png"
  16. alt=""
  17. /><img class="img4" src="@/assets/images/loginPage/bag@2x.png" alt="" />
  18. </div>
  19. <div class="poRightLogin">
  20. <div class="navImg">
  21. <img src="@/assets/images/loginPage/welcome@2x.png" alt="" />
  22. </div>
  23. <div class="userNameBox">
  24. <h4>用户名</h4>
  25. <input
  26. type="text"
  27. placeholder="输入用户名"
  28. v-model="loginData.username"
  29. />
  30. </div>
  31. <div class="passwordBox">
  32. <h4>密码</h4>
  33. <div class="passwordListB">
  34. <input
  35. :type="showPassword ? 'text' : 'password'"
  36. placeholder="输入密码"
  37. autocomplete="new-password"
  38. v-model="loginData.password"
  39. />
  40. <div class="iconImg" @click="showPassword = !showPassword">
  41. <img
  42. v-if="showPassword"
  43. src="@/assets/images/loginPage/pass.png"
  44. alt=""
  45. />
  46. <img v-else src="@/assets/images/loginPage/passno.png" alt="" />
  47. </div>
  48. </div>
  49. </div>
  50. <div class="codeBox">
  51. <input
  52. type="text"
  53. placeholder="输入验证码"
  54. v-model="loginData.code"
  55. />
  56. <div class="codeImg" @click="getUuid">
  57. <img :src="uuidBase64" alt="点击刷新" />
  58. </div>
  59. </div>
  60. <div class="toolList">
  61. <label class="checkBox"
  62. ><input type="checkbox" v-model="isRemember" />7天内免登录</label
  63. >
  64. <div class="forget">忘记密码</div>
  65. </div>
  66. <div class="loginbtnbox" @click="getApi">登录</div>
  67. </div>
  68. </div>
  69. </div>
  70. </template>
  71. <script>
  72. import cookie from "@/utils/cookie.js";
  73. export default {
  74. data() {
  75. return {
  76. showPassword: false, //密码是否可见
  77. isRemember: false, //是否选中7天内免登录
  78. uuidBase64: "", //验证码图片
  79. uuid: "", //验证码编码
  80. loginData: {
  81. //登入信息收集
  82. username: "",
  83. password: "",
  84. code: "",
  85. },
  86. };
  87. },
  88. created() {
  89. this.getUuid(); //初始化获取验证码方法
  90. var self = this;
  91. document.onkeydown = function (e) {
  92. var key = window.event.keyCode;
  93. if (key === 13) {
  94. self.getApi();
  95. }
  96. };
  97. if (this.$route.query.TenantId) {
  98. sessionStorage.TenantId = this.$route.query.TenantId;
  99. } else {
  100. if (sessionStorage.TenantId) {
  101. sessionStorage.removeItem("TenantId");
  102. }
  103. }
  104. },
  105. methods: {
  106. //获取验证码图片
  107. getUuid() {
  108. this.$api
  109. .captchaImage()
  110. .then((res) => {
  111. this.uuidBase64 = "data:image/png;base64," + res.data.img;
  112. this.uuid = res.data.uuid;
  113. })
  114. .catch((err) => {
  115. this.$message.error(err);
  116. });
  117. },
  118. //登录
  119. getApi() {
  120. if (!this.loginData.username) {
  121. this.$message.warning("请输入用户名");
  122. return;
  123. }
  124. if (!this.loginData.password) {
  125. this.$message.warning("请输入密码");
  126. return;
  127. }
  128. var data = {
  129. code: this.loginData.code.trim(),
  130. username: this.loginData.username.trim(),
  131. password: this.loginData.password.trim(),
  132. uuid: this.uuid,
  133. };
  134. this.$api
  135. .login(data)
  136. .then((res) => {
  137. if (res.code === 200) {
  138. if (this.isRemember) {
  139. cookie.setCookie("token", res.token, 7);
  140. } else {
  141. cookie.setCookie("token", res.token, 1);
  142. }
  143. this.initRoutes();
  144. } else {
  145. this.getUuid();
  146. this.loginData.code = "";
  147. }
  148. })
  149. .catch((err) => {
  150. this.getUuid();
  151. this.$message.error(err);
  152. console.log(err);
  153. });
  154. },
  155. //重定向跳转
  156. initRoutes() {
  157. this.$router
  158. .replace({
  159. name: "home",
  160. })
  161. .catch(() => {});
  162. },
  163. },
  164. };
  165. </script>
  166. <style lang="less" scoped>
  167. #login {
  168. width: 100%;
  169. background: url("../../assets/images/loginPage/bg@2x.png") no-repeat center;
  170. background-size: cover;
  171. min-height: 100vh;
  172. .loginPopple {
  173. position: fixed;
  174. top: 50%;
  175. left: 50%;
  176. transform: translateX(-50%) translateY(-50%);
  177. width: 1060px;
  178. height: 660px;
  179. background-color: #f9fdfe;
  180. // background: url("../../assets/images/loginPage/bg2@2x.png") no-repeat center;
  181. background-size: 1060px 660px;
  182. border-radius: 16px;
  183. box-shadow: 0px 30px 21px 9px rgba(71, 166, 255, 0.08);
  184. display: flex;
  185. align-items: center;
  186. justify-content: space-between;
  187. font-size: 16px;
  188. // font-family: Alibaba PuHuiTi;
  189. animation: showStatus 1s;
  190. .leftImgs {
  191. margin-left: 30px;
  192. flex: 1;
  193. height: 592px;
  194. // background: red;
  195. border-radius: 18px;
  196. padding: 20px;
  197. overflow: hidden;
  198. background: url("../../assets/images/loginPage/card@2x.png") no-repeat
  199. center;
  200. background-size: contain;
  201. position: relative;
  202. img {
  203. border-radius: 50%;
  204. box-shadow: 0px 10px 16px 4px rgba(71, 166, 255, 0.1);
  205. }
  206. .img1 {
  207. position: absolute;
  208. top: 404px;
  209. left: 28px;
  210. width: 89px;
  211. height: 89px;
  212. animation: img1s linear 3s infinite;
  213. }
  214. .img2 {
  215. position: absolute;
  216. top: 363px;
  217. left: 171px;
  218. width: 66px;
  219. height: 66px;
  220. animation: img2s linear 3s infinite;
  221. }
  222. .img3 {
  223. position: absolute;
  224. top: 449px;
  225. right: 175px;
  226. width: 65.4px;
  227. height: 65.4px;
  228. animation: img1s linear 3s infinite;
  229. }
  230. .img4 {
  231. position: absolute;
  232. top: 377px;
  233. right: 32px;
  234. width: 87px;
  235. height: 87px;
  236. animation: img2s linear 3s infinite;
  237. }
  238. @keyframes img1s {
  239. 25%{
  240. transform: translateY(-20px);
  241. }
  242. 50%{
  243. transform: translateY(0px);
  244. }
  245. 75%{
  246. transform: translateY(20px);
  247. }
  248. }
  249. @keyframes img2s {
  250. 25%{
  251. transform: translateY(20px);
  252. }
  253. 50%{
  254. transform: translateY(0px);
  255. }
  256. 75%{
  257. transform: translateY(-20px);
  258. }
  259. }
  260. }
  261. .poRightLogin {
  262. width: 530px;
  263. height: 592px;
  264. padding: 0px 71px;
  265. input {
  266. font-size: 16px;
  267. }
  268. .navImg {
  269. margin-top: 56px;
  270. width: 387px;
  271. height: 22px;
  272. margin-block: 56px;
  273. img {
  274. width: 100%;
  275. height: 100%;
  276. }
  277. }
  278. .userNameBox {
  279. margin-bottom: 21px;
  280. h4 {
  281. font-weight: 400;
  282. color: #737fa0;
  283. }
  284. input {
  285. height: 46px;
  286. line-height: 46px;
  287. border: none;
  288. background-color: transparent;
  289. outline: none;
  290. border-bottom: 2px solid #a9d0ef;
  291. width: 100%;
  292. font-weight: bold;
  293. color: #2f4379;
  294. letter-spacing: 1px;
  295. &::placeholder {
  296. color: #737fa0;
  297. font-weight: 400;
  298. }
  299. }
  300. }
  301. .passwordBox {
  302. margin-bottom: 29px;
  303. h4 {
  304. font-weight: 400;
  305. color: #737fa0;
  306. }
  307. .passwordListB {
  308. height: 46px;
  309. display: flex;
  310. align-items: center;
  311. border-bottom: 2px solid #a9d0ef;
  312. input {
  313. height: 100%;
  314. line-height: 100%;
  315. border: none;
  316. background-color: transparent;
  317. font-weight: bold;
  318. color: #2f4379;
  319. outline: none;
  320. flex: 1;
  321. padding-right: 15px;
  322. letter-spacing: 2px;
  323. &::placeholder {
  324. color: #737fa0;
  325. font-weight: 400;
  326. }
  327. }
  328. .iconImg {
  329. cursor: pointer;
  330. width: 18px;
  331. height: 18px;
  332. img {
  333. width: 100%;
  334. height: 100%;
  335. }
  336. }
  337. }
  338. }
  339. .codeBox {
  340. height: 56px;
  341. display: flex;
  342. align-items: center;
  343. border-bottom: 2px solid #a9d0ef;
  344. input {
  345. flex: 1;
  346. padding-right: 10px;
  347. border: none;
  348. background-color: transparent;
  349. outline: none;
  350. font-weight: bold;
  351. letter-spacing: 2px;
  352. color: #2f4379;
  353. &::placeholder {
  354. color: #737fa0;
  355. font-weight: 400;
  356. }
  357. }
  358. .codeImg {
  359. width: 100px;
  360. height: 45px;
  361. img {
  362. width: 100%;
  363. height: 100%;
  364. }
  365. }
  366. }
  367. .toolList {
  368. margin: 24px 0px 49px;
  369. display: flex;
  370. align-items: center;
  371. justify-content: space-between;
  372. .forget {
  373. cursor: pointer;
  374. color: #737fa0;
  375. font-weight: 300;
  376. }
  377. .checkBox {
  378. display: flex;
  379. align-items: center;
  380. color: #2f4379;
  381. input {
  382. margin-right: 6px;
  383. }
  384. }
  385. }
  386. .loginbtnbox {
  387. cursor: pointer;
  388. margin: 0 auto;
  389. width: 280px;
  390. height: 48px;
  391. text-align: center;
  392. line-height: 48px;
  393. border-radius: 8px;
  394. box-shadow: 0px 10px 16px 4px rgba(47, 67, 121, 0.1);
  395. background: #2f4379;
  396. color: #fff;
  397. transition: all 0.2s;
  398. &:hover {
  399. transform: scale(1.03);
  400. }
  401. }
  402. }
  403. }
  404. }
  405. @keyframes showStatus {
  406. 0% {
  407. opacity: 0;
  408. }
  409. 100% {
  410. opacity: 1;
  411. }
  412. }
  413. </style>