clientloginBox.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. <!-- 协议勾选框和按钮 -->
  22. <view class="agreement-checkbox-box">
  23. <checkbox-group @change="handleChange">
  24. <checkbox class="agreement-checkbox-input" color="#3fd2a1" value="agree"
  25. :checked="isAgreed" style="transform:scale(0.7)" />
  26. </checkbox-group>
  27. <view class="agreement-text-box">
  28. 在使用当前小程序服务之前,请仔细阅读<view class="agreement-text" @click="agreeBtn('yhxy')">《诚祥学用户协议》</view>和<view
  29. @click="agreeBtn('ystk')" class="agreement-text">《诚祥学隐私政策》</view>,如您同意,请勾选后开始使用
  30. </view>
  31. </view>
  32. <button type="default" @click="handleLogin" :disabled="!isAgreed" class="phone-green-btn login-btn">登录</button>
  33. <!-- 已加密的:{{lliPassword}} -->
  34. </view>
  35. <!-- <passwordLli ref="passLLiRef" :password="password" @lli-password="onLliPassword" /> -->
  36. </view>
  37. </template>
  38. <script setup>
  39. import cacheManager from '@/utils/cacheManager.js'
  40. import * as httpApi from "@/api/login.js"
  41. // import passwordLli from "@/components/password-lli/password-lli.vue";
  42. import {ref} from "vue"
  43. import {toast} from "@/utils/common";
  44. import {useIsCanBack} from "@/store/isCanBack.js"
  45. import {
  46. onLoad
  47. } from "@dcloudio/uni-app";
  48. const userName = ref('') // 用户名
  49. const password = ref('') // 密码
  50. const lliPassword = ref('') // 加密后的密码
  51. const passLLiRef = ref(null)
  52. const showPassword= ref(true)
  53. const clearTelIcon= ref(false)
  54. const clearPwIcon= ref(false)
  55. const isAgreed = ref(false)
  56. const store = useIsCanBack();
  57. onLoad(() => {
  58. getAllImg();
  59. })
  60. function handleChange() {
  61. isAgreed.value = !isAgreed.value
  62. }
  63. function agreeBtn(code) {
  64. if (code === 'yhxy') {
  65. uni.navigateTo({
  66. url:"/pages/client/my/xieyi"
  67. })
  68. } else {
  69. uni.navigateTo({
  70. url:"/pages/client/my/zhengce"
  71. })
  72. }
  73. }
  74. // 加密
  75. function handleUpdateLLiPassword() {
  76. console.log('handleUpdateLLiPassword')
  77. passLLiRef.value.lliPassword();
  78. }
  79. function onLliPassword(password) {
  80. console.log('onLliPassword',password)
  81. lliPassword.value = password;
  82. }
  83. // 手机号校验
  84. function userInputChange(event){
  85. if (event.detail.value.length > 0) {
  86. clearTelIcon.value = true;
  87. } else {
  88. clearTelIcon.value = false;
  89. }
  90. }
  91. // 密码校验
  92. function passwordInputChange(event){
  93. if (event.detail.value.length > 0) {
  94. clearPwIcon.value = true;
  95. } else {
  96. clearPwIcon.value = false;
  97. }
  98. }
  99. // 清除手机号
  100. function clearTel(){
  101. userName.value = '';
  102. clearTelIcon.value = false;
  103. }
  104. // 清除密码
  105. function clearPw(){
  106. password.value = '';
  107. clearPwIcon.value = false;
  108. }
  109. // 密码显隐
  110. function changePassword() {
  111. showPassword.value = !showPassword.value;
  112. }
  113. // 登录
  114. function handleLogin() {
  115. if(userName.value.length ===0){
  116. toast('请输入手机号!')
  117. return
  118. }
  119. if(password.value.length ===0){
  120. toast('请输入密码!')
  121. return
  122. }
  123. // 去除 userName 两端的空格
  124. const trimmedUserName = userName.value;
  125. const trimmedPassword = password.value;
  126. uni.showLoading({
  127. title: '登录中'
  128. })
  129. httpApi.loginTemp({
  130. // type 1app 2为H5
  131. type:2,
  132. userName: trimmedUserName,
  133. password:trimmedPassword,
  134. }).then(res => {
  135. // 4为家政人员
  136. if(res.data.type ===4){
  137. cacheManager.set('auth', res.data)
  138. store.setIsCanBack(false)
  139. // 页面跳转
  140. gotoPage();
  141. }else{
  142. toast('登录失败,您的身份有误,请联系管理员。')
  143. }
  144. }).catch(err => {
  145. store.setIsCanBack(true)
  146. }).finally(err => {
  147. uni.hideLoading()
  148. })
  149. }
  150. // 跳转
  151. function gotoPage(){
  152. uni.navigateTo({
  153. url: `/pages/client/ShouYe/shouye`
  154. })
  155. }
  156. function getAllImg() {
  157. httpApi.getAllImgList({}).then(res => {
  158. cacheManager.set('projectImg', res.data)
  159. // defultKsImg.value = cacheManager.get('projectImg').index_ks_default
  160. });
  161. }
  162. </script>
  163. <style>
  164. </style>