login.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="normal-login-container">
  3. <image :src="loadImgSrc('login-bg.png')" class="login-bg-img"></image>
  4. <view class="login-form-content">
  5. <view class="flex">
  6. <view class="login-title flex">
  7. <image :src="loadImgSrc('login-logo.png')"></image>长春贞达市政施工管理平台
  8. </view>
  9. </view>
  10. <view class="input-item flex align-center" style="margin-top: 80rpx;justify-content: center;">
  11. <!-- <view class="iconfont icon-user icon"></view> -->
  12. <view class="">
  13. <image :src="loadImgSrc('username.png')" style="width: 20px;height: 20px;margin-left:20px;">
  14. </image>
  15. </view>
  16. <input v-model="loginForm.username" class="input" type="text" placeholder="账号" maxlength="30" />
  17. </view>
  18. <view class="input-item flex align-center">
  19. <!-- <view class="iconfont icon-password icon"></view> -->
  20. <view class="">
  21. <image :src="loadImgSrc('password.png')" style="width: 20px;height: 20px;margin-left:20px;">
  22. </image>
  23. </view>
  24. <input v-model="loginForm.password" type="password" class="input" placeholder="密码" maxlength="20" />
  25. </view>
  26. <!-- <view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
  27. <view class="iconfont icon-code icon"></view>
  28. <input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
  29. <view class="login-code">
  30. <image :src="codeUrl" @click="getCode" class="login-code-img"></image>
  31. </view>
  32. </view> -->
  33. <view class="action-btn">
  34. <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. getCodeImg
  42. } from '@/api/login'
  43. export default {
  44. data() {
  45. return {
  46. codeUrl: "",
  47. captchaEnabled: true,
  48. // 用户注册开关
  49. register: false,
  50. globalConfig: getApp().globalData.config,
  51. loginForm: {
  52. username: "010401001",
  53. password: "123456",
  54. code: "",
  55. uuid: '',
  56. type: 'app'
  57. }
  58. }
  59. },
  60. created() {
  61. //this.getCode()
  62. },
  63. methods: {
  64. // 获取图形验证码
  65. // getCode() {
  66. // getCodeImg().then(res => {
  67. // this.captchaEnabled = res.data.captchaEnabled === undefined ? true : res.data.captchaEnabled
  68. // if (this.captchaEnabled) {
  69. // this.codeUrl = 'data:image/gif;base64,' + res.data.img
  70. // this.loginForm.uuid = res.data.uuid
  71. // }
  72. // })
  73. // },
  74. // 登录方法
  75. async handleLogin() {
  76. if (this.loginForm.username === "") {
  77. this.$modal.msgError("请输入您的账号")
  78. } else if (this.loginForm.password === "") {
  79. this.$modal.msgError("请输入您的密码")
  80. }
  81. // else if (this.loginForm.code === "" && this.captchaEnabled) {
  82. // this.$modal.msgError("请输入验证码")
  83. // }
  84. else {
  85. this.$modal.loading("登录中,请耐心等待...")
  86. this.pwdLogin()
  87. }
  88. },
  89. // 密码登录
  90. async pwdLogin() {
  91. this.loginForm.type = 'app'
  92. this.$store.dispatch('Login', this.loginForm).then(() => {
  93. this.$modal.closeLoading()
  94. this.loginSuccess()
  95. }).catch(() => {
  96. if (this.captchaEnabled) {
  97. this.getCode()
  98. }
  99. })
  100. },
  101. // 登录成功后,处理函数
  102. loginSuccess(result) {
  103. // 设置用户信息
  104. this.$store.dispatch('GetInfo').then(res => {
  105. this.$tab.reLaunch('/pages/work/index')
  106. })
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss">
  112. page {
  113. background-color: #ffffff;
  114. }
  115. .normal-login-container {
  116. width: 100%;
  117. .login-bg-img {
  118. width: 100%;
  119. height: 100vh;
  120. position: absolute;
  121. top: 0;
  122. left: 0;
  123. z-index: -1;
  124. }
  125. .logo-content {
  126. width: 100%;
  127. font-size: 21px;
  128. text-align: center;
  129. padding-top: 15%;
  130. image {
  131. border-radius: 4px;
  132. }
  133. .title {
  134. margin-left: 10px;
  135. }
  136. }
  137. .login-form-content {
  138. text-align: center;
  139. width: 90%;
  140. min-height: 45vh;
  141. background-color: #ffffff;
  142. border-radius: 40rpx;
  143. padding: 5%;
  144. box-shadow: 0 0 10px #a7a7a7;
  145. position: absolute;
  146. bottom: 10vh;
  147. left: 50%;
  148. transform: translateX(-50%);
  149. .login-title {
  150. margin-top: 20px;
  151. font-size: 40rpx;
  152. color: #898989;
  153. image {
  154. width: 70rpx;
  155. height: 53rpx;
  156. margin-right: 20rpx;
  157. }
  158. }
  159. .input-item {
  160. margin: 20px auto;
  161. background-color: #f5f6f7;
  162. height: 96rpx;
  163. border-radius: 50px;
  164. .icon {
  165. font-size: 38rpx;
  166. margin-left: 10px;
  167. color: #999;
  168. }
  169. .input {
  170. width: 100%;
  171. font-size: 14px;
  172. line-height: 20px;
  173. text-align: left;
  174. padding-left: 15px;
  175. }
  176. }
  177. .login-btn {
  178. margin-top: 40px;
  179. height: 96rpx;
  180. background: linear-gradient(105deg, #72C6FF, #79A4F0);
  181. box-shadow: 0rpx 18rpx 24rpx 0rpx rgba(63, 143, 255, 0.23);
  182. border-radius: 48rpx;
  183. color: #f5f6f7;
  184. }
  185. .reg {
  186. margin-top: 15px;
  187. }
  188. .xieyi {
  189. color: #333;
  190. margin-top: 20px;
  191. }
  192. .login-code {
  193. height: 38px;
  194. float: right;
  195. .login-code-img {
  196. height: 38px;
  197. position: absolute;
  198. margin-left: 10px;
  199. width: 200rpx;
  200. }
  201. }
  202. }
  203. }
  204. </style>