// 微信登录逻辑
uni.login({
provider: 'weixin',
success: (loginRes) => {
// 获取用户信息
uni.getUserInfo({
provider: 'weixin',
success: (infoRes) => {
// 处理登录逻辑
this.handleLogin({
loginType: 'weixin',
code: loginRes.code,
userInfo: infoRes.userInfo
});
},
fail: (err) => {
uni.showToast({
title: '获取用户信息失败',
icon: 'none'
});
this.wechatLoading = false;
},
complete: () => {
this.wechatLoading = false;
}
});
},
fail: (err) => {
uni.showToast({
title: '微信登录失败',
icon: 'none'
});
this.wechatLoading = false;
}
});
// #endif
// #ifndef APP-PLUS
// 非APP环境下的模拟登录成功,可以在开发时测试UI
setTimeout(() => {
this.mockSuccessLogin();
}, 1500);
// #endif
},
// 处理登录逻辑
handleLogin(loginData) {
// 调用后端登录接口
// 登录成功后存储用户信息
// 然后跳转到首页
console.log('登录数据', loginData);
// 模拟登录成功
this.mockSuccessLogin();
},
0 个回复