hookehuyr

fix(AdPage): 修复点击图片时未实时查询家庭状态的问题

在handleImageClick中增加实时查询家庭状态的逻辑,当查询失败时回退到之前的状态
...@@ -187,17 +187,37 @@ const performSilentAuth = async () => { ...@@ -187,17 +187,37 @@ const performSilentAuth = async () => {
187 /** 187 /**
188 * 点击图片处理 188 * 点击图片处理
189 */ 189 */
190 -const handleImageClick = () => { 190 +const handleImageClick = async () => {
191 - if (hasFamily.value) { 191 + try {
192 - // 已加入家庭,跳转到dashboard页面 192 + // 重新查询家庭状态
193 - Taro.redirectTo({ 193 + const { code, data } = await getMyFamiliesAPI();
194 - url: '/pages/Dashboard/index' 194 + const currentHasFamily = code && data && data?.families?.length > 0;
195 - }); 195 +
196 - } else { 196 + if (currentHasFamily) {
197 - // 未加入家庭,跳转到welcome页面 197 + // 已加入家庭,跳转到dashboard页面
198 - Taro.redirectTo({ 198 + Taro.redirectTo({
199 - url: '/pages/Welcome/index' 199 + url: '/pages/Dashboard/index'
200 - }); 200 + });
201 + } else {
202 + // 未加入家庭,跳转到welcome页面
203 + Taro.redirectTo({
204 + url: '/pages/Welcome/index'
205 + });
206 + }
207 + } catch (error) {
208 + console.error('查询家庭状态失败:', error);
209 + // 查询失败时,使用之前的状态进行跳转
210 + if (hasFamily.value) {
211 + // 已加入家庭,跳转到dashboard页面
212 + Taro.redirectTo({
213 + url: '/pages/Dashboard/index'
214 + });
215 + } else {
216 + // 未加入家庭,跳转到welcome页面
217 + Taro.redirectTo({
218 + url: '/pages/Welcome/index'
219 + });
220 + }
201 } 221 }
202 }; 222 };
203 223
......