Login.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <div class="loginPic">
  3. <!-- <div class="login_left">
  4. <p>Welcome!</p>
  5. <p class="title">光耀集中式风电功率预测系统</p>
  6. </div> -->
  7. <div class="login_right">
  8. <img class="titleIcon" src="../assets/loginImage/logo.png" alt="">
  9. <div class="loginCom" style="margin-bottom: 30px">
  10. <img class="userIcon" src="../assets/loginImage/userIcon.png" alt="">
  11. <el-input v-model="inputUser" placeholder="请输入用户名" />
  12. </div>
  13. <div class="loginCom" style="margin-bottom: 16px">
  14. <img class="passwordIcon" src="../assets/loginImage/passwordIcon.png" alt="">
  15. <el-input type="password" v-model="inputMima" placeholder="请输入密码" />
  16. </div>
  17. <div class="remeber">
  18. <el-checkbox v-model="ememberMe" disabled>记住密码</el-checkbox>
  19. </div>
  20. <div class="loginBtn" @click="handleLogin">
  21. <span class="loginSpan">登录</span>
  22. </div>
  23. </div>
  24. <!-- 底部 -->
  25. <!-- <div class="loginFooter">
  26. <span>Copyright © 2021-2022 GuangYaoDianLi All Rights Reserved.</span>
  27. </div> -->
  28. </div>
  29. </template>
  30. <script>
  31. import { setToken } from '@/api/auth'
  32. import { ElMessage } from "element-plus";
  33. import { loginApi, apiGetCodeByToken } from '../api/api'
  34. export default {
  35. data() {
  36. return {
  37. inputUser:'testdbkp',
  38. inputMima:'Gddl!#%135',
  39. codeUrl:'',
  40. ememberMe:false,
  41. loading:false,
  42. loginText: ''
  43. }
  44. },
  45. created() {
  46. },
  47. methods:{
  48. handleLogin() {
  49. if (this.inputUser !== '' && this.inputMima !== '') {
  50. this.getLogin(this.inputUser, this.inputMima)
  51. } else {
  52. ElMessage.error('请输入账号或密码');
  53. }
  54. },
  55. //登录接口
  56. getLogin(userName, password) {
  57. // setToken('userMsg', params)
  58. let that = this
  59. loginApi(userName, password).then(datas=>{
  60. if (datas) {
  61. setToken('token', datas.data.access_token)
  62. that.getTokenCode(datas.data.access_token)
  63. } else {
  64. ElMessage.error(datas.data.msg);
  65. }
  66. }).catch(e =>{
  67. that.loading = false
  68. })
  69. // this.$router.push({ path: "/home"})
  70. },
  71. // 根据token获取code
  72. getTokenCode(val) {
  73. let that = this
  74. apiGetCodeByToken(val).then(datas =>{
  75. if (datas && datas.data) {
  76. setToken('code', datas.data)
  77. that.$router.push({ path: "/home"})
  78. }
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss">
  85. @media screen and (max-width: 1200px) {
  86. .loginPic{
  87. .login_left {
  88. display: none;
  89. }
  90. }
  91. }
  92. .loginPic{
  93. position: relative;
  94. width: 100%;
  95. height:1080px;
  96. background-image: url('../assets/loginImage/loginBak.png');
  97. background-position: 0 0;
  98. background-repeat: no-repeat;
  99. display: flex;
  100. .login_left{
  101. position: fixed;
  102. left: 15%;
  103. top: 35%;
  104. p{
  105. margin-bottom: 0px;
  106. font-size: 32px;
  107. color: #fff;
  108. margin-top: 10px;
  109. }
  110. .title{
  111. letter-spacing: 5px;
  112. }
  113. }
  114. .login_right{
  115. width: 470px;
  116. height:680px;
  117. background: rgba(0,0,0,0.4);
  118. position: fixed;
  119. right: 15%;
  120. top: 15%;
  121. .titleIcon{
  122. margin: 100px 0px 43px 95px;
  123. }
  124. .loginCom{
  125. margin: 0 30px 0px 43px;
  126. width: 384px;
  127. height: 56px;
  128. background: #1B1A1F;
  129. border-radius: 5px;
  130. display: flex;
  131. .userIcon {
  132. width: 24px;
  133. height: 24px;
  134. margin: 16px;
  135. }
  136. .passwordIcon {
  137. width: 24px;
  138. height: 24px;
  139. margin: 16px;
  140. }
  141. .el-input{
  142. border: 0 solid transparent;
  143. .el-input__wrapper{
  144. background: transparent;
  145. box-shadow: none;
  146. .el-input__inner, .el-input__inner:focus{
  147. background: none;
  148. border: none !important;
  149. color: #fff;
  150. height: 30px;
  151. width: 100%;
  152. font-size: 14px;
  153. }
  154. }
  155. }
  156. }
  157. .remeber{
  158. margin: 0 0 0 50px;
  159. .el-checkbox{
  160. .el-checkbox__label{
  161. color: #fff;
  162. font-size: 12px;
  163. padding-left:6px;
  164. }
  165. }
  166. }
  167. .loginBtn{
  168. margin: 48px 0 0 43px;
  169. width: 384px;
  170. height: 56px;
  171. background-image: url('../assets/loginImage/loginBtn.png');
  172. cursor: pointer;
  173. .loginSpan{
  174. position: relative;
  175. top: 27%;
  176. left: 45%;
  177. font-size: 18px;
  178. font-family: Microsoft YaHei;
  179. font-weight: 400;
  180. color: #FFFFFF;
  181. }
  182. }
  183. input::-webkit-input-placeholder{ /*WebKit browsers*/
  184. color: #fff;
  185. }
  186. input::-moz-input-placeholder{ /*Mozilla Firefox*/
  187. color: #fff;
  188. }
  189. input::-ms-input-placeholder{ /*Internet Explorer*/
  190. color: #fff;
  191. }
  192. }
  193. .loginFooter{
  194. height: 40px;
  195. line-height: 40px;
  196. position: fixed;
  197. bottom: 0;
  198. width: 100%;
  199. text-align: center;
  200. color: #fff;
  201. font-family: Arial;
  202. font-size: 12px;
  203. letter-spacing: 1px;
  204. }
  205. }
  206. </style>