Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
6c6d8ca3
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6172
Star
101
Fork
177
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
21
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
21
Issue
21
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6c6d8ca3
编写于
12月 21, 2024
作者:
DCloud_iOS_WZT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update get-univerify-manager.uvue
上级
55e752f6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
78 addition
and
64 deletion
+78
-64
pages/API/get-univerify-manager/get-univerify-manager.uvue
pages/API/get-univerify-manager/get-univerify-manager.uvue
+8
-8
pages/API/get-univerify-manager/univerify-custom-page.uvue
pages/API/get-univerify-manager/univerify-custom-page.uvue
+70
-56
未找到文件。
pages/API/get-univerify-manager/get-univerify-manager.uvue
浏览文件 @
6c6d8ca3
...
...
@@ -20,7 +20,7 @@
data() {
return {
title: '一键登录',
uni
verifyManager: null as Univ
erifyManager | null,
uni
VerifyManager: null as UniV
erifyManager | null,
phone: '',
slogan: '',
privacyName: '',
...
...
@@ -28,7 +28,7 @@
}
},
onLoad() {
this.uni
verifyManager = uni.getUniv
erifyManager();
this.uni
VerifyManager = uni.getUniV
erifyManager();
// 预登录
this.preLogin(() => { });
},
...
...
@@ -42,7 +42,7 @@
})
return
}
const isPreLoginValid = this.uni
v
erifyManager?.isPreLoginValid() ?? false;
const isPreLoginValid = this.uni
V
erifyManager?.isPreLoginValid() ?? false;
if (isPreLoginValid) {
this.pushCustomPage();
} else {
...
...
@@ -74,7 +74,7 @@
return
}
// 校验预登录是否有效
const isPreLoginValid = this.uni
v
erifyManager?.isPreLoginValid() ?? false;
const isPreLoginValid = this.uni
V
erifyManager?.isPreLoginValid() ?? false;
if (isPreLoginValid) {
// 预登录有效,执行登录
this.login(fullScreen);
...
...
@@ -86,7 +86,7 @@
}
},
preLogin(callback: (() => void)) {
this.uni
v
erifyManager?.preLogin({
this.uni
V
erifyManager?.preLogin({
success: (res) => {
this.phone = res.number;
this.slogan = res.slogan;
...
...
@@ -106,7 +106,7 @@
});
},
login(fullScreen : boolean) {
this.uni
v
erifyManager?.login({
this.uni
V
erifyManager?.login({
univerifyStyle:{
fullScreen: fullScreen,
backgroundColor: "#FFFFFF",
...
...
@@ -137,7 +137,7 @@
}
}).then(res => {
// 关闭登录页
this.uni
v
erifyManager?.close();
this.uni
V
erifyManager?.close();
setTimeout(() => {
uni.showModal({
title: '取号成功',
...
...
@@ -148,7 +148,7 @@
}).catch(err => {
console.error(JSON.stringify(err));
// 关闭登录页
this.uni
v
erifyManager?.close();
this.uni
V
erifyManager?.close();
setTimeout(() => {
uni.showModal({
title: '取号失败',
...
...
pages/API/get-univerify-manager/univerify-custom-page.uvue
浏览文件 @
6c6d8ca3
...
...
@@ -22,16 +22,17 @@
export default {
data() {
return {
uni
verifyManager: null as Univ
erifyManager | null,
uni
VerifyManager: null as UniV
erifyManager | null,
phone: '',
slogan: '',
privacyName: '',
privacyUrl: '',
closeIcon: '\uE650'
closeIcon: '\uE650',
isLoading: false //是否正在登录中
}
},
onLoad(options : OnLoadOptions) {
this.uni
verifyManager = uni.getUniv
erifyManager();
onLoad(options : OnLoadOptions) {
this.uni
VerifyManager = uni.getUniV
erifyManager();
this.phone = options['phone'] as string;
this.slogan = options['slogan'] as string;
this.privacyName = options['name'] as string;
...
...
@@ -39,15 +40,15 @@
},
methods: {
closePage() {
uni.closeDialogPage({
dialogPage: this.$page,
animationType:
'slide-out-bottom',
success(res) {
console.log('closeThisDialog success', res)
},
fail(err) {
console.log('closeThisDialog fail', err)
}
uni.closeDialogPage({
dialogPage: this.$page,
animationType:
'slide-out-bottom',
success(res) {
console.log('closeThisDialog success', res)
},
fail(err) {
console.log('closeThisDialog fail', err)
}
})
},
openLink() {
...
...
@@ -64,53 +65,66 @@
})
},
loginIn() {
loginIn() {
if (this.isLoading) {
uni.showToast({
title: "正在登录中,请稍后",
position: "bottom",
duration: 2000
})
return;
}else{
this.isLoading = true;
}
const numberTextElement = this.$page.getElementById('number-text');
const sloganTextElement = this.$page.getElementById('slogan-text');
const loginButtonElement = this.$page.getElementById('login-button');
const privacyCheckBoxElement = this.$page.getElementById('privacy-checkbox');
const privacyTextElement = this.$page.getElementById('privacy-text');
if(numberTextElement != null && sloganTextElement != null && loginButtonElement != null && privacyCheckBoxElement != null && privacyTextElement != null){
this.univerifyManager?.customLogin({
numberTextElement: numberTextElement,
sloganTextElement: sloganTextElement,
loginButtonElement: loginButtonElement,
privacyCheckBoxElement: privacyCheckBoxElement,
privacyTextElement: privacyTextElement,
success: (res) => {
console.log(res);
this.takePhoneNumber(res.accessToken, res.openId);
const privacyTextElement = this.$page.getElementById('privacy-text');
if (numberTextElement != null && sloganTextElement != null && loginButtonElement != null && privacyCheckBoxElement != null && privacyTextElement != null) {
this.uniVerifyManager?.customLogin({
numberTextElement: numberTextElement,
sloganTextElement: sloganTextElement,
loginButtonElement: loginButtonElement,
privacyCheckBoxElement: privacyCheckBoxElement,
privacyTextElement: privacyTextElement,
success: (res) => {
console.log(res);
this.takePhoneNumber(res.accessToken, res.openId);
},
fail: (error) => {
if (error.errCode == 40001) {
uni.showToast({
title: "请同意服务条款",
position: "bottom",
duration: 2000
})
} else if (error.errCode == 40002) {
uni.showToast({
title: "授权页不符合规范",
position: "bottom",
duration: 2000
})
} else {
const errorMsg = JSON.parseObject(error.cause?.cause?.message ?? "")?.getString("errorDesc") ?? error.errMsg;
uni.showToast({
title: errorMsg,
position: "bottom",
duration: 2000
})
}
},
fail: (error) => {
if (error.errCode == 40001){
uni.showToast({
title:"请同意服务条款",
position: "bottom",
duration:2000
})
}else if(error.errCode == 40002){
uni.showToast({
title:"授权页不符合规范",
position: "bottom",
duration:2000
})
}else{
const errorMsg = JSON.parseObject(error.cause?.cause?.message ?? "")?.getString("errorDesc") ?? error.errMsg;
uni.showToast({
title:errorMsg,
position: "bottom",
duration:2000
})
}
}
})
}else{
uni.showToast({
title:"元素不能为空",
position: "bottom",
duration:2000
complete: () =>{
this.isLoading = false;
}
})
} else {
uni.showToast({
title: "未获取到页面元素",
position: "bottom",
duration: 2000
})
this.isLoading = false;
}
},
...
...
@@ -148,7 +162,7 @@
otherLogin() {
//此处可实现其他登录方式
uni.showToast({
title: "使用其他方式登录",
title: "使用其他方式登录",
position: "bottom"
})
}
...
...
@@ -224,7 +238,7 @@
flex-wrap: wrap;
top: 45%;
width: 100%;
justify-content: center;
justify-content: center;
align-self: center;
position: absolute;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录