1
This commit is contained in:
@@ -185,7 +185,7 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
gamesNum: 0,
|
||||
|
||||
// 组装搜索数据
|
||||
getSearchParams: () => {
|
||||
getSearchParams: (overrideArea?: [string, string]) => {
|
||||
const state = get();
|
||||
const currentPageState = state.isSearchResult ? state.searchPageState : state.listPageState;
|
||||
const filterOptions = currentPageState?.filterOptions || {};
|
||||
@@ -193,9 +193,12 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
const distanceQuickFilter = currentPageState?.distanceQuickFilter || {};
|
||||
const { distanceFilter, order, district } = distanceQuickFilter || {};
|
||||
|
||||
// 从用户信息中获取 last_location_province 和 last_location_city
|
||||
// 优先使用 overrideArea(切换城市时传入),其次使用 area 状态中的省份,最后使用用户信息中的
|
||||
const areaProvince = overrideArea?.at(1) || state.area?.at(1) || "";
|
||||
const userInfo = useUser.getState().user as any;
|
||||
const last_location_province = userInfo?.last_location_province || "";
|
||||
const userLastLocationProvince = userInfo?.last_location_province || "";
|
||||
// 优先使用切换后的城市,如果没有切换过则使用用户信息中的
|
||||
const last_location_province = areaProvince || userLastLocationProvince;
|
||||
const last_location_city = userInfo?.last_location_city || "";
|
||||
|
||||
// city 参数逻辑:
|
||||
@@ -221,16 +224,13 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
ntrpMax: filterOptions?.ntrp?.[1],
|
||||
dateRange: dateRange, // 确保始终是两个值的数组
|
||||
distanceFilter: distanceFilter,
|
||||
last_location_province: last_location_province, // 使用 last_location_province
|
||||
province: last_location_province, // 使用 province 替代 last_location_province
|
||||
};
|
||||
|
||||
// 只在有值时添加 city 参数(使用 last_location_city)
|
||||
// 只在有值时添加 city 参数
|
||||
if (city) {
|
||||
searchOption.last_location_city = city;
|
||||
} else if (last_location_city) {
|
||||
// 如果没有选择行政区,但有 last_location_city,则使用它
|
||||
searchOption.last_location_city = last_location_city;
|
||||
}
|
||||
searchOption.city = city;
|
||||
}
|
||||
|
||||
const params = {
|
||||
pageOption: currentPageState?.pageOption,
|
||||
@@ -337,13 +337,13 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
},
|
||||
|
||||
// 同时更新两个列表接口(常规列表和智能排序列表)
|
||||
refreshBothLists: async () => {
|
||||
refreshBothLists: async (overrideArea?: [string, string]) => {
|
||||
const state = get();
|
||||
const { getSearchParams, setListData } = state;
|
||||
const { getGamesList, getGamesIntegrateList } = await import("../services/listApi");
|
||||
|
||||
try {
|
||||
const searchParams = getSearchParams() || {};
|
||||
const searchParams = getSearchParams(overrideArea) || {};
|
||||
|
||||
// 调用常规列表接口
|
||||
const listParams = {
|
||||
@@ -408,11 +408,14 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
},
|
||||
|
||||
// 获取球局数量
|
||||
fetchGetGamesCount: async () => {
|
||||
const { getSearchParams } = get();
|
||||
const params = getSearchParams() || {};
|
||||
fetchGetGamesCount: async (overrideArea?: [string, string]) => {
|
||||
const state = get();
|
||||
const { getSearchParams } = state;
|
||||
const params = getSearchParams(overrideArea) || {};
|
||||
console.log("fetchGetGamesCount 参数:", { overrideArea, params: JSON.stringify(params) });
|
||||
const resData = (await getGamesCount(params)) || {};
|
||||
const gamesNum = resData?.data?.count || 0;
|
||||
console.log("fetchGetGamesCount 结果:", gamesNum);
|
||||
set({ gamesNum });
|
||||
},
|
||||
|
||||
@@ -695,9 +698,7 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
},
|
||||
|
||||
updateArea(payload: [string, string]) {
|
||||
const state = get();
|
||||
set({
|
||||
...state,
|
||||
area: payload,
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user