index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <div class="login-container">
  3. <template v-if="type == 1">
  4. <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
  5. <div class="title-container flex-wrap">
  6. <div class="avitor"></div>
  7. <!-- <el-divider direction="vertical"></el-divider> -->
  8. <div class="content-box">
  9. <div class="title">国航行李数据整合及应用</div>
  10. <div class="title-en">AirChina.BDHUB</div>
  11. </div>
  12. </div>
  13. <el-form-item prop="username">
  14. <!-- <span class="svg-container">
  15. <svg-icon style="color:#606266;" icon-class="user" />
  16. </span> -->
  17. <el-input ref="username" v-model="loginForm.username" placeholder="用户名" name="username" type="text" tabindex="1" auto-complete="on" />
  18. </el-form-item>
  19. <el-form-item prop="password">
  20. <!-- <span class="svg-container">
  21. <svg-icon style="color:#606266;" icon-class="password" />
  22. </span> -->
  23. <el-input ref="password" v-model="loginForm.password" show-password placeholder="密码" name="password" tabindex="2" auto-complete="on" />
  24. </el-form-item>
  25. <div class="flex-wrap">
  26. <el-form-item class="flex1" prop="identify">
  27. <el-input ref="identify" v-model="loginForm.identify" placeholder="请输入验证码" name="identify" tabindex="1" auto-complete="on" @keyup.enter.native="handleLogin" />
  28. </el-form-item>
  29. <Identify @changeCode="changeCode" :identifyCode="loginForm.CheckCode" style="margin-left: 24px" />
  30. </div>
  31. <el-button :loading="loading" type="primary" style="
  32. width: 100%;
  33. margin-top: 18px;
  34. height: 42px;
  35. border-radius: 2px;
  36. " @click.native.prevent="handleLogin">登录</el-button>
  37. <div class="forgetPwd">
  38. <span @click="handleClick" class="fpwd">忘记密码</span>
  39. </div>
  40. </el-form>
  41. </template>
  42. <template v-else>
  43. <Dialog :flag="flag" customClass="dormancyDialog" width="496px">
  44. <div class="dormancy">
  45. <div class="title">忘记密码</div>
  46. <div class="content">
  47. <p style="font-size: 16px; font-weight: 400; color: #303133">
  48. {{ PwdMessage }}
  49. </p>
  50. <div style="display: flex; justify-content: flex-end">
  51. <el-button size="small" type="primary" @click="onSubmit">
  52. 确定
  53. </el-button>
  54. </div>
  55. </div>
  56. </div>
  57. </Dialog>
  58. </template>
  59. </div>
  60. </template>
  61. <script>
  62. import Identify from "./identify.vue";
  63. import Dialog from "@/layout/components/Dialog/index.vue";
  64. import { GetCheckCode, gettoken } from "@/api/login";
  65. import { GetSystemSet } from "@/api/systemConfiguration";
  66. import { setCodeToken } from '@/utils/auth';
  67. import { getAuthListByUser } from '@/api/Account';
  68. import { setToken } from '@/utils/auth';
  69. import router from '@/router'
  70. export default {
  71. name: "Login",
  72. components: { Identify, Dialog },
  73. data () {
  74. return {
  75. type: 1,
  76. flag: false,
  77. PwdMessage: null,
  78. loginForm: {
  79. username: "",
  80. password: "",
  81. identify: "",
  82. CheckCode: null,
  83. },
  84. loginRules: {
  85. username: [
  86. { required: true, trigger: "blur", message: "请输入用户名" },
  87. ],
  88. password: [{ required: true, trigger: "blur", message: "请输入密码" }],
  89. identify: [
  90. { required: true, trigger: "blur", message: "请输入验证码" },
  91. ],
  92. },
  93. loading: false,
  94. passwordType: "password",
  95. redirect: undefined,
  96. };
  97. },
  98. watch: {
  99. $route: {
  100. handler: function (route) {
  101. this.redirect = route.query && route.query.redirect;
  102. },
  103. immediate: true,
  104. },
  105. },
  106. async created () {
  107. // this.getCheckCode();
  108. // this.getSystemSet();
  109. try {
  110. const res = await gettoken({
  111. 'appID': PLATFROM_CONFIG.appId
  112. })
  113. if (res.code == 0 && res.returnData.token) {
  114. setCodeToken(res.returnData.token);
  115. setTimeout(() => {
  116. this.getCheckCode();
  117. this.getSystemSet();
  118. }, 100);
  119. } else {
  120. this.$message.error(res.message);
  121. }
  122. } catch (error) {
  123. console.log(error);
  124. }
  125. },
  126. methods: {
  127. showPwd () {
  128. if (this.passwordType === "password") {
  129. this.passwordType = "";
  130. } else {
  131. this.passwordType = "password";
  132. }
  133. this.$nextTick(() => {
  134. this.$refs.password.focus();
  135. });
  136. },
  137. // 登录
  138. handleLogin () {
  139. this.$refs.loginForm.validate((valid) => {
  140. if (valid) {
  141. this.loading = true;
  142. const params = {
  143. LoginName: this.loginForm.username.replace(/\s+/g, ""),
  144. LoginPwd: this.loginForm.password.replace(/\s+/g, ""),
  145. CheckCode: this.loginForm.identify.replace(/\s+/g, ""),
  146. };
  147. this.$store
  148. .dispatch("user/login", params)
  149. .then(() => {
  150. this.$store.dispatch("app/toggleOutcheck", false);
  151. sessionStorage.setItem("userName", params.LoginName);
  152. setTimeout(() => {
  153. const UserId = this.$store.getters.UserId;
  154. const UserType = this.$store.getters.UserType;
  155. getAuthListByUser({
  156. UserId: UserId,
  157. UserType: UserType
  158. }).then(res => {
  159. if (res.code == 0) {
  160. //res.returnData.push('account_menu');
  161. const datas = res.returnData
  162. if (datas && datas.length) {
  163. const arrs = [];
  164. for (const item of datas) {
  165. arrs.push(item.AuthIdent);
  166. }
  167. arrs.push('transit');
  168. setToken('userAuthList', arrs);
  169. this.$store.dispatch('user/setPowerList', arrs);
  170. } else {
  171. setToken('userAuthList', []);
  172. this.$store.dispatch('user/setPowerList', []);
  173. }
  174. this.$router.push({ path: this.redirect || "/" });
  175. } else {
  176. this.loading = false;
  177. this.$store.dispatch("user/logout");
  178. this.$message.error('当前用户获取权限失败,请联系管理员');
  179. }
  180. }).catch(err => {
  181. this.loading = false;
  182. this.$store.dispatch("user/logout");
  183. this.$message.error('当前用户获取权限失败,请联系管理员');
  184. })
  185. }, 100);
  186. this.loading = false;
  187. })
  188. .catch(() => {
  189. this.loading = false;
  190. });
  191. } else {
  192. console.log("error submit!!");
  193. return false;
  194. }
  195. });
  196. },
  197. // 忘记密码确定
  198. onSubmit () {
  199. this.flag = false;
  200. this.type = 1;
  201. },
  202. //获取动态验证码
  203. async getCheckCode () {
  204. const res = await GetCheckCode({});
  205. if (res.code === 0) {
  206. this.loginForm.CheckCode = res.returnData;
  207. } else {
  208. this.$message.error(res.message);
  209. }
  210. },
  211. //获取系统设置
  212. getSystemSet () {
  213. GetSystemSet({})
  214. .then((response) => {
  215. const { returnData } = response;
  216. const { PwdMessage } = returnData;
  217. this.PwdMessage = PwdMessage;
  218. this.$store.dispatch("app/getSystemSet", returnData);
  219. })
  220. .catch((error) => {
  221. reject(error);
  222. });
  223. },
  224. // 忘记密码
  225. handleClick () {
  226. // this.flag = true;
  227. // this.type = 2;
  228. this.$message.warning('忘记密码,请联系管理员');
  229. },
  230. //验证码重新获取
  231. changeCode () {
  232. this.getCheckCode();
  233. },
  234. },
  235. };
  236. </script>
  237. <style lang="scss">
  238. /* 修复input 背景不协调 和光标变色 */
  239. /* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
  240. $bg: #283443;
  241. $light_gray: #fff;
  242. $cursor: #fff;
  243. @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  244. .login-container .el-input input {
  245. color: $cursor;
  246. }
  247. }
  248. /* reset element-ui css */
  249. .login-container {
  250. .el-input {
  251. display: inline-block;
  252. height: 47px;
  253. input {
  254. background: transparent;
  255. border: 0px;
  256. -webkit-appearance: none;
  257. border-radius: 0px;
  258. padding: 12px 5px 12px 15px;
  259. color: $light_gray;
  260. // caret-color: $cursor;
  261. &:-webkit-autofill {
  262. box-shadow: 0 0 0px 1000px #f5f7fa inset !important;
  263. }
  264. }
  265. }
  266. .el-form-item {
  267. background: rgba(0, 0, 0, 0.1);
  268. border-radius: 5px;
  269. color: #454545;
  270. }
  271. }
  272. </style>
  273. <style lang="scss" scoped>
  274. $bg: #2d3a4b;
  275. $dark_gray: #889aa4;
  276. $light_gray: #eee;
  277. .login-container {
  278. min-height: 100%;
  279. width: 100%;
  280. background-color: $bg;
  281. overflow: hidden;
  282. background-image: url("../../assets/loginpage/bg.png");
  283. background-repeat: no-repeat;
  284. background-size: cover;
  285. display: flex;
  286. justify-content: center;
  287. align-items: center;
  288. ::v-deep .login-form {
  289. position: relative;
  290. width: 416px;
  291. height: 424px;
  292. background: #ffffff;
  293. box-shadow: 0px 7px 18px 0px rgba(0, 0, 0, 0.5);
  294. border-radius: 8px;
  295. padding: 40px 48px 27px 48px;
  296. .el-form-item__content {
  297. height: 40px;
  298. background: #fff;
  299. border-radius: 6px;
  300. .el-input {
  301. height: 40px;
  302. border-radius: 2px;
  303. input {
  304. height: 40px;
  305. border: 1px solid #d2d6df;
  306. color: #303133;
  307. }
  308. }
  309. }
  310. }
  311. .forgetPwd {
  312. display: flex;
  313. justify-content: flex-end;
  314. margin-top: 22px;
  315. font-size: 14px;
  316. font-family: Microsoft YaHei;
  317. font-weight: 400;
  318. text-decoration: underline;
  319. color: #2d67e3;
  320. .fpwd {
  321. cursor: pointer;
  322. }
  323. }
  324. .tips {
  325. font-size: 14px;
  326. color: #fff;
  327. margin-bottom: 10px;
  328. span {
  329. &:first-of-type {
  330. margin-right: 16px;
  331. }
  332. }
  333. }
  334. .svg-container {
  335. vertical-align: middle;
  336. width: 55px;
  337. display: inline-block;
  338. text-align: center;
  339. }
  340. .title-container {
  341. position: relative;
  342. margin-bottom: 39px;
  343. line-height: 32px;
  344. .title {
  345. // height: 16px;
  346. font-size: 16px;
  347. font-family: Microsoft YaHei;
  348. font-weight: bold;
  349. color: #303133;
  350. margin: 0;
  351. }
  352. .title-en {
  353. position: absolute;
  354. top: 23px;
  355. left: 0;
  356. font-size: 12px;
  357. }
  358. .content-box {
  359. position: relative;
  360. }
  361. .avitor {
  362. width: 36px;
  363. height: 36px;
  364. margin-right: 20px;
  365. background: url("../../assets/logo/pic_logo.png") no-repeat;
  366. // border-radius: 50%;
  367. position: relative;
  368. top: 7px;
  369. }
  370. .el-divider {
  371. height: 20px;
  372. background: #101116;
  373. margin: 0 16px;
  374. position: relative;
  375. top: 5px;
  376. }
  377. }
  378. .show-pwd {
  379. position: absolute;
  380. right: 10px;
  381. top: 7px;
  382. font-size: 16px;
  383. color: $dark_gray;
  384. cursor: pointer;
  385. user-select: none;
  386. }
  387. }
  388. </style>