- 发布:2023-05-30 17:55
- 更新:2023-05-31 12:07
- 阅读:843
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 11
HBuilderX类型: 正式
HBuilderX版本号: 3.8.3
手机系统: 全部
手机厂商: 华为
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
App下载地址或H5⽹址: https://mp-8e355e8c-443f-4807-9944-25e045e1ba9d.cdn.bspapp.com/cloudstorage/e935e621-8144-4bdb-a701-1c202b8b7a65.apk
测试过的手机:
示例代码:
getProvider() {
uni.preLogin({
provider: 'univerify',
success: () => {
uni.getProvider({
service: 'oauth',
success: (res) => {
console.log(res);
uni.login({
provider: 'univerify',
univerifyStyle: {
fullScreen: true,
otherLoginButton: {
"visible": true,
"title": '其他账号登录'
},
buttons: {
"iconWidth": "45px",
list: this.typeCode
},
privacyTerms: {
"checkBoxSize": 20, // 可选 条款勾选框大小,仅android支持
"defaultCheckBoxState": false, // 条款勾选框初始状态 默认值: true
privacyItems: [{
url: '',
title: '服务协议'
},
{
url: '',
title: '用户信息与隐私协议'
}
]
}
},
success: (res) => {
let obj = {
openid: res.authResult.openid,
access_token: res.authResult
.access_token,
client_id: uni.getStorageSync(
'clientid')
}
// return console.log(obj);
api.tel_one_login(obj).then((res) => {
console.log('手机号一键登录', res)
if (res.code == '0') {
this.isLoginStutas = true
this.bindIns(res.data.ins_info)
uni.setStorageSync('isPhone', res.data.is_phone)
uni.setStorageSync('user', res
.data)
uni.setStorageSync(
'access_token', res
.data.access_token)
uni.setStorageSync(
'refresh_token', res
.data.refresh_token)
api.memberjg({
jg_id: uni
.getStorageSync(
'register_id'
)
}).then((res) => {
console.log('绑定成功')
})
this.userInfo.nickname = res
.data.nickname
this.userInfo.avatar = res.data
.avatar
this.institution()
uni.closeAuthView()
this.$Toast('登录成功!')
} else {
uni.showToast({
title: '请改为其它状态方式登录',
icon: 'none'
})
// uni.closeAuthView()
}
})
},
fail: (res) => {
if (res.errCode === 30002) {
uni.closeAuthView()
uni.navigateTo({
url: '/pages/AppLogin/AppLogin'
})
} else if (res.provider == 'weixin') { //微信登录方式
uni.getCheckBoxState({
success: (resCode) => {
console.log(
'============',
resCode)
if (resCode.state) {
this.getProviderWX()
uni.closeAuthView()
} else {
uni.getCheckBoxState({
success: (resCode) => {
console.log(
'============',
resCode)
if (resCode.state) {
this.getProviderWX()
uni.closeAuthView()
} else {
uni.showToast({
title: '你还没有同意相关协议',
icon: 'none'
})
}
}
})
}
}
})
} else if (res.provider == 'apple') {
uni.getCheckBoxState({
success: (resCode) => {
if (resCode.state) {
this.IOSApple()
uni.closeAuthView()
} else {
uni.showToast({
title: '你还没有同意相关协议',
icon: 'none'
})
}
}
})
}
},
complete: (res) => {
// console.log('===========', res)
}
})
}
});
},
fail: (res) => {
console.log(res);
uni.navigateTo({
url: '/pages/AppLogin/AppLogin'
})
}
})
},
getProvider() {
uni.preLogin({
provider: 'univerify',
success: () => {
uni.getProvider({
service: 'oauth',
success: (res) => {
console.log(res);
uni.login({
provider: 'univerify',
univerifyStyle: {
fullScreen: true,
otherLoginButton: {
"visible": true,
"title": '其他账号登录'
},
buttons: {
"iconWidth": "45px",
list: this.typeCode
},
privacyTerms: {
"checkBoxSize": 20, // 可选 条款勾选框大小,仅android支持
"defaultCheckBoxState": false, // 条款勾选框初始状态 默认值: true
privacyItems: [{
url: '',
title: '服务协议'
},
{
url: '',
title: '用户信息与隐私协议'
}
]
}
},
success: (res) => {
let obj = {
openid: res.authResult.openid,
access_token: res.authResult
.access_token,
client_id: uni.getStorageSync(
'clientid')
}
// return console.log(obj);
api.tel_one_login(obj).then((res) => {
console.log('手机号一键登录', res)
if (res.code == '0') {
this.isLoginStutas = true
this.bindIns(res.data.ins_info)
uni.setStorageSync('isPhone', res.data.is_phone)
uni.setStorageSync('user', res
.data)
uni.setStorageSync(
'access_token', res
.data.access_token)
uni.setStorageSync(
'refresh_token', res
.data.refresh_token)
api.memberjg({
jg_id: uni
.getStorageSync(
'register_id'
)
}).then((res) => {
console.log('绑定成功')
})
this.userInfo.nickname = res
.data.nickname
this.userInfo.avatar = res.data
.avatar
this.institution()
uni.closeAuthView()
this.$Toast('登录成功!')
} else {
uni.showToast({
title: '请改为其它状态方式登录',
icon: 'none'
})
// uni.closeAuthView()
}
})
},
fail: (res) => {
if (res.errCode === 30002) {
uni.closeAuthView()
uni.navigateTo({
url: '/pages/AppLogin/AppLogin'
})
} else if (res.provider == 'weixin') { //微信登录方式
uni.getCheckBoxState({
success: (resCode) => {
console.log(
'============',
resCode)
if (resCode.state) {
this.getProviderWX()
uni.closeAuthView()
} else {
uni.getCheckBoxState({
success: (resCode) => {
console.log(
'============',
resCode)
if (resCode.state) {
this.getProviderWX()
uni.closeAuthView()
} else {
uni.showToast({
title: '你还没有同意相关协议',
icon: 'none'
})
}
}
})
}
}
})
} else if (res.provider == 'apple') {
uni.getCheckBoxState({
success: (resCode) => {
if (resCode.state) {
this.IOSApple()
uni.closeAuthView()
} else {
uni.showToast({
title: '你还没有同意相关协议',
icon: 'none'
})
}
}
})
}
},
complete: (res) => {
// console.log('===========', res)
}
})
}
});
},
fail: (res) => {
console.log(res);
uni.navigateTo({
url: '/pages/AppLogin/AppLogin'
})
}
})
}, 操作步骤:
HarmonyOS一键登录问题,已经同意隐私协议,点击其他账号登录,或者第三方登录,依然提示,"请同意隐私协议"
HarmonyOS一键登录问题,已经同意隐私协议,点击其他账号登录,或者第三方登录,依然提示,"请同意隐私协议"
预期结果:
勾选之后就不要弹框
勾选之后就不要弹框
实际结果:
HarmonyOS一键登录问题,已经同意隐私协议,点击其他账号登录,或者第三方登录,依然提示,"请同意隐私协议"
HarmonyOS一键登录问题,已经同意隐私协议,点击其他账号登录,或者第三方登录,依然提示,"请同意隐私协议"
bug描述:
问题:
HarmonyOS一键登录问题,已经同意隐私协议,点击其他账号登录,或者第三方登录,依然提示,"请同意隐私协议"
出现原因:
经测试,在HarmonyOS系统中一键登陆的 获取用户是否选中了勾选框的方法 uni.getCheckBoxState(),无论是否勾选 state永远是false