|
@@ -1,7 +1,10 @@
|
|
|
import { Barrage } from "@/components/Barrage";
|
|
import { Barrage } from "@/components/Barrage";
|
|
|
|
|
+import { CouponModal } from "@/components/CouponModal";
|
|
|
import { Colors } from "@/constants/Colors";
|
|
import { Colors } from "@/constants/Colors";
|
|
|
import { Images } from "@/constants/images";
|
|
import { Images } from "@/constants/images";
|
|
|
|
|
+import { CouponItem, getNewbieGiftBagInfo, listValidCoupon } from "@/services/activity";
|
|
|
import { getFeedbackList, getPoolList, PoolItem } from "@/services/award";
|
|
import { getFeedbackList, getPoolList, PoolItem } from "@/services/award";
|
|
|
|
|
+import { getToken } from "@/services/http";
|
|
|
import { Image } from "expo-image";
|
|
import { Image } from "expo-image";
|
|
|
import { useRouter } from "expo-router";
|
|
import { useRouter } from "expo-router";
|
|
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
@@ -140,6 +143,10 @@ export default function BoxScreen() {
|
|
|
const [current, setCurrent] = useState(1);
|
|
const [current, setCurrent] = useState(1);
|
|
|
const [hasMore, setHasMore] = useState(true);
|
|
const [hasMore, setHasMore] = useState(true);
|
|
|
const [barrageList, setBarrageList] = useState<BarrageItem[]>([]);
|
|
const [barrageList, setBarrageList] = useState<BarrageItem[]>([]);
|
|
|
|
|
+ // 新人优惠券弹窗
|
|
|
|
|
+ const [couponVisible, setCouponVisible] = useState(false);
|
|
|
|
|
+ const [couponList, setCouponList] = useState<CouponItem[]>([]);
|
|
|
|
|
+ const [newPeopleChecked, setNewPeopleChecked] = useState(false);
|
|
|
|
|
|
|
|
// 加载弹幕
|
|
// 加载弹幕
|
|
|
const loadBarrage = useCallback(async () => {
|
|
const loadBarrage = useCallback(async () => {
|
|
@@ -153,6 +160,37 @@ export default function BoxScreen() {
|
|
|
}
|
|
}
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
+ // 新人大礼包检测(Vue: initNewPeople)
|
|
|
|
|
+ const initNewPeople = useCallback(async () => {
|
|
|
|
|
+ if (newPeopleChecked) return;
|
|
|
|
|
+ const token = getToken();
|
|
|
|
|
+ if (!token) return; // 未登录不检测
|
|
|
|
|
+ try {
|
|
|
|
|
+ const data = await getNewbieGiftBagInfo();
|
|
|
|
|
+ if (data) {
|
|
|
|
|
+ setNewPeopleChecked(true);
|
|
|
|
|
+ // Vue 原项目只是展示一张海报图片,这里跳过(无具体交互)
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ // 静默失败
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [newPeopleChecked]);
|
|
|
|
|
+
|
|
|
|
|
+ // 优惠券检测(Vue: initCoupon)
|
|
|
|
|
+ const initCoupon = useCallback(async () => {
|
|
|
|
|
+ const token = getToken();
|
|
|
|
|
+ if (!token) return;
|
|
|
|
|
+ try {
|
|
|
|
|
+ const coupons = await listValidCoupon("LUCK");
|
|
|
|
|
+ if (coupons && coupons.length > 0) {
|
|
|
|
|
+ setCouponList(coupons);
|
|
|
|
|
+ setCouponVisible(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ // 静默失败
|
|
|
|
|
+ }
|
|
|
|
|
+ }, []);
|
|
|
|
|
+
|
|
|
const loadData = useCallback(
|
|
const loadData = useCallback(
|
|
|
async (isRefresh = false) => {
|
|
async (isRefresh = false) => {
|
|
|
if (loading) return;
|
|
if (loading) return;
|
|
@@ -190,6 +228,8 @@ export default function BoxScreen() {
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
loadData(true);
|
|
loadData(true);
|
|
|
loadBarrage();
|
|
loadBarrage();
|
|
|
|
|
+ initNewPeople();
|
|
|
|
|
+ initCoupon();
|
|
|
}, [typeIndex, priceSort]);
|
|
}, [typeIndex, priceSort]);
|
|
|
|
|
|
|
|
// 执行搜索
|
|
// 执行搜索
|
|
@@ -366,6 +406,17 @@ export default function BoxScreen() {
|
|
|
onEndReached={handleLoadMore}
|
|
onEndReached={handleLoadMore}
|
|
|
onEndReachedThreshold={0.3}
|
|
onEndReachedThreshold={0.3}
|
|
|
/>
|
|
/>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 新人优惠券弹窗 */}
|
|
|
|
|
+ <CouponModal
|
|
|
|
|
+ visible={couponVisible}
|
|
|
|
|
+ coupons={couponList}
|
|
|
|
|
+ onClose={() => setCouponVisible(false)}
|
|
|
|
|
+ onSuccess={() => {
|
|
|
|
|
+ setCouponList([]);
|
|
|
|
|
+ loadData(true);
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|
|
|
);
|
|
);
|