index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <template>
  2. <div class="loginPic">
  3. <div class="login_left">
  4. <p class="titleW">Welcome!</p>
  5. <p class="title">基于风机发电量全寿命周期管控的研究与应用</p>
  6. <p class="titleEn">Research and application of full lifecycle control based on wind turbine power generation
  7. </p>
  8. </div>
  9. <div class="login_right">
  10. <p class="loginTit">账号登录</p>
  11. <div class="loginUser">
  12. <el-icon>
  13. <UserFilled />
  14. </el-icon>
  15. <el-input v-model="inputUser" placeholder="请输入账号">
  16. </el-input>
  17. </div>
  18. <div class="loginMima">
  19. <el-input type="password" v-model="inputMima" placeholder="请输入密码" @keyup.enter="handleLogin">
  20. <template #prepend>
  21. <i class="el-input__icon icon-mima" />
  22. </template>
  23. </el-input>
  24. </div>
  25. <!-- <div class="loginYanzhengma">
  26. <el-input type="password" v-model="inputYanzhengma" placeholder="请输入验证码" @keyup.enter="handleLogin">
  27. <template #prepend>
  28. <i class="el-input__icon icon-yanzhengma" />
  29. </template>
  30. </el-input>
  31. <div class="login-code">
  32. <img :src="codeUrl" @click="getCode" class="login-code-img" />
  33. </div>
  34. </div> -->
  35. <div class="remeber">
  36. <el-checkbox v-model="ememberMe" disabled>记住密码</el-checkbox>
  37. <!-- <p @click="drawerDia = true">账号注册</p> -->
  38. </div>
  39. <el-button class="loginBtn" :loading="loading" @click.prevent="handleLogin">
  40. <span v-if="!loading">登 录</span>
  41. <span v-else>登 录 中...</span>
  42. </el-button>
  43. </div>
  44. <!-- <el-drawer v-model="drawerDia" title="账号注册" class="registerdrawer" :direction="direction"
  45. :before-close="handleClose">
  46. <div class="register">
  47. <el-form :model="drawerform" label-width="80px" :rules="rules" size="default" style="max-width: 500px">
  48. <el-form-item label="用户名" prop="username">
  49. <el-input v-model="drawerform.username" placeholder="请输入用户名" />
  50. </el-form-item>
  51. <el-form-item label="密码" prop="password">
  52. <el-input v-model="drawerform.password" placeholder="请输入密码" />
  53. </el-form-item>
  54. <el-form-item label="姓名" prop="name">
  55. <el-input v-model="drawerform.name" placeholder="请输入姓名" />
  56. </el-form-item>
  57. <el-form-item label="性别">
  58. <el-radio-group v-model="drawerform.gender">
  59. <el-radio value="1">男</el-radio>
  60. <el-radio value="2">女</el-radio>
  61. </el-radio-group>
  62. </el-form-item>
  63. <el-form-item label="部门" prop="deptname">
  64. <el-select v-model="drawerform.deptname" placeholder="请选择部门">
  65. <el-option label="部门1" value="shanghai" />
  66. <el-option label="部门2" value="beijing" />
  67. </el-select>
  68. </el-form-item>
  69. <el-form-item label="职位" prop="job">
  70. <el-select v-model="drawerform.job" placeholder="请选择职位">
  71. <el-option label="主任" value="shanghai" />
  72. <el-option label="员工" value="beijing" />
  73. </el-select>
  74. </el-form-item>
  75. <el-form-item>
  76. <el-button class="registerBtn" :loading="regisloading" @click.prevent="handleLogin">
  77. <span v-if="!regisloading">注 册</span>
  78. <span v-else>注 册 中...</span>
  79. </el-button>
  80. <el-button class="ResetBtn" @click="drawerDia = false">已有账号?去登录</el-button>
  81. </el-form-item>
  82. </el-form>
  83. </div>
  84. </el-drawer> -->
  85. </div>
  86. </template>
  87. <script>
  88. import {
  89. setToken
  90. } from '@/utils/auth'
  91. import {
  92. ElMessage
  93. } from "element-plus";
  94. import {
  95. apiGetUserInfo,
  96. toLoginApi,
  97. apiGetWeather
  98. } from '@/api/api'
  99. import {
  100. apiProjectLogin
  101. } from '@/api/gengra'
  102. export default {
  103. data() {
  104. return {
  105. // administrator qweABC123
  106. inputUser: 'admin',
  107. inputMima: 'admin123',
  108. inputYanzhengma: '',
  109. codeUrl: '',
  110. ememberMe: true,
  111. loading: false,
  112. loginText: '',
  113. drawerDia: false,
  114. regisloading: false,
  115. drawerform: {
  116. username: '',
  117. password: '',
  118. name: '',
  119. gender: '1',
  120. job: '',
  121. deptname: ''
  122. },
  123. rules: {
  124. username: [{
  125. required: true,
  126. message: '请输入用户名',
  127. trigger: 'blur'
  128. },
  129. {
  130. min: 3,
  131. max: 15,
  132. message: '长度为3-15位',
  133. trigger: 'blur'
  134. },
  135. ],
  136. password: [{
  137. required: true,
  138. message: '请输入密码',
  139. trigger: 'blur'
  140. },
  141. {
  142. min: 3,
  143. max: 15,
  144. message: '长度为3-15位',
  145. trigger: 'blur'
  146. },
  147. ],
  148. name: [{
  149. required: true,
  150. message: '请输入姓名',
  151. trigger: 'blur'
  152. },
  153. {
  154. min: 2,
  155. max: 6,
  156. message: '长度为2-6位',
  157. trigger: 'blur'
  158. },
  159. ],
  160. job: [{
  161. required: true,
  162. message: '请选择职位',
  163. trigger: 'change',
  164. }, ],
  165. deptname: [{
  166. required: true,
  167. message: '请选择部门',
  168. trigger: 'change',
  169. }, ],
  170. }
  171. }
  172. },
  173. created() {
  174. // this.getCode();
  175. },
  176. methods: {
  177. getCode() {
  178. apiGetUserInfo().then((res => {
  179. if (res.msg === "操作成功") {
  180. // this.codeUrl = window.URL.createObjectURL(res) // 返回流的形式
  181. this.codeUrl = "data:image/gif;base64," + res.img; //返回base64形式
  182. this.loginText = this.$utils.strChangeCase(res.text, 5)
  183. }
  184. }))
  185. },
  186. handleLogin() {
  187. if (this.loginText === this.$utils.strChangeCase(this.inputYanzhengma, 5)) {
  188. if (this.inputUser && this.inputMima) {
  189. this.loading = true
  190. // this.toLogin(this.inputUser, this.inputMima)
  191. this.toNewLogin(this.inputUser, this.inputMima)
  192. } else {
  193. ElMessage.error('请输入账号或密码');
  194. }
  195. } else {
  196. this.inputYanzhengma = ''
  197. this.loading = false
  198. ElMessage.error('验证码验证失败,请重新输入');
  199. this.getCode()
  200. }
  201. },
  202. //原登录接口---带token
  203. toLogin(name, pass) {
  204. let params = {
  205. username: name,
  206. password: pass
  207. }
  208. toLoginApi(params).then(datas => {
  209. if (datas && datas.code === 0) {
  210. this.loading = false
  211. setToken(datas.token)
  212. let userObj = {
  213. role: '',
  214. userId: datas.id
  215. }
  216. if (datas.role === '0' || datas.role === '1') {
  217. userObj.role = 'administrators'
  218. window.sessionStorage.setItem('userMessage', JSON.stringify(userObj))
  219. } else {
  220. userObj.role = 'ordinaryUser'
  221. window.sessionStorage.setItem('userMessage', JSON.stringify(userObj))
  222. }
  223. this.$router.push({
  224. path: "/home"
  225. })
  226. } else {
  227. ElMessage.error(datas.msg);
  228. }
  229. })
  230. },
  231. //现登录接口---不带token
  232. toNewLogin(name, pass) {
  233. let that = this
  234. let params = {
  235. username: name,
  236. password: pass
  237. }
  238. apiProjectLogin(params).then(datas => {
  239. if (datas && datas.code === 0) {
  240. setToken(datas.data.accessToken)
  241. that.$router.push({
  242. path: "/home"
  243. // path: "/generatingCap/dataFilter/prepare"
  244. })
  245. } else {
  246. ElMessage.error(datas.msg);
  247. }
  248. })
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="less">
  254. @media screen and (max-width: 1200px) {
  255. .loginPic {
  256. .login_left {
  257. display: none;
  258. }
  259. }
  260. }
  261. .loginPic {
  262. // position: relative;
  263. // width: 100%;
  264. // height: 1080px;
  265. height: 100vh;
  266. background-image: url('../../assets/windFramPicture/background1.jpg');
  267. // background-position: 0 0;
  268. background-position: center;
  269. background-repeat: no-repeat;
  270. background-size: cover;
  271. display: flex;
  272. .login_left {
  273. position: fixed;
  274. left: 15%;
  275. top: 35%;
  276. p {
  277. margin-bottom: 0px;
  278. color: #fff;
  279. margin-top: 10px;
  280. }
  281. .titleW {
  282. font-size: 33px;
  283. }
  284. .title {
  285. font-size: 33px;
  286. letter-spacing: 5px;
  287. }
  288. .titleEn {
  289. font-size: 17px;
  290. letter-spacing: 1px;
  291. }
  292. }
  293. .login_right {
  294. width: 350px;
  295. height: 400px;
  296. border-radius: 20px;
  297. background: rgba(255, 255, 255, 0.2);
  298. position: fixed;
  299. right: 15%;
  300. top: 25%;
  301. .loginTit {
  302. font-size: 18px;
  303. text-align: center;
  304. color: #fff;
  305. margin: 30px 0;
  306. }
  307. .loginUser {
  308. margin: 0 30px 30px 30px;
  309. border-bottom: 1px solid #fff;
  310. display: flex;
  311. .el-icon {
  312. font-size: 26px;
  313. color: #fff;
  314. }
  315. .el-input {
  316. border: 0 solid transparent;
  317. .el-input__wrapper {
  318. background: transparent;
  319. box-shadow: none;
  320. .el-input__inner,
  321. .el-input__inner:focus {
  322. background: none;
  323. border: none !important;
  324. color: #fff;
  325. height: 30px;
  326. width: 100%;
  327. font-size: 14px;
  328. }
  329. }
  330. }
  331. }
  332. .loginMima {
  333. margin: 0 30px 30px 30px;
  334. border-bottom: 1px solid #fff;
  335. .el-input {
  336. .el-input__wrapper {
  337. background: transparent;
  338. box-shadow: none;
  339. }
  340. .el-input__inner {
  341. background: none;
  342. border: none;
  343. color: #fff;
  344. height: 30px;
  345. width: 100%;
  346. }
  347. .el-input-group__prepend {
  348. background: transparent;
  349. box-shadow: none;
  350. width: 28px;
  351. padding: 0;
  352. .icon-mima {
  353. width: 28px;
  354. height: 28px;
  355. display: inline-block;
  356. background-image: url(../../assets/iconNeed/iconFont.png);
  357. background-position: -44px -70px;
  358. position: absolute;
  359. left: -10px;
  360. }
  361. }
  362. }
  363. }
  364. .loginYanzhengma {
  365. display: flex;
  366. margin: 0 30px 0 30px;
  367. border-bottom: 1px solid #fff;
  368. .login-code {
  369. width: 100px;
  370. height: 40px;
  371. .login-code-img {
  372. width: 100px;
  373. }
  374. }
  375. .el-input {
  376. .el-input__wrapper {
  377. background: transparent;
  378. box-shadow: none;
  379. }
  380. .el-input__inner {
  381. background: none;
  382. border: none;
  383. color: #fff;
  384. height: 30px;
  385. width: 100%;
  386. }
  387. .el-input-group__prepend {
  388. background: transparent;
  389. box-shadow: none;
  390. width: 28px;
  391. padding: 0;
  392. .icon-yanzhengma {
  393. width: 27px;
  394. height: 24px;
  395. display: inline-block;
  396. background-image: url(../../assets/iconNeed/iconFont.png);
  397. background-position: -74px -70px;
  398. position: absolute;
  399. left: -10px;
  400. }
  401. }
  402. }
  403. }
  404. .remeber {
  405. margin: 0 30px;
  406. display: flex;
  407. justify-content: space-between;
  408. .el-checkbox {
  409. .el-checkbox__label {
  410. color: #fff;
  411. font-size: 12px;
  412. padding-left: 6px;
  413. }
  414. }
  415. p {
  416. cursor: pointer;
  417. color: #fff;
  418. padding-right: 6px;
  419. font-size: 12px;
  420. position: relative;
  421. top: 3px;
  422. font-weight: 600;
  423. }
  424. }
  425. .loginBtn {
  426. position: absolute;
  427. left: 30px;
  428. bottom: 35px;
  429. width: 294px;
  430. height: 34px;
  431. background-image: linear-gradient(to right, #5a91f6, #6656ff);
  432. border: none;
  433. color: #fff;
  434. }
  435. input::-webkit-input-placeholder {
  436. /*WebKit browsers*/
  437. color: #fff;
  438. }
  439. input::-moz-input-placeholder {
  440. /*Mozilla Firefox*/
  441. color: #fff;
  442. }
  443. input::-ms-input-placeholder {
  444. /*Internet Explorer*/
  445. color: #fff;
  446. }
  447. }
  448. .loginFooter {
  449. height: 40px;
  450. line-height: 40px;
  451. position: fixed;
  452. bottom: 0;
  453. width: 100%;
  454. text-align: center;
  455. color: #fff;
  456. font-family: Arial;
  457. font-size: 12px;
  458. letter-spacing: 1px;
  459. }
  460. .el-overlay {
  461. .registerdrawer {
  462. .register {
  463. margin-top: 20px;
  464. .el-form {
  465. .el-form-item--default {
  466. margin-bottom: 25px;
  467. }
  468. .el-input__wrapper {
  469. background: transparent !important;
  470. }
  471. .el-input .el-input__wrapper .el-input__inner {
  472. color: #5c5c5c !important;
  473. }
  474. .el-radio-group .el-radio .el-radio__label {
  475. color: #000;
  476. }
  477. .el-select .el-select__wrapper {
  478. background: transparent !important;
  479. }
  480. .el-select .el-select__wrapper .el-select__placeholder {
  481. color: #ababab !important;
  482. }
  483. .registerBtn {
  484. width: 500px;
  485. height: 34px;
  486. background-image: linear-gradient(to right, #5a91f6, #6656ff);
  487. border: none;
  488. color: #fff;
  489. margin-top: 10px;
  490. }
  491. .ResetBtn {
  492. width: 500px;
  493. height: 34px;
  494. margin: 15px 0 0 0;
  495. }
  496. }
  497. }
  498. }
  499. }
  500. }
  501. </style>
  502. <style lang="less" scoped>
  503. // .el-overlay {
  504. // .registerdrawer {
  505. // .register {
  506. // margin-top: 20px;
  507. // .el-form {
  508. // .el-form-item--default {
  509. // margin-bottom: 25px;
  510. // }
  511. // .el-input__wrapper {
  512. // background: transparent !important;
  513. // }
  514. // .el-input .el-input__wrapper .el-input__inner {
  515. // color: #5c5c5c !important;
  516. // }
  517. // .el-radio-group .el-radio .el-radio__label {
  518. // color: #000;
  519. // }
  520. // .el-select .el-select__wrapper {
  521. // background: transparent !important;
  522. // }
  523. // .el-select .el-select__wrapper .el-select__placeholder {
  524. // color: #ababab !important;
  525. // }
  526. // .registerBtn {
  527. // width: 500px;
  528. // height: 34px;
  529. // background-image: linear-gradient(to right, #5a91f6, #6656ff);
  530. // border: none;
  531. // color: #fff;
  532. // margin-top: 10px;
  533. // }
  534. // .ResetBtn {
  535. // width: 500px;
  536. // height: 34px;
  537. // margin: 15px 0 0 0;
  538. // }
  539. // }
  540. // }
  541. // }
  542. // }
  543. // .el-popper .el-select-dropdown__wrap {
  544. // background-color: #fff !important;
  545. // border: 1px solid #fff !important;
  546. // }
  547. // .el-popper .el-select-dropdown__wrap .el-select-dropdown__item {
  548. // color: #5c5c5c;
  549. // }
  550. </style>