提交 e71ce7df 编写于 作者: DCloud_JSON's avatar DCloud_JSON

新增 一键登录

上级 6b32420a
{ {
"name" : "hello uni-id-pages", "name" : "hello uni-id-pages",
"appid" : "__UNI__0B1B311", "appid" : "__UNI__7BF095C",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
"versionCode" : "100", "versionCode" : "100",
......
...@@ -16,12 +16,20 @@ ...@@ -16,12 +16,20 @@
<text class="list-item-text">账号密码登录</text> <text class="list-item-text">账号密码登录</text>
<uni-id-pages-x-icons type="right-arrow" color="#999" /> <uni-id-pages-x-icons type="right-arrow" color="#999" />
</view> </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>
</view> </view>
</template> </template>
<script> <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 { export default {
computed: { computed: {
userInfo() : UTSJSONObject { userInfo() : UTSJSONObject {
...@@ -34,20 +42,35 @@ ...@@ -34,20 +42,35 @@
if(this.isLogin){ if(this.isLogin){
let nickname = userInfo.getString("nickname") let nickname = userInfo.getString("nickname")
let username = userInfo.getString("username") let username = userInfo.getString("username")
let mobile = userInfo.getString("mobile")
if(nickname == null){ if(nickname == null){
nickname = ""; nickname = "";
} }
if(username == null){ if(username == null){
username = ""; username = "";
} }
if(mobile == null){
mobile = "";
}
if(nickname.length != 0){ if(nickname.length != 0){
return nickname return nickname
}else{ }else if(username.length != 0){
return username return username
}else {
return mobile
} }
}else{ }else{
return '未登录' return '未登录'
} }
},
hasUniverify():boolean{
const loginTypes = config.getArray<string>('loginTypes')
if(loginTypes != null){
return loginTypes.includes('univerify');
}
return false
} }
}, },
data() { data() {
......
...@@ -28,7 +28,7 @@ export const loginSuccess = (_ : UTSJSONObject) => { ...@@ -28,7 +28,7 @@ export const loginSuccess = (_ : UTSJSONObject) => {
// console.log('uniIdRouter redirectTo success'); // console.log('uniIdRouter redirectTo success');
} }
}) })
} else { } else if(currentPage.route == "uni_modules/uni-id-pages-x/pages/login/login") {
uni.navigateBack() uni.navigateBack()
} }
}; };
......
...@@ -16,11 +16,8 @@ ...@@ -16,11 +16,8 @@
import config from '@/uni_modules/uni-id-pages-x/config.uts'; import config from '@/uni_modules/uni-id-pages-x/config.uts';
import { state } from '@/uni_modules/uni-id-pages-x/store.uts'; import { state } from '@/uni_modules/uni-id-pages-x/store.uts';
type Services = { import {servicesList,Services} from '@/uni_modules/uni-id-pages-x/lib/servicesList.uts';
id : string, // console.log('servicesList',servicesList)
text : string,
logo : string
}
export default { export default {
name: "uni-id-pages-x-fab-login", name: "uni-id-pages-x-fab-login",
props: { props: {
...@@ -47,145 +44,40 @@ ...@@ -47,145 +44,40 @@
// } // }
// ] // ]
}, },
servicesList() : Services[] { servicesList():Services[]{
const servicesList = [{ // 过滤当前已经显示的
"id": "username", return (servicesList as Services[]).filter((item:Services):boolean => item['id'] != this.currentLoginType)
"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)
})
} }
}, },
data() { data() {
return { return {
// univerifyStyle: { //一键登录弹出窗的样式配置参数 univerifyStyle:{ //一键登录弹出窗的样式配置参数
// "fullScreen": true, // 是否全屏显示,true表示全屏模式,false表示非全屏模式,默认值为false。 "fullScreen": true, // 是否全屏显示,true表示全屏模式,false表示非全屏模式,默认值为false。
// "backgroundColor": "#ffffff", // 授权页面背景颜色,默认值:#ffffff "backgroundColor": "#ffffff", // 授权页面背景颜色,默认值:#ffffff
// "buttons": { // 自定义登录按钮 "buttons": { // 自定义登录按钮
// "iconWidth": "45px", // 图标宽度(高度等比例缩放) 默认值:45px "iconWidth": "45px", // 图标宽度(高度等比例缩放) 默认值:45px
// "list": [] // "list": [] as Array
// }, },
// "privacyTerms": { "privacyTerms": {
// "defaultCheckBoxState": false, // 条款勾选框初始状态 默认值: true "defaultCheckBoxState": false, // 条款勾选框初始状态 默认值: true
// "textColor": "#BBBBBB", // 文字颜色 默认值:#BBBBBB "textColor": "#BBBBBB", // 文字颜色 默认值:#BBBBBB
// "termsColor": "#5496E3", // 协议文字颜色 默认值: #5496E3 "termsColor": "#5496E3", // 协议文字颜色 默认值: #5496E3
// "prefix": "我已阅读并同意", // 条款前的文案 默认值:“我已阅读并同意” "prefix": "我已阅读并同意", // 条款前的文案 默认值:“我已阅读并同意”
// "suffix": "并使用本机号码登录", // 条款后的文案 默认值:“并使用本机号码登录” "suffix": "并使用本机号码登录", // 条款后的文案 默认值:“并使用本机号码登录”
// "privacyItems": [] // "privacyItems": []
// } }
// } } as UTSJSONObject
} }
}, },
watch: { watch: {
// TODO---- agree(agree) {
// agree(agree) { this.univerifyStyle.privacyTerms.defaultCheckBoxState = 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,
// })
// }
// })
} }
}, },
methods: { methods: {
changeLoginType(index : number) { changeLoginType(index : number) {
const id = this.servicesList[index].id const id = this.servicesList[index].id
if (!["username", "smsCode"].includes(id)) { if (!["username", "smsCode","univerify"].includes(id)) {
return uni.showToast({ return uni.showToast({
title: 'uni-app x暂未支持此登录方式', title: 'uni-app x暂未支持此登录方式',
icon: 'none', icon: 'none',
...@@ -200,11 +92,11 @@ ...@@ -200,11 +92,11 @@
} }
}, },
login_before(type : string) { login_before(type : string) {
// console.log(type); console.log(type);
// 提示空实现 // 提示空实现
if (["qq", "xiaomi", "sinaweibo", "taobao", "facebook", "google", "alipay", "douyin"].includes(type)) { if (["qq", "xiaomi", "sinaweibo", "taobao", "facebook", "google", "alipay", "douyin"].includes(type)) {
return uni.showToast({ return uni.showToast({
title: '该登录方式暂未实现,欢迎提交pr', title: '该登录方式暂未支持',
icon: 'none', icon: 'none',
duration: 3000 duration: 3000
}); });
...@@ -212,49 +104,20 @@ ...@@ -212,49 +104,20 @@
//检查当前环境是否支持这种登录方式 //检查当前环境是否支持这种登录方式
//判断是否需要弹出隐私协议授权框 //判断是否需要弹出隐私协议授权框
const scope = config.getAny('agreements.scope') as string[] const scopeList = config.getArray<string>('agreements.scopeList')
// 配置中,当前类型是否需要,用户同意隐私协议 // 配置中,当前类型是否需要,用户同意隐私协议
let needAgreements = scope.includes('register') let needAgreements = scopeList!.includes('register')
// console.log('needAgreements',needAgreements)
// 排除一键登录的情况(在一键登录的弹出层中选择) && !this.agree 未同意 && 需要同意 // 排除一键登录的情况(在一键登录的弹出层中选择) && !this.agree 未同意 && 需要同意
if (type != 'univerify' && needAgreements && !state.pendingAgreements) { if (type != 'univerify' && needAgreements && !state.pendingAgreements) {
return uni.showToast({ return uni.showToast({
title: '你未同意隐私政策协议', title: '你未同意隐私政策协议',
icon: 'none' icon: 'none'
}); });
// console.log('弹出申请同意隐私协议的框'); // console.log('晃动申请同意隐私协议的框');
// uni.$emit("uni-id-pages-x-agreements-shake",'') // 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()
// // }
// })
} }
} }
} }
......
...@@ -9,26 +9,31 @@ export default { ...@@ -9,26 +9,31 @@ export default {
* 2. login登录(如:用户名密码登录,短信验证码登录) * 2. login登录(如:用户名密码登录,短信验证码登录)
*/ */
"scopeList": [ "scopeList": [
"register","login","realNameVerify" "register","login","realNameVerify","univerify"
] ]
}, },
"loginTypes":[ "loginTypes":[
"username", // #ifdef APP && ( uniVersion > 3.99 || uniVersion == 3.99)
"univerify",
// #endif
"smsCode", "smsCode",
"username",
// 以下登录方式 uni-app x 暂不支持 // 以下登录方式 uni-app x 暂不支持
// "qq", /*
// "xiaomi", "qq",
// "sinaweibo", "xiaomi",
// "taobao", "sinaweibo",
// "facebook", "taobao",
// "google", "facebook",
// "alipay", "google",
// "douyin", "alipay",
// "weixin", "douyin",
"weixin",
// #ifdef APP // #ifdef APP
// "univerify", "univerify",
// "apple" "apple"
// #endif // #endif
*/
], ],
/** /**
* 密码强度 * 密码强度
......
...@@ -14,12 +14,15 @@ const uniIdCo = uniCloud.importObject('uni-id-co', { ...@@ -14,12 +14,15 @@ const uniIdCo = uniCloud.importObject('uni-id-co', {
const loginTypes = config.getArray<string>('loginTypes'); const loginTypes = config.getArray<string>('loginTypes');
const debug = config.getBoolean('debug') as boolean; const debug = config.getBoolean('debug') as boolean;
import Univerify from '@/uni_modules/uni-id-pages-x/lib/Univerify.uts'
export default async function () { export default async function () {
// 有打开调试模式的情况下 // 有打开调试模式的情况下
if (debug) { if (debug) {
// 1. 检查本地uni-id-pages中配置的登录方式,服务器端是否已经配置正确。否则提醒并引导去配置 // 1. 检查本地uni-id-pages中配置的登录方式,服务器端是否已经配置正确。否则提醒并引导去配置
// 调用云对象,获取服务端已正确配置的登录方式 // 调用云对象,获取服务端已正确配置的登录方式
const res = await uniIdCo.getSupportedLoginType() uniIdCo.getSupportedLoginType().then(res=>{
// console.log('7777res',res)
let supportedLoginType = res.getArray<string>('supportedLoginType') let supportedLoginType = res.getArray<string>('supportedLoginType')
if(supportedLoginType == null){ if(supportedLoginType == null){
supportedLoginType = [] supportedLoginType = []
...@@ -53,18 +56,50 @@ export default async function () { ...@@ -53,18 +56,50 @@ export default async function () {
`错误:前端启用的登录方式:${list?.join(',')};没有在服务端完成配置。配置文件路径:"/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json"` `错误:前端启用的登录方式:${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配置的登录功能有一键登录,有则执行预登录(异步) // 如果uni-id-pages配置的登录功能有一键登录,有则执行预登录(异步)
// if (loginTypes.includes('univerify')) { if (loginTypes != null && loginTypes.includes('univerify')) {
// // uni.preLogin({ const myUniverify = new Univerify()
// // provider: 'univerify', const univerifyManager = uni.getUniverifyManager();
// // complete: e => { univerifyManager.preLogin({
// // // console.log(e); 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 // #endif
// // 3. 绑定clientDB错误事件 // // 3. 绑定clientDB错误事件
......
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
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}
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<uni-id-pages-x-loginByPwd v-if="loginType == 'username'" /> <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" <uni-id-pages-x-fab-login :currentLoginType="loginType"
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
<script> <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'; import config from '@/uni_modules/uni-id-pages-x/config.uts';
import Univerify from '@/uni_modules/uni-id-pages-x/lib/Univerify.uts'
export default { export default {
computed: { computed: {
//大快捷登录按钮图 //大快捷登录按钮图
...@@ -50,26 +51,31 @@ ...@@ -50,26 +51,31 @@
} }
}, },
onLoad(param) { onLoad(param) {
const type = param["type"] let type = param["type"]
// 如果传递了参数就按参数指定的登录方式,否则指定为 config 中配置的第一项 if (type === null){
if (type != null) {
this.loginType = type
} else {
let loginTypes = config.getArray<string>("loginTypes"); let loginTypes = config.getArray<string>("loginTypes");
this.loginType = loginTypes![0]; type = loginTypes![0];
} }
console.log('type:',type)
this.loginType = type
}, },
methods: { methods: {
login() { login(){},
verify(){
// #ifdef uniVersion > 3.99 || uniVersion == 3.99
const univerifyManager = new Univerify()
univerifyManager.verify(true)
// #endif
}, },
changeLoginType(type : string) { changeLoginType(type : string) {
// if (["weixin", "apple", "univerify"].includes(type)) { if ( type === "univerify" ) {
// } this.verify()
}else{
this.loginType = type this.loginType = type
} }
} }
} }
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册