adminloginBox.vue 7.0 KB

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