login.vue 5.3 KB

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