Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦想橡皮擦
uni-starter
提交
f3793a09
U
uni-starter
项目概览
梦想橡皮擦
/
uni-starter
与 Fork 源项目一致
Fork自
DCloud / uni-starter
通知
1
Star
0
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看板
提交
f3793a09
编写于
4月 22, 2021
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
改为点击头像直接修改头像
上级
8e68abdd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
59 deletion
+80
-59
baseapp.config.js
baseapp.config.js
+2
-1
pages/ucenter/ucenter.vue
pages/ucenter/ucenter.vue
+50
-4
uni_modules/uni-id-users/pages/uni-id-users/edit.vue
uni_modules/uni-id-users/pages/uni-id-users/edit.vue
+1
-7
uni_modules/uni-login-page/uniCloud/cloudfunctions/user-center/index.js
...i-login-page/uniCloud/cloudfunctions/user-center/index.js
+27
-47
未找到文件。
baseapp.config.js
浏览文件 @
f3793a09
...
...
@@ -15,7 +15,8 @@ module.exports = {
"
router
"
:{
"
needLogin
"
:[
//配置需要路由拦截的页面地址,在打开这些页面之前会自动检查(不联网)uni_id_token的值是否存在/过期等
"
/uni_modules/uni-id-users/pages/uni-id-users/edit
"
,
"
/uni_modules/uni-news-favorite/pages/uni-news-favorite/list
"
"
/uni_modules/uni-news-favorite/pages/uni-news-favorite/list
"
,
"
/pages/ucenter/edit/uploadCutImageToUnicloud
"
],
"
login
"
:[
"
univerify
"
,
"
smsCode
"
,
"
username
"
,
"
weixin
"
,
"
apple
"
]
//默认就是短信验证码登陆
},
...
...
pages/ucenter/ucenter.vue
浏览文件 @
f3793a09
...
...
@@ -111,7 +111,10 @@
}
// #endif
},
methods
:
{
methods
:
{
...
mapMutations
({
setUserInfo
:
'
user/login
'
}),
toSettings
()
{
uni
.
navigateTo
({
url
:
"
/pages/ucenter/settings/settings
"
...
...
@@ -131,9 +134,52 @@
},
toEdit
()
{
console
.
log
(
'
点击编辑信息
'
);
uni
.
navigateTo
({
url
:
'
/uni_modules/uni-id-users/pages/uni-id-users/edit
'
})
// uni.navigateTo({
// url: '/uni_modules/uni-id-users/pages/uni-id-users/edit'
// })
const
token
=
uni
.
getStorageSync
(
'
uni_id_token
'
)
if
(
token
){
uni
.
chooseImage
({
count
:
1
,
success
:(
res
)
=>
{
// 头像剪裁尺寸
let
options
=
{
width
:
600
,
height
:
600
}
// 剪裁并上传头像
uni
.
navigateTo
({
url
:
'
/pages/ucenter/edit/uploadCutImageToUnicloud?path=
'
+
res
.
tempFilePaths
[
0
]
+
`&options=
${
JSON
.
stringify
(
options
)}
`
,
animationType
:
"
fade-in
"
,
events
:{
uploadAvatarAfter
:({
url
})
=>
{
console
.
log
(
url
);
// 使用 clientDB 提交数据
db
.
collection
(
'
uni-id-users
'
).
where
(
'
_id==$env.uid
'
).
update
({
avatar
:
url
}).
then
((
res
)
=>
{
console
.
log
(
res
);
uni
.
showToast
({
icon
:
'
none
'
,
title
:
'
修改成功
'
})
this
.
setUserInfo
({
avatar
:
url
});
}).
catch
((
err
)
=>
{
uni
.
showModal
({
content
:
err
.
message
||
'
请求服务失败
'
,
showCancel
:
false
})
}).
finally
(()
=>
{
uni
.
hideLoading
()
})
}
}
});
}
})
}
else
{
uni
.
navigateTo
({
url
:
'
/uni_modules/uni-login-page/pages/index/index
'
})
}
},
tapGrid
(
index
)
{
uni
.
showToast
({
...
...
uni_modules/uni-id-users/pages/uni-id-users/edit.vue
浏览文件 @
f3793a09
...
...
@@ -50,7 +50,7 @@
return
{
formData
:
{
"
avatar
"
:
""
,
"
gender
"
:
0
,
"
gender
"
:
''
,
"
mobile
"
:
""
,
"
nickname
"
:
""
},
...
...
@@ -100,12 +100,6 @@
width
:
600
,
height
:
600
}
uni
.
navigateTo
({
url
:
'
/pages/ucenter/edit/uploadCutImageToUnicloud
'
,
success
:
res
=>
{},
fail
:
()
=>
{},
complete
:
()
=>
{}
});
// 剪裁并上传头像
uni
.
navigateTo
({
url
:
'
/pages/ucenter/edit/uploadCutImageToUnicloud?path=
'
+
res
.
tempFilePaths
[
0
]
+
`&options=
${
JSON
.
stringify
(
options
)}
`
,
...
...
uni_modules/uni-login-page/uniCloud/cloudfunctions/user-center/index.js
浏览文件 @
f3793a09
...
...
@@ -32,18 +32,6 @@ exports.main = async (event, context) => {
return
recentRecord
.
data
.
filter
(
item
=>
item
.
state
===
0
).
length
===
recordSize
;
}
//注册成功后为用户执行相关操作,如创建该用户的积分表等
function
registerSuccess
(
uid
)
{
await
db
.
collection
(
'
uni-id-scores
'
).
add
({
user_id
:
uid
,
score
:
1
,
type
:
1
,
balance
:
1
,
comment
:
""
,
create_date
:
Date
.
now
()
})
}
//设置某些模块不需要token(也就是登陆成功后)才能操作,如果需要token就获取当前操作账户的uid
let
noCheckAction
=
[
'
register
'
,
'
checkToken
'
,
'
login
'
,
'
logout
'
,
'
sendSmsCode
'
,
...
...
@@ -66,7 +54,17 @@ exports.main = async (event, context) => {
params
.
uid
=
payload
.
uid
}
//注册成功后为用户执行相关操作,如创建该用户的积分表等
async
function
registerSuccess
(
uid
)
{
await
db
.
collection
(
'
uni-id-scores
'
).
add
({
user_id
:
uid
,
score
:
1
,
type
:
1
,
balance
:
1
,
comment
:
""
,
create_date
:
Date
.
now
()
})
}
//记录成功登陆的日志
const
loginLog
=
async
(
res
=
{},
type
=
'
login
'
)
=>
{
const
now
=
Date
.
now
()
...
...
@@ -86,8 +84,10 @@ exports.main = async (event, context) => {
}
:
{
state
:
0
})
return
uniIdLogCollection
.
add
(
logData
)
if
(
res
.
type
==
'
register
'
){
await
registerSuccess
(
res
.
uid
)
}
return
await
uniIdLogCollection
.
add
(
logData
)
}
...
...
@@ -118,7 +118,7 @@ exports.main = async (event, context) => {
password
});
if
(
res
.
code
===
0
)
{
registerSuccess
(
res
.
uid
)
await
registerSuccess
(
res
.
uid
)
}
break
;
case
'
login
'
:
...
...
@@ -136,10 +136,6 @@ exports.main = async (event, context) => {
queryField
:
[
'
username
'
,
'
email
'
,
'
mobile
'
]
});
await
loginLog
(
res
);
if
(
res
.
code
==
0
&&
res
.
type
==
'
register
'
)
{
registerSuccess
(
res
.
uid
)
}
needCaptcha
=
await
getNeedCaptcha
();
}
...
...
@@ -150,25 +146,17 @@ exports.main = async (event, context) => {
await
uniID
.
updateUser
({
uid
:
res
.
uid
,
username
:
"
微信用户
"
});
if
(
res
.
code
==
0
&&
res
.
type
==
'
register
'
)
{
registerSuccess
(
res
.
uid
)
}
});
res
.
userInfo
.
username
=
"
微信用户
"
loginLog
(
res
)
await
loginLog
(
res
)
break
;
case
'
login_by_univerify
'
:
res
=
await
uniID
.
loginByUniverify
(
params
)
if
(
res
.
code
==
0
&&
res
.
type
==
'
register
'
)
{
registerSuccess
(
res
.
uid
)
}
res
=
await
uniID
.
loginByUniverify
(
params
)
await
loginLog
(
res
)
break
;
case
'
login_by_apple
'
:
res
=
await
uniID
.
loginByApple
(
params
)
if
(
res
.
code
==
0
&&
res
.
type
==
'
register
'
)
{
registerSuccess
(
res
.
uid
)
}
loginLog
(
res
)
res
=
await
uniID
.
loginByApple
(
params
)
await
loginLog
(
res
)
break
;
case
'
checkToken
'
:
res
=
await
uniID
.
checkToken
(
event
.
uniIdToken
);
...
...
@@ -202,10 +190,8 @@ exports.main = async (event, context) => {
code
,
type
:
params
.
type
,
templateId
})
if
(
res
.
code
==
0
&&
res
.
type
==
'
register
'
)
{
registerSuccess
(
res
.
uid
)
}
})
await
loginLog
(
res
)
break
;
case
'
loginBySms
'
:
if
(
!
params
.
code
)
{
...
...
@@ -220,11 +206,8 @@ exports.main = async (event, context) => {
msg
:
'
手机号码填写错误
'
}
}
res
=
await
uniID
.
loginBySms
(
params
)
if
(
res
.
code
==
0
&&
res
.
type
==
'
register
'
)
{
registerSuccess
(
res
.
uid
)
}
loginLog
(
res
)
res
=
await
uniID
.
loginBySms
(
params
)
await
loginLog
(
res
)
break
;
case
'
inviteLogin
'
:
if
(
!
params
.
code
)
{
...
...
@@ -236,10 +219,7 @@ exports.main = async (event, context) => {
res
=
await
uniID
.
loginBySms
({
...
params
,
type
:
'
register
'
})
if
(
res
.
code
==
0
&&
res
.
type
==
'
register
'
)
{
registerSuccess
(
res
.
uid
)
}
})
break
;
case
'
resetPwdBySmsCode
'
:
if
(
!
params
.
code
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录