index.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <view><!-- 授权页面 --></view>
  3. </template>
  4. <script setup>
  5. import { onLoad } from '@dcloudio/uni-app'
  6. import { getQueryString } from '../../util/getParams.js'
  7. const APPKEY = '4AA7B3944BDF3739'
  8. const ocode = '1015730314'
  9. // 线上地址
  10. // const URL = 'https://chtech.ncjti.edu.cn/carstop/carbook/appopenid.action'
  11. // 本地地址
  12. const URL = 'http://192.168.161.170:8088/carBook/appopenid.action'
  13. onLoad(() => {
  14. loginFilter()
  15. })
  16. // 获取用户card_number
  17. const loginFilter = () => {
  18. const card_number = uni.getStorageSync('bus_card_number')
  19. if (!card_number) {
  20. const card_number = getQueryString('card_number')
  21. if (!card_number) {
  22. getCardnumberURL()
  23. } else {
  24. uni.setStorageSync('bus_card_number', card_number)
  25. uni.switchTab({
  26. url: '/pages/home/home'
  27. })
  28. }
  29. } else {
  30. uni.switchTab({
  31. url: '/pages/home/home'
  32. })
  33. }
  34. }
  35. // 跳转授权页面
  36. const getCardnumberURL = () => {
  37. window.location.href = `https://open.wecard.qq.com/connect/oauth/authorize?app_key=${APPKEY}&response_type=code&scope=snsapi_base&ocode=${ocode}&redirect_uri=${URL}&state=${URL}`
  38. }
  39. </script>