adminloginBox.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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="handleAgreementChange">
  24. <checkbox class="agreement-checkbox-input" color="#FFFFFF" value="agree"
  25. :checked="isAgreed" />
  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" class="phone-green-btn login-btn">登录</button>
  33. <!-- 已加密的:{{lliPassword}} -->
  34. </view>
  35. <passwordLli ref="passLLiRef" :password="password" @lli-password="onLliPassword" />
  36. <tip-dialog ref="tipDialogRef" :title="tipTitle" :content="tipContent"></tip-dialog>
  37. <!-- 安卓强制升级 -->
  38. <shengJiDialog ref="tipDialogRef2" :closeFlag='false' :title="tipTitle" @confirm-btn="BanbenConfirmBtn" :showTip="true"
  39. :notClose="true" :content="tipContentAndroid">
  40. </shengJiDialog>
  41. <!-- 用户协议及隐私保护 -->
  42. <common-dialog ref="commonDialogRef" :title="yhxyTitle" :content="yhxyContent"
  43. @confirm-btn="yhxyBtn" okBtn="同意并登录" notBtn="不同意"></common-dialog>
  44. </view>
  45. </template>
  46. <script setup>
  47. import {onShow} from '@dcloudio/uni-app';
  48. import cacheManager from '@/utils/cacheManager.js'
  49. import * as httpApi from "@/api/login.js"
  50. import passwordLli from "@/components/password-lli/password-lli.vue";
  51. import {ref} from "vue"
  52. import {toast} from "@/utils/common";
  53. import {useIsCanBack} from "@/store/isCanBack.js"
  54. import config from '../../../config.js'
  55. import tipDialog from '@/components/dialog/tipDialog.vue';
  56. import shengJiDialog from '@/components/dialog/shengJiDialog.vue';
  57. import {useVersionUpdate} from "@/utils/versionUpdate.js";
  58. import commonDialog from '@/components/dialog/commonDialog.vue';
  59. const userName = ref('') // 用户名
  60. const password = ref('') // 密码
  61. const lliPassword = ref('') // 加密后的密码
  62. const passLLiRef = ref(null)
  63. const showPassword= ref(true)
  64. const clearTelIcon= ref(false)
  65. const clearPwIcon= ref(false)
  66. const isAgreed = ref(false)
  67. const store = useIsCanBack();
  68. const version = config.appInfo.version;
  69. const tipDialogRef = ref(null);
  70. const tipTitle = '升级提醒';
  71. const tipContent = '您的APP不是最新版本,部分功能不能使用,请升级至最新版本!';
  72. const tipContentAndroid = '您的APP不是最新版本,部分功能不能使用,请升级至最新版本!'
  73. const tipDialogRef2 = ref(null)
  74. const updateUrl = ref(null)
  75. const handleAgreementChange = (event) => {
  76. if (event.detail.value[0] === 'agree') {
  77. isAgreed.value = true;
  78. } else {
  79. isAgreed.value = false;
  80. }
  81. }
  82. const commonDialogRef = ref(null);
  83. const yhxyContent = '我已阅读并同意《家政学用户协议》和《家政学隐私政策》';
  84. const yhxyTitle = '用户协议及隐私保护';
  85. const {
  86. initDownload
  87. } = useVersionUpdate()
  88. const agreeBtn = (data) => {
  89. if (data === 'yhxy') {
  90. uni.navigateTo({
  91. url: `/pages/admin/my/yhxy?from=login`
  92. })
  93. } else {
  94. uni.navigateTo({
  95. url: `/pages/admin/my/yszc?from=login`
  96. })
  97. }
  98. };
  99. function BanbenConfirmBtn() {
  100. const systemInfo = uni.getSystemInfoSync();
  101. if (systemInfo.platform == 'ios') {
  102. const appStoreUrl = 'itms-apps://itunes.apple.com/app/6754060756'
  103. plus.runtime.openURL(appStoreUrl)
  104. } else {
  105. initDownload(updateUrl.value)
  106. }
  107. }
  108. // 加密
  109. function handleUpdateLLiPassword() {
  110. passLLiRef.value.lliPassword();
  111. }
  112. function onLliPassword(password) {
  113. console.log('onLliPassword',password)
  114. lliPassword.value = password;
  115. }
  116. // 手机号校验
  117. function userInputChange(event){
  118. if (event.detail.value.length > 0) {
  119. clearTelIcon.value = true;
  120. } else {
  121. clearTelIcon.value = false;
  122. }
  123. }
  124. // 密码校验
  125. function passwordInputChange(event){
  126. if (event.detail.value.length > 0) {
  127. clearPwIcon.value = true;
  128. } else {
  129. clearPwIcon.value = false;
  130. }
  131. }
  132. // 清除手机号
  133. function clearTel(){
  134. userName.value = '';
  135. clearTelIcon.value = false;
  136. }
  137. // 清除密码
  138. function clearPw(){
  139. password.value = '';
  140. clearPwIcon.value = false;
  141. }
  142. // 密码显隐
  143. function changePassword() {
  144. showPassword.value = !showPassword.value;
  145. }
  146. // 登录
  147. function handleLogin() {
  148. if(userName.value.length ===0){
  149. toast('请输入手机号!')
  150. return
  151. }
  152. if(password.value.length ===0){
  153. toast('请输入密码!')
  154. return
  155. }
  156. if(!isAgreed.value){
  157. commonDialogRef.value.handleShow();
  158. return
  159. }
  160. // 去除 userName 两端的空格
  161. const trimmedUserName = userName.value;
  162. const trimmedPassword = lliPassword.value;
  163. httpApi.login({
  164. // type 1app 2为H5
  165. type:1,
  166. userName: trimmedUserName,
  167. password: lliPassword.value,
  168. }).then(res => {
  169. // 2为家政管理员
  170. if(res.data.type ===2 ||res.data.type ===5){
  171. cacheManager.set('auth', res.data)
  172. store.setIsCanBack(false)
  173. // 页面跳转
  174. gotoPage();
  175. }else{
  176. toast('登录失败,您的身份有误,请联系管理员。')
  177. }
  178. }).catch(err => {
  179. store.setIsCanBack(true)
  180. })
  181. }
  182. function yhxyBtn(){
  183. isAgreed.value = true;
  184. handleLogin()
  185. }
  186. // 跳转
  187. function gotoPage(){
  188. uni.navigateTo({
  189. url: `/pages/admin/ShouYe/shouye`
  190. })
  191. }
  192. function getLoginInit(){
  193. httpApi.getVersion({}).then(res => {
  194. if (version != res.data.version) {
  195. updateUrl.value = res.data.updateUrl
  196. const systemInfo = uni.getSystemInfoSync();
  197. if (systemInfo.platform == 'ios') {
  198. } else {
  199. tipDialogRef2.value.handleShow();
  200. }
  201. }
  202. })
  203. }
  204. onShow(() => {
  205. getLoginInit()
  206. })
  207. </script>
  208. <style>
  209. </style>