loginNew.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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. v-model="ruleForm.pass"
  53. autocomplete="off"
  54. >
  55. <template slot="prefix">
  56. <div class="account-inner">
  57. <img
  58. style="height: 20px; margin-left: 10px"
  59. src="../assets/img/login/password1.png"
  60. />
  61. <div class="account-inner-line"></div>
  62. </div>
  63. </template>
  64. </el-input>
  65. </el-form-item>
  66. <el-form-item class="button-new-parent_login">
  67. <!-- <el-button class="button-new" type="primary" @click="submitForm('ruleForm')"
  68. >登&nbsp;录</el-button
  69. > -->
  70. <!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
  71. <div class="button-new" @click="submitForm('ruleForm')">登录</div>
  72. </el-form-item>
  73. </el-form>
  74. </div>
  75. </div>
  76. </div>
  77. </template>
  78. <script>
  79. import md5 from "md5";
  80. import { oSessionStorage } from "@/utils/utils";
  81. // import Footer1 from "@/components/Footer1";
  82. // import Footer from '../components/Footer.vue';
  83. export default {
  84. // components: { Footer1 },
  85. name: "loginNew",
  86. // components:[Footer1],
  87. data() {
  88. var validateAccount = (rule, value, callback) => {
  89. if (value === "") {
  90. callback(new Error("请输入账号"));
  91. } else {
  92. // if (this.ruleForm.account !== '') {
  93. // this.$refs.ruleForm.validateField('account');
  94. // }
  95. callback();
  96. }
  97. };
  98. var validatePass = (rule, value, callback) => {
  99. if (value === "") {
  100. callback(new Error("请输入密码"));
  101. } else {
  102. // if (this.ruleForm.pass !== '') {
  103. // this.$refs.ruleForm.validateField('pass');
  104. // }
  105. callback();
  106. }
  107. };
  108. var validateType = (rule, value, callback) => {
  109. if (value === "") {
  110. callback(new Error("请输入账号"));
  111. } else {
  112. // if (this.ruleForm.type !== '') {
  113. // this.$refs.ruleForm.validateField('type');
  114. // }
  115. callback();
  116. }
  117. };
  118. var validateImgText = (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. return {
  129. input1: "",
  130. imageUrl: "",
  131. ruleForm: {
  132. account: "",
  133. pass: "",
  134. type: "0",
  135. imgText: "",
  136. },
  137. rules: {
  138. account: [{ validator: validateAccount, trigger: "blur" }],
  139. pass: [{ validator: validatePass, trigger: "blur" }],
  140. type: [{ validator: validateType, trigger: "change" }],
  141. imgText: [{ validator: validateImgText, trigger: "blur" }],
  142. },
  143. };
  144. },
  145. mounted() {
  146. // this.getCode();
  147. },
  148. methods: {
  149. getCode() {
  150. this.$http.getImg(`/user/getCode`, {}, (res) => {
  151. let blob = new Blob([res.data], { type: "image/jpeg" });
  152. this.imageUrl = window.URL.createObjectURL(blob);
  153. });
  154. },
  155. submitForm(formName) {
  156. this.$refs[formName].validate((valid) => {
  157. if (valid) {
  158. //?userNo=${this.ruleForm.account}&password=${md5(this.ruleForm.pass)}
  159. this.$http.get(
  160. `/system/login?userNo=${this.ruleForm.account}&password=${md5(
  161. this.ruleForm.pass
  162. )}`,
  163. //"/v1/system/login",
  164. {
  165. // userNo: this.ruleForm.account,
  166. // password: md5(this.ruleForm.pass),
  167. // imgText: this.ruleForm.imgText,
  168. // type: 0,
  169. },
  170. (res) => {
  171. console.log(res, "登录返回");
  172. if (res && res.code == 200) {
  173. // type等于3 超级管理员
  174. // type等于2 普通管理员
  175. // type等于1 普通用户等不能登录
  176. oSessionStorage.setItem("userInfo", JSON.stringify(res.data.user));
  177. oSessionStorage.setItem("token", res.data.token);
  178. // oSessionStorage.setItem("invitationCode", res.data.user.invitationCode);
  179. //如果类型返回的是0则为普通用户
  180. //如果类型返回的是1则为管理员用户
  181. // this.$router.push({ path: "/manage/adminHome" });
  182. if (res.data.user.roleType == "5") {
  183. this.$router.push({ path: "/manage/generalSituation" });
  184. // this.$router.push({ path: "/manage/userManage" });
  185. } else if (res.data.user.roleType == "4") {
  186. // this.$router.push({ path: "/manage/userManage" });
  187. this.$router.push({ path: "/manage/generalSituation" });
  188. } else if (res.data.user.roleType == "3") {
  189. this.$router.push({ path: "/manage/generalSituation" });
  190. } else {
  191. this.$message({
  192. message: "请使用管理账号登录",
  193. type: "error",
  194. });
  195. }
  196. // if (res.data.user.roleType === "0") {
  197. // this.$message.warning("账号密码错误");
  198. // // this.$router.push({ path: "/home" });
  199. // // this.$router.push({ path: "/manageMain" });
  200. // } else {
  201. // this.$router.push({ path: "/manage/adminHome" });
  202. // }
  203. } else if (res && res.code == 2001) {
  204. //调用刷新的方法
  205. this.getCode();
  206. this.$message({
  207. message: res.msg,
  208. type: "error",
  209. });
  210. } else {
  211. this.$message({
  212. message: res.msg,
  213. type: "error",
  214. });
  215. }
  216. }
  217. );
  218. } else {
  219. console.log("error submit!!");
  220. return false;
  221. }
  222. });
  223. },
  224. resetForm(formName) {
  225. this.$refs[formName].resetFields();
  226. },
  227. },
  228. };
  229. </script>
  230. <style scoped>
  231. .input-account-new >>> .el-input__inner {
  232. background-color: #f7f7f7 !important;
  233. background-image: none;
  234. border-radius: 30px;
  235. border: 0px solid #dcdfe6;
  236. box-sizing: border-box;
  237. border: 0px;
  238. box-shadow: none;
  239. outline: none;
  240. /*color: #fff;*/
  241. color: #000;
  242. display: inline-block;
  243. height: 45px;
  244. line-height: 45px;
  245. outline: 0;
  246. padding-left: 60px;
  247. -webkit-transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  248. transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  249. width: 100%;
  250. }
  251. .account-new >>> .el-input {
  252. display: table !important;
  253. }
  254. .input-account-new >>> .el-input__inner::placeholder {
  255. /*color: #f9f9f9;*/
  256. color: #9a9a9a;
  257. }
  258. .input-password-new >>> .el-input__inner::placeholder {
  259. /*color: #f9f9f9;*/
  260. color: #9a9a9a;
  261. }
  262. .input-password-new >>> .el-input__inner {
  263. background-color: #f7f7f7 !important;
  264. background-image: none;
  265. border-radius: 30px;
  266. border: 0px solid #dcdfe6;
  267. box-sizing: border-box;
  268. /*color: #fff;*/
  269. color: #000;
  270. display: inline-block;
  271. height: 45px;
  272. line-height: 45px;
  273. outline: 0;
  274. padding-left: 60px;
  275. -webkit-transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  276. transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  277. width: 100%;
  278. }
  279. .button-new-parent >>> .el-form-item__content {
  280. }
  281. </style>
  282. <style lang="less" scoped>
  283. @import "../styles/theme.less";
  284. .login-wrapper-new {
  285. width: 100%;
  286. overflow: hidden;
  287. height: 100%;
  288. background: url("../assets/img/login/login_bg.png") no-repeat left;
  289. background-size: 100% 100%;
  290. display: flex;
  291. flex-direction: row;
  292. justify-content: space-between;
  293. align-items: center;
  294. .login-left-new {
  295. display: flex;
  296. // background-color: #0263c4;
  297. position: absolute;
  298. top: 0;
  299. bottom: 0;
  300. left: 0;
  301. right: 0;
  302. margin: auto;
  303. width: 1080px;
  304. height: 600px;
  305. box-sizing: border-box;
  306. border-radius: 40px;
  307. .cpdm_left {
  308. position: relative;
  309. width: 50%;
  310. height: 100%;
  311. background: url("../assets/img/login/login_left.png") no-repeat;
  312. background-size: 100% 100%;
  313. .logo {
  314. height: 60px;
  315. margin-left: 10%;
  316. margin-top: 5%;
  317. width: auto;
  318. }
  319. .ye1 {
  320. width: 40px;
  321. margin-left: -20px;
  322. position: absolute;
  323. margin-top: 25%;
  324. }
  325. .ye2 {
  326. position: absolute;
  327. margin-left: calc(100% - 20px);
  328. width: 40px;
  329. margin-top: 40%;
  330. }
  331. }
  332. .cpdm_right {
  333. background-color: #fff;
  334. width: 50%;
  335. height: 100%;
  336. // border-radius: 40px;
  337. border-top-right-radius: 40px;
  338. border-bottom-right-radius: 40px;
  339. }
  340. .login-left-top-new {
  341. margin-left: 10%;
  342. width: 80%;
  343. padding-top: 10%;
  344. padding-bottom: 12%;
  345. }
  346. .login-left-middle-new {
  347. width: 78%;
  348. margin-left: 11%;
  349. .cpdm_right_top {
  350. margin-top: 50px;
  351. margin-bottom: 60px;
  352. display: flex;
  353. flex-direction: row;
  354. align-items: center;
  355. justify-content: space-between;
  356. .cpdm_right_top_des {
  357. letter-spacing: 3px;
  358. font-size: 30px;
  359. font-weight: 700;
  360. margin-left: 10px;
  361. }
  362. .cpdm_right_top_img {
  363. width: 100px;
  364. }
  365. }
  366. .account-new {
  367. color: #fff;
  368. margin-bottom: 10%;
  369. .login-label {
  370. display: inline-block;
  371. margin-top: 8px;
  372. //color: #fff;
  373. font-size: 16px;
  374. font-weight: bold;
  375. }
  376. .input-account-new {
  377. background: rgba(255, 255, 255, 0.2);
  378. border-radius: 30px 30px 30px 30px;
  379. opacity: 1;
  380. //border: 1px solid #ffffff;
  381. // border: 1px solid #0263c4;
  382. width: 100%;
  383. }
  384. }
  385. .account-two-new {
  386. color: #fff;
  387. margin-bottom: 10%;
  388. .login-label {
  389. display: inline-block;
  390. margin-top: 8px;
  391. //color: #fff;
  392. color: #0263c4;
  393. font-size: 16px;
  394. font-weight: bold;
  395. }
  396. .input-password-new {
  397. background: rgba(255, 255, 255, 0.2);
  398. border-radius: 30px 30px 30px 30px;
  399. opacity: 1;
  400. //border: 1px solid #ffffff;
  401. // border: 1px solid #0263c4;
  402. width: 100%;
  403. }
  404. }
  405. }
  406. }
  407. }
  408. .beian {
  409. position: fixed;
  410. left: 50%;
  411. // top:50%;
  412. transform: translate(-50%, -50%);
  413. bottom: 20px;
  414. font-size: 15px;
  415. z-index: 1000;
  416. }
  417. .beianDetail {
  418. display: flex;
  419. justify-items: center;
  420. align-items: center;
  421. }
  422. .login-title-p {
  423. text-align: center;
  424. font-size: 20px;
  425. margin-bottom: 40px;
  426. }
  427. .code-class {
  428. height: 100%;
  429. border-radius: 20px;
  430. }
  431. .account-inner {
  432. display: flex;
  433. flex-direction: row;
  434. justify-content: center;
  435. align-items: center;
  436. height: 50px;
  437. }
  438. .account-inner-line {
  439. width: 1px;
  440. background-color: #b5c8ff;
  441. height: 30px;
  442. margin-left: 10px;
  443. }
  444. .button-new-parent_login {
  445. margin-top: 80px;
  446. display: flex;
  447. justify-content: center;
  448. .button-new {
  449. text-align: center;
  450. border-radius: 50px;
  451. border: 3px solid #48d68e;
  452. color: #ffffff;
  453. background-color: #000000;
  454. // margin-right: 20px;
  455. padding: 10px 90px;
  456. cursor: pointer;
  457. display: flex;
  458. align-items: center;
  459. font-size: 24px;
  460. }
  461. }
  462. .aab {
  463. color: #48d68e;
  464. margin-left: 20px;
  465. margin-top: 40px;
  466. font-weight: 700;
  467. font-size: 24px;
  468. -webkit-transform: skew(-10deg);
  469. letter-spacing: 2px;
  470. /* for Chrome||Safari */
  471. -ms-transform: skew(-10deg);
  472. /* for IE */
  473. -moz-transform: skew(-10deg);
  474. /* for Firefox */
  475. -o-transform: skew(-10deg);
  476. /* for Opera */
  477. }
  478. </style>