Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Without Ocean
uni-starter
提交
bdbdacc1
U
uni-starter
项目概览
Without Ocean
/
uni-starter
与 Fork 源项目一致
Fork自
DCloud / uni-starter
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-starter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bdbdacc1
编写于
4月 21, 2021
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增了合并了无聊的this.loginSuccess() 和注册功能
新增了合并了无聊的this.loginSuccess() 和注册功能
上级
1dc56d7b
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
150 addition
and
173 deletion
+150
-173
common/appInit.js
common/appInit.js
+0
-67
pages.json
pages.json
+2
-6
template.h5.html
template.h5.html
+9
-9
uni_modules/uni-login-page/common/loginPage.css
uni_modules/uni-login-page/common/loginPage.css
+3
-1
uni_modules/uni-login-page/common/loginPage.mixin.js
uni_modules/uni-login-page/common/loginPage.mixin.js
+21
-1
uni_modules/uni-login-page/components/uni-quick-login/uni-quick-login.vue
...login-page/components/uni-quick-login/uni-quick-login.vue
+1
-19
uni_modules/uni-login-page/pages/phone-code/phone-code.vue
uni_modules/uni-login-page/pages/phone-code/phone-code.vue
+1
-13
uni_modules/uni-login-page/pages/pwd-login/pwd-login.vue
uni_modules/uni-login-page/pages/pwd-login/pwd-login.vue
+17
-18
uni_modules/uni-login-page/pages/register/register.vue
uni_modules/uni-login-page/pages/register/register.vue
+20
-37
uni_modules/uni-login-page/pages/register/validator.js
uni_modules/uni-login-page/pages/register/validator.js
+61
-0
uni_modules/uni-login-page/uniCloud/cloudfunctions/user-center/index.js
...i-login-page/uniCloud/cloudfunctions/user-center/index.js
+15
-2
未找到文件。
common/appInit.js
浏览文件 @
bdbdacc1
...
...
@@ -4,31 +4,12 @@ import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update
import
callCheckVersion
from
'
@/uni_modules/uni-upgrade-center-app/utils/call-check-version
'
;
// #endif
export
default
function
()
{
// 初始化appVersion(仅app生效)
initAppVersion
();
//自定义路由拦截
const
{
"
router
"
:{
needLogin
,
login
}}
=
baseappConfig
//需要登陆的页面
// changeAction(["navigateTo", "redirectTo", "reLaunch", "switchTab"], {
// before_action: e => {
// let token = uni.getStorageSync('uni-id-token')
// let url = e.url.split('?')[0]
// if (needLogin.includes(url) && token == '') {
// console.log('该页面需要登陆,即将跳转到login页面');
// uni.showToast({title:'该页面需要登陆,即将跳转到login页面',icon:'none'})
// uni.navigateTo({
// url:"/uni_modules/uni-login-page/pages/index/index"
// })
// return false
// }
// return true
// }
// })
//uni.addInterceptor的写法
let
list
=
[
"
navigateTo
"
,
"
redirectTo
"
,
"
reLaunch
"
,
"
switchTab
"
];
list
.
forEach
(
item
=>
{
uni
.
addInterceptor
(
item
,{
...
...
@@ -76,35 +57,14 @@ export default function() {
})
// 移除拦截器API removeInterceptor('request')
})
//提示网络变化
eventListenerNetwork
()
/*
当某个权限调用失败
1.先检测手机的该模块是否打开
2.检测当前应用是否被授权了该模块对应的权限
提示,并点击跳转到设置
*/
// #ifndef H5
// changeAction('chooseImage', {
// after_action: e => {
// console.log('changeAction', e);
// if(e.errCode === 11){
// uni.showModal({
// content: '无权限',
// confirmText:"前往设置",
// success(e) {
// if(e.confirm){
// permision.gotoAppPermissionSetting()
// }
// }
// });
// }
// }
// })
// #endif
}
/**
* // 初始化appVersion
...
...
@@ -166,31 +126,4 @@ function eventListenerNetwork () {
});
}
});
}
function
changeAction
(
actions
,
{
before_action
,
after_action
})
{
if
(
typeof
actions
==
'
string
'
){
actions
=
[
actions
]
}
if
(
!
before_action
)
{
before_action
=
()
=>
true
}
actions
.
forEach
(
action
=>
{
let
old_action
=
uni
[
action
]
uni
[
action
]
=
e
=>
{
if
(
before_action
(
e
))
{
// console.log(after_action);
if
(
after_action
)
{
var
compose
=
function
(
f
,
g
)
{
return
function
(
x
)
{
return
f
(
x
,
g
(
x
));
};
};
e
.
complete
=
compose
(
e
.
complete
,
after_action
)
}
old_action
(
e
)
}
}
})
}
\ No newline at end of file
pages.json
浏览文件 @
bdbdacc1
...
...
@@ -211,11 +211,7 @@
"condition"
:
{
"list"
:
[
{
"path"
:
"pages/list/list"
,
"style"
:
{
"navigationStyle"
:
"custom"
,
"enablePullDownRefresh"
:
true
}
"path"
:
"pages/list/list"
},
{
"path"
:
"uni_modules/uni-login-page/pages/index/index"
...
...
@@ -227,7 +223,7 @@
"path"
:
"pages/ucenter/settings/settings"
}
],
"current"
:
0
"current"
:
1
},
"tabBar"
:
{
"color"
:
"#7A7E83"
,
...
...
template.h5.html
浏览文件 @
bdbdacc1
...
...
@@ -36,13 +36,13 @@
// document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
// })
setTimeout
(()
=>
{
document
.
querySelector
(
'
#gg
'
).
addEventListener
(
'
click
'
,
e
=>
{
console
.
log
(
e
);
alert
(
12
)
window
.
location
.
href
=
"
https://m3w.cn/uniapp
"
})
},
1000
)
//
setTimeout(()=>{
//
document.querySelector('#gg').addEventListener('click',e=>{
//
console.log(e);
//
alert(12)
//
window.location.href = "https://m3w.cn/uniapp"
//
})
//
},1000)
</script>
<link
rel=
"stylesheet"
href=
"<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css"
/>
...
...
@@ -54,8 +54,8 @@
<noscript>
<strong>
Please enable JavaScript to continue.
</strong>
</noscript>
<div
id=
"gg"
style=
"width: 99px;height: 99px;background-color: #007AFF;"
>
下载app
</div>
<
!-- <
div id="gg" style="width: 99px;height: 99px;background-color: #007AFF;"
>下载app</div>
-->
<div
style=
"margin-top: 100px;"
id=
"app"
></div>
<!-- built files will be auto injected -->
<script>
...
...
uni_modules/uni-login-page/common/loginPage.css
浏览文件 @
bdbdacc1
...
...
@@ -40,7 +40,9 @@ page {
font-weight
:
600
;
padding-top
:
50
rpx
;
}
.content
/
deep
/
.uni-easyinput
{
padding
:
6px
0
;
}
.login-iknow
{
padding-top
:
24
rpx
;
padding-bottom
:
48
rpx
;
...
...
uni_modules/uni-login-page/common/loginPage.mixin.js
浏览文件 @
bdbdacc1
...
...
@@ -79,7 +79,27 @@ let mixin = {
methods
:{
...
mapMutations
({
setUserInfo
:
'
user/login
'
})
}),
loginSuccess
(
result
){
uni
.
showToast
({
title
:
'
登陆成功
'
,
icon
:
'
none
'
});
uni
.
setStorageSync
(
'
uni_id_uid
'
,
result
.
uid
)
uni
.
setStorageSync
(
'
uni_id_token
'
,
result
.
token
)
uni
.
setStorageSync
(
'
uni_id_token_expired
'
,
result
.
tokenExpired
)
delete
result
.
userInfo
.
token
this
.
setUserInfo
(
result
.
userInfo
)
var
delta
=
0
//判断需要返回几层
let
pages
=
getCurrentPages
();
pages
.
forEach
((
page
,
index
)
=>
{
if
(
pages
[
pages
.
length
-
index
-
1
].
route
.
split
(
'
/
'
)[
1
]
==
'
uni-login-page
'
){
delta
++
}
})
uni
.
navigateBack
({
delta
})
}
}
}
export
default
mixin
\ No newline at end of file
uni_modules/uni-login-page/components/uni-quick-login/uni-quick-login.vue
浏览文件 @
bdbdacc1
...
...
@@ -181,29 +181,11 @@
this
.
request
(
'
user-center/login_by_
'
+
type
,
params
,(
data
,
result
)
=>
{
console
.
log
(
result
);
if
(
result
.
code
===
0
){
uni
.
setStorageSync
(
'
uni_id_uid
'
,
result
.
uid
)
uni
.
setStorageSync
(
'
uni_id_token
'
,
result
.
token
)
uni
.
setStorageSync
(
'
uni_id_token_expired
'
,
result
.
tokenExpired
)
delete
result
.
userInfo
.
token
this
.
setUserInfo
(
result
.
userInfo
)
if
(
type
==
'
univerify
'
){
uni
.
closeAuthView
()
}
uni
.
showToast
({
title
:
'
登陆成功
'
,
icon
:
'
none
'
});
uni
.
hideLoading
()
var
delta
=
0
//判断需要返回几层
let
pages
=
getCurrentPages
();
pages
.
forEach
((
page
,
index
)
=>
{
if
(
pages
[
pages
.
length
-
index
-
1
].
route
.
split
(
'
/
'
)[
1
]
==
'
uni-login-page
'
){
delta
++
}
})
uni
.
navigateBack
({
delta
})
this
.
loginSuccess
(
result
)
}
},{
showLoading
:
true
})
},
...
...
uni_modules/uni-login-page/pages/phone-code/phone-code.vue
浏览文件 @
bdbdacc1
...
...
@@ -69,19 +69,7 @@
uni
.
hideLoading
()
console
.
log
(
e
.
result
);
if
(
e
.
result
.
code
===
0
){
uni
.
setStorageSync
(
'
uni_id_uid
'
,
e
.
result
.
uid
)
uni
.
setStorageSync
(
'
uni_id_token
'
,
e
.
result
.
token
)
uni
.
setStorageSync
(
'
uni_id_token_expired
'
,
e
.
result
.
tokenExpired
)
// console.log('66666=',e.result.uid,e.result.token,e.result.tokenExpired);
delete
e
.
result
.
userInfo
.
token
this
.
setUserInfo
(
e
.
result
.
userInfo
)
uni
.
showToast
({
title
:
'
登陆成功
'
,
icon
:
'
none
'
});
uni
.
switchTab
({
url
:
"
/pages/list/list
"
})
this
.
loginSuccess
(
e
.
result
)
}
else
{
uni
.
showModal
({
title
:
'
错误
'
,
...
...
uni_modules/uni-login-page/pages/pwd-login/pwd-login.vue
浏览文件 @
bdbdacc1
...
...
@@ -20,15 +20,15 @@
<uni-easyinput
type=
"password"
class=
"phone-input-box"
:inputBorder=
"false"
v-model=
"formData.pwd"
placeholder=
"请输入密码"
></uni-easyinput>
</uni-forms-item>
<button
class=
"send-btn-box"
:disabled=
"!canLogin"
:type=
"canLogin?'primary':'default'"
@
click=
"pwdLogin"
>
登录
</button>
<button
class=
"send-btn-box"
:disabled=
"!canLogin"
:type=
"canLogin?'primary':'default'"
@
click=
"pwdLogin"
>
登录
</button>
</uni-forms>
<!-- 忘记密码 -->
<view
class=
"auth-box"
>
<text
class=
"login-text login-text-sub"
>
忘记了?
</text>
<text
class=
"login-text"
@
click=
"toRetrievePwd"
>
找回密码
</text>
</view>
</view>
<button
type=
"primary"
class=
"toRegister"
@
click=
"toRegister"
>
注册账号
</button>
</view>
</view>
<uni-quick-login
ref=
"uniQuickLogin"
></uni-quick-login>
...
...
@@ -81,19 +81,7 @@
uni
.
hideLoading
()
console
.
log
(
e
.
result
);
if
(
e
.
result
.
code
===
0
){
uni
.
setStorageSync
(
'
uni_id_uid
'
,
e
.
result
.
uid
)
uni
.
setStorageSync
(
'
uni_id_token
'
,
e
.
result
.
token
)
uni
.
setStorageSync
(
'
uni_id_token_expired
'
,
e
.
result
.
tokenExpired
)
// console.log('66666=',e.result.uid,e.result.token,e.result.tokenExpired);
delete
e
.
result
.
userInfo
.
token
this
.
setUserInfo
(
e
.
result
.
userInfo
)
uni
.
showToast
({
title
:
'
登陆成功
'
,
icon
:
'
none
'
});
uni
.
switchTab
({
url
:
"
/pages/list/list
"
})
this
.
loginSuccess
(
e
.
result
)
}
else
{
uni
.
showModal
({
title
:
'
错误
'
,
...
...
@@ -126,7 +114,14 @@
icon
:
'
none
'
});
// this.currenPhoneArea = this.phoneArea[event.detail.value];
},
},
/* 前往注册 */
toRegister
(
e
){
console
.
log
(
e
);
uni
.
navigateTo
({
url
:
'
/uni_modules/uni-login-page/pages/register/register
'
})
}
}
}
</
script
>
...
...
@@ -142,5 +137,9 @@
}
.login-text-sub
{
color
:
#8a8f8b
;
}
.toRegister
{
margin-top
:
80px
;
width
:
600
rpx
;
}
</
style
>
uni_modules/uni-login-page/pages/register/register.vue
浏览文件 @
bdbdacc1
<
template
>
<view
class=
"uni-container"
>
<uni-forms
ref=
"form"
:value=
"formData"
:rules=
"rules"
validate-trigger=
"submit"
err-show-type=
"
toas
t"
>
<uni-forms
ref=
"form"
:value=
"formData"
:rules=
"rules"
validate-trigger=
"submit"
err-show-type=
"
undertex
t"
>
<uni-forms-item
name=
"username"
label=
"用户名"
required
>
<uni-easyinput
placeholder=
"请输入用户名"
v-model=
"formData.username"
trim=
"both"
/>
</uni-forms-item>
<uni-forms-item
name=
"gender"
label=
"性别"
required
>
<uni-forms-item
name=
"gender"
label=
"性别"
>
<uni-data-checkbox
v-model=
"formData.gender"
:localdata=
"formOptions.gender_localdata"
/>
</uni-forms-item>
<uni-forms-item
name=
"nickname"
label=
"昵称"
required
>
<uni-forms-item
name=
"nickname"
label=
"昵称"
>
<uni-easyinput
placeholder=
"请输入用户昵称"
v-model=
"formData.nickname"
trim=
"both"
/>
</uni-forms-item>
<uni-forms-item
name=
"p
wd"
label=
"密码"
v-model=
"formData.pw
d"
required
>
<uni-easyinput
placeholder=
"请输入6-20位密码"
type=
"password"
v-model=
"formData.p
w
d"
trim=
"both"
/>
<uni-forms-item
name=
"p
assword"
label=
"密码"
v-model=
"formData.passwor
d"
required
>
<uni-easyinput
placeholder=
"请输入6-20位密码"
type=
"password"
v-model=
"formData.p
asswor
d"
trim=
"both"
/>
</uni-forms-item>
<uni-forms-item
name=
"pwd2"
label=
"确认密码"
v-model=
"formData.pwd2"
required
>
<uni-easyinput
placeholder=
"再次输入密码"
type=
"password"
v-model=
"formData.pwd2"
trim=
"both"
/>
...
...
@@ -23,33 +23,19 @@
</view>
</
template
>
<
script
>
import
{
validator
}
from
'
../../js_sdk/validator/uni-id-users.js
'
;
const
db
=
uniCloud
.
database
();
const
dbCollectionName
=
'
uni-id-users
'
;
function
getValidator
(
fields
)
{
let
reuslt
=
{}
for
(
let
key
in
validator
)
{
if
(
fields
.
indexOf
(
key
)
>
-
1
)
{
reuslt
[
key
]
=
validator
[
key
]
}
}
return
reuslt
}
export
default
{
<
script
>
import
rules
from
'
./validator.js
'
;
import
mixin
from
'
../../common/loginPage.mixin.js
'
;
export
default
{
mixins
:[
mixin
],
data
()
{
return
{
formData
:
{
"
username
"
:
""
,
"
gender
"
:
0
,
"
nickname
"
:
""
,
'
p
wd
'
:
'
'
,
'
pwd2
'
:
''
'
p
assword
'
:
'
123456
'
,
'
pwd2
'
:
'
123456
'
},
formOptions
:
{
"
gender_localdata
"
:
[{
...
...
@@ -65,9 +51,7 @@
}
]
},
rules
:
{
...
getValidator
([
"
username
"
,
"
gender
"
,
"
nickname
"
,
'
pwd
'
,
'
pwd2
'
])
}
rules
}
},
onReady
()
{
...
...
@@ -78,15 +62,10 @@
* 触发表单提交
*/
submit
()
{
uni
.
showLoading
({
mask
:
true
})
this
.
$refs
.
form
.
submit
().
then
((
res
)
=>
{
if
(
res
.
pwd
!=
res
.
pwd2
)
return
uni
.
showToast
({
title
:
'
两次输入密码不一致
'
,
icon
:
'
none
'
});
this
.
$refs
.
form
.
submit
().
then
((
res
)
=>
{
this
.
submitForm
(
res
)
}).
catch
((
errors
)
=>
{
console
.
log
(
errors
);
...
...
@@ -95,9 +74,13 @@
uni
.
hideLoading
()
})
},
submitForm
(
value
)
{
this
.
request
(
'
user-center/register
'
,
value
,(
data
,
result
)
=>
{
console
.
log
(
result
);
if
(
result
.
code
===
0
){
this
.
loginSuccess
(
result
)
}
})
}
}
}
...
...
uni_modules/uni-login-page/
js_sdk/validator/uni-id-users
.js
→
uni_modules/uni-login-page/
pages/register/validator
.js
浏览文件 @
bdbdacc1
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const
validator
=
{
"
gender
"
:
{
"
rules
"
:
[{
"
format
"
:
"
int
"
},
{
"
range
"
:
[{
"
text
"
:
"
未知
"
,
"
value
"
:
0
},
{
"
text
"
:
"
男
"
,
"
value
"
:
1
},
{
"
text
"
:
"
女
"
,
"
value
"
:
2
}
]
}
],
"
defaultValue
"
:
0
,
"
label
"
:
"
性别
"
},
"
username
"
:
{
"
rules
"
:
[{
required
:
true
,
errorMessage
:
'
请输入用户名
'
,
},
{
minLength
:
3
,
maxLength
:
10
,
errorMessage
:
'
用户名长度在 {minLength} 到 {maxLength} 个字符
'
,
}
],
"
label
"
:
"
用户名
"
},
"
nickname
"
:
{
"
rules
"
:
[{
required
:
true
,
errorMessage
:
'
请输入昵称
'
,
},
{
minLength
:
3
,
maxLength
:
10
,
errorMessage
:
'
昵称长度在 {minLength} 到 {maxLength} 个字符
'
,
}
],
"
label
"
:
"
昵称
"
export
default
{
"
username
"
:
{
"
rules
"
:
[{
required
:
true
,
errorMessage
:
'
请输入用户名
'
,
},
{
minLength
:
3
,
maxLength
:
32
,
errorMessage
:
'
用户名长度在 {minLength} 到 {maxLength} 个字符
'
,
},
{
validateFunction
:
function
(
rule
,
value
,
data
,
callback
){
console
.
log
(
value
);
if
(
/^1
\d{10}
$/
.
test
(
value
)
||
/^
(\w
-*
\.
*
)
+@
(\w
-
?)
+
(\.\w{2,})
+$/
.
test
(
value
)){
callback
(
'
用户名不能是:手机号或邮箱
'
)
};
return
true
}
}
],
"
label
"
:
"
用户名
"
},
"
p
w
d
"
:{
"
p
asswor
d
"
:{
"
rules
"
:
[{
required
:
true
,
errorMessage
:
'
请输入密码
'
,
},
{
minLength
:
6
,
...
...
@@ -82,21 +45,17 @@ const validator = {
minLength
:
6
,
maxLength
:
20
,
errorMessage
:
'
密码长度在 {minLength} 到 {maxLength} 个字符
'
,
},
{
validateFunction
:
function
(
rule
,
value
,
data
,
callback
){
console
.
log
(
value
);
if
(
value
!=
data
.
password
){
callback
(
'
两次输入密码不一致
'
)
};
return
true
}
}
],
"
label
"
:
"
确认密码
"
}
}
const
enumConverter
=
{
"
gender_valuetotext
"
:
{
"
0
"
:
"
未知
"
,
"
1
"
:
"
男
"
,
"
2
"
:
"
女
"
}
}
export
{
validator
,
enumConverter
}
}
}
\ No newline at end of file
uni_modules/uni-login-page/uniCloud/cloudfunctions/user-center/index.js
浏览文件 @
bdbdacc1
...
...
@@ -82,8 +82,21 @@ exports.main = async (event, context) => {
let
res
=
{}
switch
(
event
.
action
)
{
case
'
register
'
:
res
=
await
uniID
.
register
(
params
);
case
'
register
'
:
let
{
username
,
password
,
gender
,
nickname
,
password
}
=
params
if
(
/^1
\d{10}
$/
.
test
(
username
)){
return
{
code
:
401
,
msg
:
'
用户名不能是手机号
'
}
};
if
(
/^
(\w
-*
\.
*
)
+@
(\w
-
?)
+
(\.\w{2,})
+$/
.
test
(
username
)){
return
{
code
:
401
,
msg
:
'
用户名不能是邮箱
'
}
}
res
=
await
uniID
.
register
({
username
,
password
,
gender
,
nickname
,
password
});
break
;
case
'
login
'
:
let
passed
=
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录