| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <template>
- <view><!-- 授权页面 --></view>
- </template>
- <script setup>
- import { onLoad } from '@dcloudio/uni-app'
- import { getQueryString } from '../../util/getParams.js'
- import { myRequest } from '../../util/api.js'
- const APPKEY = '4AA7B3944BDF3739'
- const ocode = '1015730314'
- // 线上地址
- const URL = 'https://chtech.ncjti.edu.cn/carstop/carbook/appopenid.action'
- // const URL = 'https://chtech.ncjti.edu.cn/testingServer/carbook/appopenid.action'
- // 本地地址
- // const URL = 'http://192.168.161.170:8088/carBook/appopenid.action'
- onLoad(() => {
- loginFilter()
- })
- // 获取用户card_number
- const loginFilter = () => {
- const card_number = uni.getStorageSync('bus_card_number')
- if (!card_number) {
- const card_number = getQueryString('card_number')
- if (!card_number) {
- getCardnumberURL()
- } else {
- uni.setStorageSync('bus_card_number', card_number)
- getUserInfo()
- }
- } else {
- getUserInfo()
- }
- }
- // 获取用户信息
- const getUserInfo = async () => {
- const card_number = uni.getStorageSync('bus_card_number')
- const res = await myRequest({
- url: '/appget_user.action',
- data: {
- card_number
- }
- })
- // console.log(res);
- uni.setStorageSync('bus-userInfo', JSON.stringify(res.data))
- // 判断用户权限
- if (res.data && res.data.user_zz === '教师') {
- uni.switchTab({
- url: '/pages/home/home'
- })
- } else if (res.data && res.data.user_zz === '车队长') {
- uni.reLaunch({
- url: '/pages/record/record'
- })
- } else if (res.data && res.data.user_zz === '司机') {
- uni.reLaunch({
- url: '/pages/recordDriver/recordDriver'
- })
- }
- }
- // 跳转授权页面
- const getCardnumberURL = () => {
- 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}`
- }
- </script>
|