Login.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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 name="user" scale="2" style="padding: 5px 0px; z-index: 3;" />
  16. <input
  17. @keyup.enter="login"
  18. type="text"
  19. id="accountValue"
  20. v-model="loginInfo.accountValue"
  21. placeholder="请输入账号"
  22. />
  23. </div>
  24. <div class="password">
  25. <v-icon name="lock" scale="2" style="padding: 5px 0px; z-index: 3;" />
  26. <input
  27. @keyup.enter="login"
  28. type="password"
  29. id="password"
  30. v-model="loginInfo.password"
  31. placeholder="请输入密码"
  32. />
  33. </div>
  34. <button class="login-btn" @click="login">登 录</button>
  35. </div>
  36. <footer class="login-footer">
  37. Copyright &copy; 2019 <a href="javascript:void(0)">讯飞启明</a>.
  38. </footer>
  39. </main>
  40. <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
  41. <input
  42. @keyup.enter="loginWithSms"
  43. type="number"
  44. v-model="loginInfo.smsCode"
  45. style="width: 80%"
  46. placeholder="请向王伟咨询手机验证码"
  47. />
  48. <span slot="footer" class="dialog-footer">
  49. <el-button @click="dialogVisible = false">取 消</el-button>
  50. <el-button type="primary" @click="loginWithSms">确 定</el-button>
  51. </span>
  52. </el-dialog>
  53. </div>
  54. </template>
  55. <script>
  56. import { mapActions } from "vuex";
  57. import { USER_SIGNIN } from "../store/user";
  58. import { CORE_API } from "@/constants/constants";
  59. export default {
  60. data() {
  61. return {
  62. errorInfo: "",
  63. title: "考试云平台",
  64. jwptCustomize: false,
  65. dialogVisible: false,
  66. loginInfo: {
  67. rootOrgId: "",
  68. domain: "",
  69. accountType: "COMMON_LOGIN_NAME",
  70. accountValue: "",
  71. password: "",
  72. smsCode: null
  73. }
  74. };
  75. },
  76. methods: {
  77. ...mapActions([USER_SIGNIN]),
  78. checkAccountValue() {
  79. this.errorInfo = "";
  80. if (!this.loginInfo.accountValue) {
  81. this.errorInfo += "账号不能为空!\n";
  82. }
  83. if (this.errorInfo) {
  84. this.$notify({
  85. showClose: true,
  86. message: this.errorInfo,
  87. type: "error"
  88. });
  89. return false;
  90. }
  91. return true;
  92. },
  93. checkPassword() {
  94. this.errorInfo = "";
  95. if (!this.loginInfo.password) {
  96. this.errorInfo += "密码不能为空!\n";
  97. }
  98. if (this.errorInfo) {
  99. this.$notify({
  100. showClose: true,
  101. message: this.errorInfo,
  102. type: "error"
  103. });
  104. return false;
  105. }
  106. return true;
  107. },
  108. login() {
  109. if (!this.checkAccountValue()) {
  110. return;
  111. }
  112. if (!this.checkPassword()) {
  113. return;
  114. }
  115. var url = CORE_API + "/auth/login";
  116. this.$httpWithMsg
  117. .post(url, this.loginInfo)
  118. .then(response => {
  119. var user = response.data;
  120. this.USER_SIGNIN(user);
  121. this.$router.replace({ path: "/home/overview" });
  122. this.$notify({
  123. message: "登录成功",
  124. type: "success",
  125. duration: 1000
  126. });
  127. })
  128. .catch(error => {
  129. if (error.response.data.code === "B-001100") {
  130. this.dialogVisible = true;
  131. }
  132. });
  133. },
  134. loginWithSms() {
  135. this.dialogVisible = false;
  136. this.login();
  137. },
  138. jwptCustomizeMethod() {
  139. // 普通高校考试综合管理平台 定制
  140. if (location.host === "jwpt.ecs.qmth.com.cn") {
  141. document.title = "普通高校-题库";
  142. this.title = " | 普通高校-题库";
  143. this.jwptCustomize = true;
  144. }
  145. }
  146. },
  147. created() {
  148. if (this.$route.hash && this.$route.hash.startsWith("#/access?")) {
  149. this.$router.push(this.$route.hash.slice(1));
  150. return;
  151. }
  152. this.loginInfo.domain = window.location.host;
  153. sessionStorage.clear();
  154. var params = this.$route.query;
  155. this.loginInfo.rootOrgId = params.orgId;
  156. this.jwptCustomizeMethod();
  157. },
  158. watch: {
  159. $route(to) {
  160. this.loginInfo.rootOrgId = to.query.orgId;
  161. }
  162. }
  163. };
  164. </script>
  165. <style scoped>
  166. .bg {
  167. width: 100vw;
  168. height: 100vh;
  169. background-image: url("../assets/images/bg.jpg");
  170. background-size: cover;
  171. }
  172. .qm-logo-text {
  173. font-size: 36px;
  174. font-weight: 700;
  175. font-stretch: normal;
  176. line-height: 36px;
  177. letter-spacing: 0px;
  178. margin-left: 40px;
  179. }
  180. .logo-text {
  181. /* font-family: "Xingkai SC", "STXingkai", "KaiTi"; */
  182. width: 100%;
  183. height: 40px;
  184. font-size: 40px;
  185. margin-bottom: 30px;
  186. font-weight: bold;
  187. font-stretch: normal;
  188. line-height: 48px;
  189. letter-spacing: 0px;
  190. color: #3968d7;
  191. text-shadow: 0px 7px 4px rgba(77, 124, 196, 0.3);
  192. text-align: center;
  193. }
  194. .login-main {
  195. width: 100%;
  196. height: 90vh;
  197. display: flex;
  198. flex-direction: column;
  199. align-items: center;
  200. justify-content: center;
  201. }
  202. .right_login {
  203. width: 480px;
  204. height: 350px;
  205. background-color: #ffffff;
  206. box-shadow: 0px 7px 20px 0px rgba(77, 124, 196, 0.1);
  207. border-radius: 38px;
  208. opacity: 0.8;
  209. padding: 0 80px;
  210. }
  211. .right_login h1 {
  212. text-align: center;
  213. height: 20px;
  214. font-size: 20px;
  215. font-weight: normal;
  216. font-stretch: normal;
  217. line-height: 24px;
  218. letter-spacing: 0px;
  219. color: #666666;
  220. margin: 40px 0;
  221. }
  222. .right_login .username {
  223. height: 46px;
  224. display: flex;
  225. align-items: center;
  226. justify-items: center;
  227. }
  228. .right_login .password {
  229. height: 46px;
  230. display: flex;
  231. align-items: center;
  232. justify-items: center;
  233. margin-top: 30px;
  234. }
  235. .right_login input {
  236. width: 100%;
  237. padding: 10px 30px;
  238. margin-left: -28px;
  239. font-size: 16px;
  240. border-radius: 10px;
  241. }
  242. .right_login input::placeholder {
  243. font-size: 16px;
  244. color: #000000;
  245. opacity: 0.3;
  246. }
  247. .login-btn {
  248. margin-top: 30px;
  249. margin-bottom: 20px;
  250. width: 100%;
  251. background-color: #4d7cc4;
  252. font-size: 25px;
  253. color: #fff;
  254. cursor: pointer;
  255. border-radius: 27px;
  256. }
  257. .login-btn:hover {
  258. box-shadow: 0 16px 29px rgba(29, 170, 240, 0.3);
  259. }
  260. .login-footer {
  261. clear: both;
  262. width: 240px;
  263. height: 40px;
  264. line-height: 40px;
  265. background-color: #fff;
  266. color: #999999;
  267. margin: -20px auto;
  268. text-align: center;
  269. border-radius: 25px;
  270. z-index: 3;
  271. }
  272. </style>