Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-id-pages-x
提交
6640f2dc
H
hello uni-id-pages-x
项目概览
DCloud
/
hello uni-id-pages-x
通知
38
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-id-pages-x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6640f2dc
编写于
12月 13, 2023
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增 一键登录
上级
106f6be9
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
403 addition
and
255 deletion
+403
-255
manifest.json
manifest.json
+1
-1
pages/index/index.uvue
pages/index/index.uvue
+31
-8
uni_modules/uni-id-pages-x/common/common.uts
uni_modules/uni-id-pages-x/common/common.uts
+2
-2
uni_modules/uni-id-pages-x/components/uni-id-pages-x-fab-login/uni-id-pages-x-fab-login.uvue
...ts/uni-id-pages-x-fab-login/uni-id-pages-x-fab-login.uvue
+33
-170
uni_modules/uni-id-pages-x/config.uts
uni_modules/uni-id-pages-x/config.uts
+20
-15
uni_modules/uni-id-pages-x/init.uts
uni_modules/uni-id-pages-x/init.uts
+77
-42
uni_modules/uni-id-pages-x/lib/Univerify.uts
uni_modules/uni-id-pages-x/lib/Univerify.uts
+116
-0
uni_modules/uni-id-pages-x/lib/servicesList.uts
uni_modules/uni-id-pages-x/lib/servicesList.uts
+100
-0
uni_modules/uni-id-pages-x/pages/login/login.uvue
uni_modules/uni-id-pages-x/pages/login/login.uvue
+23
-17
未找到文件。
manifest.json
浏览文件 @
6640f2dc
{
"name"
:
"hello uni-id-pages"
,
"appid"
:
"__UNI__
0B1B311
"
,
"appid"
:
"__UNI__
7BF095C
"
,
"description"
:
""
,
"versionName"
:
"1.0.0"
,
"versionCode"
:
"100"
,
...
...
pages/index/index.uvue
浏览文件 @
6640f2dc
...
...
@@ -12,19 +12,27 @@
<text class="list-item-text">手机验证码登录</text>
<uni-id-pages-x-icons type="right-arrow" color="#999" />
</view>
<view class="list-item" @click="toLogin('username')">
<text class="list-item-text">账号密码登录</text>
<uni-id-pages-x-icons type="right-arrow" color="#999" />
</view>
<view class="list-item" @click="toLogin('username')">
<text class="list-item-text">账号密码登录</text>
<uni-id-pages-x-icons type="right-arrow" color="#999" />
</view>
<!-- #ifdef uniVersion > 3.99 || uniVersion == 3.99 -->
<view class="list-item" @click="toLogin('univerify')" v-if="hasUniverify">
<text class="list-item-text">一键登录</text>
<uni-id-pages-x-icons type="right-arrow" color="#999" />
</view>
<!-- #endif -->
</view>
</view>
</template>
<script>
import { state } from '@/uni_modules/uni-id-pages-x/store.uts';
import { state } from '@/uni_modules/uni-id-pages-x/store.uts';
// 导入配置
import config from '@/uni_modules/uni-id-pages-x/config.uts'
export default {
computed: {
userInfo() : UTSJSONObject {
userInfo() : UTSJSONObject {
return state.userInfo
},
isLogin() : boolean {
...
...
@@ -34,20 +42,35 @@
if(this.isLogin){
let nickname = userInfo.getString("nickname")
let username = userInfo.getString("username")
let mobile = userInfo.getString("mobile")
if(nickname == null){
nickname = "";
}
if(username == null){
username = "";
}
if(mobile == null){
mobile = "";
}
if(nickname.length != 0){
return nickname
}else{
}else
if(username.length != 0)
{
return username
}else {
return mobile
}
}else{
return '未登录'
}
},
hasUniverify():boolean{
const loginTypes = config.getArray<string>('loginTypes')
if(loginTypes != null){
return loginTypes.includes('univerify');
}
return false
}
},
data() {
...
...
@@ -115,4 +138,4 @@
}
.arrow {
}
</style>
\ No newline at end of file
</style>
uni_modules/uni-id-pages-x/common/common.uts
浏览文件 @
6640f2dc
...
...
@@ -27,8 +27,8 @@ export const loginSuccess = (_ : UTSJSONObject) => {
success() {
// console.log('uniIdRouter redirectTo success');
}
})
} else
{
})
} else
if(currentPage.route == "uni_modules/uni-id-pages-x/pages/login/login") {
uni.navigateBack()
}
};
...
...
uni_modules/uni-id-pages-x/components/uni-id-pages-x-fab-login/uni-id-pages-x-fab-login.uvue
浏览文件 @
6640f2dc
...
...
@@ -16,11 +16,8 @@
import config from '@/uni_modules/uni-id-pages-x/config.uts';
import { state } from '@/uni_modules/uni-id-pages-x/store.uts';
type Services = {
id : string,
text : string,
logo : string
}
import {servicesList,Services} from '@/uni_modules/uni-id-pages-x/lib/servicesList.uts';
// console.log('servicesList',servicesList)
export default {
name: "uni-id-pages-x-fab-login",
props: {
...
...
@@ -47,145 +44,40 @@
// }
// ]
},
servicesList() : Services[] {
const servicesList = [{
"id": "username",
"text": "账号登录",
"logo": "/uni_modules/uni-id-pages-x/static/login/uni-fab-login/user.png",
},
{
"id": "smsCode",
"text": "短信验证码",
"logo": "/uni_modules/uni-id-pages-x/static/login/uni-fab-login/sms.png",
},
{
"id": "weixin",
"text": "微信登录",
"logo": "/uni_modules/uni-id-pages-x/static/login/uni-fab-login/weixin.png",
},
{
"id": "weixinMobile",
"text": "微信手机号",
"logo": "/uni_modules/uni-id-pages-x/static/login/uni-fab-login/weixin.png",
},
// #ifndef MP-WEIXIN
{
"id": "apple",
"text": "苹果登录",
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/apple.png",
},
{
"id": "univerify",
"text": "一键登录",
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/univerify.png",
},
{
"id": "taobao",
"text": "淘宝登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/taobao.png",
},
{
"id": "facebook",
"text": "脸书登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/facebook.png",
},
{
"id": "alipay",
"text": "支付宝登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/alipay.png",
},
{
"id": "qq",
"text": "QQ登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/qq.png",
},
{
"id": "google",
"text": "谷歌登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/google.png",
},
{
"id": "douyin",
"text": "抖音登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/douyin.png",
},
{
"id": "sinaweibo",
"text": "新浪微博", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/sinaweibo.png",
}
// #endif
] as Services[]
const loginTypes = config.getArray<string>('loginTypes')
return servicesList.filter((item) : boolean => {
// #ifndef APP
//非app端去掉apple登录
if (item.id == 'apple') {
return false
}
// #endif
// #ifdef APP
//去掉非ios系统上的apple登录
if (item.id == 'apple' && uni.getSystemInfoSync().osName != 'ios') {
return false
}
// #endif
// 不能是当前已经显示的登录方式 && 必须是配置了的
return item.id != this.currentLoginType && loginTypes!.includes(item.id)
})
}
servicesList():Services[]{
// 过滤当前已经显示的
return (servicesList as Services[]).filter((item:Services):boolean => item['id'] != this.currentLoginType)
}
},
data() {
return {
// univerifyStyle:
{ //一键登录弹出窗的样式配置参数
//
"fullScreen": true, // 是否全屏显示,true表示全屏模式,false表示非全屏模式,默认值为false。
//
"backgroundColor": "#ffffff", // 授权页面背景颜色,默认值:#ffffff
//
"buttons": { // 自定义登录按钮
//
"iconWidth": "45px", // 图标宽度(高度等比例缩放) 默认值:45px
// "list": []
//
},
//
"privacyTerms": {
//
"defaultCheckBoxState": false, // 条款勾选框初始状态 默认值: true
//
"textColor": "#BBBBBB", // 文字颜色 默认值:#BBBBBB
//
"termsColor": "#5496E3", // 协议文字颜色 默认值: #5496E3
//
"prefix": "我已阅读并同意", // 条款前的文案 默认值:“我已阅读并同意”
//
"suffix": "并使用本机号码登录", // 条款后的文案 默认值:“并使用本机号码登录”
//
"privacyItems": []
//
}
// }
univerifyStyle:
{ //一键登录弹出窗的样式配置参数
"fullScreen": true, // 是否全屏显示,true表示全屏模式,false表示非全屏模式,默认值为false。
"backgroundColor": "#ffffff", // 授权页面背景颜色,默认值:#ffffff
"buttons": { // 自定义登录按钮
"iconWidth": "45px", // 图标宽度(高度等比例缩放) 默认值:45px
// "list": [] as Array
},
"privacyTerms": {
"defaultCheckBoxState": false, // 条款勾选框初始状态 默认值: true
"textColor": "#BBBBBB", // 文字颜色 默认值:#BBBBBB
"termsColor": "#5496E3", // 协议文字颜色 默认值: #5496E3
"prefix": "我已阅读并同意", // 条款前的文案 默认值:“我已阅读并同意”
"suffix": "并使用本机号码登录", // 条款后的文案 默认值:“并使用本机号码登录”
//
"privacyItems": []
}
} as UTSJSONObject
}
},
watch: {
// TODO----
// agree(agree) {
// this.univerifyStyle.privacyTerms.defaultCheckBoxState = agree
// }
},
created() {
//处理一键登录
if (this.servicesList.map((i) : string => i.id).includes('univerify')) {
// console.log('处理一键登录');
// this.univerifyStyle.privacyTerms.privacyItems = this.agreements
// //设置一键登录功能底下的快捷登录按钮
// servicesList.forEach(({
// id,
// logo,
// }) => {
// if (id != 'univerify') {
// this.univerifyStyle.buttons.list.push({
// "iconPath": logo,
// "provider": id,
// })
// }
// })
agree(agree) {
this.univerifyStyle.privacyTerms.defaultCheckBoxState = agree
}
},
methods: {
changeLoginType(index : number) {
const id = this.servicesList[index].id
if (!["username", "smsCode"].includes(id)) {
if (!["username", "smsCode"
,"univerify"
].includes(id)) {
return uni.showToast({
title: 'uni-app x暂未支持此登录方式',
icon: 'none',
...
...
@@ -200,11 +92,11 @@
}
},
login_before(type : string) {
//
console.log(type);
console.log(type);
// 提示空实现
if (["qq", "xiaomi", "sinaweibo", "taobao", "facebook", "google", "alipay", "douyin"].includes(type)) {
return uni.showToast({
title: '该登录方式暂未
实现,欢迎提交pr
',
title: '该登录方式暂未
支持
',
icon: 'none',
duration: 3000
});
...
...
@@ -212,49 +104,20 @@
//检查当前环境是否支持这种登录方式
//判断是否需要弹出隐私协议授权框
const scope
= config.getAny('agreements.scope') as string[]
const scope
List = config.getArray<string>('agreements.scopeList')
// 配置中,当前类型是否需要,用户同意隐私协议
let needAgreements = scope.includes('register')
let needAgreements = scopeList!.includes('register')
// console.log('needAgreements',needAgreements)
// 排除一键登录的情况(在一键登录的弹出层中选择) && !this.agree 未同意 && 需要同意
if (type != 'univerify' && needAgreements && !state.pendingAgreements) {
return uni.showToast({
title: '你未同意隐私政策协议',
icon: 'none'
});
// console.log('
弹出
申请同意隐私协议的框');
// console.log('
晃动
申请同意隐私协议的框');
// uni.$emit("uni-id-pages-x-agreements-shake",'')
}
uni.showToast({
title: 'login_type:' + type,
icon: 'none'
});
// uni.login({
// "provider": type,
// "onlyAuthorize": true,
// // #ifdef APP
// // "univerifyStyle": this.univerifyStyle,
// // #endif
// success: async (e:any) => {
// console.log('eeeee',e);
// // if (type == 'apple') {
// // let res = await this.getUserInfo({
// // provider: "apple"
// // })
// // Object.assign(e.authResult, res.userInfo)
// // uni.hideLoading()
// // }
// // this.login(type == 'weixin' ? {
// // code: e.code
// // } : e.authResult, type)
// }
// // fail: async (err) => {
// // console.log(err);
// // uni.hideLoading()
// // }
// })
}
}
}
...
...
@@ -296,4 +159,4 @@
height: 20px;
line-height: 20px;
}
</style>
\ No newline at end of file
</style>
uni_modules/uni-id-pages-x/config.uts
浏览文件 @
6640f2dc
...
...
@@ -9,26 +9,31 @@ export default {
* 2. login登录(如:用户名密码登录,短信验证码登录)
*/
"scopeList": [
"register","login","realNameVerify"
"register","login","realNameVerify"
,"univerify"
]
},
"loginTypes":[
"username",
// #ifdef APP && ( uniVersion > 3.99 || uniVersion == 3.99)
"univerify",
// #endif
"smsCode",
"username",
// 以下登录方式 uni-app x 暂不支持
// "qq",
// "xiaomi",
// "sinaweibo",
// "taobao",
// "facebook",
// "google",
// "alipay",
// "douyin",
// "weixin",
// #ifdef APP
// "univerify",
// "apple"
// #endif
/*
"qq",
"xiaomi",
"sinaweibo",
"taobao",
"facebook",
"google",
"alipay",
"douyin",
"weixin",
// #ifdef APP
"univerify",
"apple"
// #endif
*/
],
/**
* 密码强度
...
...
uni_modules/uni-id-pages-x/init.uts
浏览文件 @
6640f2dc
...
...
@@ -14,57 +14,92 @@ const uniIdCo = uniCloud.importObject('uni-id-co', {
const loginTypes = config.getArray<string>('loginTypes');
const debug = config.getBoolean('debug') as boolean;
import Univerify from '@/uni_modules/uni-id-pages-x/lib/Univerify.uts'
export default async function () {
// 有打开调试模式的情况下
if (debug) {
// 1. 检查本地uni-id-pages中配置的登录方式,服务器端是否已经配置正确。否则提醒并引导去配置
// 调用云对象,获取服务端已正确配置的登录方式
const res = await uniIdCo.getSupportedLoginType()
let supportedLoginType = res.getArray<string>('supportedLoginType')
if(supportedLoginType == null){
supportedLoginType = []
}
// 登录方式,服务端和客户端的映射关系
const data:UTSJSONObject = {
"smsCode": 'mobile-code',
"univerify": 'univerify',
"username": 'username-password',
"weixin": 'weixin',
"qq": 'qq',
"xiaomi": 'xiaomi',
"sinaweibo": 'sinaweibo',
"taobao": 'taobao',
"facebook": 'facebook',
"google": 'google',
"alipay": 'alipay',
"apple": 'apple',
"weixinMobile": 'weixin'
};
// 遍历客户端配置的登录方式,与服务端比对。并在错误时抛出错误提示
const list = loginTypes?.filter((type:string):boolean =>{
let currentType = data.getString(type);
if(currentType == null){
currentType = ""
uniIdCo.getSupportedLoginType().then(res=>{
// console.log('7777res',res)
let supportedLoginType = res.getArray<string>('supportedLoginType')
if(supportedLoginType == null){
supportedLoginType = []
}
return !(supportedLoginType.includes(currentType))
})
if (list?.length != 0) {
console.error(
`错误:前端启用的登录方式:${list?.join(',')};没有在服务端完成配置。配置文件路径:"/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json"`
)
}
// 登录方式,服务端和客户端的映射关系
const data:UTSJSONObject = {
"smsCode": 'mobile-code',
"univerify": 'univerify',
"username": 'username-password',
"weixin": 'weixin',
"qq": 'qq',
"xiaomi": 'xiaomi',
"sinaweibo": 'sinaweibo',
"taobao": 'taobao',
"facebook": 'facebook',
"google": 'google',
"alipay": 'alipay',
"apple": 'apple',
"weixinMobile": 'weixin'
};
// 遍历客户端配置的登录方式,与服务端比对。并在错误时抛出错误提示
const list = loginTypes?.filter((type:string):boolean =>{
let currentType = data.getString(type);
if(currentType == null){
currentType = ""
}
return !(supportedLoginType.includes(currentType))
})
if (list?.length != 0) {
console.error(
`错误:前端启用的登录方式:${list?.join(',')};没有在服务端完成配置。配置文件路径:"/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json"`
)
}
})
}
// #ifdef
UNI-APP-X
// #ifdef
uniVersion > 3.99 || uniVersion == 3.99
// 如果uni-id-pages配置的登录功能有一键登录,有则执行预登录(异步)
// if (loginTypes.includes('univerify')) {
// // uni.preLogin({
// // provider: 'univerify',
// // complete: e => {
// // // console.log(e);
// // }
// // })
// }
if (loginTypes != null && loginTypes.includes('univerify')) {
const myUniverify = new Univerify()
const univerifyManager = uni.getUniverifyManager();
univerifyManager.preLogin({
success() {
console.log("pre login success");
},
fail(err : PreLoginFail) {
console.error("pre login fail => " + JSON.stringify(err));
}
} as PreLoginOptions);
uni.addInterceptor('navigateTo',{
invoke:(e:NavigateToOptions)=>{
if (e.url.indexOf("/uni_modules/uni-id-pages-x/pages/login/login") == 0) {
let url = decodeURIComponent(e.url)
let param:UTSJSONObject = {};
// 获取链接后面的参数部分
let keyValuePairs = url!.split('?')[1].split('&'); // 将参数按&分隔为键值对数组
keyValuePairs.forEach(keyValuePair => {
let [key, value] = keyValuePair.split('='); // 将键值对按等号分隔为键和值
param[key] = value;
});
let type = param["type"]
if(type == null){
type = loginTypes[0];
}
if(type == "univerify"){
myUniverify.verify(true)
throw Error('第一优先级是一键登录(且可用),就直接调用一键登录,不打开登录页面')
}
}
}
})
}
// #endif
// // 3. 绑定clientDB错误事件
...
...
uni_modules/uni-id-pages-x/lib/Univerify.uts
0 → 100644
浏览文件 @
6640f2dc
import { loginSuccess } from '@/uni_modules/uni-id-pages-x/common/common.uts';
// 导入配置
import config from '@/uni_modules/uni-id-pages-x/config.uts'
const loginTypes = config.getArray<string>('loginTypes');
// import {servicesList,Services} from '@/uni_modules/uni-id-pages-x/lib/servicesList.uts';
// type Buttons = {
// provider:string,
// iconPath:string
// }
// const buttonsList:Buttons[] = []
// servicesList.forEach(services=>{
// let buttons:Buttons = {
// "provider": "apple",
// "iconPath": "/static/apple.png" // 图标路径仅支持本地图片
// }
// buttonsList.push(buttons)
// })
// #ifdef uniVersion < 3.99
// #endif
// #ifdef uniVersion > 3.99 || uniVersion == 3.99
const univerifyManager = uni.getUniverifyManager();
export default class Univerify {
verify(fullScreen : boolean) {
// 校验预登录是否有效
const isPreLoginValid = univerifyManager.isPreLoginValid();
if (isPreLoginValid) {
// 预登录有效,执行登录
this.login(fullScreen);
} else {
// 预登录无效,执行预登录
univerifyManager.preLogin({
success() {
console.log("pre login success");
this.login(fullScreen);
},
fail(err : PreLoginFail) {
console.error("pre login fail => " + JSON.stringify(err));
// 当前页面不是登录页面时,一键登录不可用,且还存在一键登录以外的登录方式,就跳转至此登录方式
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const loginPageRoute = "uni_modules/uni-id-pages-x/pages/login/login"
if(currentPage.route === loginPageRoute){
uni.showToast({
title: err.errMsg,
icon: 'none'
});
}else{
// 获取除一键登录以外的登录方式
let otherLoginTypes = loginTypes?.filter((type:string):Boolean => type != 'univerify')
if(currentPage.route != loginPageRoute && otherLoginTypes!.length > 0){
const type = otherLoginTypes[0]
uni.navigateTo({
url: "/" + loginPageRoute + "?type=" + type,
fail(err){
console.log('err',err)
uni.showModal({
content: err.errMsg,
showCancel: false
});
},
success(){
console.warn("一键登录不可用,已自动切换登录方式,type:" + type)
}
})
}
}
}
} as PreLoginOptions);
}
}
login(fullScreen : boolean) {
univerifyManager.login({
// 登录页样式
univerifyStyle: {
fullScreen: fullScreen,
backgroundColor: "#FFFFFF",
loginBtnText: "一键登录",
logoPath: "/static/logo.png",
// buttons:{
// "iconWidth": "45px", // 图标宽度(高度等比例缩放) 默认值:45px
// "list":buttonsList
// }
} as UniverifyStyle,
success(res : LoginSuccess) {
console.log("login success => " + JSON.stringify(res));
// 云函数取号
const uniIdCo = uniCloud.importObject("uni-id-co")
uniIdCo.loginByUniverify({
access_token: res.accessToken, // 客户端一键登录接口返回的access_token
openid: res.openId // 客户端一键登录接口返回的openid
}).then(res => {
console.log('res',res)
loginSuccess(res)
univerifyManager.close();
}).catch(err => {
console.error(JSON.stringify(err));
// 关闭登录页
univerifyManager.close();
});
},
fail(err : LoginFail) {
console.error("login fail => " + err);
// uni.showToast({
// title: "登录失败",
// icon: "error"
// });
}
} as LoginOptions);
}
}
// #endif
uni_modules/uni-id-pages-x/lib/servicesList.uts
0 → 100644
浏览文件 @
6640f2dc
import config from '@/uni_modules/uni-id-pages-x/config.uts';
type Services = {
id : string,
text : string,
logo : string
}
let servicesList = [{
"id": "username",
"text": "账号登录",
"logo": "/uni_modules/uni-id-pages-x/static/login/uni-fab-login/user.png",
},
{
"id": "smsCode",
"text": "短信验证码",
"logo": "/uni_modules/uni-id-pages-x/static/login/uni-fab-login/sms.png",
},
{
"id": "weixin",
"text": "微信登录",
"logo": "/uni_modules/uni-id-pages-x/static/login/uni-fab-login/weixin.png",
},
{
"id": "weixinMobile",
"text": "微信手机号",
"logo": "/uni_modules/uni-id-pages-x/static/login/uni-fab-login/weixin.png",
},
// #ifndef MP-WEIXIN
{
"id": "apple",
"text": "苹果登录",
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/apple.png",
},
{
"id": "univerify",
"text": "一键登录",
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/univerify.png",
},
{
"id": "taobao",
"text": "淘宝登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/taobao.png",
},
{
"id": "facebook",
"text": "脸书登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/facebook.png",
},
{
"id": "alipay",
"text": "支付宝登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/alipay.png",
},
{
"id": "qq",
"text": "QQ登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/qq.png",
},
{
"id": "google",
"text": "谷歌登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/google.png",
},
{
"id": "douyin",
"text": "抖音登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/douyin.png",
},
{
"id": "sinaweibo",
"text": "新浪微博", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages-x/static/app/uni-fab-login/sinaweibo.png",
}
// #endif
] as Services[]
const loginTypes = config.getArray<string>('loginTypes')
servicesList = servicesList.filter((item) : boolean => {
// #ifndef APP
//非app端去掉apple登录
if (item.id == 'apple') {
return false
}
// #endif
// #ifdef APP
//去掉非ios系统上的apple登录
if (item.id == 'apple' && uni.getSystemInfoSync().osName != 'ios') {
return false
}
// #endif
// 必须是配置了的
return loginTypes!.includes(item.id)
})
export {servicesList,Services}
uni_modules/uni-id-pages-x/pages/login/login.uvue
浏览文件 @
6640f2dc
...
...
@@ -21,7 +21,7 @@
<uni-id-pages-x-loginByPwd v-if="loginType == 'username'" />
<!-- 手机号验证码登录 -->
<uni-id-pages-x-loginBySmsCode v-if="loginType == 'smsCode'" />
<uni-id-pages-x-loginBySmsCode v-
else-
if="loginType == 'smsCode'" />
<!-- 固定定位的快捷登录按钮 -->
<uni-id-pages-x-fab-login :currentLoginType="loginType"
...
...
@@ -33,7 +33,8 @@
<script>
import { state } from '@/uni_modules/uni-id-pages-x/store.uts';
import config from '@/uni_modules/uni-id-pages-x/config.uts';
export default {
import Univerify from '@/uni_modules/uni-id-pages-x/lib/Univerify.uts'
export default {
computed: {
//大快捷登录按钮图
imgSrc() : string {
...
...
@@ -50,23 +51,28 @@
}
},
onLoad(param) {
const type = param["type"]
// 如果传递了参数就按参数指定的登录方式,否则指定为 config 中配置的第一项
if (type != null) {
this.loginType = type
} else {
let loginTypes = config.getArray<string>("loginTypes");
this.loginType = loginTypes![0];
}
let type = param["type"]
if (type === null){
let loginTypes = config.getArray<string>("loginTypes");
type = loginTypes![0];
}
console.log('type:',type)
this.loginType = type
},
methods: {
login() {
},
login(){},
verify(){
// #ifdef uniVersion > 3.99 || uniVersion == 3.99
const univerifyManager = new Univerify()
univerifyManager.verify(true)
// #endif
},
changeLoginType(type : string) {
// if (["weixin", "apple", "univerify"].includes(type)) {
// }
this.loginType = type
if ( type === "univerify" ) {
this.verify()
}else{
this.loginType = type
}
}
}
}
...
...
@@ -90,4 +96,4 @@
height: 60px;
width: 700rpx;
}
</style>
\ No newline at end of file
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录