import { View, Text, FlatList, RefreshControl } from "react-native"; import { Image } from "expo-image"; import React, { useState, useEffect } from "react"; import { useTailwind } from "tailwind-rn"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import Empty from "../../components/Empty"; import { ListItem, Button } from "@rneui/themed"; import { useNavigation } from "@react-navigation/native"; import Toast from "react-native-toast-message"; import baseRequest from "../../utils/baseRequest"; import GetWechatModal from "../../components/GetWechatModal"; import SubmitWechatModal from "../../components/SubmitWechatModal"; import { generateSignature } from "../../utils/crypto"; const blurhash = "LcKUTa%gOYWBYRt6xuoJo~s8V@fk"; export default function UnlockedWechat() { const navigation = useNavigation(); const tailwind = useTailwind(); const insets = useSafeAreaInsets(); //查询数据 const [data, setData] = useState([]); const [offset, setOffset] = useState(0); const [more, setMore] = useState(1); const apiUrl = process.env.EXPO_PUBLIC_API_URL; const getData = async () => { if (!more) return; try { const base = await baseRequest(); const signature = await generateSignature({ offset: offset, limit: 12, ...base, }); //查已解锁微信的主播的mid const response = await fetch( `${apiUrl}/api/vas/get_unlock_wechat_list?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ offset: offset, limit: 12, ...base, }), } ); const temData = await response.json(); if (temData.ret === -1) { Toast.show({ type: "error", text1: temData.msg, topOffset: 60, }); return; } setData([...data, ...temData.data.list]); setOffset(temData.data.offset); setMore(temData.data.more); } catch (error) { console.error(error); } }; useEffect(() => { getData(); }, []); //设置当前需要显示的查看微信modal的类型和streameMid const [isGetWechatModalVisible, setIsGetWechatModalVisible] = useState(false); const [isSubmitWechatModalVisible, setIsSubmitWechatModalVisible] = useState(false); const [streamerMid, setStreamerMid] = useState(); //单条记录组件 const renderItem = ({ item }) => { const handleWechatModal = async () => { setStreamerMid(item.account.mid); if (item.lock_type === 1) { setIsSubmitWechatModalVisible(!isSubmitWechatModalVisible); } else { setIsGetWechatModalVisible(!isGetWechatModalVisible); } }; return ( navigation.navigate("StreamerProfile", { mid: item.account.mid, }) } bottomDivider containerStyle={tailwind("p-0 bg-transparent")} > {item.account.name} {item.streamer.bio} ); }; //下拉刷新 const [refreshing, setRefreshing] = useState(false); //下拉刷新 const handleRefresh = async () => { setRefreshing(true); await getData(); setRefreshing(false); }; return ( handleRefresh()} /> } onEndReached={() => getData()} ListEmptyComponent={} /> ); }