更新成员搜索功能

This commit is contained in:
al 2024-09-07 00:15:17 +08:00
parent 30b43de2ba
commit da5463f0db
6 changed files with 80 additions and 73 deletions

View File

@ -424,27 +424,13 @@ export default function Search({ navigation, route }) {
}
}, []);
const handleChangeComprehensiveSliderValue = useCallback((value, item) => {
if (item.key == "age") {
setCurrentFiltersChangeValue((old) => ({
setCurrentFiltersChangeValue((old) => {
let newCurrentFiltersChangeValue = {
...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,
}));
}
};
newCurrentFiltersChangeValue[item.key] = value;
return { ...old, ...newCurrentFiltersChangeValue };
});
}, []);
//
@ -962,12 +948,18 @@ export default function Search({ navigation, route }) {
}
onPress={
() =>
setCurrentFiltersChangeValue((old) => ({
...old,
is_active_within_a_week: old.is_active_within_a_week
// setCurrentFiltersChangeValue((old) => ({
// ...old,
// is_active_within_a_week: old.is_active_within_a_week
// ? 0
// : 1,
// }))
handleChangeComprehensiveSliderValue(
currentFiltersChangeValue.is_active_within_a_week
? 0
: 1,
}))
item
)
// setFiltersValue((old) => ({
// ...old,
// is_active_within_a_week: old.is_active_within_a_week
@ -995,15 +987,7 @@ export default function Search({ navigation, route }) {
: currentFiltersChangeValue?.city
}
onChange={(value) =>
setCurrentFiltersChangeValue((old) => {
let newValue = { ...old };
if (item.key == "constellation") {
newValue.constellation = value;
} else {
newValue.city = value;
}
return newValue;
})
handleChangeComprehensiveSliderValue(value, item)
}
/>
)}

View File

@ -152,7 +152,7 @@ export default function AllSpaceMember({ zid }) {
onRefresh={() => handleRefresh()}
/>
}
ononEndReached={() => getData()}
onEndReached={() => getData()}
ListEmptyComponent={<Empty type="nodata" />}
ListHeaderComponent={() => (
<View

View File

@ -152,7 +152,7 @@ export default function IronfanSpaceMember({ zid }) {
onRefresh={() => handleRefresh()}
/>
}
ononEndReached={() => getData()}
onEndReached={() => getData()}
ListEmptyComponent={<Empty type="nodata" />}
ListHeaderComponent={() => (
<View

View File

@ -152,7 +152,7 @@ export default function SuperFanSpaceMember({ zid }) {
onRefresh={() => handleRefresh()}
/>
}
ononEndReached={() => getData()}
onEndReached={() => getData()}
ListEmptyComponent={<Empty type="nodata" />}
ListHeaderComponent={() => (
<View

View File

@ -3,6 +3,7 @@ import {
Text,
FlatList,
ScrollView,
TouchableOpacity,
Image as NativeImage,
} from "react-native";
import React, { useState, useEffect, useRef } from "react";
@ -25,26 +26,27 @@ export default function SpaceSearch({ navigation }) {
const [isloading, setIsloading] = useState(false);
const searchRef = useRef(null);
const getData = async (searchValue) => {
if (searchValue?.length != 6) {
setIsloading(false);
return;
}
// if (searchValue?.length != 6) {
// return;
// }
if (/[^0-9]/.test(searchValue)) {
setIsloading(false);
Toast.show({
type: "error",
text1: "请输入完整用户ID",
text1: "请输入正确的用户ID",
topOffset: 60,
});
return;
}
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
setIsloading(true);
const base = await baseRequest();
const body = {
member_user_id: Number(searchValue),
...base,
};
console.log("vvvvvv", JSON.stringify(body));
const signature = await generateSignature(body);
const _response = await fetch(
`${apiUrl}/api/zone/search_zone_member?signature=${signature}`,
@ -58,7 +60,6 @@ export default function SpaceSearch({ navigation }) {
);
const _data = await _response.json();
if (_data.ret === -1) {
// console.log("_data", _data);
setIsloading(false);
Toast.show({
type: "error",
@ -68,10 +69,10 @@ export default function SpaceSearch({ navigation }) {
return;
}
setData(_data.data.list);
setIsloading(false);
} catch (error) {
console.error(error);
}
setIsloading(false);
};
//focus
useEffect(() => {
@ -79,21 +80,20 @@ export default function SpaceSearch({ navigation }) {
getData();
}, []);
//
useEffect(() => {
if (!search) {
setData([]);
return;
}
let ignore = false;
getData(search);
return () => {
ignore = true;
};
}, [search]);
// useEffect(() => {
// if (!search) {
// setData([]);
// return;
// }
// let ignore = false;
// // getData(search);
// return () => {
// ignore = true;
// };
// }, [search]);
const updateSearch = (search) => {
setSearch(search);
if (!search) return;
setIsloading(true);
};
//
const RenderItem = ({ item }) => {
@ -225,22 +225,45 @@ export default function SpaceSearch({ navigation }) {
color="white"
onPress={() => navigation.goBack()}
/>
<SearchBar
ref={searchRef}
containerStyle={tailwind("flex-1 bg-[#07050A]")}
inputContainerStyle={tailwind("h-10 bg-[#FFFFFF1A]")}
inputStyle={tailwind("text-white")}
inputMode="numeric"
placeholder="请输入完整用户ID"
platform="ios"
cancelButtonProps={tailwind("text-[#FF669E]")}
cancelButtonTitle="清空"
clearIcon={() => <></>}
searchIcon={() => <></>}
showLoading={isloading}
onChangeText={updateSearch}
value={search}
/>
<View style={tailwind("flex-1 flex flex-row items-center")}>
<SearchBar
ref={searchRef}
containerStyle={{
...tailwind("bg-[#07050A]"),
width: "80%",
}}
inputContainerStyle={tailwind("h-10 bg-[#FFFFFF1A]")}
inputStyle={tailwind("text-white")}
inputMode="numeric"
placeholder="请输入完整用户ID"
platform="ios"
// cancelButtonProps={tailwind("text-[#FF669E]")}
cancelButtonTitle=""
clearIcon={() => <></>}
showCancel={false}
searchIcon={() => <></>}
showLoading={isloading}
onChangeText={updateSearch}
value={search}
/>
<TouchableOpacity
style={{
...tailwind(
"bg-[#FF669E] text-center rounded-lg px-2 py-1 flex-1 h-10 items-center justify-center"
),
}}
onPress={() => getData(search)}
>
<Text
style={{
...tailwind("text-center text-white text-base font-bold"),
width: 48,
}}
>
搜索
</Text>
</TouchableOpacity>
</View>
</View>
<ScrollView style={tailwind("flex-1")}>
<View style={tailwind("flex-1 px-4")}>

View File

@ -29,7 +29,7 @@ export async function storeAppInfo() {
if (Platform.OS === "android") {
if (!notFirstTimeOpenApp) return "";
return Application.getAndroidId();
} else {
} else if (Platform.OS === "ios") {
return await Application.getIosIdForVendorAsync();
}
}