Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello_uni-id-pages
提交
b85bb423
H
hello_uni-id-pages
项目概览
DCloud
/
hello_uni-id-pages
通知
1054
Star
31
Fork
43
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
2
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello_uni-id-pages
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
b85bb423
编写于
9月 14, 2022
作者:
C
chenruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加 clientType 区分普通用户还是管理员
上级
8d446f05
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
259 addition
and
56 deletion
+259
-56
uni_modules/uni-id-pages/common/login-page.mixin.js
uni_modules/uni-id-pages/common/login-page.mixin.js
+31
-20
uni_modules/uni-id-pages/common/loginSuccess.js
uni_modules/uni-id-pages/common/loginSuccess.js
+26
-13
uni_modules/uni-id-pages/config.js
uni_modules/uni-id-pages/config.js
+10
-9
uni_modules/uni-id-pages/pages/login/login-withpwd.vue
uni_modules/uni-id-pages/pages/login/login-withpwd.vue
+13
-14
uni_modules/uni-id-pages/pages/register/register-admin.vue
uni_modules/uni-id-pages/pages/register/register-admin.vue
+179
-0
未找到文件。
uni_modules/uni-id-pages/common/login-page.mixin.js
浏览文件 @
b85bb423
...
@@ -4,6 +4,7 @@ let mixin = {
...
@@ -4,6 +4,7 @@ let mixin = {
data
()
{
data
()
{
return
{
return
{
config
,
config
,
redirect
:
''
,
isMounted
:
false
isMounted
:
false
}
}
},
},
...
@@ -38,6 +39,10 @@ let mixin = {
...
@@ -38,6 +39,10 @@ let mixin = {
},
'
weixin
'
)
},
'
weixin
'
)
})
})
}
}
if
(
e
.
redirect
)
{
this
.
redirect
=
e
.
redirect
}
},
},
computed
:
{
computed
:
{
needAgreements
()
{
needAgreements
()
{
...
@@ -66,11 +71,17 @@ let mixin = {
...
@@ -66,11 +71,17 @@ let mixin = {
console
.
log
(
'
不存在 隐私政策协议组件
'
);
console
.
log
(
'
不存在 隐私政策协议组件
'
);
}
}
}
}
},
isAdmin
()
{
return
config
.
clientType
===
"
admin
"
}
}
},
},
methods
:
{
methods
:
{
loginSuccess
(
e
)
{
loginSuccess
(
e
)
{
loginSuccess
(
e
)
loginSuccess
({
...
e
,
redirect
:
this
.
redirect
})
}
}
}
}
}
}
...
...
uni_modules/uni-id-pages/common/loginSuccess.js
浏览文件 @
b85bb423
import
pagesJson
from
'
@/pages.json
'
export
default
function
(
e
=
{})
{
export
default
function
(
e
=
{})
{
const
{
const
{
showToast
=
true
,
toastText
=
'
登录成功
'
,
autoBack
=
true
showToast
=
true
,
toastText
=
'
登录成功
'
,
autoBack
=
true
,
redirect
=
''
}
=
e
}
=
e
console
.
log
({
console
.
log
({
toastText
,
toastText
,
...
@@ -24,10 +26,21 @@ export default function(e = {}) {
...
@@ -24,10 +26,21 @@ export default function(e = {}) {
})
})
console
.
log
(
'
判断需要返回几层:
'
,
pages
,
delta
);
console
.
log
(
'
判断需要返回几层:
'
,
pages
,
delta
);
// #ifdef H5
// #ifdef H5
if
(
redirect
)
{
return
uni
.
reLaunch
({
url
:
redirect
})
}
if
(
e
.
loginType
==
'
weixin
'
){
if
(
e
.
loginType
==
'
weixin
'
){
console
.
log
(
'
window.history
'
,
window
.
history
);
console
.
log
(
'
window.history
'
,
window
.
history
);
return
window
.
history
.
go
(
-
3
)
return
window
.
history
.
go
(
-
3
)
}
}
if
(
delta
)
{
const
page
=
pagesJson
.
pages
[
0
]
return
uni
.
reLaunch
({
url
:
`/
${
page
.
path
}
`
})
}
// #endif
// #endif
uni
.
navigateBack
({
uni
.
navigateBack
({
...
...
uni_modules/uni-id-pages/config.js
浏览文件 @
b85bb423
...
@@ -5,6 +5,7 @@ export default {
...
@@ -5,6 +5,7 @@ export default {
登录类型 未列举到的或运行环境不支持的,将被自动隐藏。
登录类型 未列举到的或运行环境不支持的,将被自动隐藏。
如果需要在不同平台有不同的配置,直接用条件编译即可
如果需要在不同平台有不同的配置,直接用条件编译即可
*/
*/
"
clientType
"
:
"
user
"
,
// 客户端类型 user 普通用户,admin 管理员
"
loginTypes
"
:
[
"
loginTypes
"
:
[
// "qq",
// "qq",
// "xiaomi",
// "xiaomi",
...
...
uni_modules/uni-id-pages/pages/login/login-withpwd.vue
浏览文件 @
b85bb423
...
@@ -21,11 +21,11 @@
...
@@ -21,11 +21,11 @@
<button
class=
"uni-btn"
type=
"primary"
@
click=
"pwdLogin"
>
登录
</button>
<button
class=
"uni-btn"
type=
"primary"
@
click=
"pwdLogin"
>
登录
</button>
<!-- 忘记密码 -->
<!-- 忘记密码 -->
<view
class=
"link-box"
>
<view
class=
"link-box"
>
<view>
<view
v-if=
"!isAdmin"
>
<text
class=
"forget"
>
忘记了?
</text>
<text
class=
"forget"
>
忘记了?
</text>
<text
class=
"link"
@
click=
"toRetrievePwd"
>
找回密码
</text>
<text
class=
"link"
@
click=
"toRetrievePwd"
>
找回密码
</text>
</view>
</view>
<text
class=
"link"
@
click=
"toRegister"
>
注册账号
</text>
<text
class=
"link"
@
click=
"toRegister"
>
{{
isAdmin
?
'
注册管理员账号
'
:
'
注册账号
'
}}
</text>
</view>
</view>
<!-- 悬浮登录方式组件 -->
<!-- 悬浮登录方式组件 -->
<uni-id-pages-fab-login
ref=
"uniFabLogin"
></uni-id-pages-fab-login>
<uni-id-pages-fab-login
ref=
"uniFabLogin"
></uni-id-pages-fab-login>
...
@@ -129,10 +129,9 @@
...
@@ -129,10 +129,9 @@
})
})
},
},
/* 前往注册 */
/* 前往注册 */
toRegister
(
e
)
{
toRegister
()
{
console
.
log
(
e
);
uni
.
navigateTo
({
uni
.
navigateTo
({
url
:
'
/uni_modules/uni-id-pages/pages/register/register
'
url
:
this
.
isAdmin
?
'
/uni_modules/uni-id-pages/pages/register/register-admin
'
:
'
/uni_modules/uni-id-pages/pages/register/register
'
})
})
}
}
}
}
...
...
uni_modules/uni-id-pages/pages/register/register-admin.vue
0 → 100644
浏览文件 @
b85bb423
<!-- 创建超级管理员 -->
<
template
>
<view
class=
"uni-content"
>
<match-media
:min-width=
"690"
>
<view
class=
"login-logo"
>
<image
:src=
"logo"
></image>
</view>
<!-- 顶部文字 -->
<text
class=
"title title-box"
>
创建超级管理员
</text>
</match-media>
<uni-forms
ref=
"form"
:value=
"formData"
:rules=
"rules"
validate-trigger=
"submit"
err-show-type=
"toast"
>
<uni-forms-item
name=
"username"
required
>
<uni-easyinput
:inputBorder=
"false"
:focus=
"focusUsername"
@
blur=
"focusUsername = false"
class=
"input-box"
placeholder=
"请输入用户名"
v-model=
"formData.username"
trim=
"both"
/>
</uni-forms-item>
<uni-forms-item
name=
"nickname"
>
<uni-easyinput
:inputBorder=
"false"
:focus=
"focusNickname"
@
blur=
"focusNickname = false"
class=
"input-box"
placeholder=
"请输入用户昵称"
v-model=
"formData.nickname"
trim=
"both"
/>
</uni-forms-item>
<uni-forms-item
name=
"password"
v-model=
"formData.password"
required
>
<uni-easyinput
:inputBorder=
"false"
:focus=
"focusPassword"
@
blur=
"focusPassword = false"
class=
"input-box"
maxlength=
"20"
:placeholder=
"'请输入' + (config.passwordStrength == 'weak'?'6':'8') + '-16位密码'"
type=
"password"
v-model=
"formData.password"
trim=
"both"
/>
</uni-forms-item>
<uni-forms-item
name=
"password2"
v-model=
"formData.password2"
required
>
<uni-easyinput
:inputBorder=
"false"
:focus=
"focusPassword2"
@
blur=
"focusPassword2 =false"
class=
"input-box"
placeholder=
"再次输入密码"
maxlength=
"20"
type=
"password"
v-model=
"formData.password2"
trim=
"both"
/>
</uni-forms-item>
<uni-forms-item>
<uni-captcha
ref=
"captcha"
scene=
"register"
v-model=
"formData.captcha"
/>
</uni-forms-item>
<uni-id-pages-agreements
scope=
"register"
ref=
"agreements"
></uni-id-pages-agreements>
<button
class=
"uni-btn"
type=
"primary"
@
click=
"submit"
>
注册
</button>
<button
@
click=
"navigateBack"
class=
"register-back"
>
返回
</button>
<match-media
:min-width=
"690"
>
<view
class=
"link-box"
>
<text
class=
"link"
@
click=
"toLogin"
>
已有账号?点此登录
</text>
</view>
</match-media>
</uni-forms>
</view>
</
template
>
<
script
>
import
rules
from
'
./validator.js
'
;
import
mixin
from
'
@/uni_modules/uni-id-pages/common/login-page.mixin.js
'
;
import
config
from
'
@/uni_modules/uni-id-pages/config.js
'
const
uniIdCo
=
uniCloud
.
importObject
(
"
uni-id-co
"
,
{
customUI
:
true
})
export
default
{
mixins
:
[
mixin
],
data
()
{
return
{
formData
:
{
username
:
""
,
nickname
:
""
,
password
:
""
,
password2
:
""
,
captcha
:
""
},
rules
,
focusUsername
:
false
,
focusNickname
:
false
,
focusPassword
:
false
,
focusPassword2
:
false
,
logo
:
"
/static/logo.png
"
}
},
onReady
()
{
this
.
$refs
.
form
.
setRules
(
this
.
rules
)
},
onShow
()
{
// #ifdef H5
document
.
onkeydown
=
event
=>
{
var
e
=
event
||
window
.
event
;
if
(
e
&&
e
.
keyCode
==
13
)
{
//回车键的键值为13
this
.
submit
()
}
};
// #endif
},
methods
:
{
/**
* 触发表单提交
*/
submit
()
{
this
.
$refs
.
form
.
validate
().
then
((
res
)
=>
{
if
(
this
.
formData
.
captcha
.
length
!=
4
){
this
.
$refs
.
captcha
.
focusCaptchaInput
=
true
return
uni
.
showToast
({
title
:
'
请输入验证码
'
,
icon
:
'
none
'
});
}
if
(
this
.
needAgreements
&&
!
this
.
agree
)
{
return
this
.
$refs
.
agreements
.
popup
(()
=>
{
this
.
submitForm
(
res
)
})
}
this
.
submitForm
(
res
)
}).
catch
((
errors
)
=>
{
let
key
=
errors
[
0
].
key
key
=
key
.
replace
(
key
[
0
],
key
[
0
].
toUpperCase
())
console
.
log
(
key
);
this
[
'
focus
'
+
key
]
=
true
})
},
submitForm
(
params
)
{
uniIdCo
.
registerAdmin
(
this
.
formData
).
then
(
e
=>
{
console
.
log
(
e
);
uni
.
navigateBack
()
})
.
catch
(
e
=>
{
console
.
log
(
e
);
console
.
log
(
e
.
message
);
//更好的体验:登录错误,直接刷新验证码
this
.
$refs
.
captcha
.
getImageCaptcha
()
uni
.
showModal
({
title
:
'
提示
'
,
content
:
e
.
errMsg
||
`创建失败:
${
e
.
errCode
}
`
,
showCancel
:
false
})
})
},
navigateBack
()
{
uni
.
navigateBack
()
},
toLogin
()
{
uni
.
navigateTo
({
url
:
'
/uni_modules/uni-id-pages/pages/login/login-withpwd
'
})
},
registerByEmail
()
{
uni
.
navigateTo
({
url
:
'
/uni_modules/uni-id-pages/pages/register/register-by-email
'
})
}
}
}
</
script
>
<
style
lang=
"scss"
>
@import
"@/uni_modules/uni-id-pages/common/login-page.scss"
;
@media
screen
and
(
max-width
:
690px
)
{
.uni-content
{
margin-top
:
15px
;
height
:
100%
;
background-color
:
#fff
;
}
}
@media
screen
and
(
min-width
:
690px
)
{
.uni-content
{
padding
:
30px
40px
60px
;
}
.link-box
{
/* #ifndef APP-NVUE */
display
:
flex
;
/* #endif */
flex-direction
:
row
;
justify-content
:
space-between
;
margin-top
:
10px
;
}
.link
{
font-size
:
12px
;
}
}
.
uni-content
:
:
v-deep
.
uni-forms-item__label
{
position
:
absolute
;
left
:
-15px
;
}
button
{
margin-top
:
15px
;
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录