You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
903 B
34 lines
903 B
<!-- 微信公众号的登录回调页 -->
|
|
<template>
|
|
<!-- 空登陆页 -->
|
|
<view />
|
|
</template>
|
|
|
|
<script setup>
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
import { getUserInfo} from '@/api/card'
|
|
|
|
|
|
|
|
|
|
// 使用 uni-app 的 onLoad 钩子函数获取页面加载时的 options 参数
|
|
onLoad(() => {
|
|
const params = new URLSearchParams(window.location.search);
|
|
const code = params.get('code');
|
|
const state = params.get('state');
|
|
console.log('Code:', code);
|
|
console.log('State:', state);
|
|
console.log('params:', params);
|
|
|
|
// 如果需要进一步处理,比如调用 API 使用 code 获取用户信息
|
|
if (code) {
|
|
// 调用获取用户信息的函数
|
|
getUserInfo(code).then(res => {
|
|
// 存储 openid 等信息
|
|
uni.setStorageSync('openid', res.data.openid);
|
|
}).catch(error => {
|
|
console.error('用户信息获取失败:', error);
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
|