Procházet zdrojové kódy

fix(富页面): 退出切换改用 switchBackVerify 原子接口,修正密码校验逻辑

原实现 bug: verifyPassword 返回 Result.success(false) 时 code 仍为 200,
错误地判定为密码正确。

修复:
- 改用 POST /api/family/user/switch-back-verify 单一原子接口
- 后端对错误密码直接返回 Result.error (code != 200)
- 正确清除 uni storage 中的 isSwitchedChild / currentChildId
- 添加 $store.commit 可选检查,避免 store 未定义崩溃
- 添加 setTimeout 在 toast 显示后再 reLaunch,提升体验

参考: cfc-backend/.../FamilyUserController.java:135
Xiaogang Liao před 2 měsíci
rodič
revize
69e4d7a2ea
1 změnil soubory, kde provedl 11 přidání a 5 odebrání
  1. 11 5
      cfc-frontend/pages/wealth/index.vue

+ 11 - 5
cfc-frontend/pages/wealth/index.vue

@@ -259,7 +259,7 @@
 
 <script>
 import PageBanner from '../../components/PageBanner.vue'
-import { getWealthDetail, verifyPassword, getChildren } from '../../utils/api.js'
+import { getWealthDetail, getChildren, switchBackVerify } from '../../utils/api.js'
 
 export default {
   components: { PageBanner },
@@ -390,13 +390,19 @@ export default {
         success: async (res) => {
           if (res.confirm && res.content) {
             try {
-              var verifyResult = await verifyPassword(res.content)
-              if (verifyResult.code === 200) {
-                this.$store.commit('switchBackToParent')
+              var verifyResult = await switchBackVerify(res.content)
+              if (verifyResult && verifyResult.code === 200 && verifyResult.data === true) {
+                uni.removeStorageSync('isSwitchedChild')
+                uni.removeStorageSync('currentChildId')
                 this.isSwitchedChild = false
                 this.role = 'parent'
+                if (this.$store && this.$store.commit) {
+                  this.$store.commit('switchBackToParent')
+                }
                 uni.showToast({ title: '已退出切换', icon: 'success' })
-                uni.reLaunch({ url: '/pages/index/index' })
+                setTimeout(function() {
+                  uni.reLaunch({ url: '/pages/index/index' })
+                }, 1000)
               } else {
                 uni.showToast({ title: '密码错误', icon: 'none' })
               }