增加日历
This commit is contained in:
@@ -6,7 +6,6 @@ import styles from "./index.module.scss";
|
||||
import { Button } from "@nutui/nutui-react-taro";
|
||||
import { useListStore } from "src/store/listStore";
|
||||
import { BubbleOption, FilterPopupProps } from "../../../types/list/types";
|
||||
import dateRangeUtils from '@/utils/dateRange'
|
||||
import dayjs from "dayjs";
|
||||
import { CalendarUI } from "@/components";
|
||||
// 场地
|
||||
@@ -16,13 +15,6 @@ import GamePlayType from "@/components/GamePlayType";
|
||||
import { useDictionaryActions } from "@/store/dictionaryStore";
|
||||
import { View } from "@tarojs/components";
|
||||
|
||||
|
||||
const dateTrabseformMap = {
|
||||
'1': dateRangeUtils.getThisWeekend,
|
||||
'2': dateRangeUtils.getNextWeekRange,
|
||||
'3': dateRangeUtils.getNextMonthRange
|
||||
}
|
||||
|
||||
const FilterPopup = (props: FilterPopupProps) => {
|
||||
const {
|
||||
loading,
|
||||
@@ -44,12 +36,13 @@ const FilterPopup = (props: FilterPopupProps) => {
|
||||
* @param dictionaryValue 字典选项
|
||||
* @returns 选项列表
|
||||
*/
|
||||
const [selectedDates, setSelectedDates] = useState<String[]>([])
|
||||
// const [selectedDates, setSelectedDates] = useState<String[]>([])
|
||||
|
||||
const handleDateChange = (dates: Date[]) => {
|
||||
const dateArray = dates.map(date => dayjs(date).format('YYYY-MM-DD'))
|
||||
setSelectedDates(dateArray)
|
||||
console.log('选中的日期:', dateArray)
|
||||
onChange({
|
||||
'dateRange': dateArray,
|
||||
})
|
||||
}
|
||||
|
||||
const handleOptions = (dictionaryValue: []) => {
|
||||
@@ -89,29 +82,6 @@ const FilterPopup = (props: FilterPopupProps) => {
|
||||
onCancel();
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 日期选择
|
||||
* @param date 日期
|
||||
*/
|
||||
const handleDateRangeChange = (date: Date) => {
|
||||
onChange({
|
||||
'dateRange': [date, date],
|
||||
'dateRangeQuick': '',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 点击 本周末 一周内 一月内
|
||||
*/
|
||||
const handleDateRangeQuickClick = (name, value) => {
|
||||
const date = dateTrabseformMap?.[value]()
|
||||
onChange({
|
||||
'dateRange': [date?.start, date?.end],
|
||||
[name]: value,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Popup
|
||||
@@ -127,22 +97,10 @@ const FilterPopup = (props: FilterPopupProps) => {
|
||||
<div className={styles.filterPopupWrapper}>
|
||||
{/* 日历 */}
|
||||
<View>
|
||||
{/* 快捷选日期 */}
|
||||
<View>
|
||||
<Bubble
|
||||
options={dateRangeOptions}
|
||||
value={filterOptions?.dateRangeQuick}
|
||||
onChange={handleDateRangeQuickClick}
|
||||
layout="grid"
|
||||
size="small"
|
||||
columns={3}
|
||||
name="dateRangeQuick"
|
||||
/>
|
||||
</View>
|
||||
<CalendarUI
|
||||
type="multiple"
|
||||
isBorder={true}
|
||||
value={selectedDates}
|
||||
value={filterOptions?.dateRange}
|
||||
onChange={handleDateChange}
|
||||
/>
|
||||
</View>
|
||||
@@ -164,9 +122,10 @@ const FilterPopup = (props: FilterPopupProps) => {
|
||||
max={5.0}
|
||||
step={0.5}
|
||||
className={styles.filterPopupRange}
|
||||
onChange={handleFilterChange}
|
||||
onChange={(value) => {
|
||||
handleFilterChange("ntrp", value)
|
||||
}}
|
||||
value={filterOptions?.ntrp}
|
||||
name="ntrp"
|
||||
/>
|
||||
|
||||
{/* 场次气泡选项 */}
|
||||
|
||||
@@ -16,7 +16,7 @@ interface RangeProps {
|
||||
};
|
||||
disabled?: boolean;
|
||||
className?: string;
|
||||
name: string;
|
||||
name?: string;
|
||||
showTitle?: boolean;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ const NtrpRange: React.FC<RangeProps> = ({
|
||||
if (Number(start) === Number(min) && Number(end) === Number(max)) {
|
||||
return "不限";
|
||||
}
|
||||
return `${start.toFixed(1)} - ${end.toFixed(1)}之间`;
|
||||
return `${start?.toFixed(1)} - ${end?.toFixed(1)}之间`;
|
||||
}, [JSON.stringify(currentValue || []), min, max]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -51,11 +51,12 @@ export const useGlobalStore = create<GlobalStore>()((set, get) => ({
|
||||
|
||||
// 获取位置信息
|
||||
getCurrentLocationInfo: () => {
|
||||
getCurrentLocation().then((res) => {
|
||||
return getCurrentLocation().then((res) => {
|
||||
set({
|
||||
getLocationLoading: false,
|
||||
location: res || {},
|
||||
});
|
||||
return res;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -18,9 +18,10 @@ import dateRangeUtils from '@/utils/dateRange'
|
||||
// 完整的 Store 类型
|
||||
type TennisStore = ListState & ListActions;
|
||||
|
||||
const toDate = dateRangeUtils?.formatDate(new Date())
|
||||
|
||||
const defaultFilterOptions: IFilterOptions = {
|
||||
dateRange: [new Date(), new Date()], // 日期区间
|
||||
dateRangeQuick: '',
|
||||
dateRange: [toDate, toDate], // 日期区间
|
||||
timeSlot: "", // 时间段
|
||||
ntrp: [1, 5], // NTRP 水平区间
|
||||
venueType: "", // 场地类型
|
||||
@@ -124,7 +125,6 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
getSearchParams: () => {
|
||||
const state = get();
|
||||
const filterOptions = state?.filterOptions || {};
|
||||
console.log('===1111filterOptions', filterOptions)
|
||||
const distanceQuickFilter = state?.distanceQuickFilter || {};
|
||||
const params = {
|
||||
pageOption: state.pageOption,
|
||||
@@ -133,10 +133,7 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
title: state.searchValue,
|
||||
ntrpMin: filterOptions?.ntrp?.[0],
|
||||
ntrpMax: filterOptions?.ntrp?.[1],
|
||||
dateRange: [
|
||||
dateRangeUtils.formatDate(filterOptions?.dateRange?.[0]),
|
||||
dateRangeUtils.formatDate(filterOptions?.dateRange?.[1])
|
||||
],
|
||||
dateRange: filterOptions?.dateRange,
|
||||
},
|
||||
order: distanceQuickFilter?.quick,
|
||||
lat: state?.location?.latitude,
|
||||
@@ -152,7 +149,8 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
const { error, data, loading, gamesNum } = payload;
|
||||
const saveKey = isSearchResult ? "searchResultData" : "matches";
|
||||
const saveData = { error, loading, gamesNum, [saveKey]: data };
|
||||
set(saveData);
|
||||
console.log('===saveData', saveData)
|
||||
set({...saveData});
|
||||
},
|
||||
|
||||
// 获取列表数据(常规搜索)
|
||||
|
||||
Reference in New Issue
Block a user