login.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="normal-login-container">
  3. <view class="logo-content align-center justify-center flex">
  4. <image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix">
  5. </image>
  6. <text class="title">芋道移动端登录</text>
  7. </view>
  8. <view class="login-form-content">
  9. <view class="input-item flex align-center">
  10. <view class="iconfont icon-user icon"></view>
  11. <input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
  12. </view>
  13. <view class="input-item flex align-center">
  14. <view class="iconfont icon-password icon"></view>
  15. <input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
  16. </view>
  17. <Verify @success="pwdLogin" :mode="'pop'" :captchaType="'blockPuzzle'"
  18. :imgSize="{ width: '330px', height: '155px' }" ref="verify"></Verify>
  19. <view class="action-btn">
  20. <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
  21. </view>
  22. </view>
  23. <view class="xieyi text-center">
  24. <text class="text-grey1">登录即代表同意</text>
  25. <text @click="handleUserAgrement" class="text-blue">《用户协议》</text>
  26. <text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import Verify from "@/components/verifition/Verify"
  32. export default {
  33. name: 'Login',
  34. components: {
  35. Verify
  36. },
  37. data() {
  38. return {
  39. captchaEnabled: true,
  40. globalConfig: getApp().globalData.config,
  41. loginForm: {
  42. username: "admin",
  43. password: "admin123",
  44. captchaVerification: ""
  45. }
  46. }
  47. },
  48. methods: {
  49. // 隐私协议
  50. handlePrivacy() {
  51. let site = this.globalConfig.appInfo.agreements[0]
  52. this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  53. },
  54. // 用户协议
  55. handleUserAgrement() {
  56. let site = this.globalConfig.appInfo.agreements[1]
  57. this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  58. },
  59. // 登录方法
  60. async handleLogin(params) {
  61. if (this.loginForm.username === "") {
  62. this.$modal.msgError("请输入您的账号")
  63. } else if (this.loginForm.password === "") {
  64. this.$modal.msgError("请输入您的密码")
  65. } else {
  66. this.$modal.loading("登录中,请耐心等待...")
  67. // 显示验证码
  68. this.$refs.verify.show()
  69. }
  70. },
  71. // 密码登录
  72. async pwdLogin(params) {
  73. this.loginForm.captchaVerification = params.captchaVerification
  74. this.$store.dispatch('Login', this.loginForm).then(() => {
  75. this.$modal.closeLoading()
  76. this.loginSuccess()
  77. })
  78. },
  79. // 登录成功后,处理函数
  80. loginSuccess(result) {
  81. // 设置用户信息
  82. this.$store.dispatch('GetInfo').then(res => {
  83. this.$tab.reLaunch('/pages/index')
  84. })
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss">
  90. page {
  91. background-color: #ffffff;
  92. }
  93. .normal-login-container {
  94. width: 100%;
  95. .logo-content {
  96. width: 100%;
  97. font-size: 21px;
  98. text-align: center;
  99. padding-top: 15%;
  100. image {
  101. border-radius: 4px;
  102. }
  103. .title {
  104. margin-left: 10px;
  105. }
  106. }
  107. .login-form-content {
  108. text-align: center;
  109. margin: 20px auto;
  110. margin-top: 15%;
  111. width: 80%;
  112. .input-item {
  113. margin: 20px auto;
  114. background-color: #f5f6f7;
  115. height: 45px;
  116. border-radius: 20px;
  117. .icon {
  118. font-size: 38rpx;
  119. margin-left: 10px;
  120. color: #999;
  121. }
  122. .input {
  123. width: 100%;
  124. font-size: 14px;
  125. line-height: 20px;
  126. text-align: left;
  127. padding-left: 15px;
  128. }
  129. }
  130. .login-btn {
  131. margin-top: 40px;
  132. height: 45px;
  133. }
  134. .xieyi {
  135. color: #333;
  136. margin-top: 20px;
  137. }
  138. }
  139. .easyinput {
  140. width: 100%;
  141. }
  142. }
  143. .login-code-img {
  144. height: 45px;
  145. }
  146. </style>