loginNew.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. <template>
  2. <div class="login-wrapper-new">
  3. <div class="login-left-new">
  4. <div class="cpdm_left">
  5. <!-- <p class="aab">学生心理健康测评系统</p> -->
  6. <p class="aab">金融行业职工心理健康测评系统</p>
  7. <!-- <img class="logo" src="../assets/img/login/login_logo.png" /> -->
  8. <img class="ye1" src="../assets/img/login/ye1.png" />
  9. <img class="ye2" src="../assets/img/login/ye2.png" />
  10. </div>
  11. <div class="cpdm_right">
  12. <el-form
  13. class="login-left-middle-new"
  14. :model="ruleForm"
  15. :rules="rules"
  16. ref="ruleForm"
  17. :label-position="'left'"
  18. label-width="10px"
  19. size="mini"
  20. >
  21. <div class="cpdm_right_top">
  22. <div class="cpdm_right_top_des">欢迎登录</div>
  23. <img
  24. class="cpdm_right_top_img"
  25. src="../assets/img/login/login-left-top.png"
  26. />
  27. </div>
  28. <el-form-item label="" prop="account" class="account-new">
  29. <el-input
  30. class="input-account-new"
  31. type="text"
  32. v-model="ruleForm.account"
  33. placeholder="请输入账号"
  34. autocomplete="off"
  35. >
  36. <template slot="prefix">
  37. <div class="account-inner">
  38. <img
  39. style="height: 20px; margin-left: 10px"
  40. src="../assets/img/login/persion1.png"
  41. />
  42. <div class="account-inner-line"></div>
  43. </div>
  44. </template>
  45. </el-input>
  46. <!-- <img src="../assets/img/login/persion.png" /> -->
  47. </el-form-item>
  48. <el-form-item label="" class="account-two-new" prop="pass">
  49. <el-input
  50. class="input-password-new"
  51. type="password"
  52. placeholder="请输入密码"
  53. show-password
  54. v-model="ruleForm.pass"
  55. autocomplete="off"
  56. @keyup.enter.native="submitForm('ruleForm')"
  57. >
  58. <template slot="prefix">
  59. <div class="account-inner">
  60. <img
  61. style="height: 20px; margin-left: 10px"
  62. src="../assets/img/login/password1.png"
  63. />
  64. <div class="account-inner-line"></div>
  65. </div>
  66. </template>
  67. </el-input>
  68. </el-form-item>
  69. <el-form-item class="button-new-parent_login">
  70. <!-- <el-button class="button-new" type="primary" @click="submitForm('ruleForm')"
  71. >登&nbsp;录</el-button
  72. > -->
  73. <!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
  74. <div class="button-new" @click="submitForm('ruleForm')">登录</div>
  75. </el-form-item>
  76. </el-form>
  77. <div v-show="isTest">
  78. <el-divider style="width: 80%">演示账号一键登录</el-divider>
  79. </div>
  80. <div style="text-align: center" v-show="isTest">
  81. <el-button size="mini" @click="loginTest(1)">运维演示账号登录</el-button>
  82. <el-button size="mini" @click="loginTest(2)">管理员演示账号登录</el-button>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. import md5 from "md5";
  90. import { oSessionStorage } from "@/utils/utils";
  91. // import Footer1 from "@/components/Footer1";
  92. // import Footer from '../components/Footer.vue';
  93. export default {
  94. // components: { Footer1 },
  95. name: "loginNew",
  96. // components:[Footer1],
  97. data() {
  98. var validateAccount = (rule, value, callback) => {
  99. if (value === "") {
  100. callback(new Error("请输入账号"));
  101. } else {
  102. // if (this.ruleForm.account !== '') {
  103. // this.$refs.ruleForm.validateField('account');
  104. // }
  105. callback();
  106. }
  107. };
  108. var validatePass = (rule, value, callback) => {
  109. if (value === "") {
  110. callback(new Error("请输入密码"));
  111. } else {
  112. // if (this.ruleForm.pass !== '') {
  113. // this.$refs.ruleForm.validateField('pass');
  114. // }
  115. callback();
  116. }
  117. };
  118. var validateType = (rule, value, callback) => {
  119. if (value === "") {
  120. callback(new Error("请输入账号"));
  121. } else {
  122. // if (this.ruleForm.type !== '') {
  123. // this.$refs.ruleForm.validateField('type');
  124. // }
  125. callback();
  126. }
  127. };
  128. var validateImgText = (rule, value, callback) => {
  129. if (value === "") {
  130. callback(new Error("请输入验证码"));
  131. } else {
  132. // if (this.ruleForm.type !== '') {
  133. // this.$refs.ruleForm.validateField('type');
  134. // }
  135. callback();
  136. }
  137. };
  138. return {
  139. input1: "",
  140. imageUrl: "",
  141. ruleForm: {
  142. account: "",
  143. pass: "",
  144. type: "0",
  145. imgText: "",
  146. },
  147. rules: {
  148. account: [{ validator: validateAccount, trigger: "blur" }],
  149. pass: [{ validator: validatePass, trigger: "blur" }],
  150. type: [{ validator: validateType, trigger: "change" }],
  151. imgText: [{ validator: validateImgText, trigger: "blur" }],
  152. },
  153. isTest: false,
  154. };
  155. },
  156. mounted() {
  157. // this.getCode();
  158. //调用接口
  159. //调用接口查看返回值
  160. this.viewStaus();
  161. },
  162. methods: {
  163. viewStaus() {
  164. this.$http.get(
  165. `/system/getVersion`,
  166. //"/v1/system/login",
  167. {
  168. // userNo: this.ruleForm.account,
  169. // password: md5(this.ruleForm.pass),
  170. // imgText: this.ruleForm.imgText,
  171. // type: 0,
  172. },
  173. (res) => {
  174. if (res && res.code == 200) {
  175. //
  176. if (res.msg == "test") {
  177. this.isTest = true;
  178. } else {
  179. this.isTest = false;
  180. }
  181. } else if (res && res.code == 2001) {
  182. //调用刷新的方法
  183. // this.getCode();
  184. // this.$message({
  185. // message: res.msg,
  186. // type: "error",
  187. // });
  188. } else {
  189. // this.$message({
  190. // message: res.msg,
  191. // type: "error",
  192. // });
  193. }
  194. }
  195. );
  196. },
  197. loginTest(val) {
  198. let url = "";
  199. if (val == 1) {
  200. url = `/system/login?userNo=admin&password=${md5("Admin123456")}`;
  201. } else if (val == 2) {
  202. url = `/system/login?userNo=sjcc&password=${md5("123456")}`;
  203. } else {
  204. return;
  205. }
  206. this.$http.get(
  207. url,
  208. //"/v1/system/login",
  209. {
  210. // userNo: this.ruleForm.account,
  211. // password: md5(this.ruleForm.pass),
  212. // imgText: this.ruleForm.imgText,
  213. // type: 0,
  214. },
  215. (res) => {
  216. if (res && res.code == 200) {
  217. // type等于3 超级管理员
  218. // type等于2 普通管理员
  219. // type等于1 普通用户等不能登录
  220. oSessionStorage.setItem("userInfo", JSON.stringify(res.data.user));
  221. oSessionStorage.setItem("token", res.data.token);
  222. // oSessionStorage.setItem("invitationCode", res.data.user.invitationCode);
  223. //如果类型返回的是0则为普通用户
  224. //如果类型返回的是1则为管理员用户
  225. // this.$router.push({ path: "/manage/adminHome" });
  226. if (res.data.user.roleType == "5") {
  227. this.$router.push({ path: "/manage/generalSituation" });
  228. // this.$router.push({ path: "/manage/userManage" });
  229. } else if (res.data.user.roleType == "4") {
  230. // this.$router.push({ path: "/manage/userManage" });
  231. this.$router.push({ path: "/manage/generalSituation" });
  232. } else if (res.data.user.roleType == "3") {
  233. this.$router.push({ path: "/manage/userManage" });
  234. } else {
  235. this.$message({
  236. message: "请使用管理账号登录",
  237. type: "error",
  238. });
  239. }
  240. // if (res.data.user.roleType === "0") {
  241. // this.$message.warning("账号密码错误");
  242. // // this.$router.push({ path: "/home" });
  243. // // this.$router.push({ path: "/manageMain" });
  244. // } else {
  245. // this.$router.push({ path: "/manage/adminHome" });
  246. // }
  247. } else if (res && res.code == 2001) {
  248. //调用刷新的方法
  249. // this.getCode();
  250. this.$message({
  251. message: res.msg,
  252. type: "error",
  253. });
  254. } else {
  255. this.$message({
  256. message: res.msg,
  257. type: "error",
  258. });
  259. }
  260. }
  261. );
  262. },
  263. getCode() {
  264. this.$http.getImg(`/user/getCode`, {}, (res) => {
  265. let blob = new Blob([res.data], { type: "image/jpeg" });
  266. this.imageUrl = window.URL.createObjectURL(blob);
  267. });
  268. },
  269. submitForm(formName) {
  270. this.$refs[formName].validate((valid) => {
  271. if (valid) {
  272. //?userNo=${this.ruleForm.account}&password=${md5(this.ruleForm.pass)}
  273. this.$http.get(
  274. `/system/login?userNo=${this.ruleForm.account}&password=${md5(
  275. this.ruleForm.pass
  276. )}`,
  277. //"/v1/system/login",
  278. {
  279. // userNo: this.ruleForm.account,
  280. // password: md5(this.ruleForm.pass),
  281. // imgText: this.ruleForm.imgText,
  282. // type: 0,
  283. },
  284. (res) => {
  285. if (res && res.code == 200) {
  286. // type等于3 超级管理员
  287. // type等于2 普通管理员
  288. // type等于1 普通用户等不能登录
  289. oSessionStorage.setItem("userInfo", JSON.stringify(res.data.user));
  290. oSessionStorage.setItem("token", res.data.token);
  291. // oSessionStorage.setItem("invitationCode", res.data.user.invitationCode);
  292. //如果类型返回的是0则为普通用户
  293. //如果类型返回的是1则为管理员用户
  294. // this.$router.push({ path: "/manage/adminHome" });
  295. if (res.data.user.roleType == "5") {
  296. this.$router.push({ path: "/manage/generalSituation" });
  297. // this.$router.push({ path: "/manage/userManage" });
  298. } else if (res.data.user.roleType == "4") {
  299. // this.$router.push({ path: "/manage/userManage" });
  300. this.$router.push({ path: "/manage/generalSituation" });
  301. } else if (res.data.user.roleType == "3") {
  302. this.$router.push({ path: "/manage/userManage" });
  303. } else {
  304. this.$message({
  305. message: "请使用管理账号登录",
  306. type: "error",
  307. });
  308. }
  309. // if (res.data.user.roleType === "0") {
  310. // this.$message.warning("账号密码错误");
  311. // // this.$router.push({ path: "/home" });
  312. // // this.$router.push({ path: "/manageMain" });
  313. // } else {
  314. // this.$router.push({ path: "/manage/adminHome" });
  315. // }
  316. } else if (res && res.code == 2001) {
  317. //调用刷新的方法
  318. // this.getCode();
  319. this.$message({
  320. message: res.msg,
  321. type: "error",
  322. });
  323. } else {
  324. this.$message({
  325. message: res.msg,
  326. type: "error",
  327. });
  328. }
  329. }
  330. );
  331. } else {
  332. console.log("error submit!!");
  333. return false;
  334. }
  335. });
  336. },
  337. resetForm(formName) {
  338. this.$refs[formName].resetFields();
  339. },
  340. },
  341. };
  342. </script>
  343. <style scoped>
  344. .el-divider--horizontal {
  345. display: block;
  346. height: 1px;
  347. width: 80% !important;
  348. margin: 24px 0;
  349. margin-left: 10%;
  350. }
  351. /* @font-face {
  352. font-family: "Electronic";
  353. src: url("../../assets/font/sjxk.ttf") format("truetype");
  354. } */
  355. .input-account-new >>> .el-input__inner {
  356. background-color: #f7f7f7 !important;
  357. background-image: none;
  358. border-radius: 30px;
  359. border: 0px solid #dcdfe6;
  360. box-sizing: border-box;
  361. border: 0px;
  362. box-shadow: none;
  363. outline: none;
  364. /*color: #fff;*/
  365. color: #000;
  366. display: inline-block;
  367. height: 45px;
  368. line-height: 45px;
  369. outline: 0;
  370. padding-left: 60px;
  371. -webkit-transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  372. transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  373. width: 100%;
  374. }
  375. .account-new >>> .el-input {
  376. display: table !important;
  377. }
  378. .input-account-new >>> .el-input__inner::placeholder {
  379. /*color: #f9f9f9;*/
  380. color: #9a9a9a;
  381. }
  382. .input-password-new >>> .el-input__inner::placeholder {
  383. /*color: #f9f9f9;*/
  384. color: #9a9a9a !important;
  385. }
  386. .input-password-new >>> .el-input__icon {
  387. /*color: #f9f9f9;*/
  388. line-height: 46px !important;
  389. }
  390. .input-password-new >>> .el-input__inner {
  391. background-color: #f7f7f7 !important;
  392. background-image: none;
  393. border-radius: 30px;
  394. border: 0px solid #dcdfe6;
  395. box-sizing: border-box;
  396. /*color: #fff;*/
  397. color: #000;
  398. display: inline-block;
  399. height: 45px;
  400. line-height: 45px;
  401. outline: 0;
  402. padding-left: 60px;
  403. -webkit-transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  404. transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  405. width: 100%;
  406. }
  407. .button-new-parent >>> .el-form-item__content {
  408. }
  409. </style>
  410. <style lang="less" scoped>
  411. @import "../styles/theme.less";
  412. .login-wrapper-new {
  413. width: 100%;
  414. overflow: hidden;
  415. height: 100%;
  416. background: url("../assets/img/login/login_bg.png") no-repeat left;
  417. background-size: 100% 100%;
  418. display: flex;
  419. flex-direction: row;
  420. justify-content: space-between;
  421. align-items: center;
  422. .login-left-new {
  423. display: flex;
  424. // background-color: #0263c4;
  425. position: absolute;
  426. top: 0;
  427. bottom: 0;
  428. left: 0;
  429. right: 0;
  430. margin: auto;
  431. width: 1080px;
  432. height: 600px;
  433. box-sizing: border-box;
  434. border-radius: 40px;
  435. .cpdm_left {
  436. position: relative;
  437. width: 50%;
  438. height: 100%;
  439. background: url("../assets/img/login/login_left.png") no-repeat;
  440. background-size: 100% 100%;
  441. .logo {
  442. height: 60px;
  443. margin-left: 10%;
  444. margin-top: 5%;
  445. width: auto;
  446. }
  447. .ye1 {
  448. width: 40px;
  449. margin-left: -20px;
  450. position: absolute;
  451. margin-top: 25%;
  452. }
  453. .ye2 {
  454. position: absolute;
  455. margin-left: calc(100% - 20px);
  456. width: 40px;
  457. margin-top: 40%;
  458. }
  459. }
  460. .cpdm_right {
  461. background-color: #fff;
  462. width: 50%;
  463. height: 100%;
  464. // border-radius: 40px;
  465. border-top-right-radius: 40px;
  466. border-bottom-right-radius: 40px;
  467. }
  468. .login-left-top-new {
  469. margin-left: 10%;
  470. width: 80%;
  471. padding-top: 10%;
  472. padding-bottom: 12%;
  473. }
  474. .login-left-middle-new {
  475. width: 78%;
  476. margin-left: 11%;
  477. .cpdm_right_top {
  478. margin-top: 50px;
  479. margin-bottom: 60px;
  480. display: flex;
  481. flex-direction: row;
  482. align-items: center;
  483. justify-content: space-between;
  484. .cpdm_right_top_des {
  485. letter-spacing: 3px;
  486. font-size: 30px;
  487. font-weight: 700;
  488. margin-left: 10px;
  489. }
  490. .cpdm_right_top_img {
  491. width: 100px;
  492. }
  493. }
  494. .account-new {
  495. color: #fff;
  496. margin-bottom: 10%;
  497. .login-label {
  498. display: inline-block;
  499. margin-top: 8px;
  500. //color: #fff;
  501. font-size: 16px;
  502. font-weight: bold;
  503. }
  504. .input-account-new {
  505. background: rgba(255, 255, 255, 0.2);
  506. border-radius: 30px 30px 30px 30px;
  507. opacity: 1;
  508. //border: 1px solid #ffffff;
  509. // border: 1px solid #0263c4;
  510. width: 100%;
  511. }
  512. }
  513. .account-two-new {
  514. color: #fff;
  515. margin-bottom: 10%;
  516. .login-label {
  517. display: inline-block;
  518. margin-top: 8px;
  519. //color: #fff;
  520. color: #0263c4;
  521. font-size: 16px;
  522. font-weight: bold;
  523. }
  524. .input-password-new {
  525. background: rgba(255, 255, 255, 0.2);
  526. border-radius: 30px 30px 30px 30px;
  527. opacity: 1;
  528. //border: 1px solid #ffffff;
  529. // border: 1px solid #0263c4;
  530. width: 100%;
  531. }
  532. }
  533. }
  534. }
  535. }
  536. .beian {
  537. position: fixed;
  538. left: 50%;
  539. // top:50%;
  540. transform: translate(-50%, -50%);
  541. bottom: 20px;
  542. font-size: 15px;
  543. z-index: 1000;
  544. }
  545. .beianDetail {
  546. display: flex;
  547. justify-items: center;
  548. align-items: center;
  549. }
  550. .login-title-p {
  551. text-align: center;
  552. font-size: 20px;
  553. margin-bottom: 40px;
  554. }
  555. .code-class {
  556. height: 100%;
  557. border-radius: 20px;
  558. }
  559. .account-inner {
  560. display: flex;
  561. flex-direction: row;
  562. justify-content: center;
  563. align-items: center;
  564. height: 45px;
  565. }
  566. .account-inner-line {
  567. width: 1px;
  568. background-color: #e9e9e9;
  569. height: 30px;
  570. margin-left: 10px;
  571. }
  572. .button-new-parent_login {
  573. margin-top: 80px;
  574. display: flex;
  575. justify-content: center;
  576. .button-new {
  577. text-align: center;
  578. border-radius: 50px;
  579. border: 3px solid #48d68e;
  580. color: #ffffff;
  581. background-color: #000000;
  582. // margin-right: 20px;
  583. padding: 10px 90px;
  584. cursor: pointer;
  585. display: flex;
  586. align-items: center;
  587. font-size: 24px;
  588. }
  589. }
  590. .aab {
  591. color: #48d68e;
  592. margin-left: 50px;
  593. margin-top: 40px;
  594. font-weight: 700;
  595. font-size: 24px;
  596. -webkit-transform: skew(-10deg);
  597. letter-spacing: 2px;
  598. /* for Chrome||Safari */
  599. -ms-transform: skew(-10deg);
  600. /* for IE */
  601. -moz-transform: skew(-10deg);
  602. /* for Firefox */
  603. -o-transform: skew(-10deg);
  604. /* for Opera */
  605. }
  606. </style>