loginNew.vue 17 KB

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