index.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <view>
  3. 这是登录页面 {{counter.count}}
  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. <button type="warn" @click="handleLogin">登录</button>
  10. </view>
  11. </view>
  12. </template>
  13. <script setup>
  14. import {setAuth} from "@/utils/auth.js"
  15. import { useCounterStore } from "@/store/counter.js"
  16. import * as httpApi from "@/api/login.js"
  17. const counter = useCounterStore();
  18. function goAdminShouye() {
  19. uni.navigateTo({
  20. url: "/pages/ShouYe/shouyeOne"
  21. })
  22. }
  23. function goJiaZhengShouye() {
  24. uni.navigateTo({
  25. url: "/pages/ShouYe/shouyeTwo"
  26. })
  27. }
  28. function setLocalData() {
  29. setAuth({
  30. a:1,
  31. b:2,
  32. c:3
  33. })
  34. }
  35. function setPinia() {
  36. counter.increment();
  37. }
  38. function handleLogin() {
  39. httpApi.login({
  40. userName: 'root1',
  41. password: 'root'
  42. }).then(res => {
  43. console.log('res', res.data)
  44. })
  45. }
  46. </script>
  47. <style lang="scss">
  48. </style>