From d149de1f421de412380eb81bab2e7cccee9cbd77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=88=90?= Date: Fri, 6 Feb 2026 00:26:31 +0800 Subject: [PATCH] 1 --- README.md | 6 +- project.config.json | 3 +- .../DistanceQuickFilterV2/index.tsx | 2 +- src/components/HomeNavbar/index.tsx | 51 ++++++++------- src/main_pages/components/ListPageContent.tsx | 19 ++++-- src/services/listApi.ts | 2 +- src/store/dictionaryStore.ts | 7 +- src/store/listStore.ts | 64 +++++++++---------- src/store/userStore.ts | 10 +-- 9 files changed, 91 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index f6aa878..e8e5643 100644 --- a/README.md +++ b/README.md @@ -148,4 +148,8 @@ src/ ## License -MIT \ No newline at end of file +MIT + +"appid": "wx915ecf6c01bea4ec", + + "appid": "wx815b533167eb7b53", \ No newline at end of file diff --git a/project.config.json b/project.config.json index fcd025f..3812516 100644 --- a/project.config.json +++ b/project.config.json @@ -2,7 +2,8 @@ "miniprogramRoot": "dist/", "projectname": "playBallTogether", "description": "playBallTogether", - "appid": "wx915ecf6c01bea4ec", + "appid": "wx815b533167eb7b53", + "setting": { "urlCheck": true, "es6": true, diff --git a/src/components/DistanceQuickFilterV2/index.tsx b/src/components/DistanceQuickFilterV2/index.tsx index 2989a64..c6aa7a0 100644 --- a/src/components/DistanceQuickFilterV2/index.tsx +++ b/src/components/DistanceQuickFilterV2/index.tsx @@ -116,7 +116,7 @@ const DistanceQuickFilterV2 = (props) => { // 延时一下 await new Promise(resolve => setTimeout(resolve, 600)); // 先清除缓存和 area,确保使用最新的用户信息 - await updateCache( ["中国", response.data.last_location_province]); + await updateCache( [ response.data.last_location_province, response.data.last_location_city ]); } diff --git a/src/components/HomeNavbar/index.tsx b/src/components/HomeNavbar/index.tsx index 019eea6..361369b 100644 --- a/src/components/HomeNavbar/index.tsx +++ b/src/components/HomeNavbar/index.tsx @@ -105,15 +105,15 @@ const HomeNavbar = (props: IProps) => { const userInfo = useUserInfo(); // 使用用户详情接口中的 last_location 字段 // USER_SELECTED_CITY 第二个值应该是省份/直辖市,不能是区 - const lastLocationProvince = (userInfo as any)?.last_location_province || ""; + const lastLocationCity = (userInfo as any)?.last_location_city || ""; // 只使用省份/直辖市,不使用城市(城市可能是区) - const detectedLocation = lastLocationProvince; + const detectedLocation = lastLocationCity; // 检查是否应该显示定位确认弹窗 const should_show_location_dialog = (): boolean => { try { const current_time = Date.now(); - + // 检查是否在2小时内切换过城市 const city_change_time = (Taro as any).getStorageSync(CITY_CHANGE_TIME_KEY); if (city_change_time) { @@ -127,13 +127,13 @@ const HomeNavbar = (props: IProps) => { (Taro as any).removeStorageSync(CITY_CHANGE_TIME_KEY); } } - + // 检查是否在2小时内已选择"继续浏览" const dismiss_time = (Taro as any).getStorageSync(LOCATION_DIALOG_DISMISS_TIME_KEY); if (!dismiss_time) { return true; // 没有记录,可以显示 } - + const time_diff = current_time - dismiss_time; // 如果距离上次选择"继续浏览"已超过2小时,可以再次显示 if (time_diff >= TWO_HOURS_MS) { @@ -141,7 +141,7 @@ const HomeNavbar = (props: IProps) => { (Taro as any).removeStorageSync(LOCATION_DIALOG_DISMISS_TIME_KEY); return true; } - + // 在2小时内,不显示弹窗 console.log(`[HomeNavbar] 距离上次选择"继续浏览"还不到2小时,剩余时间: ${Math.ceil((TWO_HOURS_MS - time_diff) / 1000 / 60)}分钟`); return false; @@ -158,7 +158,7 @@ const HomeNavbar = (props: IProps) => { console.log('[HomeNavbar] 用户在2小时内已选择"继续浏览"或切换过城市,不显示弹窗'); return; } - + console.log('[HomeNavbar] 准备显示定位确认弹窗,隐藏 GuideBar'); setLocationDialogData({ detectedProvince: detectedLocation, cachedCity }); setLocationDialogVisible(true); @@ -172,13 +172,13 @@ const HomeNavbar = (props: IProps) => { useEffect(() => { // 1. 优先尝试从缓存中读取上次的定位信息 const cachedCity = (Taro as any).getStorageSync(CITY_CACHE_KEY); - + if (cachedCity && Array.isArray(cachedCity) && cachedCity.length === 2) { // 如果有缓存的定位信息,使用缓存 const cachedCityArray = cachedCity as [string, string]; console.log("[HomeNavbar] 使用缓存的定位城市:", cachedCityArray); updateArea(cachedCityArray); - + // 如果用户详情中有位置信息,且与缓存不一致,检查是否需要弹窗 if (detectedLocation && cachedCityArray[1] !== detectedLocation) { // 检查时间缓存,如果没有或过期,则弹出选择框 @@ -192,7 +192,7 @@ const HomeNavbar = (props: IProps) => { } else if (detectedLocation) { // 只有在完全没有缓存的情况下,才使用用户详情中的位置信息 console.log("[HomeNavbar] 没有缓存,使用用户详情中的位置信息:", detectedLocation); - const newArea: [string, string] = ["中国", detectedLocation]; + const newArea: [string, string] = [(userInfo as any)?.last_location_province || "", detectedLocation]; updateArea(newArea); // 保存定位信息到缓存 (Taro as any).setStorageSync(CITY_CACHE_KEY, newArea); @@ -263,10 +263,10 @@ const HomeNavbar = (props: IProps) => { // 处理定位弹窗确认 const handleLocationDialogConfirm = () => { if (!locationDialogData) return; - + const { detectedProvince } = locationDialogData; // 用户选择"切换到",使用用户详情中的位置信息 - const newArea: [string, string] = ["中国", detectedProvince]; + const newArea: [string, string] = [(userInfo as any)?.last_location_province || "", detectedProvince]; updateArea(newArea); // 更新缓存为新的定位信息 (Taro as any).setStorageSync(CITY_CACHE_KEY, newArea); @@ -279,13 +279,13 @@ const HomeNavbar = (props: IProps) => { console.error('保存城市切换时间失败:', error); } console.log("切换到用户详情中的位置信息并更新缓存:", detectedProvince); - + // 关闭弹窗 setLocationDialogVisible(false); setLocationDialogData(null); // 关闭弹窗时显示 GuideBar setShowGuideBar(true); - + // 刷新数据 handleCityChangeWithoutCache(); }; @@ -293,11 +293,11 @@ const HomeNavbar = (props: IProps) => { // 处理定位弹窗取消(用户选择"继续浏览") const handleLocationDialogCancel = () => { if (!locationDialogData) return; - + const { cachedCity } = locationDialogData; // 用户选择"继续浏览",保持缓存的定位城市 console.log("保持缓存的定位城市:", cachedCity[1]); - + // 记录用户选择"继续浏览"的时间戳,2小时内不再提示 try { const current_time = Date.now(); @@ -306,7 +306,7 @@ const HomeNavbar = (props: IProps) => { } catch (error) { console.error('保存定位弹窗关闭时间失败:', error); } - + // 关闭弹窗 setLocationDialogVisible(false); setLocationDialogData(null); @@ -321,7 +321,7 @@ const HomeNavbar = (props: IProps) => { if (cityPopupVisible) { setCityPopupVisible(false); } - + const currentPagePath = getCurrentFullPath(); if (currentPagePath === "/game_pages/searchResult/index") { (Taro as any).navigateBack(); @@ -338,7 +338,7 @@ const HomeNavbar = (props: IProps) => { if (cityPopupVisible) { setCityPopupVisible(false); } - + // 如果当前在列表页,点击后页面回到顶部 if (getCurrentFullPath() === "/main_pages/index") { // 使用父组件传递的滚动方法(适配 ScrollView) @@ -363,7 +363,7 @@ const HomeNavbar = (props: IProps) => { if (cityPopupVisible) { setCityPopupVisible(false); } - + if (leftIconClick) { leftIconClick(); } else { @@ -397,10 +397,10 @@ const HomeNavbar = (props: IProps) => { const handleCityChange = async (_newArea: any) => { // 用户手动选择的城市保存到缓存 console.log("用户手动选择城市,更新缓存:", _newArea); - + // 先更新 area 状态(用于界面显示和接口参数) updateArea(_newArea); - + // 保存城市到缓存 try { (Taro as any).setStorageSync(CITY_CACHE_KEY, _newArea); @@ -411,7 +411,7 @@ const HomeNavbar = (props: IProps) => { } catch (error) { console.error("保存城市缓存失败:", error); } - + // 先调用列表接口(会使用更新后的 state.area) if (refreshBothLists) { await refreshBothLists(); @@ -481,9 +481,8 @@ const HomeNavbar = (props: IProps) => { {/* 搜索导航 */} {!showTitle && (