index.vue 1.1 KB

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