Login.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div class="bg">
  3. <!-- <header class="login-header">
  4. <img v-if="!jwptCustomize" src="../assets/images/login_footer_logo.jpg" />
  5. <img v-else src="../assets/images/new_login_logo.png" />
  6. <span class="qm-logo-text" v-if="!jwptCustomize">考试云平台</span>
  7. <span class="qm-logo-text" v-else>{{ title }}</span>
  8. </header> -->
  9. <main class="login-main">
  10. <!-- <img class="left_tree" src="../assets/images/login_main_left_tree.png" /> -->
  11. <div class="logo-text">考试云平台</div>
  12. <div class="right_login">
  13. <h1 style="font-size: 20px; color: #666">欢迎登录</h1>
  14. <div class="username">
  15. <v-icon
  16. name="user"
  17. scale="1.4"
  18. style="padding: 5px 0px; z-index: 3"
  19. />
  20. <input
  21. id="accountValue"
  22. v-model="loginInfo.accountValue"
  23. type="text"
  24. placeholder="请输入账号"
  25. @keyup.enter="login"
  26. @change="nameChange"
  27. />
  28. </div>
  29. <div class="password">
  30. <v-icon
  31. name="lock"
  32. scale="1.4"
  33. style="padding: 5px 0px; z-index: 3"
  34. />
  35. <input
  36. id="password"
  37. v-model="loginInfo.password"
  38. :type="seePassword ? 'text' : 'password'"
  39. placeholder="请输入密码"
  40. @keyup.enter="login"
  41. />
  42. <v-icon
  43. v-if="!seePassword"
  44. name="eye-slash"
  45. scale="1.2"
  46. class="eye-icon"
  47. @click="seePassword = !seePassword"
  48. ></v-icon>
  49. <v-icon
  50. v-else
  51. name="eye"
  52. scale="1.2"
  53. class="eye-icon"
  54. @click="seePassword = !seePassword"
  55. ></v-icon>
  56. </div>
  57. <div class="smscode">
  58. <v-icon
  59. v-if="dialogVisible"
  60. name="lock"
  61. scale="1.4"
  62. style="padding: 5px 0px; z-index: 3"
  63. />
  64. <input
  65. v-if="dialogVisible"
  66. id="smsCode"
  67. v-model="loginInfo.smsCode"
  68. type="text"
  69. placeholder="请输入短信验证码"
  70. @keyup.enter="login"
  71. />
  72. </div>
  73. <button class="login-btn" @click="login">登 录</button>
  74. </div>
  75. </main>
  76. <footer class="login-footer">
  77. 启明泰和 Copyright © www.qmth.com.cn, All Rights Reserved.
  78. 鄂ICP备12000033号-7
  79. </footer>
  80. </div>
  81. </template>
  82. <script>
  83. import { mapActions } from "vuex";
  84. import { USER_SIGNIN } from "../store/user";
  85. import { CORE_API } from "@/constants/constants";
  86. export default {
  87. data() {
  88. return {
  89. errorInfo: "",
  90. title: "考试云平台",
  91. jwptCustomize: false,
  92. dialogVisible: false,
  93. loginInfo: {
  94. rootOrgId: "",
  95. domain: "",
  96. accountType: "COMMON_LOGIN_NAME",
  97. accountValue: "",
  98. password: "",
  99. smsCode: null,
  100. },
  101. seePassword: false,
  102. };
  103. },
  104. watch: {
  105. $route(to) {
  106. this.loginInfo.rootOrgId = to.query.orgId;
  107. },
  108. },
  109. created() {
  110. if (this.$route.hash && this.$route.hash.startsWith("#/access?")) {
  111. this.$router.push(this.$route.hash.slice(1));
  112. return;
  113. }
  114. this.loginInfo.domain =
  115. window.location.hostname.split(".")[0] + ".ecs.qmth.com.cn";
  116. sessionStorage.clear();
  117. var params = this.$route.query;
  118. this.loginInfo.rootOrgId = params.orgId;
  119. this.jwptCustomizeMethod();
  120. },
  121. methods: {
  122. ...mapActions([USER_SIGNIN]),
  123. nameChange() {
  124. // this.dialogVisible = false;
  125. },
  126. checkAccountValue() {
  127. this.errorInfo = "";
  128. if (!this.loginInfo.accountValue) {
  129. this.errorInfo += "账号不能为空!\n";
  130. }
  131. if (this.errorInfo) {
  132. this.$notify({
  133. showClose: true,
  134. message: this.errorInfo,
  135. type: "error",
  136. });
  137. return false;
  138. }
  139. return true;
  140. },
  141. checkPassword() {
  142. this.errorInfo = "";
  143. if (!this.loginInfo.password) {
  144. this.errorInfo += "密码不能为空!\n";
  145. }
  146. if (this.errorInfo) {
  147. this.$notify({
  148. showClose: true,
  149. message: this.errorInfo,
  150. type: "error",
  151. });
  152. return false;
  153. }
  154. return true;
  155. },
  156. login() {
  157. if (!this.checkAccountValue()) {
  158. return;
  159. }
  160. if (!this.checkPassword()) {
  161. return;
  162. }
  163. var url = CORE_API + "/auth/login";
  164. this.$httpWithMsg
  165. .post(url, this.loginInfo)
  166. .then((response) => {
  167. var user = response.data;
  168. this.USER_SIGNIN(user);
  169. this.$router.replace({ path: "/home/overview" });
  170. this.$notify({
  171. message: "登录成功",
  172. type: "success",
  173. duration: 1000,
  174. });
  175. })
  176. .catch((error) => {
  177. if (
  178. error.response.data.code === "B-003100" ||
  179. error.response.data.code === "B-EX-102008"
  180. ) {
  181. this.dialogVisible = true;
  182. }
  183. });
  184. },
  185. loginWithSms() {
  186. this.dialogVisible = false;
  187. this.login();
  188. },
  189. jwptCustomizeMethod() {
  190. // 普通高校考试综合管理平台 定制
  191. if (location.host === "jwpt.ecs.qmth.com.cn") {
  192. document.title = "普通高校-题库";
  193. this.title = " | 普通高校-题库";
  194. this.jwptCustomize = true;
  195. }
  196. },
  197. },
  198. };
  199. </script>
  200. <style lang="scss" scoped>
  201. .bg {
  202. width: 100vw;
  203. height: 100vh;
  204. background-image: url("../assets/images/bg.jpg");
  205. background-size: cover;
  206. }
  207. .qm-logo-text {
  208. font-size: 36px;
  209. font-weight: 700;
  210. font-stretch: normal;
  211. line-height: 36px;
  212. letter-spacing: 0px;
  213. margin-left: 40px;
  214. }
  215. .logo-text {
  216. /* font-family: "Xingkai SC", "STXingkai", "KaiTi"; */
  217. width: 100%;
  218. height: 40px;
  219. font-size: 40px;
  220. margin-bottom: 30px;
  221. font-weight: bold;
  222. font-stretch: normal;
  223. line-height: 48px;
  224. letter-spacing: 0px;
  225. color: #3968d7;
  226. text-shadow: 0px 7px 4px rgba(77, 124, 196, 0.3);
  227. text-align: center;
  228. letter-spacing: 0.2em;
  229. }
  230. .login-main {
  231. width: 100%;
  232. height: 90vh;
  233. display: flex;
  234. flex-direction: column;
  235. align-items: center;
  236. justify-content: center;
  237. }
  238. .right_login {
  239. width: 480px;
  240. height: 330px;
  241. background-color: #ffffff;
  242. box-shadow: 0px 7px 20px 0px rgba(77, 124, 196, 0.1);
  243. border-radius: 38px;
  244. opacity: 0.8;
  245. padding: 0 80px;
  246. }
  247. .right_login h1 {
  248. text-align: center;
  249. height: 20px;
  250. font-size: 20px;
  251. font-weight: normal;
  252. font-stretch: normal;
  253. line-height: 24px;
  254. letter-spacing: 0px;
  255. color: #666666;
  256. margin: 30px 0;
  257. }
  258. .right_login .username {
  259. display: flex;
  260. align-items: center;
  261. justify-items: center;
  262. }
  263. .right_login .password {
  264. display: flex;
  265. align-items: center;
  266. justify-items: center;
  267. margin-top: 10px;
  268. position: relative;
  269. .eye-icon {
  270. position: absolute;
  271. right: 10px;
  272. cursor: pointer;
  273. }
  274. }
  275. .right_login .smscode {
  276. height: 38px;
  277. display: flex;
  278. align-items: center;
  279. justify-items: center;
  280. margin-top: 10px;
  281. }
  282. .right_login input {
  283. width: 100%;
  284. padding: 5px 30px;
  285. margin-left: -21px;
  286. font-size: 16px;
  287. border-radius: 10px;
  288. }
  289. .right_login input::placeholder {
  290. font-size: 16px;
  291. color: #000000;
  292. opacity: 0.3;
  293. }
  294. .login-btn {
  295. margin-top: 20px;
  296. margin-bottom: 20px;
  297. width: 100%;
  298. background-color: #4d7cc4;
  299. font-size: 25px;
  300. color: #fff;
  301. cursor: pointer;
  302. border-radius: 27px;
  303. }
  304. .login-btn:hover {
  305. box-shadow: 0 16px 29px rgba(29, 170, 240, 0.3);
  306. }
  307. .login-footer {
  308. position: absolute;
  309. bottom: 30px;
  310. left: 0;
  311. right: 0;
  312. font-size: 14px;
  313. color: #333;
  314. text-align: center;
  315. }
  316. </style>