- 发布:2026-04-27 18:16
- 更新:2026-04-27 18:16
- 阅读:23
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 22H2
HBuilderX类型: 正式
HBuilderX版本号: 5.07
手机系统: 全部
手机厂商: 小米
手机机型: 红米k70pro
页面类型: vue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
测试过的手机:
示例代码:
uni.getProvider({
service: 'oauth',
success: function(res) {
console.log(res.provider, res.provider == 'univerify') // ['qq', 'univerify']
if (~res.provider.indexOf('univerify')) {
console.log("univerify:SIM一键登录", verifyButton.value) // ['qq', 'univerify']
const univerifyManager = uni.getUniverifyManager()
uni.login({
provider: 'univerify',
univerifyStyle: {
fullScreen: true,
backgroundColor: "#ffffff", // 授权页面背景颜色,默认值:#ffffff
backgroundImage: isIos.value ? "" :
"/static/imgs/loginIcon/univerify/univerify.png",
icon: {
"path": " ", // 自定义显示在授权框中的logo,仅支持本地图片 默认显示App logo
"width": "0px", //图标宽度 默认值:60px
"height": "0px" //图标高度 默认值:60px
},
closeIcon: {
"path": " ", // 自定义显示在授权框中的logo,仅支持本地图片
"width": "0px", //图标宽度 默认值:60px (HBuilderX 4.0+ 仅iOS支持)
"height": "0px" //图标高度 默认值:60px (HBuilderX 4.0+ 仅iOS支持)
},
phoneNum: {
"color": "#05110D" // 手机号文字颜色 默认值:#202020
},
slogan: {
"color": "#05110D" // slogan 字体颜色 默认值:#BBBBBB
},
authButton: {
"normalColor": "#FF6B35", // 授权按钮正常状态背景颜色 默认值:#3479f5
"highlightColor": "#FF6B35", // 授权按钮按下状态背景颜色 默认值:#2861c5(仅ios支持)
"disabledColor": "#FF6B35", // 授权按钮不可点击时背景颜色 默认值:#73aaf5(仅ios支持)
"textColor": "#ffffff", // 授权按钮文字颜色 默认值:#ffffff
"title": "登录", // 授权按钮文案 默认值:“本机号码一键登录”
"borderRadius": "8px" // 授权按钮圆角 默认值:"24px" (按钮高度的一半)
},
otherLoginButton: {
"visible": true, // 是否显示其他登录按钮,默认值:true
"normalColor": "", // 其他登录按钮正常状态背景颜色 默认值:透明
"highlightColor": "", // 其他登录按钮按下状态背景颜色 默认值:透明
"textColor": "#7B7B7B", // 其他登录按钮文字颜色 默认值:#656565
"title": "短信验证码登录", // 其他登录方式按钮文字 默认值:“其他登录方式”
"borderColor": "", //边框颜色 默认值:透明(仅iOS支持)
"borderRadius": "0px" // 其他登录按钮圆角 默认值:"24px" (按钮高度的一半)
},
privacyTerms: {
"defaultCheckBoxState": false, // 条款勾选框初始状态 默认值: true
"isCenterHint": false, //未勾选服务条款时点击登录按钮的提示是否居中显示 默认值: false (3.7.13+ 版本支持)
"uncheckedImage": "/static/imgs/loginIcon/univerify/wxz.png", // 可选 条款勾选框未选中状态图片(仅支持本地图片 建议尺寸 24x24px)(3.2.0+ 版本支持)
"checkedImage": "/static/imgs/loginIcon/univerify/xz.png", // 可选 条款勾选框选中状态图片(仅支持本地图片 建议尺寸24x24px)(3.2.0+ 版本支持)
"checkBoxSize": 18, // 可选 条款勾选框大小
"textColor": "#969B9C", // 文字颜色 默认值:#BBBBBB
"termsColor": "#1F2021", // 协议文字颜色 默认值: #5496E3
"prefix": "我已阅读并同意", // 条款前的文案 默认值:“我已阅读并同意”
"suffix": "并使用本机号码登录", // 条款后的文案 默认值:“并使用本机号码登录”
"privacyItems": [ // 自定义协议条款,最大支持2个,需要同时设置url和title. 否则不生效
{
"url": "https://api.minihongyu.com/privacy/usageLicense.html", // 点击跳转的协议详情页面
"title": "用户协议" // 协议名称
},
{
"url": "https://api.minihongyu.com/privacy/privacyAgreement.html", // 点击跳转的协议详情页面
"title": "隐私政策" // 协议名称
}
]
},
buttons: { // 自定义页面下方按钮仅全屏模式生效(3.1.14+ 版本支持)
"iconWidth": "40px", // 图标宽度(高度等比例缩放) 默认值:45px
"list": verifyButton.value
}
},
success: function(res) {
// 关闭授权弹窗
// uni.closeAuthView()
// {openid:'登录授权唯一标识',access_token:'接口返回的 token'}
// 登录成功
console.log(res.authResult, "sim授权的信息")
console.log(res, "sim授权的信息")
// return
simAuth.value = res.authResult
goUniCloudFunction()
},
fail: function(err) {
console.log("失败了++++++++++++++",err)
if (err.code == '30008') {
console.log(err.provider)
switch (err.provider) {
case 'apple': {
// 苹果登录
console.log('苹果登录')
goAppleAuth();
break;
}
case 'weixin': {
// 微信登录
console.log('微信登录')
goWechatAuth();
break;
}
case 'douyin': {
// 抖音登录
console.log('抖音登录')
goTiktokAuth()
break;
}
default: {
console.log('不知道点的啥')
}
}
return
} else if (err.code == '30005') {
console.log("111请开启移动数据后再次使用")
uni.showToast({
title: err.metadata.desc + ',请开启移动数据后再次使用',
icon: "none"
})
return
} else if (err.code == '30003') {
// 用户关闭验证界面
uni.closeAuthView();
uni.hideLoading();
return
} else if (err.code == '30002') {
// 用户点击了其他登录方式
uni.closeAuthView();
uni.hideLoading();
return
} else {
uni.showToast({
title: '一键登录失败,请使用其他方式登录',
icon: "none"
})
uni.closeAuthView();
uni.hideLoading();
return
}
// 登录授权失败
console.log(err, "当前授权·失败了")
},
complete(err) {
console.log("请求完的回调", err)
}
})
}
}
});
uni.getProvider({
service: 'oauth',
success: function(res) {
console.log(res.provider, res.provider == 'univerify') // ['qq', 'univerify']
if (~res.provider.indexOf('univerify')) {
console.log("univerify:SIM一键登录", verifyButton.value) // ['qq', 'univerify']
const univerifyManager = uni.getUniverifyManager()
uni.login({
provider: 'univerify',
univerifyStyle: {
fullScreen: true,
backgroundColor: "#ffffff", // 授权页面背景颜色,默认值:#ffffff
backgroundImage: isIos.value ? "" :
"/static/imgs/loginIcon/univerify/univerify.png",
icon: {
"path": " ", // 自定义显示在授权框中的logo,仅支持本地图片 默认显示App logo
"width": "0px", //图标宽度 默认值:60px
"height": "0px" //图标高度 默认值:60px
},
closeIcon: {
"path": " ", // 自定义显示在授权框中的logo,仅支持本地图片
"width": "0px", //图标宽度 默认值:60px (HBuilderX 4.0+ 仅iOS支持)
"height": "0px" //图标高度 默认值:60px (HBuilderX 4.0+ 仅iOS支持)
},
phoneNum: {
"color": "#05110D" // 手机号文字颜色 默认值:#202020
},
slogan: {
"color": "#05110D" // slogan 字体颜色 默认值:#BBBBBB
},
authButton: {
"normalColor": "#FF6B35", // 授权按钮正常状态背景颜色 默认值:#3479f5
"highlightColor": "#FF6B35", // 授权按钮按下状态背景颜色 默认值:#2861c5(仅ios支持)
"disabledColor": "#FF6B35", // 授权按钮不可点击时背景颜色 默认值:#73aaf5(仅ios支持)
"textColor": "#ffffff", // 授权按钮文字颜色 默认值:#ffffff
"title": "登录", // 授权按钮文案 默认值:“本机号码一键登录”
"borderRadius": "8px" // 授权按钮圆角 默认值:"24px" (按钮高度的一半)
},
otherLoginButton: {
"visible": true, // 是否显示其他登录按钮,默认值:true
"normalColor": "", // 其他登录按钮正常状态背景颜色 默认值:透明
"highlightColor": "", // 其他登录按钮按下状态背景颜色 默认值:透明
"textColor": "#7B7B7B", // 其他登录按钮文字颜色 默认值:#656565
"title": "短信验证码登录", // 其他登录方式按钮文字 默认值:“其他登录方式”
"borderColor": "", //边框颜色 默认值:透明(仅iOS支持)
"borderRadius": "0px" // 其他登录按钮圆角 默认值:"24px" (按钮高度的一半)
},
privacyTerms: {
"defaultCheckBoxState": false, // 条款勾选框初始状态 默认值: true
"isCenterHint": false, //未勾选服务条款时点击登录按钮的提示是否居中显示 默认值: false (3.7.13+ 版本支持)
"uncheckedImage": "/static/imgs/loginIcon/univerify/wxz.png", // 可选 条款勾选框未选中状态图片(仅支持本地图片 建议尺寸 24x24px)(3.2.0+ 版本支持)
"checkedImage": "/static/imgs/loginIcon/univerify/xz.png", // 可选 条款勾选框选中状态图片(仅支持本地图片 建议尺寸24x24px)(3.2.0+ 版本支持)
"checkBoxSize": 18, // 可选 条款勾选框大小
"textColor": "#969B9C", // 文字颜色 默认值:#BBBBBB
"termsColor": "#1F2021", // 协议文字颜色 默认值: #5496E3
"prefix": "我已阅读并同意", // 条款前的文案 默认值:“我已阅读并同意”
"suffix": "并使用本机号码登录", // 条款后的文案 默认值:“并使用本机号码登录”
"privacyItems": [ // 自定义协议条款,最大支持2个,需要同时设置url和title. 否则不生效
{
"url": "https://api.minihongyu.com/privacy/usageLicense.html", // 点击跳转的协议详情页面
"title": "用户协议" // 协议名称
},
{
"url": "https://api.minihongyu.com/privacy/privacyAgreement.html", // 点击跳转的协议详情页面
"title": "隐私政策" // 协议名称
}
]
},
buttons: { // 自定义页面下方按钮仅全屏模式生效(3.1.14+ 版本支持)
"iconWidth": "40px", // 图标宽度(高度等比例缩放) 默认值:45px
"list": verifyButton.value
}
},
success: function(res) {
// 关闭授权弹窗
// uni.closeAuthView()
// {openid:'登录授权唯一标识',access_token:'接口返回的 token'}
// 登录成功
console.log(res.authResult, "sim授权的信息")
console.log(res, "sim授权的信息")
// return
simAuth.value = res.authResult
goUniCloudFunction()
},
fail: function(err) {
console.log("失败了++++++++++++++",err)
if (err.code == '30008') {
console.log(err.provider)
switch (err.provider) {
case 'apple': {
// 苹果登录
console.log('苹果登录')
goAppleAuth();
break;
}
case 'weixin': {
// 微信登录
console.log('微信登录')
goWechatAuth();
break;
}
case 'douyin': {
// 抖音登录
console.log('抖音登录')
goTiktokAuth()
break;
}
default: {
console.log('不知道点的啥')
}
}
return
} else if (err.code == '30005') {
console.log("111请开启移动数据后再次使用")
uni.showToast({
title: err.metadata.desc + ',请开启移动数据后再次使用',
icon: "none"
})
return
} else if (err.code == '30003') {
// 用户关闭验证界面
uni.closeAuthView();
uni.hideLoading();
return
} else if (err.code == '30002') {
// 用户点击了其他登录方式
uni.closeAuthView();
uni.hideLoading();
return
} else {
uni.showToast({
title: '一键登录失败,请使用其他方式登录',
icon: "none"
})
uni.closeAuthView();
uni.hideLoading();
return
}
// 登录授权失败
console.log(err, "当前授权·失败了")
},
complete(err) {
console.log("请求完的回调", err)
}
})
}
}
}); 操作步骤:
用最新版打自定义基座使用代码就能复现
用最新版打自定义基座使用代码就能复现 预期结果:
点击触发自定义按钮
点击触发自定义按钮 实际结果:
没反应
没反应 bug描述:
一键登录自定义按钮失效点击无反应,控制台没有打印,之前都是好的
0 个回复