参考代码:
LoginWithHuaweiIDButton({
params: {
style: loginComponentManager.Style.ICON_RED,
loginType: loginComponentManager.LoginType.ID,
iconRadius: 16
},
controller: this.controller
})
.width(32)
.height(32)
.margin({ top: 16, bottom: AppManager.shared().safeAreaBottom() + 40 })
controller: loginComponentManager.LoginWithHuaweiIDButtonController =
new loginComponentManager.LoginWithHuaweiIDButtonController()
.onClickLoginWithHuaweiIDButton((error: BusinessError, response: loginComponentManager.HuaweiIDCredential) => {
if (error) {
promptAction.showToast({ message: '授权失败' })
return;
}
if (response) {
const code = response.authorizationCode
AppManager.shared().harmonyLogin(code)
return;
}
});
参考此demo,若未点击用户已阅读并同意,点击一键登录,可弹窗让用户点击同意并登录,参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/account-api-component-manager-V5\#section11946121217577