index.vue 915 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <div></div>
  3. </template>
  4. <script>
  5. import {defineComponent, ref} from "vue";
  6. import {useRouter} from "vue-router";
  7. import {useUserStore} from "@/store/modules/user";
  8. import {isWechat, wxAuth} from "@/utils/wechat";
  9. import {getUrlParams} from "@/utils/urlUtils";
  10. export default defineComponent({
  11. name: "sysindex",
  12. setup() {
  13. const router = useRouter();
  14. const userStore = useUserStore();
  15. const user = ref(userStore.getUserInfo);
  16. const urlParams = getUrlParams();
  17. let redirectUrl = urlParams["redirectUrl"] || '/login';
  18. if (redirectUrl === '/index') {
  19. redirectUrl = '/login';
  20. }
  21. const wxLogin = async function () {
  22. await wxAuth(redirectUrl);
  23. };
  24. if (isWechat()) {
  25. wxLogin().then(res => {
  26. router.push(redirectUrl);
  27. });
  28. } else {
  29. router.push(redirectUrl);
  30. }
  31. return {}
  32. }
  33. });
  34. </script>
  35. <style lang="less">
  36. </style>