diff --git a/screeens/Search/index.jsx b/screeens/Search/index.jsx index eec8309..1639ce3 100644 --- a/screeens/Search/index.jsx +++ b/screeens/Search/index.jsx @@ -30,6 +30,21 @@ import MyDivider from "../../components/MyDivider/index"; import MySlider from "../../components/MySlider"; import Picker from "../../components/Picker"; import { get } from "../../utils/storeInfo"; +const filterComprehensiveItems = { + age: { lower_bound: 18, upper_bound: 60 }, + fans: { lower_bound: 1, upper_bound: 1000 }, + weight: { lower_bound: 35, upper_bound: 100 }, + height: { lower_bound: 140, upper_bound: 200 }, + city: "", + constellation: "", + is_active_within_a_week: 0, + comprehensiveUsed: { show: false, used: false }, +}; +const filterPriceItems = { + zone_admission_price: { lower_bound: 0, upper_bound: 4000 }, + wechat_coin_price: { lower_bound: 0, upper_bound: 100000 }, + priceUsed: { show: false, used: false }, +}; export default function Search({ navigation, route }) { const tailwind = useTailwind(); const insets = useSafeAreaInsets(); @@ -201,21 +216,13 @@ export default function Search({ navigation, route }) { }, ]; const [filtersValue, setFiltersValue] = useState({ - age: { lower_bound: 18, upper_bound: 60 }, - fans: { lower_bound: 1, upper_bound: 1000 }, - height: { lower_bound: 140, upper_bound: 200 }, - weight: { lower_bound: 35, upper_bound: 100 }, - city: "", - constellation: "", - is_active_within_a_week: 0, - zone_admission_price: { lower_bound: 0, upper_bound: 4000 }, - wechat_coin_price: { lower_bound: 0, upper_bound: 100000 }, - priceUsed: { show: false, used: false }, - comprehensiveUsed: { show: false, used: false }, + ...filterComprehensiveItems, + ...filterPriceItems, + }); + const [currentFiltersChangeValue, setCurrentFiltersChangeValue] = useState({ + ...filterComprehensiveItems, + ...filterPriceItems, }); - const [currentFiltersChangeValue, setCurrentFiltersChangeValue] = useState( - {} - ); const updateSearch = (search) => { setSearch(search); if (!search) return; @@ -274,13 +281,9 @@ export default function Search({ navigation, route }) { }; const getResult = async () => { if (filtersValue.comprehensiveUsed.used || filtersValue.priceUsed.used) { - setFiltersValue((old) => ({ - ...old, - comprehensiveUsed: { show: false, used: false }, - priceUsed: { show: false, used: false }, - })); + handleResetFiltersValue(); + handleResetFiltersSearchValue(); } - const apiUrl = process.env.EXPO_PUBLIC_API_URL; const isSearchInt = isNumeric(search); let api; @@ -344,10 +347,11 @@ export default function Search({ navigation, route }) { if (search != "") { setSearch(""); } - setFiltersValue({ - ...filtersValue, - ...currentFiltersChangeValue, - // comprehensiveUsed: { show: false, used: true }, + setFiltersValue((old) => { + return { + ...old, + ...obj, + }; }); const apiUrl = process.env.EXPO_PUBLIC_API_URL; const newObj = obj || { ...filtersValue, ...currentFiltersChangeValue }; @@ -405,27 +409,61 @@ export default function Search({ navigation, route }) { console.error(error); } }; + // 更新MySlider值 + const handleChangePriceSliderValue = useCallback((value, item) => { + if (item.key == "zone") { + setCurrentFiltersChangeValue((old) => ({ + ...old, + zone_admission_price: value, + })); + } else if (item.key == "wechat") { + setCurrentFiltersChangeValue((old) => ({ + ...old, + wechat_coin_price: value, + })); + } + }, []); + const handleChangeComprehensiveSliderValue = useCallback((value, item) => { + if (item.key == "age") { + setCurrentFiltersChangeValue((old) => ({ + ...old, + age: value, + })); + } else if (item.key == "fans") { + setCurrentFiltersChangeValue((old) => ({ + ...old, + fans: value, + })); + } else if (item.key == "height") { + setCurrentFiltersChangeValue((old) => ({ + ...old, + height: value, + })); + } else if (item.key == "weight") { + setCurrentFiltersChangeValue((old) => ({ + ...old, + weight: value, + })); + } + }, []); + // 重置重置筛选值 const handleResetFiltersValue = (type) => { let obj = filtersValue; if (type == "comprehensive") { obj = { ...filtersValue, - age: { lower_bound: 18, upper_bound: 60 }, - fans: { lower_bound: 1, upper_bound: 1000 }, - weight: { lower_bound: 35, upper_bound: 100 }, - height: { lower_bound: 140, upper_bound: 200 }, - city: "", - constellation: "", - is_active_within_a_week: 0, - comprehensiveUsed: { show: false, used: false }, + ...filterComprehensiveItems, }; } else if (type == "zone_admission_price") { obj = { ...filtersValue, - zone_admission_price: { lower_bound: 0, upper_bound: 4000 }, - wechat_coin_price: { lower_bound: 0, upper_bound: 100000 }, - priceUsed: { show: false, used: false }, + ...filterPriceItems, + }; + } else { + obj = { + ...filterComprehensiveItems, + ...filterPriceItems, }; } setCurrentFiltersChangeValue((old) => { @@ -442,35 +480,17 @@ export default function Search({ navigation, route }) { if (type == "comprehensive") { obj = { ...filtersValue, - age: { lower_bound: 18, upper_bound: 60 }, - fans: { lower_bound: 1, upper_bound: 1000 }, - weight: { lower_bound: 35, upper_bound: 100 }, - height: { lower_bound: 140, upper_bound: 200 }, - city: "", - constellation: "", - is_active_within_a_week: 0, - comprehensiveUsed: { show: false, used: false }, + ...filterComprehensiveItems, }; } else if (type == "zone_admission_price") { obj = { ...filtersValue, - zone_admission_price: { lower_bound: 0, upper_bound: 4000 }, - wechat_coin_price: { lower_bound: 0, upper_bound: 100000 }, - priceUsed: { show: false, used: false }, + ...filterPriceItems, }; } else { obj = { - age: { lower_bound: 18, upper_bound: 60 }, - fans: { lower_bound: 1, upper_bound: 1000 }, - weight: { lower_bound: 35, upper_bound: 100 }, - height: { lower_bound: 140, upper_bound: 200 }, - city: "", - constellation: "", - is_active_within_a_week: 0, - comprehensiveUsed: { show: false, used: false }, - zone_admission_price: { lower_bound: 0, upper_bound: 4000 }, - wechat_coin_price: { lower_bound: 0, upper_bound: 100000 }, - priceUsed: { show: false, used: false }, + ...filterComprehensiveItems, + ...filterPriceItems, }; } setFiltersValue((old) => { @@ -767,16 +787,18 @@ export default function Search({ navigation, route }) { {filtersValue.comprehensiveUsed.used && ( handleResetFiltersSearchValue("comprehensive")} + onPress={() => { + handleResetFiltersValue("comprehensive"); + handleResetFiltersSearchValue("comprehensive"); + }} style={{ - width: 48, + width: "34%", height: 32, display: "flex", alignItems: "flex-center", justifyContent: "center", backgroundColor: "#301024", borderRadius: 12, - marginRight: -8, }} > {filtersValue.priceUsed.used && ( - handleResetFiltersSearchValue("zone_admission_price") - } + onPress={() => { + handleResetFiltersValue("zone_admission_price"); + handleResetFiltersSearchValue("zone_admission_price"); + }} style={{ - width: 48, + width: "34%", height: 32, display: "flex", alignItems: "flex-center", justifyContent: "center", backgroundColor: "#301024", borderRadius: 12, - marginRight: -8, }} > !old); }} leftValue={ - item.key == "age" - ? currentFiltersChangeValue?.age?.lower_bound - : item.key == "height" - ? currentFiltersChangeValue?.height?.lower_bound - : item.key == "weight" - ? currentFiltersChangeValue?.weight?.lower_bound - : currentFiltersChangeValue?.fans?.lower_bound + currentFiltersChangeValue[item.key]?.lower_bound } rightValue={ - item.key == "age" - ? currentFiltersChangeValue?.age?.upper_bound - : item.key == "height" - ? currentFiltersChangeValue?.height?.upper_bound - : item.key == "weight" - ? currentFiltersChangeValue?.weight?.upper_bound - : currentFiltersChangeValue?.fans?.upper_bound + currentFiltersChangeValue[item.key]?.upper_bound } step={item.step} hasInfinity={item.key == "fans"} stepValues={item.stepValues} - onChange={(value) => { - if (item.key == "age") { - setCurrentFiltersChangeValue((old) => ({ - ...old, - age: value, - })); - // setFiltersValue((old) => ({ ...old, age: value })); - } else if (item.key == "fans") { - setCurrentFiltersChangeValue((old) => ({ - ...old, - fans: value, - })); - // setFiltersValue((old) => ({ ...old, fans: value })); - } else if (item.key == "height") { - setCurrentFiltersChangeValue((old) => ({ - ...old, - height: value, - })); - // setFiltersValue((old) => ({ - // ...old, - // height: value, - // })); - } else if (item.key == "weight") { - setCurrentFiltersChangeValue((old) => ({ - ...old, - weight: value, - })); - // setFiltersValue((old) => ({ - // ...old, - // weight: value, - // })); - } - }} + onChange={(value) => + handleChangeComprehensiveSliderValue(value, item) + } maximumTrackTintColor="#382435" minimumTrackTintColor="#ff75c8" processHeight={5} @@ -1094,7 +1074,10 @@ export default function Search({ navigation, route }) { return; } - getFiltersResult(); + getFiltersResult({ + ...currentFiltersChangeValue, + priceUsed: filtersValue.priceUsed, + }); setFiltersValue((old) => ({ ...old, comprehensiveUsed: { show: false, used: true }, @@ -1208,27 +1191,9 @@ export default function Search({ navigation, route }) { }} hasInfinity={true} itemKey={item.key} - onChange={(value) => { - if (item.key == "zone") { - setCurrentFiltersChangeValue((old) => ({ - ...old, - zone_admission_price: value, - })); - // setFiltersValue((old) => ({ - // ...old, - // zone_admission_price: value, - // })); - } else if (item.key == "wechat") { - setCurrentFiltersChangeValue((old) => ({ - ...old, - wechat_coin_price: value, - })); - // setFiltersValue((old) => ({ - // ...old, - // wechat_coin_price: value, - // })); - } - }} + onChange={(value) => + handleChangePriceSliderValue(value, item) + } maximumTrackTintColor="#382435" minimumTrackTintColor="#ff75c8" processHeight={5} @@ -1307,7 +1272,10 @@ export default function Search({ navigation, route }) { }); return; } - getFiltersResult(); + getFiltersResult({ + ...currentFiltersChangeValue, + comprehensiveUsed: filtersValue.comprehensiveUsed, + }); setFiltersValue((old) => ({ ...old, priceUsed: { show: false, used: true }, diff --git a/screeens/SpaceSetting/SpaceSearch/index.jsx b/screeens/SpaceSetting/SpaceSearch/index.jsx index aaf39f4..0f89292 100644 --- a/screeens/SpaceSetting/SpaceSearch/index.jsx +++ b/screeens/SpaceSetting/SpaceSearch/index.jsx @@ -33,7 +33,7 @@ export default function SpaceSearch({ navigation }) { setIsloading(false); Toast.show({ type: "error", - text1: "请输入六位用户ID", + text1: "请输入完整用户ID", topOffset: 60, }); return; @@ -45,7 +45,6 @@ export default function SpaceSearch({ navigation }) { member_user_id: Number(searchValue), ...base, }; - console.log(body); const signature = await generateSignature(body); const _response = await fetch( `${apiUrl}/api/zone/search_zone_member?signature=${signature}`, @@ -57,11 +56,9 @@ export default function SpaceSearch({ navigation }) { body: JSON.stringify(body), } ); - console.log("******", JSON.stringify(body)); - const _data = await _response.json(); if (_data.ret === -1) { - console.log("_data", _data); + // console.log("_data", _data); setIsloading(false); Toast.show({ type: "error", @@ -234,7 +231,7 @@ export default function SpaceSearch({ navigation }) { inputContainerStyle={tailwind("h-10 bg-[#FFFFFF1A]")} inputStyle={tailwind("text-white")} inputMode="numeric" - placeholder="请输入六位用户ID" + placeholder="请输入完整用户ID" platform="ios" cancelButtonProps={tailwind("text-[#FF669E]")} cancelButtonTitle="清空"