login.vue 6.3KB

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