feat: 将list相关的代码迁移到game_pages目录
This commit is contained in:
4
src/game_pages/searchResult/index.config.ts
Normal file
4
src/game_pages/searchResult/index.config.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '搜索结果',
|
||||
navigationStyle: 'custom',
|
||||
})
|
||||
68
src/game_pages/searchResult/index.scss
Normal file
68
src/game_pages/searchResult/index.scss
Normal file
@@ -0,0 +1,68 @@
|
||||
.searchResultPage {
|
||||
position: relative;
|
||||
|
||||
.searchResultFilterWrapper {
|
||||
position: sticky;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 5px 15px 10px 15px;
|
||||
position: sticky;
|
||||
top: -1px;
|
||||
background-color: #fefefe;
|
||||
z-index: 123;
|
||||
|
||||
.nut-menu-bar {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.nut-menu-container-wrap {
|
||||
left: -15px;
|
||||
}
|
||||
|
||||
.filterIconWrapper {
|
||||
display: flex;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-shrink: 0;
|
||||
aspect-ratio: 1/1;
|
||||
border-radius: 999px;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.06);
|
||||
background: #FFF;
|
||||
position: relative;
|
||||
|
||||
&.active {
|
||||
background-color: #000000;
|
||||
}
|
||||
}
|
||||
|
||||
.filterIcon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.filterCount {
|
||||
background-color: #000000;
|
||||
position: absolute;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border: 2px solid #ffffff;
|
||||
border-radius: 50%;
|
||||
right: -5px;
|
||||
bottom: -5px;
|
||||
color: #ffffff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
.menuFilter {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
157
src/game_pages/searchResult/index.tsx
Normal file
157
src/game_pages/searchResult/index.tsx
Normal file
@@ -0,0 +1,157 @@
|
||||
import { View, Image, Text } from "@tarojs/components";
|
||||
// import { useSearchResultState } from "@/store/searchResultStore";
|
||||
import { useListStore } from "@/store/listStore";
|
||||
import { useGlobalState } from "@/store/global";
|
||||
import ListContainer from "@/container/listContainer";
|
||||
import img from "@/config/images";
|
||||
import CustomerNavBar from "@/container/listCustomNavbar";
|
||||
import DistanceQuickFilter from "@/components/DistanceQuickFilter";
|
||||
import { withAuth } from "@/components";
|
||||
import { useEffect } from "react";
|
||||
import FilterPopup from "@/components/FilterPopup";
|
||||
import "./index.scss";
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
const SearchResult = () => {
|
||||
const {
|
||||
isShowFilterPopup,
|
||||
error,
|
||||
distanceQuickFilter,
|
||||
searchResultData,
|
||||
recommendList,
|
||||
loading,
|
||||
updateState,
|
||||
filterCount,
|
||||
updateFilterOptions, // 更新筛选条件
|
||||
filterOptions,
|
||||
clearFilterOptions,
|
||||
distanceData,
|
||||
quickFilterData,
|
||||
loadMoreMatches,
|
||||
getMatchesData
|
||||
} = useListStore() || {};
|
||||
const { statusNavbarHeightInfo } = useGlobalState() || {};
|
||||
const { totalHeight } = statusNavbarHeightInfo || {};
|
||||
const isSelect = filterCount > 0;
|
||||
|
||||
useEffect(() => {
|
||||
const pages = Taro.getCurrentPages()
|
||||
const currentPage = pages?.[pages.length - 1];
|
||||
updateState({currentPage, isSearchResult: true})
|
||||
// if (location?.address) {
|
||||
// 保存位置
|
||||
// updateState({ location });
|
||||
// 页面加载时获取数据
|
||||
console.log('===搜索结果页===')
|
||||
getMatchesData();
|
||||
// }
|
||||
|
||||
return () => {
|
||||
console.log('===搜索结果组件卸载')
|
||||
updateState({currentPage: '', isSearchResult: false})
|
||||
}
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* @description 更新筛选条件
|
||||
* @param {Record<string, any>} params 筛选项
|
||||
*/
|
||||
const handleUpdateFilterOptions = (params: Record<string, any>) => {
|
||||
updateFilterOptions(params);
|
||||
};
|
||||
|
||||
const toggleShowPopup = () => {
|
||||
updateState({ isShowFilterPopup: !isShowFilterPopup });
|
||||
};
|
||||
|
||||
// 距离筛选
|
||||
const handleDistanceOrQuickChange = (name, value) => {
|
||||
updateState({
|
||||
distanceQuickFilter: {
|
||||
...distanceQuickFilter,
|
||||
[name]: value,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const refreshMatches = () => {
|
||||
getMatchesData();
|
||||
};
|
||||
|
||||
const handleLeftIconClick = () => {
|
||||
Taro.navigateBack()
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="searchResultPage">
|
||||
{/* 自定义导航 */}
|
||||
<CustomerNavBar
|
||||
config={{
|
||||
showInput: true,
|
||||
inputLeftIcon: img.ICON_LIST_SEARCH_BACK,
|
||||
leftIconClick: handleLeftIconClick
|
||||
}}
|
||||
/>
|
||||
{/* 筛选 */}
|
||||
<View
|
||||
className="searchResultFilterWrapper"
|
||||
style={
|
||||
{
|
||||
top: `${totalHeight}px`
|
||||
}
|
||||
}
|
||||
>
|
||||
<DistanceQuickFilter
|
||||
cityOptions={distanceData}
|
||||
quickOptions={quickFilterData}
|
||||
onChange={handleDistanceOrQuickChange}
|
||||
cityName="distance"
|
||||
quickName="quick"
|
||||
cityValue={distanceQuickFilter?.distance}
|
||||
quickValue={distanceQuickFilter?.quick}
|
||||
/>
|
||||
{/* 筛选 icon */}
|
||||
<View
|
||||
className={`filterIconWrapper ${isSelect && "active"}`}
|
||||
onClick={toggleShowPopup}
|
||||
>
|
||||
<Image
|
||||
src={isSelect ? img.ICON_FILTER_SELECTED : img.ICON_FILTER}
|
||||
className={`filterIcon ${isSelect && "active"}`}
|
||||
/>
|
||||
{isSelect && <Text className="filterCount">{filterCount}</Text>}
|
||||
</View>
|
||||
{/* 筛选弹框 */}
|
||||
{/* 综合筛选 */}
|
||||
{isShowFilterPopup && (
|
||||
<View>
|
||||
<FilterPopup
|
||||
loading={loading}
|
||||
onCancel={toggleShowPopup}
|
||||
onConfirm={toggleShowPopup}
|
||||
onChange={handleUpdateFilterOptions}
|
||||
filterOptions={filterOptions}
|
||||
onClear={clearFilterOptions}
|
||||
visible={isShowFilterPopup}
|
||||
onClose={toggleShowPopup}
|
||||
// statusNavbarHeigh={0}
|
||||
statusNavbarHeigh={statusNavbarHeightInfo?.totalHeight}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
{/* 列表内容 */}
|
||||
<ListContainer
|
||||
data={searchResultData}
|
||||
recommendList={recommendList}
|
||||
loading={loading}
|
||||
error={error}
|
||||
reload={refreshMatches}
|
||||
loadMoreMatches={loadMoreMatches}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default withAuth(SearchResult);
|
||||
Reference in New Issue
Block a user