index.vue 799 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <view>
  3. </view>
  4. </template>
  5. <script setup>
  6. import {
  7. onLoad
  8. } from "@dcloudio/uni-app"
  9. const APPKEY = '4AA7B3944BDF3739'
  10. const ocode = '1015730314'
  11. const URL = 'http://192.168.161.125:5173/#/pages/home/home'
  12. onLoad(() => {
  13. hasUserInfo()
  14. })
  15. const hasUserInfo = () => {
  16. try {
  17. const busUserInfo = uni.getStorageSync('busUserInfo');
  18. if (!busUserInfo) {
  19. window.
  20. location.href =
  21. `https://open.wecard.qq.com/connect/oauth/authorize?app_key=${APPKEY}&response_type=code&scope=snsapi_base&ocode=${ocode}&redirect_uri=${encodeURIComponent(URL)}`
  22. } else {
  23. uni.switchTab({
  24. url: "/pages/home/home"
  25. })
  26. }
  27. } catch (e) {
  28. uni.showToast({
  29. title: '异常:' + e,
  30. duration: 3000
  31. })
  32. }
  33. }
  34. </script>
  35. <style lang="scss" scoped>
  36. </style>