提交 f4ff8033 编写于 作者: Anne_LXM's avatar Anne_LXM

修复用户头像没有更新的问题

上级 482b9dfd
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
uni.removeStorageSync('uni_id_token'); uni.removeStorageSync('uni_id_token');
uni.setStorageSync('uni_id_token_expired', 0) uni.setStorageSync('uni_id_token_expired', 0)
uni.navigateTo({ uni.navigateTo({
url: "/uni_modules/uni-id-pages-x/pages/login/login-withoutpwd" url: "/uni_modules/uni-id-pages-x/pages/login/login"
}) })
}) })
} else { } else {
...@@ -98,4 +98,4 @@ ...@@ -98,4 +98,4 @@
.button-group .btn.next { .button-group .btn.next {
color: #0070ff; color: #0070ff;
} }
</style> </style>
\ No newline at end of file
...@@ -24,7 +24,7 @@ function initState() { ...@@ -24,7 +24,7 @@ function initState() {
userInfo = new UTSJSONObject(userInfo) userInfo = new UTSJSONObject(userInfo)
// #endif // #endif
if (userInfo instanceof UTSJSONObject) { if (userInfo instanceof UTSJSONObject) {
state.userInfo = userInfo state.userInfo = userInfo as UTSJSONObject
// console.log('init userInfo',userInfo); // console.log('init userInfo',userInfo);
} }
} catch (e) { } catch (e) {
...@@ -45,40 +45,47 @@ export const mutations = { ...@@ -45,40 +45,47 @@ export const mutations = {
// console.log('afterUpdateUserInfo', state.userInfo); // console.log('afterUpdateUserInfo', state.userInfo);
uni.setStorageSync('uni-id-pages-x-userInfo', state.userInfo) uni.setStorageSync('uni-id-pages-x-userInfo', state.userInfo)
} }
const db = uniCloud.databaseForJQL()
const usersCollection = db.collection('uni-id-users')
const user_id = uniCloud.getCurrentUserInfo().uid
console.log('user_id', user_id);
if(user_id == null){
return
}
if (param == null) { if (param == null) {
const db = uniCloud.databaseForJQL() usersCollection
const user_id = uniCloud.getCurrentUserInfo().uid .doc(user_id)
console.log('user_id', user_id); .field('_id,username,nickname,avatar_file,mobile')
if (user_id != null) { .get()
db.collection('uni-id-users') .then(res => {
.doc(user_id) const uniIdCo = uniCloud.importObject('uni-id-co', {
.field('_id,username,nickname,avatar_file,mobile') customUI: true
.get() })
.then(res => {
const uniIdCo = uniCloud.importObject('uni-id-co', {
customUI: true
})
uniIdCo
.getRealNameInfo()
.then((realNameInfo) => {
state.userInfo = Object.assign(res.data[0], {
realNameInfo
})
afterUpdateUserInfo() uniIdCo
.getRealNameInfo()
.then((realNameInfo) => {
state.userInfo = Object.assign(res.data[0], {
realNameInfo
}) })
afterUpdateUserInfo()
}) })
.catch((err: any | null) => { })
const error = err as UniCloudError .catch((err: any | null) => {
console.error(error.errMsg, '错误') const error = err as UniCloudError
}) console.error(error.errMsg, '错误')
} })
} else { } else {
param.toMap().forEach((value, key) => { param.toMap().forEach((value, key) => {
state.userInfo.set(key, value) state.userInfo.set(key, value)
}) })
usersCollection
.doc(user_id)
.update(param)
afterUpdateUserInfo() afterUpdateUserInfo()
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册