index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. <passwordLli ref="passLLiRef" :password="password" @lli-password="onLliPassword" />
  15. </view>
  16. </template>
  17. <script setup>
  18. import cacheManager from '@/utils/cacheManager.js'
  19. import * as httpApi from "@/api/login.js"
  20. import passwordLli from "@/components/password-lli/password-lli.vue";
  21. import {
  22. ref
  23. } from "vue"
  24. const userName = ref('18604088413') // 用户名
  25. const password = ref('1') // 密码
  26. const lliPassword = ref('') // 加密后的密码
  27. const passLLiRef = ref(null)
  28. function goAdminShouye() {
  29. uni.navigateTo({
  30. url: "/pages/ShouYe/shouyeOne"
  31. })
  32. }
  33. function goJiaZhengShouye() {
  34. uni.navigateTo({
  35. url: "/pages/ShouYe/shouyeTwo"
  36. })
  37. }
  38. function handleUpdateLLiPassword() {
  39. passLLiRef.value.lliPassword();
  40. }
  41. function onLliPassword(password) {
  42. lliPassword.value = password;
  43. }
  44. function handleLogin() {
  45. httpApi.login({
  46. userName: userName.value,
  47. password: lliPassword.value
  48. }).then(res => {
  49. cacheManager.set('auth', res.data)
  50. console.log('登录成功')
  51. // 目前默认跳转管理端首页
  52. // uni.navigateTo({
  53. // url: `/pages/admin/ShouYe/shouye`
  54. // })
  55. // 目前默认管理端考试页面
  56. uni.navigateTo({
  57. url: `/pages/admin/Kaoshi/list`
  58. })
  59. })
  60. }
  61. </script>
  62. <style lang="scss">
  63. </style>