login.vue 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. <view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
  18. <view class="iconfont icon-code icon"></view>
  19. <input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
  20. <view class="login-code">
  21. <image :src="codeUrl" @click="getCode" class="login-code-img"></image>
  22. </view>
  23. </view>
  24. <view class="ageen-read">
  25. <checkbox-group @change="handleAgreeChange">
  26. <checkbox value="agree"/>
  27. <text class="agreen-text">阅读并同意</text>
  28. <text @click="equityNotice" class="text-blue">《权益告知书》</text>
  29. </checkbox-group>
  30. </view>
  31. <view class="action-btn">
  32. <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
  33. </view>
  34. <view class="reg text-center" v-if="register">
  35. <text class="text-grey1">没有账号?</text>
  36. <text @click="handleUserRegister" class="text-blue">立即注册</text>
  37. </view>
  38. <!-- <view class="reg text-center" v-if="register">
  39. <text class="text-grey1">使用其他方式登录:</text>
  40. <text @click="handleUserRegister" class="text-blue"></text>
  41. </view> -->
  42. <!-- <view class="xieyi text-center">
  43. <text class="text-grey1">登录即代表同意</text>
  44. <text @click="handleUserAgrement" class="text-blue">《用户协议》</text>
  45. <text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
  46. </view> -->
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. getCodeImg
  53. } from '@/api/login'
  54. export default {
  55. data() {
  56. return {
  57. codeUrl: "",
  58. captchaEnabled: true,
  59. // 用户注册开关
  60. register: true,
  61. globalConfig: getApp().globalData.config,
  62. loginForm: {
  63. username: "",
  64. password: "",
  65. code: "",
  66. uuid: '',
  67. },
  68. isSelectAgree:[]
  69. }
  70. },
  71. created() {
  72. this.getCode()
  73. },
  74. methods: {
  75. handleAgreeChange(e){
  76. this.isSelectAgree = e.detail.value
  77. },
  78. // 用户注册
  79. handleUserRegister() {
  80. this.$tab.redirectTo(`/pages/realName`)
  81. },
  82. // 权益告知书
  83. equityNotice(){
  84. //this.$tab.redirectTo(`/pages/personalInfoCollection`)
  85. this.$tab.navigateTo(`/pages/personalInfoCollection?title=权益告知书`)
  86. },
  87. // 隐私协议
  88. handlePrivacy() {
  89. let site = this.globalConfig.appInfo.agreements[0]
  90. this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  91. },
  92. // 用户协议
  93. handleUserAgrement() {
  94. let site = this.globalConfig.appInfo.agreements[1]
  95. this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  96. },
  97. // 获取图形验证码
  98. getCode() {
  99. getCodeImg().then(res => {
  100. this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
  101. if (this.captchaEnabled) {
  102. this.codeUrl = 'data:image/gif;base64,' + res.img
  103. this.loginForm.uuid = res.uuid
  104. }
  105. })
  106. },
  107. // 登录方法
  108. async handleLogin() {
  109. console.log(this.isSelectAgree,'xxxx')
  110. if (this.loginForm.username === "") {
  111. this.$modal.msgError("请输入您的账号")
  112. }else if(this.isSelectAgree.length < 1){
  113. this.$modal.msgError("请先阅读个人信息收集条款并同意")
  114. } else if (this.loginForm.password === "") {
  115. this.$modal.msgError("请输入您的密码")
  116. } else if (this.loginForm.code === "" && this.captchaEnabled) {
  117. this.$modal.msgError("请输入验证码")
  118. } else {
  119. this.$modal.loading("登录中,请耐心等待...")
  120. this.pwdLogin()
  121. }
  122. },
  123. // 密码登录
  124. async pwdLogin() {
  125. this.$store.dispatch('Login', this.loginForm).then(() => {
  126. this.$modal.closeLoading()
  127. this.loginSuccess()
  128. }).catch(() => {
  129. if (this.captchaEnabled) {
  130. this.getCode()
  131. }
  132. })
  133. },
  134. // 登录成功后,处理函数
  135. loginSuccess(result) {
  136. // 设置用户信息
  137. this.$store.dispatch('GetInfo').then(res => {
  138. this.$tab.reLaunch('/pages/work/index')
  139. })
  140. },
  141. }
  142. }
  143. </script>
  144. <style lang="scss">
  145. page {
  146. background-color: #ffffff;
  147. }
  148. .normal-login-container {
  149. width: 100%;
  150. .logo-content {
  151. width: 100%;
  152. font-size: 21px;
  153. text-align: center;
  154. padding-top: 15%;
  155. image {
  156. border-radius: 4px;
  157. }
  158. .title {
  159. margin-left: 10px;
  160. }
  161. }
  162. .login-form-content {
  163. // text-align: center;
  164. margin: 20px auto;
  165. margin-top: 15%;
  166. width: 80%;
  167. .input-item {
  168. margin: 20px auto;
  169. background-color: #f5f6f7;
  170. height: 45px;
  171. border-radius: 20px;
  172. .icon {
  173. font-size: 38rpx;
  174. margin-left: 10px;
  175. color: #999;
  176. }
  177. .input {
  178. width: 100%;
  179. font-size: 14px;
  180. line-height: 20px;
  181. text-align: left;
  182. padding-left: 15px;
  183. }
  184. }
  185. .login-btn {
  186. margin-top: 40px;
  187. height: 45px;
  188. }
  189. .reg {
  190. margin-top: 15px;
  191. }
  192. .xieyi {
  193. color: #333;
  194. margin-top: 20px;
  195. }
  196. .login-code {
  197. height: 38px;
  198. float: right;
  199. .login-code-img {
  200. height: 38px;
  201. position: absolute;
  202. margin-left: 10px;
  203. width: 200rpx;
  204. }
  205. }
  206. .ageen-read{
  207. margin-top:65rpx;
  208. .agreen-text{
  209. padding-left:20rpx;
  210. color: #999;
  211. }
  212. }
  213. }
  214. }
  215. </style>