Home.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div class="home">
  3. <div class="top"></div>
  4. <div class="flex-center flex-column login-body">
  5. <h2>{{title}}</h2>
  6. <div class="login-form">
  7. <!-- <div class="flex-center">
  8. <img src="../assets/logo.png" alt="" class="logo" />
  9. </div>-->
  10. <div class="input-body flex-vertical-center-l">
  11. <img src="../assets/log-user.png" />
  12. <input type="text" placeholder="请输入用户名" v-model="name" @keydown.enter="login" />
  13. </div>
  14. <div class="input-body flex-vertical-center-l">
  15. <img src="../assets/log-pas.png" />
  16. <input type="password" placeholder="请输入密码" v-model="pas" @keydown.enter="login" />
  17. </div>
  18. <div class="flex-vertical-center-l">
  19. <div class="input-body flex-vertical-center-l">
  20. <!-- <img src='../assets/log-code.png' /> -->
  21. <input type="text" placeholder="请输入验证码" v-model="code" @keydown.enter="login" />
  22. </div>
  23. <img :src="src" alt class="code" @click="changeImg()" />
  24. </div>
  25. <div class="login-btn flex-center" @click="login()">登录</div>
  26. <div>
  27. <el-checkbox v-model="checked">记住我</el-checkbox>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="bottom">
  32. <!-- <span>杭州寻脉科技有限公司</span> -->
  33. <!-- <a href="https://beian.miit.gov.cn/#/Integrated/index">网站备案号 浙icp备2021018580号-1</a> -->
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import { mapActions } from 'vuex';
  39. import { login, getCode, getCodeimg, loginAndUserinfo} from '@/api/user.js';
  40. import { setTimeout } from "timers";
  41. export default {
  42. name: "Home",
  43. components: {},
  44. data() {
  45. return {
  46. title: window.SIX_config.title,
  47. name: "",
  48. pas: "",
  49. code: "",
  50. checked: false,
  51. src: process.env.VUE_APP_BASE_API + "/captchaImage"
  52. };
  53. },
  54. created() {
  55. // this.getCodeimg()
  56. this.changeImg();
  57. setTimeout(() => {
  58. sessionStorage.setItem("isAllow", "true");
  59. }, 1000);
  60. },
  61. methods: {
  62. async getCodeimg() {
  63. let res = await getCodeimg();
  64. let time = new Date().getTime();
  65. this.src = process.env.VUE_APP_BASE_API + "/captchaImage?time=" + time;
  66. },
  67. async login() {
  68. localStorage.removeItem("token");
  69. if (this.name == "") {
  70. this.$message.warning("请输入用户名");
  71. return;
  72. }
  73. if (this.pas == "") {
  74. this.$message.warning("请输入密码");
  75. return;
  76. }
  77. if (this.code == "") {
  78. this.$message.warning("请输入验证码");
  79. return;
  80. }
  81. const loading = this.$loading({
  82. lock: true,
  83. text: "正在登录",
  84. spinner: "el-icon-loading",
  85. background: "rgba(0, 0, 0, 0.7)"
  86. });
  87. let params = {
  88. password: this.pas,
  89. username: this.name,
  90. vercode: this.code
  91. };
  92. try {
  93. await this.setInfo({});
  94. const { token, userInfo, defaultHomePage } = await loginAndUserinfo(params);
  95. await this.setInfo(userInfo);
  96. await this.$router.push({ path: defaultHomePage });
  97. this.$message.success("登录成功");
  98. } catch (e) {
  99. this.changeImg();
  100. }
  101. loading.close();
  102. },
  103. // 修改验证码
  104. changeImg() {
  105. // let time = new Date().getTime()
  106. // this.src = this.src + '?time=' + time
  107. this.getCodeimg();
  108. },
  109. ...mapActions({
  110. setInfo: "user/setUserinfoAndPermissions"
  111. }),
  112. }
  113. };
  114. </script>
  115. <style lang="scss" scoped>
  116. @import "../style/common.scss";
  117. .home {
  118. width: 100%;
  119. height: 100%;
  120. background: #fff;
  121. background: url("../assets/log-bg.png") no-repeat;
  122. background-size: 100% 100%;
  123. background-position: center;
  124. .top {
  125. width: 100%;
  126. height: 50%;
  127. // background: url('../assets/login-bg.png') no-repeat;
  128. background-position: center;
  129. background-size: 100% 100%;
  130. }
  131. .login-body {
  132. position: absolute;
  133. top: 0;
  134. bottom: 0;
  135. left: 0;
  136. right: 0;
  137. // background: red;
  138. h2 {
  139. font-size: 58px;
  140. font-family: Source Han Sans CN;
  141. font-weight: bold;
  142. color: #ffffff;
  143. margin-bottom: 83px;
  144. }
  145. .logo {
  146. width: 92px;
  147. margin: 0 auto 20px;
  148. }
  149. .login-btn {
  150. height: 56px;
  151. // background: #5386F6;
  152. background: #5386f6;
  153. opacity: 0.91;
  154. border-radius: 8px;
  155. font-size: 18px;
  156. font-family: Microsoft YaHei;
  157. font-weight: 400;
  158. color: #ffffff;
  159. cursor: pointer;
  160. margin-bottom: 20px;
  161. }
  162. .login-form {
  163. width: 509px;
  164. // height: 377px;
  165. box-sizing: border-box;
  166. padding: 23px 47px 23px;
  167. // background: rgba($color: #fff, $alpha: 0.35);
  168. background: #fff;
  169. box-shadow: 0px 3px 8px 0px rgba(30, 72, 111, 0.35);
  170. // opacity: 0.35;
  171. border-radius: 10px;
  172. .code {
  173. width: 170px;
  174. height: 44px;
  175. border-radius: 8px;
  176. margin-left: 20px;
  177. margin-bottom: 20px;
  178. }
  179. .input-body {
  180. box-sizing: border-box;
  181. flex: 1;
  182. padding: 14px 27px;
  183. background: #ffffff;
  184. border: 1px solid #e5e5e5;
  185. // box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
  186. border-radius: 8px;
  187. margin-bottom: 20px;
  188. img {
  189. width: 14px;
  190. }
  191. input {
  192. flex: 1;
  193. border: 0;
  194. outline: none;
  195. font-size: 14px;
  196. font-family: Microsoft YaHei;
  197. font-weight: 400;
  198. line-height: 20px;
  199. margin-left: 20px;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. .bottom {
  206. position: fixed;
  207. left: 0;
  208. right: 0;
  209. bottom: 42px;
  210. text-align: center;
  211. font-size: 20px;
  212. font-family: PingFang SC;
  213. font-weight: bold;
  214. color: #ffffff;
  215. a {
  216. color: #fff;
  217. text-decoration: none;
  218. margin-left: 30px;
  219. }
  220. }
  221. </style>