From 71416db3604bd292c534e5ea650dfa0c5a45d307 Mon Sep 17 00:00:00 2001 From: Anne_LXM Date: Fri, 14 Jun 2024 21:01:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E6=B2=A1=E6=9C=89=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/userinfo/deactivate/deactivate.uvue | 4 +- uni_modules/uni-id-pages-x/store.uts | 61 +++++++++++-------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/uni_modules/uni-id-pages-x/pages/userinfo/deactivate/deactivate.uvue b/uni_modules/uni-id-pages-x/pages/userinfo/deactivate/deactivate.uvue index f40c66d..31589a4 100644 --- a/uni_modules/uni-id-pages-x/pages/userinfo/deactivate/deactivate.uvue +++ b/uni_modules/uni-id-pages-x/pages/userinfo/deactivate/deactivate.uvue @@ -49,7 +49,7 @@ uni.removeStorageSync('uni_id_token'); uni.setStorageSync('uni_id_token_expired', 0) uni.navigateTo({ - url: "/uni_modules/uni-id-pages-x/pages/login/login-withoutpwd" + url: "/uni_modules/uni-id-pages-x/pages/login/login" }) }) } else { @@ -98,4 +98,4 @@ .button-group .btn.next { color: #0070ff; } - \ No newline at end of file + diff --git a/uni_modules/uni-id-pages-x/store.uts b/uni_modules/uni-id-pages-x/store.uts index 4e2150b..f0b257d 100644 --- a/uni_modules/uni-id-pages-x/store.uts +++ b/uni_modules/uni-id-pages-x/store.uts @@ -24,7 +24,7 @@ function initState() { userInfo = new UTSJSONObject(userInfo) // #endif if (userInfo instanceof UTSJSONObject) { - state.userInfo = userInfo + state.userInfo = userInfo as UTSJSONObject // console.log('init userInfo',userInfo); } } catch (e) { @@ -45,40 +45,47 @@ export const mutations = { // console.log('afterUpdateUserInfo', 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) { - const db = uniCloud.databaseForJQL() - const user_id = uniCloud.getCurrentUserInfo().uid - console.log('user_id', user_id); - if (user_id != null) { - db.collection('uni-id-users') - .doc(user_id) - .field('_id,username,nickname,avatar_file,mobile') - .get() - .then(res => { - const uniIdCo = uniCloud.importObject('uni-id-co', { - customUI: true - }) - - uniIdCo - .getRealNameInfo() - .then((realNameInfo) => { - state.userInfo = Object.assign(res.data[0], { - realNameInfo - }) + usersCollection + .doc(user_id) + .field('_id,username,nickname,avatar_file,mobile') + .get() + .then(res => { + const uniIdCo = uniCloud.importObject('uni-id-co', { + customUI: true + }) - afterUpdateUserInfo() + uniIdCo + .getRealNameInfo() + .then((realNameInfo) => { + state.userInfo = Object.assign(res.data[0], { + realNameInfo }) + + afterUpdateUserInfo() }) - .catch((err: any | null) => { - const error = err as UniCloudError - console.error(error.errMsg, '错误') - }) - } + }) + .catch((err: any | null) => { + const error = err as UniCloudError + console.error(error.errMsg, '错误') + }) + } else { param.toMap().forEach((value, key) => { state.userInfo.set(key, value) }) + + usersCollection + .doc(user_id) + .update(param) + afterUpdateUserInfo() } } -- GitLab