login.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view class="normal-login-container">
  3. <view class="logo-content">
  4. <!-- <image src="../../static/jnImage/loginPage/logo.png">
  5. </image> -->
  6. <view class="logoTit">
  7. <view class="titleZN">晋能控股电力集团</view>
  8. <view class="titleZN">清洁能源有限公司</view>
  9. <view class="titleEN">发电场站生产实时运营管理平台</view>
  10. </view>
  11. </view>
  12. <view class="login-form-content">
  13. <view class="input-item flex align-center">
  14. <image src="../../static/jnImage/loginPage/userName.png">
  15. <input v-model="loginForm.username" class="input" type="text" placeholder="用户名" maxlength="30" />
  16. </view>
  17. <view class="input-item flex align-center">
  18. <image src="../../static/jnImage/loginPage/locked.png">
  19. <input v-model="loginForm.password" type="password" class="input" placeholder="密码" maxlength="20" />
  20. </view>
  21. <view class="action-btn">
  22. <button @click="handleLogin" class="login-btn">登录</button>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import {
  29. setToken
  30. } from '@/utils/auth'
  31. import {
  32. login
  33. } from '../../api/login.js'
  34. export default {
  35. name: 'Login',
  36. data() {
  37. return {
  38. captchaEnabled: false, // 验证码开关 TODO 芋艿:需要抽到配置里
  39. globalConfig: getApp().globalData.config,
  40. loginForm: {
  41. username: "admin",
  42. password: "123456"
  43. }
  44. }
  45. },
  46. methods: {
  47. // 登录方法
  48. handleLogin(params) {
  49. let that = this
  50. // if (this.loginForm.username === "") {
  51. // this.$modal.msgError("请输入您的账号")
  52. // } else if (this.loginForm.password === "") {
  53. // this.$modal.msgError("请输入您的密码")
  54. // } else {
  55. // this.pwdLogin({})
  56. // }
  57. that.$tab.switchTab('/pages/home/index')
  58. },
  59. // 密码登录
  60. pwdLogin() {
  61. this.$modal.loading("登录中,请耐心等待...")
  62. let params = {
  63. username: this.loginForm.username,
  64. password: this.loginForm.password
  65. }
  66. login(params).then(res => {
  67. if (res && res.data) {
  68. this.$modal.closeLoading()
  69. setToken(res.data)
  70. this.$tab.switchTab('/pages/home/index')
  71. }
  72. })
  73. },
  74. // 登录成功后,处理函数
  75. loginSuccess(result) {
  76. // 设置用户信息
  77. // this.$store.dispatch('GetInfo').then(res => {
  78. // this.$tab.reLaunch('/pages/index')
  79. // })
  80. // this.$tab.reLaunch('/pages/index')
  81. uni.navigateTo({
  82. url: '/pages/index',
  83. success: res => {},
  84. fail: () => {},
  85. complete: () => {}
  86. });
  87. // this.$tab.navigateTo('/pages/index')
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. page {
  94. background-color: #202246;
  95. }
  96. .normal-login-container {
  97. background: url('../../static/jnImage/loginPage/loginBac.png');
  98. background-size: cover;
  99. width: 100%;
  100. hieght: 100vh;
  101. .logo-content {
  102. width: 100%;
  103. font-size: 21px;
  104. text-align: center;
  105. padding-top: 45%;
  106. // image {
  107. // border-radius: 4px;
  108. // margin-top: 40px;
  109. // width: 80px;
  110. // height: 60px;
  111. // }
  112. .logoTit {
  113. color: #fff;
  114. .titleZN {
  115. font-size: 60upx;
  116. font-family: FZZhengHeiS-M-GB;
  117. font-weight: 500;
  118. color: #FFFFFF;
  119. letter-spacing: 3px;
  120. }
  121. .titleEN {
  122. margin-top: 5px;
  123. font-size: 26upx;
  124. color: #E5E9F2;
  125. letter-spacing: 5px;
  126. }
  127. }
  128. }
  129. .login-form-content {
  130. text-align: center;
  131. margin: 20px auto;
  132. margin-top: 50%;
  133. width: 80%;
  134. .input-item {
  135. margin: 20px auto;
  136. // background-color: #f5f6f7;
  137. height: 45px;
  138. border-bottom: 1px solid #f5f6f7;
  139. image {
  140. width: 20px;
  141. height: 23px;
  142. }
  143. .input {
  144. color: #fff;
  145. width: 100%;
  146. font-size: 14px;
  147. line-height: 20px;
  148. text-align: left;
  149. padding-left: 15px;
  150. .uni-input-wrapper {
  151. .input-placeholder {
  152. color: #fff;
  153. font-size: 16px;
  154. }
  155. }
  156. }
  157. }
  158. .login-btn {
  159. margin-top: 30px;
  160. height: 40px;
  161. color: #fff;
  162. background: #4287FF;
  163. border-radius: 10px;
  164. letter-spacing: 10px;
  165. line-height: 40px;
  166. }
  167. }
  168. .easyinput {
  169. width: 100%;
  170. }
  171. }
  172. .login-code-img {
  173. height: 45px;
  174. }
  175. </style>