index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view>
  3. 北京诚祥 登录页面
  4. <view>
  5. <!-- <button type="primary" @click="setLocalData">设置缓存</button>
  6. <button type="primary" @click="setPinia">设置状态</button>
  7. <button type="primary" @click="goAdminShouye">去管理首页</button>
  8. <button type="warn" @click="goJiaZhengShouye">去家政首页</button> -->
  9. <input type="text" v-model="userName" placeholder="请输入用户名">
  10. <input type="text" v-model="password" @blur="handleUpdateLLiPassword" placeholder="请输入密码">
  11. <button type="warn" @click="handleLogin">登录</button>
  12. </view>
  13. 已加密的:{{lliPassword}}
  14. <!-- 隐藏的同步加密密码组件 非可见 -->
  15. <passwordLli ref="passLLiRef" :password="password" @lli-password="onLliPassword" />
  16. </view>
  17. </template>
  18. <script setup>
  19. import cacheManager from '@/utils/cacheManager.js'
  20. import * as httpApi from "@/api/login.js"
  21. import passwordLli from "@/components/password-lli/password-lli.vue";
  22. import {
  23. ref
  24. } from "vue"
  25. const userName = ref('18604088413') // 用户名
  26. const password = ref('1') // 密码
  27. const lliPassword = ref('') // 加密后的密码
  28. const passLLiRef = ref(null)
  29. function goAdminShouye() {
  30. uni.navigateTo({
  31. url: "/pages/ShouYe/shouyeOne"
  32. })
  33. }
  34. function goJiaZhengShouye() {
  35. uni.navigateTo({
  36. url: "/pages/ShouYe/shouyeTwo"
  37. })
  38. }
  39. function handleUpdateLLiPassword() {
  40. passLLiRef.value.lliPassword();
  41. }
  42. function onLliPassword(password) {
  43. lliPassword.value = password;
  44. }
  45. function handleLogin() {
  46. httpApi.login({
  47. userName: userName.value,
  48. password: lliPassword.value
  49. }).then(res => {
  50. cacheManager.set('auth', res.data)
  51. console.log('登录成功')
  52. // 目前默认跳转管理端首页
  53. // uni.navigateTo({
  54. // url: `/pages/admin/ShouYe/shouye`
  55. // })
  56. // 目前默认管理端考试页面
  57. uni.navigateTo({
  58. url: `/pages/admin/Kaoshi/list`
  59. })
  60. })
  61. }
  62. </script>
  63. <style lang="scss">
  64. </style>