Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-id-pages-x
提交
6e730d49
H
hello uni-id-pages-x
项目概览
DCloud
/
hello uni-id-pages-x
通知
43
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看板
提交
6e730d49
编写于
1月 27, 2024
作者:
A
Anne_LXM
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 兼容uni-app-x web端
上级
47537094
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
156 addition
and
155 deletion
+156
-155
pages/index/index.uvue
pages/index/index.uvue
+119
-129
uni_modules/uni-id-pages-x/init.uts
uni_modules/uni-id-pages-x/init.uts
+28
-13
uni_modules/uni-id-pages-x/pages/userinfo/realnameAuth/realnameAuth.uvue
...-id-pages-x/pages/userinfo/realnameAuth/realnameAuth.uvue
+3
-2
uni_modules/uni-id-pages-x/pages/userinfo/userinfo.uvue
uni_modules/uni-id-pages-x/pages/userinfo/userinfo.uvue
+6
-11
未找到文件。
pages/index/index.uvue
浏览文件 @
6e730d49
<template>
<view class="content">
<view class="userinfo" @click="toUserInfoPage">
<uni-id-pages-x-avatar class="avatar" ref="avatar" width="45px" height="45px" :readOnly="true" :border="false"></uni-id-pages-x-avatar>
<view class="openName">
<text class="openName-text">{{openName}}</text>
</view>
<view class="content">
<view class="userinfo" @click="toUserInfoPage">
<uni-id-pages-x-avatar class="avatar" ref="avatar" width="45px" height="45px" :readOnly="true"
:border="false"></uni-id-pages-x-avatar>
<view class="openName">
<text class="openName-text">{{openName}}</text>
</view>
<uni-id-pages-x-icons type="right-arrow" color="#999" />
</view>
<view class="list">
<view class="list-item" hover-class="list-active" @click="toLogin('smsCode')">
<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>
</view>
<view class="list">
<view class="list-item" hover-class="list-active" @click="toLogin('smsCode')">
<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>
</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 {
return state.userInfo
},
isLogin() : boolean {
return state.isLogin
},
openName():string{
if(this.isLogin){
let nickname = this.userInfo.getString("nickname")
let username = this.userInfo.getString("username")
let mobile = this.userInfo.getString("mobile")
if(nickname == null){
nickname = "";
}
if(username == null){
username = "";
}
if(mobile == null){
mobile = "";
}
if(nickname.length != 0){
return nickname
}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
export default {
computed: {
userInfo() : UTSJSONObject {
return state.userInfo
},
isLogin() : boolean {
return state.isLogin
},
openName() : string {
if (this.isLogin) {
let nickname = this.userInfo["nickname"] as string | null
let username = this.userInfo["username"] as string | null
let mobile = this.userInfo["mobile"] as string | null
if (nickname == null) {
nickname = "";
}
if (username == null) {
username = "";
}
if (mobile == null) {
mobile = "";
}
if (nickname.length != 0) {
return nickname
} 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() {
return {}
},
onLoad() {
},
methods: {
toLogin(loginType:
string) {
uni.navigateTo({
url: "/uni_modules/uni-id-pages-x/pages/login/login?type=" + loginType
})
},
toUserInfoPage() {
uni.navigateTo({
url: "/uni_modules/uni-id-pages-x/pages/userinfo/userinfo?showLoginManage=true"
})
},
}
}
},
data() {
return {}
},
onLoad() {
},
methods: {
toLogin(loginType :
string) {
uni.navigateTo({
url: "/uni_modules/uni-id-pages-x/pages/login/login?type=" + loginType
})
},
toUserInfoPage() {
uni.navigateTo({
url: "/uni_modules/uni-id-pages-x/pages/userinfo/userinfo?showLoginManage=true"
})
},
}
}
</script>
<style lang="scss">
.content {
height: 100%;
background-color: #f5f5f5;
}
.userinfo {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 15px;
// padding-bottom: 30px;
background-color: #fff;
.openName {
flex: 1;
padding: 0 10px;
.openName-text {
font-size: 14px;
color: #333;
}
}
}
.list {
background-color: #fff;
margin-top: 15px;
.list-item {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 0 15px;
height: 50px;
border-bottom: 1px #f5f5f5 solid;
.list-item-text {
font-size: 14px;
}
}
}
.arrow {
}
.content {
height: 100%;
background-color: #f5f5f5;
}
.userinfo {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 15px;
background-color: #fff;
.openName {
flex: 1;
padding: 0 10px;
.openName-text {
font-size: 14px;
color: #333;
}
}
}
.list {
background-color: #fff;
margin-top: 15px;
.list-item {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 0 15px;
height: 50px;
border-bottom: 1px #f5f5f5 solid;
.list-item-text {
font-size: 14px;
}
}
}
</style>
uni_modules/uni-id-pages-x/init.uts
浏览文件 @
6e730d49
...
...
@@ -3,7 +3,6 @@
// 导入配置
import config from '@/uni_modules/uni-id-pages-x/config.uts'
import {state} from '@/uni_modules/uni-id-pages-x/store.uts';
// uni-id的云对象
...
...
@@ -11,7 +10,9 @@ const uniIdCo = uniCloud.importObject('uni-id-co', {
customUI: true
})
// 用户配置的登录方式、是否打开调试模式
const loginTypes = config.getArray<string>('loginTypes');
const configLoginTypes = config.getArray<string>('loginTypes');
const loginTypes = configLoginTypes == null ? [] as string[] : configLoginTypes;
const debug = config.getBoolean('debug') as boolean;
// #ifdef APP && ( uniVersion > 3.99 || uniVersion == 3.99)
...
...
@@ -27,7 +28,7 @@ export default async function () {
uniIdCo.getSupportedLoginType().then((res:UTSJSONObject)=>{
// console.log('7777res',res)
let supportedLoginType = res.getArray<string>('supportedLoginType')
console.log('supportedLoginType: ',supportedLoginType);
//
console.log('supportedLoginType: ',supportedLoginType);
if(supportedLoginType == null){
supportedLoginType = []
}
...
...
@@ -47,17 +48,31 @@ export default async function () {
"weixinMobile": 'weixin'
};
// 遍历客户端配置的登录方式,与服务端比对。并在错误时抛出错误提示
const list = loginTypes?.filter((type:string):boolean =>type != 'smsCode')
?.filter((type:string):boolean =>{
let currentType = data.getString(type);
if(currentType == null){
currentType = ""
// const list = loginTypes?.filter((type:string):boolean =>type != 'smsCode')
// ?.filter((type:string):boolean =>{
// let currentType = data.getString(type);
// if(currentType == null){
// currentType = ""
// }
// return supportedLoginType?.includes(currentType) != true
// })
const list:Array<string> = [];
console.log('loginTypes: ',loginTypes);
for (let i = 0; i < loginTypes.length; i++) {
const type = loginTypes[i];
if (type != 'smsCode') {
let currentType = data.getString(type);
if (currentType === null) {
currentType = '';
}
if (!supportedLoginType.includes(currentType)) {
list.push(type);
}
}
return supportedLoginType?.includes(currentType) != true
})
if (list?.length != 0) {
}
if (list.length != 0) {
console.error(
`错误:前端启用的登录方式:${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"`
)
}
})
...
...
@@ -65,7 +80,7 @@ export default async function () {
// #ifdef APP
// 如果uni-id-pages配置的登录功能有一键登录,有则执行预登录(异步)
if (loginTypes
!= null && loginTypes
.includes('univerify')) {
if (loginTypes.includes('univerify')) {
const myUniverify = new Univerify()
const univerifyManager = uni.getUniverifyManager();
univerifyManager.preLogin({
...
...
uni_modules/uni-id-pages-x/pages/userinfo/realnameAuth/realnameAuth.uvue
浏览文件 @
6e730d49
...
...
@@ -222,9 +222,10 @@
uni.removeStorage({
key: tempFrvInfoKey
})
} catch (e: UniCloudError) {
} catch (e: Error) {
const error = e as UniCloudError
this.verifyFail = true
this.verifyFailTitle = e.errMsg
this.verifyFailTitle = e
rror
.errMsg
console.error(JSON.stringify(e))
}
uni.hideLoading()
...
...
uni_modules/uni-id-pages-x/pages/userinfo/userinfo.uvue
浏览文件 @
6e730d49
...
...
@@ -58,12 +58,13 @@
</template>
<script>
import {state
, mutations
} from '@/uni_modules/uni-id-pages-x/store.uts';
import {state} from '@/uni_modules/uni-id-pages-x/store.uts';
import {logout} from '@/uni_modules/uni-id-pages-x/common/common.uts';
export default {
data() {
return {}
return {
showLoginManage: true
}
},
computed: {
userInfo(): UTSJSONObject {
...
...
@@ -75,19 +76,14 @@
realNameStatus (): number {
const realNameAuth = this.userInfo.getJSON('realNameInfo')
const authStatus = realNameAuth?.getNumber('authStatus')
if (realNameAuth == null || authStatus == null) {
return 0
}
return authStatus as number
}
},
props: {
showLoginManage: {
type: Boolean,
default: true
}
onLoad(options){
this.showLoginManage = options['showLoginManage'] == 'true'
},
methods: {
setNickname() {
...
...
@@ -130,7 +126,6 @@
}
}
</script>
<style>
.uni-content {
width: 750rpx;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录