Home.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <div class="home">
  3. <div class="top"></div>
  4. <div class="flex-center flex-column login-body">
  5. <h2>中医智能辅助诊疗系统</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. name: "",
  47. pas: "",
  48. code: "",
  49. checked: false,
  50. src: process.env.VUE_APP_BASE_API + "captchaImage"
  51. };
  52. },
  53. created() {
  54. // this.getCodeimg()
  55. this.changeImg();
  56. setTimeout(() => {
  57. sessionStorage.setItem("isAllow", "true");
  58. }, 1000);
  59. },
  60. methods: {
  61. async getCodeimg() {
  62. let res = await getCodeimg();
  63. let time = new Date().getTime();
  64. this.src = process.env.VUE_APP_BASE_API + "captchaImage?time=" + time;
  65. },
  66. async login() {
  67. localStorage.removeItem("token");
  68. if (this.name == "") {
  69. this.$message.warning("请输入用户名");
  70. return;
  71. }
  72. if (this.pas == "") {
  73. this.$message.warning("请输入密码");
  74. return;
  75. }
  76. if (this.code == "") {
  77. this.$message.warning("请输入验证码");
  78. return;
  79. }
  80. const loading = this.$loading({
  81. lock: true,
  82. text: "正在登录",
  83. spinner: "el-icon-loading",
  84. background: "rgba(0, 0, 0, 0.7)"
  85. });
  86. let params = {
  87. password: this.pas,
  88. username: this.name,
  89. vercode: this.code
  90. };
  91. try {
  92. await this.setInfo({});
  93. const { token, userInfo, defaultHomePage } = await loginAndUserinfo(params);
  94. await this.setInfo(userInfo);
  95. await this.$router.push({ path: defaultHomePage });
  96. this.$message.success("登录成功");
  97. } catch (e) {
  98. this.changeImg();
  99. }
  100. loading.close();
  101. },
  102. // 修改验证码
  103. changeImg() {
  104. // let time = new Date().getTime()
  105. // this.src = this.src + '?time=' + time
  106. this.getCodeimg();
  107. },
  108. ...mapActions({
  109. setInfo: "user/setUserinfoAndPermissions"
  110. }),
  111. }
  112. };
  113. </script>
  114. <style lang="scss" scoped>
  115. @import "../style/common.scss";
  116. .home {
  117. width: 100%;
  118. height: 100%;
  119. background: #fff;
  120. background: url("../assets/log-bg.png") no-repeat;
  121. background-size: 100% 100%;
  122. background-position: center;
  123. .top {
  124. width: 100%;
  125. height: 50%;
  126. // background: url('../assets/login-bg.png') no-repeat;
  127. background-position: center;
  128. background-size: 100% 100%;
  129. }
  130. .login-body {
  131. position: absolute;
  132. top: 0;
  133. bottom: 0;
  134. left: 0;
  135. right: 0;
  136. // background: red;
  137. h2 {
  138. font-size: 58px;
  139. font-family: Source Han Sans CN;
  140. font-weight: bold;
  141. color: #ffffff;
  142. margin-bottom: 83px;
  143. }
  144. .logo {
  145. width: 92px;
  146. margin: 0 auto 20px;
  147. }
  148. .login-btn {
  149. height: 56px;
  150. // background: #5386F6;
  151. background: #5386f6;
  152. opacity: 0.91;
  153. border-radius: 8px;
  154. font-size: 18px;
  155. font-family: Microsoft YaHei;
  156. font-weight: 400;
  157. color: #ffffff;
  158. cursor: pointer;
  159. margin-bottom: 20px;
  160. }
  161. .login-form {
  162. width: 509px;
  163. // height: 377px;
  164. box-sizing: border-box;
  165. padding: 23px 47px 23px;
  166. // background: rgba($color: #fff, $alpha: 0.35);
  167. background: #fff;
  168. box-shadow: 0px 3px 8px 0px rgba(30, 72, 111, 0.35);
  169. // opacity: 0.35;
  170. border-radius: 10px;
  171. .code {
  172. width: 170px;
  173. height: 44px;
  174. border-radius: 8px;
  175. margin-left: 20px;
  176. margin-bottom: 20px;
  177. }
  178. .input-body {
  179. box-sizing: border-box;
  180. flex: 1;
  181. padding: 14px 27px;
  182. background: #ffffff;
  183. border: 1px solid #e5e5e5;
  184. // box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
  185. border-radius: 8px;
  186. margin-bottom: 20px;
  187. img {
  188. width: 14px;
  189. }
  190. input {
  191. flex: 1;
  192. border: 0;
  193. outline: none;
  194. font-size: 14px;
  195. font-family: Microsoft YaHei;
  196. font-weight: 400;
  197. line-height: 20px;
  198. margin-left: 20px;
  199. }
  200. }
  201. }
  202. }
  203. }
  204. .bottom {
  205. position: fixed;
  206. left: 0;
  207. right: 0;
  208. bottom: 42px;
  209. text-align: center;
  210. font-size: 20px;
  211. font-family: PingFang SC;
  212. font-weight: bold;
  213. color: #ffffff;
  214. a {
  215. color: #fff;
  216. text-decoration: none;
  217. margin-left: 30px;
  218. }
  219. }
  220. </style>