fix(AdPage): 修复点击图片时未实时查询家庭状态的问题
在handleImageClick中增加实时查询家庭状态的逻辑,当查询失败时回退到之前的状态
Showing
1 changed file
with
21 additions
and
1 deletions
| ... | @@ -187,7 +187,26 @@ const performSilentAuth = async () => { | ... | @@ -187,7 +187,26 @@ const performSilentAuth = async () => { |
| 187 | /** | 187 | /** |
| 188 | * 点击图片处理 | 188 | * 点击图片处理 |
| 189 | */ | 189 | */ |
| 190 | -const handleImageClick = () => { | 190 | +const handleImageClick = async () => { |
| 191 | + try { | ||
| 192 | + // 重新查询家庭状态 | ||
| 193 | + const { code, data } = await getMyFamiliesAPI(); | ||
| 194 | + const currentHasFamily = code && data && data?.families?.length > 0; | ||
| 195 | + | ||
| 196 | + if (currentHasFamily) { | ||
| 197 | + // 已加入家庭,跳转到dashboard页面 | ||
| 198 | + Taro.redirectTo({ | ||
| 199 | + url: '/pages/Dashboard/index' | ||
| 200 | + }); | ||
| 201 | + } else { | ||
| 202 | + // 未加入家庭,跳转到welcome页面 | ||
| 203 | + Taro.redirectTo({ | ||
| 204 | + url: '/pages/Welcome/index' | ||
| 205 | + }); | ||
| 206 | + } | ||
| 207 | + } catch (error) { | ||
| 208 | + console.error('查询家庭状态失败:', error); | ||
| 209 | + // 查询失败时,使用之前的状态进行跳转 | ||
| 191 | if (hasFamily.value) { | 210 | if (hasFamily.value) { |
| 192 | // 已加入家庭,跳转到dashboard页面 | 211 | // 已加入家庭,跳转到dashboard页面 |
| 193 | Taro.redirectTo({ | 212 | Taro.redirectTo({ |
| ... | @@ -199,6 +218,7 @@ const handleImageClick = () => { | ... | @@ -199,6 +218,7 @@ const handleImageClick = () => { |
| 199 | url: '/pages/Welcome/index' | 218 | url: '/pages/Welcome/index' |
| 200 | }); | 219 | }); |
| 201 | } | 220 | } |
| 221 | + } | ||
| 202 | }; | 222 | }; |
| 203 | 223 | ||
| 204 | /** | 224 | /** | ... | ... |
-
Please register or login to post a comment