clientloginBox.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="phone-login-page">
  3. <view class="login-wrap-box">
  4. <view class="bjcx-head-box">
  5. <icon class="bjcx-logo-box"></icon>
  6. <view class="bjcx-logo-title">家政学</view>
  7. </view>
  8. <view class="login-input-box">
  9. <icon class="user-icon"></icon>
  10. <input class="login-input" type="text" v-model="userName" placeholder="请输入手机号" @input="userInputChange">
  11. <view class="close-btn" v-if="clearTelIcon" @click="clearTel"></view>
  12. </view>
  13. <view class="login-input-box">
  14. <icon class="tel-icon"></icon>
  15. <input class="login-input" placeholder="请输入证件号后六位" v-model="password" :password="showPassword"
  16. @input="passwordInputChange"/>
  17. <text class="login-eye" :class="[!showPassword ? 'uni-eye-active' : '']"
  18. @click="changePassword"></text>
  19. <view class="close-btn" v-if="clearPwIcon" @click="clearPw"></view>
  20. </view>
  21. <button type="default" @click="handleLogin" class="phone-green-btn login-btn">登录</button>
  22. <!-- 已加密的:{{lliPassword}} -->
  23. </view>
  24. <passwordLli ref="passLLiRef" :password="password" @lli-password="onLliPassword" />
  25. </view>
  26. </template>
  27. <script setup>
  28. import cacheManager from '@/utils/cacheManager.js'
  29. import * as httpApi from "@/api/login.js"
  30. import passwordLli from "@/components/password-lli/password-lli.vue";
  31. import {ref} from "vue"
  32. import {toast} from "@/utils/common";
  33. import {useIsCanBack} from "@/store/isCanBack.js"
  34. import {
  35. onLoad
  36. } from "@dcloudio/uni-app";
  37. const userName = ref('') // 用户名
  38. const password = ref('') // 密码
  39. const lliPassword = ref('') // 加密后的密码
  40. const passLLiRef = ref(null)
  41. const showPassword= ref(true)
  42. const clearTelIcon= ref(false)
  43. const clearPwIcon= ref(false)
  44. const store = useIsCanBack();
  45. onLoad(() => {
  46. getAllImg();
  47. })
  48. // 加密
  49. function handleUpdateLLiPassword() {
  50. console.log('handleUpdateLLiPassword')
  51. passLLiRef.value.lliPassword();
  52. }
  53. function onLliPassword(password) {
  54. console.log('onLliPassword',password)
  55. lliPassword.value = password;
  56. }
  57. // 手机号校验
  58. function userInputChange(event){
  59. if (event.detail.value.length > 0) {
  60. clearTelIcon.value = true;
  61. } else {
  62. clearTelIcon.value = false;
  63. }
  64. }
  65. // 密码校验
  66. function passwordInputChange(event){
  67. if (event.detail.value.length > 0) {
  68. clearPwIcon.value = true;
  69. } else {
  70. clearPwIcon.value = false;
  71. }
  72. }
  73. // 清除手机号
  74. function clearTel(){
  75. userName.value = '';
  76. clearTelIcon.value = false;
  77. }
  78. // 清除密码
  79. function clearPw(){
  80. password.value = '';
  81. clearPwIcon.value = false;
  82. }
  83. // 密码显隐
  84. function changePassword() {
  85. showPassword.value = !showPassword.value;
  86. }
  87. // 登录
  88. function handleLogin() {
  89. if(userName.value.length ===0){
  90. toast('请输入手机号!')
  91. return
  92. }
  93. if(password.value.length ===0){
  94. toast('请输入密码!')
  95. return
  96. }
  97. // 去除 userName 两端的空格
  98. const trimmedUserName = userName.value;
  99. const trimmedPassword = lliPassword.value;
  100. uni.showLoading({
  101. title: '登录中'
  102. })
  103. httpApi.login({
  104. // type 1app 2为H5
  105. type:2,
  106. userName: trimmedUserName,
  107. // password: lliPassword.value,
  108. password: 'XXJytwnw7lpzdDuUFqVl59Hzir+IQ9j0If7ytUcwA2jcB5tBLvRqY8dfDZYnbXzQy28MeQ3nKbTw/+AxFoUE4+o6jyrIV9Z4bllrTvHEliUb78zCOStgMw55doAMvobokXbakT6joafw8ymc6A5D6jHL0UaDz2UGgMXzdD0S1W8='
  109. }).then(res => {
  110. // 4为家政人员
  111. if(res.data.type ===4){
  112. cacheManager.set('auth', res.data)
  113. store.setIsCanBack(false)
  114. // 页面跳转
  115. gotoPage();
  116. }else{
  117. toast('登录失败,您的身份有误,请联系管理员。')
  118. }
  119. }).catch(err => {
  120. store.setIsCanBack(true)
  121. }).finally(err => {
  122. uni.hideLoading()
  123. })
  124. }
  125. // 跳转
  126. function gotoPage(){
  127. uni.navigateTo({
  128. url: `/pages/client/ShouYe/shouye`
  129. })
  130. }
  131. function getAllImg() {
  132. httpApi.getAllImgList({}).then(res => {
  133. cacheManager.set('projectImg', res.data)
  134. // defultKsImg.value = cacheManager.get('projectImg').index_ks_default
  135. });
  136. }
  137. </script>
  138. <style>
  139. </style>