index.tsx 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. import { Image } from 'expo-image';
  2. import { useLocalSearchParams, useRouter } from 'expo-router';
  3. import React, { useCallback, useEffect, useRef, useState } from 'react';
  4. import {
  5. ActivityIndicator,
  6. Alert,
  7. Animated,
  8. Dimensions,
  9. ImageBackground,
  10. ScrollView,
  11. StatusBar,
  12. StyleSheet,
  13. Text,
  14. TouchableOpacity,
  15. View,
  16. } from 'react-native';
  17. import { useSafeAreaInsets } from 'react-native-safe-area-context';
  18. import { Images } from '@/constants/images';
  19. import { useAuth } from '@/contexts/AuthContext';
  20. import { getBoxDetail, getWinRecords, poolIn, poolOut, previewOrder, unlockBox } from '@/services/award';
  21. import { get } from '@/services/http';
  22. import { CheckoutModal } from '../award-detail/components/CheckoutModal';
  23. import { RuleModal } from '../award-detail/components/RuleModal';
  24. import { BoxPopup, BoxPopupRef } from './components/BoxPopup';
  25. import { DetailsPopup, DetailsPopupRef } from './components/DetailsPopup';
  26. const { width: SCREEN_WIDTH } = Dimensions.get('window');
  27. interface PoolData {
  28. id: string;
  29. poolName: string;
  30. name?: string;
  31. cover: string;
  32. price: number;
  33. specialPrice?: number;
  34. bigBoxPrizes?: ProductItem[];
  35. activityGoods?: any[];
  36. }
  37. interface ProductItem {
  38. id: string;
  39. name: string;
  40. cover: string;
  41. level: string;
  42. price?: number;
  43. }
  44. interface BoxData {
  45. number: string;
  46. leftQuantity: number;
  47. lastNumber: number;
  48. lock?: { locker: string; leftTime: number };
  49. usedStat?: Record<string, { spuId: string; quantity: number }>;
  50. }
  51. // 使用正确的 API 接口
  52. const getBoxPoolDetail = async (poolId: string) => {
  53. const res = await get('/api/luck/treasure-box/pool-detail', { poolId });
  54. return res.data;
  55. };
  56. const getBoxHistory = async (poolId: string) => {
  57. const res = await get('/api/luck/treasure-box/box-history', { poolId });
  58. return res.data;
  59. };
  60. const getEmptyRunStatus = async (poolId: string) => {
  61. const res = await get('/api/luck/treasure-box/empty-run-status', { poolId });
  62. return res.data;
  63. };
  64. export default function BoxInBoxScreen() {
  65. const { poolId } = useLocalSearchParams<{ poolId: string }>();
  66. const router = useRouter();
  67. const insets = useSafeAreaInsets();
  68. const { user } = useAuth();
  69. const [loading, setLoading] = useState(true);
  70. const [data, setData] = useState<PoolData | null>(null);
  71. const [products, setProducts] = useState<ProductItem[]>([]);
  72. const [activityGoods, setActivityGoods] = useState<any[]>([]);
  73. const [boxHistory, setBoxHistory] = useState<any[]>([]);
  74. const [boxHistoryInfo, setBoxHistoryInfo] = useState<any>(null);
  75. const [box, setBox] = useState<BoxData | null>(null);
  76. const [boxNum, setBoxNum] = useState<string>('');
  77. const [currentIndex, setCurrentIndex] = useState(0);
  78. const [leftTime, setLeftTime] = useState(0);
  79. const [emptyRuns, setEmptyRuns] = useState(0);
  80. const [scrollTop, setScrollTop] = useState(0);
  81. const [tabIndex, setTabIndex] = useState(0);
  82. const [recordList, setRecordList] = useState<any[]>([]);
  83. const checkoutRef = useRef<any>(null);
  84. const ruleRef = useRef<any>(null);
  85. const boxPopupRef = useRef<BoxPopupRef>(null);
  86. const detailsPopupRef = useRef<DetailsPopupRef>(null);
  87. const floatAnim = useRef(new Animated.Value(0)).current;
  88. const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
  89. useEffect(() => {
  90. Animated.loop(
  91. Animated.sequence([
  92. Animated.timing(floatAnim, { toValue: 10, duration: 1500, useNativeDriver: true }),
  93. Animated.timing(floatAnim, { toValue: -10, duration: 1500, useNativeDriver: true }),
  94. ])
  95. ).start();
  96. }, []);
  97. const loadData = useCallback(async () => {
  98. if (!poolId) return;
  99. setLoading(true);
  100. try {
  101. const detail = await getBoxPoolDetail(poolId);
  102. if (detail) {
  103. setData({ ...detail, name: detail.poolName, price: detail.price || detail.specialPrice || 0 });
  104. setProducts(detail.bigBoxPrizes || []);
  105. setActivityGoods(detail.activityGoods || []);
  106. }
  107. } catch (error) {
  108. console.error('加载数据失败:', error);
  109. }
  110. setLoading(false);
  111. }, [poolId]);
  112. const loadBoxHistory = useCallback(async () => {
  113. if (!poolId) return;
  114. try {
  115. const res = await getBoxHistory(poolId);
  116. if (res && res.length > 0) {
  117. setBoxHistory(res);
  118. setBoxHistoryInfo(res[0]);
  119. }
  120. } catch {}
  121. }, [poolId]);
  122. const loadBox = useCallback(
  123. async (num?: string) => {
  124. if (!poolId) return;
  125. try {
  126. const res = await getBoxDetail(poolId, num);
  127. if (res) handleBoxResult(res);
  128. } catch (error) {
  129. console.error('加载盒子失败:', error);
  130. }
  131. },
  132. [poolId]
  133. );
  134. const loadEmptyRuns = useCallback(async () => {
  135. if (!poolId) return;
  136. try {
  137. const res = await getEmptyRunStatus(poolId);
  138. if (res) setEmptyRuns(res.emptyRuns || 0);
  139. } catch {}
  140. }, [poolId]);
  141. // 加载中奖记录
  142. const loadRecords = useCallback(async (boxNumber?: string) => {
  143. if (!poolId) return;
  144. try {
  145. const num = boxNumber || boxHistoryInfo?.boxNumber;
  146. if (!num) return;
  147. const res = await getWinRecords(poolId, num);
  148. if (res && res.records) {
  149. setRecordList(res.records);
  150. }
  151. } catch {}
  152. }, [poolId, boxHistoryInfo]);
  153. const refreshBox = useCallback(async () => {
  154. if (!poolId) return;
  155. try {
  156. const res = await getBoxHistory(poolId);
  157. if (res && res.length > 0) {
  158. setBoxHistory(res);
  159. setBoxHistoryInfo(res[0]);
  160. loadData();
  161. loadBox(res[0].boxNumber);
  162. loadRecords(res[0].boxNumber);
  163. }
  164. loadEmptyRuns();
  165. } catch {}
  166. }, [poolId, loadData, loadBox, loadEmptyRuns, loadRecords]);
  167. // 打开换盒弹窗
  168. const openBoxPopup = useCallback(async () => {
  169. if (!poolId) return;
  170. try {
  171. const res = await getBoxHistory(poolId);
  172. if (res && res.length > 0) {
  173. boxPopupRef.current?.open(res);
  174. }
  175. } catch {}
  176. }, [poolId]);
  177. // 选择盒子
  178. const handleSelectBox = useCallback((item: any) => {
  179. setBoxHistoryInfo(item);
  180. loadBox(item.boxNumber);
  181. loadEmptyRuns();
  182. loadRecords(item.boxNumber);
  183. }, [loadBox, loadEmptyRuns, loadRecords]);
  184. // 打开商品详情弹窗
  185. const handleShowDetails = useCallback((item: any) => {
  186. // 根据商品的 level 传入对应的奖品列表
  187. let prizes = products;
  188. if (item.level === 'NESTED_BOX_MEDIUM') {
  189. prizes = data?.mediumBoxPrizes || products;
  190. } else if (item.level === 'NESTED_BOX_SMALL') {
  191. prizes = data?.smallBoxPrizes || products;
  192. }
  193. detailsPopupRef.current?.open(item, prizes);
  194. }, [products, data]);
  195. const handleBoxResult = (res: any) => {
  196. const map: Record<string, any> = {};
  197. if (res.usedStat)
  198. res.usedStat.forEach((item: any) => {
  199. map[item.spuId] = item;
  200. });
  201. res.usedStat = map;
  202. setBox(res);
  203. setBoxNum(res.number);
  204. lockTimeStart(res);
  205. };
  206. const lockTimeStart = (boxData: BoxData) => {
  207. lockTimeEnd();
  208. if (boxData?.lock) {
  209. setLeftTime(boxData.lock.leftTime);
  210. timerRef.current = setInterval(() => {
  211. setLeftTime((prev) => {
  212. if (prev <= 1) {
  213. lockTimeEnd();
  214. loadBox();
  215. return 0;
  216. }
  217. return prev - 1;
  218. });
  219. }, 1000);
  220. }
  221. };
  222. const lockTimeEnd = () => {
  223. if (timerRef.current) {
  224. clearInterval(timerRef.current);
  225. timerRef.current = null;
  226. }
  227. setLeftTime(0);
  228. };
  229. useEffect(() => {
  230. loadData();
  231. loadBox();
  232. loadBoxHistory();
  233. loadEmptyRuns();
  234. loadRecords();
  235. if (poolId) poolIn(poolId);
  236. return () => {
  237. if (poolId) poolOut(poolId);
  238. lockTimeEnd();
  239. };
  240. }, [poolId]);
  241. const handlePay = async (num: number) => {
  242. if (!poolId || !data || !box) {
  243. Alert.alert('提示', '请先选择盒子');
  244. return;
  245. }
  246. try {
  247. const preview = await previewOrder(poolId, num, box.number);
  248. if (preview) checkoutRef.current?.show(num, preview, box.number);
  249. } catch (error) {
  250. console.error('预览订单失败:', error);
  251. }
  252. };
  253. const handleSuccess = () => {
  254. setTimeout(() => {
  255. loadData();
  256. loadBox(boxNum);
  257. loadEmptyRuns();
  258. }, 500);
  259. };
  260. const handleUnlock = async () => {
  261. if (!poolId || !boxNum) return;
  262. try {
  263. await unlockBox(poolId, boxNum);
  264. loadBox(boxNum);
  265. } catch {}
  266. };
  267. const handlePrev = () => {
  268. if (currentIndex > 0) setCurrentIndex(currentIndex - 1);
  269. };
  270. const handleNext = () => {
  271. if (currentIndex < products.length - 1) setCurrentIndex(currentIndex + 1);
  272. };
  273. const getLevelName = (level: string) => {
  274. const map: Record<string, string> = { A: '超神款', B: '欧皇款', C: '隐藏款', D: '普通款', NESTED_BOX_GUARANTEED: '保底款' };
  275. return map[level] || level;
  276. };
  277. const getLevelBg = (level: string) => {
  278. const map: Record<string, string> = {
  279. A: Images.box.detail.productItemA,
  280. B: Images.box.detail.productItemB,
  281. C: Images.box.detail.productItemC,
  282. D: Images.box.detail.productItemD,
  283. NESTED_BOX_GUARANTEED: Images.box.detail.productItemD,
  284. };
  285. return map[level] || Images.box.detail.productItemD;
  286. };
  287. const leftNum = box?.lock ? (leftTime / box.lock.leftTime) * 100 : 0;
  288. const headerBg = scrollTop > 0 ? '#333' : 'transparent';
  289. if (loading) return <View style={styles.loadingContainer}><ActivityIndicator size="large" color="#fff" /></View>;
  290. if (!data)
  291. return (
  292. <View style={styles.loadingContainer}>
  293. <Text style={styles.errorText}>奖池不存在</Text>
  294. <TouchableOpacity style={styles.backBtn2} onPress={() => router.back()}>
  295. <Text style={styles.backBtn2Text}>返回</Text>
  296. </TouchableOpacity>
  297. </View>
  298. );
  299. const currentProduct = products[currentIndex];
  300. return (
  301. <View style={styles.container}>
  302. <StatusBar barStyle="light-content" />
  303. <ImageBackground source={{ uri: Images.common.indexBg }} style={styles.background} resizeMode="cover">
  304. {/* 顶部导航 */}
  305. <View style={[styles.header, { paddingTop: insets.top, backgroundColor: headerBg }]}>
  306. <TouchableOpacity style={styles.backBtn} onPress={() => router.back()}>
  307. <Text style={styles.backText}>{'<'}</Text>
  308. </TouchableOpacity>
  309. <Text style={styles.headerTitle} numberOfLines={1}>{data.poolName || data.name}</Text>
  310. <View style={styles.placeholder} />
  311. </View>
  312. <ScrollView style={styles.scrollView} showsVerticalScrollIndicator={false} onScroll={(e) => setScrollTop(e.nativeEvent.contentOffset.y)} scrollEventThrottle={16}>
  313. {/* 主商品展示区域 */}
  314. <ImageBackground source={{ uri: Images.box.detail.mainGoodsSection }} style={styles.mainGoodsSection} resizeMode="cover">
  315. <View style={{ height: 72 + insets.top }} />
  316. <View style={styles.mainSwiper}>
  317. {currentProduct && (
  318. <>
  319. <Animated.View style={[styles.productImageBox, { transform: [{ translateY: floatAnim }] }]}>
  320. <Image source={{ uri: currentProduct.cover }} style={styles.productImage} contentFit="contain" />
  321. </Animated.View>
  322. {currentProduct.price && <Text style={styles.priceText}>¥{currentProduct.price}</Text>}
  323. <ImageBackground source={{ uri: Images.box.detail.detailsBut }} style={styles.detailsBut} resizeMode="contain">
  324. <Text style={styles.levelText}>{getLevelName(currentProduct.level)}</Text>
  325. </ImageBackground>
  326. <ImageBackground source={{ uri: Images.box.detail.nameBg }} style={styles.goodsNameBg} resizeMode="contain">
  327. <Text style={styles.goodsNameText} numberOfLines={6}>{currentProduct.name}</Text>
  328. </ImageBackground>
  329. </>
  330. )}
  331. {currentIndex > 0 && (
  332. <TouchableOpacity style={styles.prevBtn} onPress={handlePrev}>
  333. <Image source={{ uri: Images.box.detail.left }} style={styles.arrowImg} contentFit="contain" />
  334. </TouchableOpacity>
  335. )}
  336. {currentIndex < products.length - 1 && (
  337. <TouchableOpacity style={styles.nextBtn} onPress={handleNext}>
  338. <Image source={{ uri: Images.box.detail.right }} style={styles.arrowImg} contentFit="contain" />
  339. </TouchableOpacity>
  340. )}
  341. </View>
  342. <Image source={{ uri: Images.box.detail.positionBgleftBg }} style={styles.positionBgleftBg} contentFit="contain" />
  343. <Image source={{ uri: Images.box.detail.positionBgRightBg }} style={styles.positionBgRightBg} contentFit="contain" />
  344. </ImageBackground>
  345. <Image source={{ uri: Images.box.detail.mainGoodsSectionBtext }} style={styles.mainGoodsSectionBtext} contentFit="cover" />
  346. {/* 侧边按钮 */}
  347. <TouchableOpacity style={[styles.positionBut, styles.positionRule]} onPress={() => ruleRef.current?.show()}>
  348. <ImageBackground source={{ uri: Images.box.detail.positionBgLeft }} style={styles.positionButBg} resizeMode="contain">
  349. <Text style={styles.positionButText}>规则</Text>
  350. </ImageBackground>
  351. </TouchableOpacity>
  352. {box?.lock && user && box.lock.locker === (user.userId || user.id) && (
  353. <TouchableOpacity style={[styles.positionBut, styles.positionLock]} onPress={handleUnlock}>
  354. <ImageBackground source={{ uri: Images.box.detail.positionBgLeft }} style={styles.positionButBg} resizeMode="contain">
  355. <Text style={styles.positionButText}>解锁</Text>
  356. </ImageBackground>
  357. </TouchableOpacity>
  358. )}
  359. <TouchableOpacity style={[styles.positionBut, styles.positionStore]} onPress={() => router.push('/boxInBox/boxList' as any)}>
  360. <ImageBackground source={{ uri: Images.box.detail.positionBgRight }} style={styles.positionButBg} resizeMode="contain">
  361. <Text style={styles.positionButTextR}>宝箱</Text>
  362. </ImageBackground>
  363. </TouchableOpacity>
  364. <TouchableOpacity style={[styles.positionBut, styles.positionRefresh]} onPress={() => refreshBox()}>
  365. <ImageBackground source={{ uri: Images.box.detail.positionBgRight }} style={styles.positionButBg} resizeMode="contain">
  366. <Text style={styles.positionButTextR}>刷新</Text>
  367. </ImageBackground>
  368. </TouchableOpacity>
  369. {/* 空车计数 */}
  370. <View style={styles.emptyRunsBox}>
  371. <Text style={styles.emptyRunsText}>连续空车:{emptyRuns}</Text>
  372. </View>
  373. {/* 锁定倒计时 */}
  374. {box?.lock && (
  375. <View style={styles.lockTimeBox}>
  376. <Text style={styles.lockTimeLabel}>剩余时间:</Text>
  377. <View style={styles.lockTimeBarBox}>
  378. <View style={styles.lockTimeBar}>
  379. <View style={[styles.processBar, { width: `${leftNum}%` }]} />
  380. </View>
  381. <Text style={[styles.lockTimeText, { left: `${leftNum}%` }]}>{leftTime}</Text>
  382. </View>
  383. </View>
  384. )}
  385. {/* 箱子信息区域 */}
  386. <View style={styles.firstLastWrapper}>
  387. {/* 标题栏 */}
  388. <View style={styles.firstLastTitle}>
  389. <View style={styles.firstLastInfo}>
  390. {boxHistoryInfo && (
  391. <>
  392. <View style={styles.sizeInfo}>
  393. <Text style={styles.sizeLabel}>箱数:</Text>
  394. <Text style={styles.sizeValue}>{boxHistoryInfo.boxNumber}</Text>
  395. <Text style={styles.sizeLabel}>/{boxHistory.length || '-'}箱</Text>
  396. </View>
  397. <View style={styles.sizeInfo}>
  398. <Text style={styles.sizeLabel}>总数:</Text>
  399. <Text style={styles.sizeValue}>{boxHistoryInfo.leftQuantity}</Text>
  400. <Text style={styles.sizeLabel}>/{boxHistoryInfo.quantity}</Text>
  401. </View>
  402. </>
  403. )}
  404. </View>
  405. <TouchableOpacity style={styles.changeBoxBtn} onPress={openBoxPopup}>
  406. <Text style={styles.changeBoxText}>换箱</Text>
  407. </TouchableOpacity>
  408. </View>
  409. {/* Tab 切换 */}
  410. <View style={styles.tabSection}>
  411. <TouchableOpacity style={[styles.tabItem, tabIndex === 0 && styles.tabItemActive]} onPress={() => setTabIndex(0)}>
  412. <Text style={[styles.tabText, tabIndex === 0 && styles.tabTextActive]}>赏品预览</Text>
  413. </TouchableOpacity>
  414. <TouchableOpacity style={[styles.tabItem, tabIndex === 1 && styles.tabItemActive]} onPress={() => setTabIndex(1)}>
  415. <Text style={[styles.tabText, tabIndex === 1 && styles.tabTextActive]}>中奖记录</Text>
  416. </TouchableOpacity>
  417. </View>
  418. {/* 活动商品列表 */}
  419. {tabIndex === 0 && (
  420. <View style={styles.activityGoodsGrid}>
  421. {activityGoods.map((item, index) => (
  422. <TouchableOpacity key={item.id || index} style={styles.activityGoodsItem} onPress={() => handleShowDetails(item)}>
  423. <View style={styles.activityImageBox}>
  424. <Image source={{ uri: item.cover }} style={styles.activityImage} contentFit="cover" />
  425. <View style={styles.probabilityBadge}>
  426. <Text style={styles.probabilityText}>概率:{((item.probability || 0) * 100).toFixed(2)}%</Text>
  427. </View>
  428. <View style={styles.priceBadge}>
  429. <Text style={styles.priceTextSmall}>参考价:{item.price}</Text>
  430. </View>
  431. </View>
  432. <View style={[styles.levelBadgeSmall, item.level === 'NESTED_BOX_GUARANTEED' ? styles.levelD : styles.levelAll]}>
  433. <Text style={styles.levelBadgeText}>{item.level === 'NESTED_BOX_GUARANTEED' ? 'D赏' : '全局赏'}</Text>
  434. </View>
  435. <Text style={styles.activityName} numberOfLines={1}>{item.name}</Text>
  436. </TouchableOpacity>
  437. ))}
  438. </View>
  439. )}
  440. {/* 中奖记录 */}
  441. {tabIndex === 1 && (
  442. <ScrollView style={styles.recordScroll} showsVerticalScrollIndicator={false}>
  443. {recordList.length === 0 ? (
  444. <View style={styles.emptyRecord}>
  445. <Text style={styles.emptyRecordText}>暂无中奖记录</Text>
  446. </View>
  447. ) : (
  448. recordList.map((item, index) => (
  449. <View key={index} style={styles.recordItem}>
  450. <View style={styles.recordLeft}>
  451. <Text style={styles.recordNickname}>{item.nickname}</Text>
  452. <Text style={styles.recordTime}>{item.createTime} | 第{item.seatNumber}发</Text>
  453. <Text style={styles.recordPrize}>获得:<Text style={styles.recordPrizeName}>{item.prizeName}</Text></Text>
  454. </View>
  455. <View style={[styles.recordLevelBadge, item.level === 'D' ? styles.levelD : styles.levelAll]}>
  456. <Text style={styles.recordLevelText}>{item.level === 'D' ? 'D赏' : '全局赏'}</Text>
  457. </View>
  458. </View>
  459. ))
  460. )}
  461. </ScrollView>
  462. )}
  463. </View>
  464. {/* 奖品列表 */}
  465. <View style={styles.productGrid}>
  466. <Text style={styles.gridTitle}>奖品列表</Text>
  467. <View style={styles.gridContent}>
  468. {products.map((item, index) => (
  469. <View key={item.id || index} style={styles.gridItem}>
  470. <ImageBackground source={{ uri: getLevelBg(item.level) }} style={styles.gridItemBg} resizeMode="stretch">
  471. <View style={styles.gridImageBox}>
  472. <Image source={{ uri: item.cover }} style={styles.gridImage} contentFit="cover" />
  473. </View>
  474. <Text style={styles.gridName} numberOfLines={2}>{item.name}</Text>
  475. <Text style={styles.gridLevel}>{getLevelName(item.level)}</Text>
  476. {item.price && <Text style={styles.gridPrice}>¥{item.price}</Text>}
  477. </ImageBackground>
  478. </View>
  479. ))}
  480. </View>
  481. </View>
  482. <View style={{ height: 150 }} />
  483. </ScrollView>
  484. {/* 底部购买栏 */}
  485. <ImageBackground source={{ uri: Images.box.detail.boxDetailBott }} style={[styles.bottomBar, { paddingBottom: insets.bottom + 10 }]} resizeMode="cover">
  486. <View style={styles.bottomBtns}>
  487. <TouchableOpacity style={styles.btnItemFull} onPress={() => handlePay(1)} activeOpacity={0.8}>
  488. <ImageBackground source={{ uri: Images.common.butBgV }} style={styles.btnBg} resizeMode="contain">
  489. <Text style={styles.btnText}>×1</Text>
  490. </ImageBackground>
  491. </TouchableOpacity>
  492. </View>
  493. </ImageBackground>
  494. </ImageBackground>
  495. <CheckoutModal ref={checkoutRef} data={data} poolId={poolId!} boxNumber={boxNum} onSuccess={handleSuccess} />
  496. <RuleModal ref={ruleRef} />
  497. <BoxPopup ref={boxPopupRef} onSelect={handleSelectBox} />
  498. <DetailsPopup ref={detailsPopupRef} />
  499. </View>
  500. );
  501. }
  502. const styles = StyleSheet.create({
  503. container: { flex: 1, backgroundColor: '#1a1a2e' },
  504. background: { flex: 1 },
  505. loadingContainer: { flex: 1, backgroundColor: '#1a1a2e', justifyContent: 'center', alignItems: 'center' },
  506. errorText: { color: '#999', fontSize: 16 },
  507. backBtn2: { marginTop: 20, backgroundColor: '#ff6600', paddingHorizontal: 20, paddingVertical: 10, borderRadius: 8 },
  508. backBtn2Text: { color: '#fff', fontSize: 14 },
  509. header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 10, paddingBottom: 10, position: 'absolute', top: 0, left: 0, right: 0, zIndex: 100 },
  510. backBtn: { width: 40, height: 40, justifyContent: 'center', alignItems: 'center' },
  511. backText: { color: '#fff', fontSize: 16, fontWeight: 'bold' },
  512. headerTitle: { color: '#fff', fontSize: 15, fontWeight: 'bold', flex: 1, textAlign: 'center', width: 250 },
  513. placeholder: { width: 40 },
  514. scrollView: { flex: 1 },
  515. mainGoodsSection: { width: SCREEN_WIDTH, height: 504, position: 'relative' },
  516. mainSwiper: { position: 'relative', width: '100%', height: 375, alignItems: 'center', justifyContent: 'center', marginTop: -50 },
  517. productImageBox: { width: 200, height: 280, justifyContent: 'center', alignItems: 'center' },
  518. productImage: { width: 200, height: 280 },
  519. priceText: { color: '#fff', fontSize: 16, fontWeight: 'bold', marginTop: -20 },
  520. detailsBut: { width: 120, height: 45, justifyContent: 'center', alignItems: 'center', marginTop: -10 },
  521. levelText: { fontSize: 14, color: '#FBC400', fontWeight: 'bold' },
  522. goodsNameBg: { position: 'absolute', left: 47, top: 53, width: 43, height: 100, paddingTop: 8, justifyContent: 'flex-start', alignItems: 'center' },
  523. goodsNameText: { fontSize: 12, fontWeight: 'bold', color: '#000', width: 20, textAlign: 'center' },
  524. prevBtn: { position: 'absolute', left: 35, top: '40%' },
  525. nextBtn: { position: 'absolute', right: 35, top: '40%' },
  526. arrowImg: { width: 33, height: 38 },
  527. positionBgleftBg: { position: 'absolute', left: 0, top: 225, width: 32, height: 188 },
  528. positionBgRightBg: { position: 'absolute', right: 0, top: 225, width: 32, height: 188 },
  529. mainGoodsSectionBtext: { width: SCREEN_WIDTH, height: 74, marginTop: -10 },
  530. positionBut: { position: 'absolute', zIndex: 10, width: 35, height: 34 },
  531. positionButBg: { width: 35, height: 34, justifyContent: 'center', alignItems: 'center' },
  532. positionButText: { fontSize: 12, fontWeight: 'bold', color: '#fff', transform: [{ rotate: '14deg' }], textShadowColor: '#000', textShadowOffset: { width: 1, height: 1 }, textShadowRadius: 1 },
  533. positionButTextR: { fontSize: 12, fontWeight: 'bold', color: '#fff', transform: [{ rotate: '-16deg' }], textShadowColor: '#000', textShadowOffset: { width: 1, height: 1 }, textShadowRadius: 1 },
  534. positionRule: { top: 256, left: 0 },
  535. positionLock: { top: 300, left: 0 },
  536. positionStore: { top: 256, right: 0 },
  537. positionRefresh: { top: 300, right: 0 },
  538. emptyRunsBox: { alignItems: 'center', marginTop: -60, marginBottom: 10 },
  539. emptyRunsText: { color: '#fff', fontSize: 12, backgroundColor: 'rgba(0,0,0,0.5)', paddingHorizontal: 15, paddingVertical: 5, borderRadius: 10 },
  540. lockTimeBox: { flexDirection: 'row', alignItems: 'center', backgroundColor: '#71ccff', padding: 10, marginHorizontal: 10, borderRadius: 8, marginBottom: 10 },
  541. lockTimeLabel: { color: '#000', fontSize: 12 },
  542. lockTimeBarBox: { flex: 1, height: 30, position: 'relative', justifyContent: 'center' },
  543. lockTimeBar: { height: 8, backgroundColor: 'rgba(255,255,255,0.6)', borderRadius: 4, overflow: 'hidden' },
  544. processBar: { height: '100%', backgroundColor: '#209ae5', borderRadius: 4 },
  545. lockTimeText: { position: 'absolute', top: -5, fontSize: 10, backgroundColor: '#000', color: '#fff', paddingHorizontal: 4, borderRadius: 2, marginLeft: -13 },
  546. // 箱子信息区域样式
  547. firstLastWrapper: { marginHorizontal: 10, marginBottom: 10, backgroundColor: '#fff', borderRadius: 8, overflow: 'hidden', borderWidth: 2, borderColor: '#000' },
  548. firstLastTitle: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', backgroundColor: '#ffc900', paddingHorizontal: 20, paddingVertical: 15, borderBottomWidth: 2, borderBottomColor: '#000' },
  549. firstLastInfo: { flexDirection: 'row', alignItems: 'center' },
  550. sizeInfo: { flexDirection: 'row', alignItems: 'center', marginRight: 15 },
  551. sizeLabel: { fontSize: 11, color: '#fff' },
  552. sizeValue: { fontSize: 16, fontWeight: 'bold', color: '#fff' },
  553. changeBoxBtn: { backgroundColor: '#ff8c16', paddingHorizontal: 15, paddingVertical: 8, borderRadius: 4, borderWidth: 1, borderColor: '#333' },
  554. changeBoxText: { fontSize: 11, color: '#fff' },
  555. // Tab 切换样式
  556. tabSection: { flexDirection: 'row', borderBottomWidth: 1, borderBottomColor: '#E4E4E4' },
  557. tabItem: { flex: 1, paddingVertical: 12, alignItems: 'center' },
  558. tabItemActive: {},
  559. tabText: { fontSize: 14, color: '#9E9E9E' },
  560. tabTextActive: { color: '#ff8c16', fontWeight: 'bold' },
  561. // 活动商品列表样式
  562. activityGoodsGrid: { flexDirection: 'row', flexWrap: 'wrap', padding: 8 },
  563. activityGoodsItem: { width: '33.33%', padding: 4, alignItems: 'center', marginBottom: 10 },
  564. activityImageBox: { width: 100, height: 100, borderWidth: 2, borderColor: '#1A1A1A', borderRadius: 4, overflow: 'hidden', position: 'relative' },
  565. activityImage: { width: '100%', height: '100%' },
  566. probabilityBadge: { position: 'absolute', top: 0, left: 0, right: 0, backgroundColor: 'rgba(0,0,0,0.5)', paddingVertical: 2 },
  567. probabilityText: { fontSize: 7, color: '#fff', textAlign: 'center' },
  568. priceBadge: { position: 'absolute', bottom: 5, left: 5, right: 5, backgroundColor: 'rgba(0,0,0,0.5)', paddingVertical: 4, borderRadius: 2 },
  569. priceTextSmall: { fontSize: 7, color: '#fff', textAlign: 'center' },
  570. levelBadgeSmall: { marginTop: 5, paddingHorizontal: 10, paddingVertical: 3, borderRadius: 2 },
  571. levelD: { backgroundColor: '#6340FF', borderWidth: 1, borderColor: '#A2BBFF' },
  572. levelAll: { backgroundColor: '#A3E100', borderWidth: 1, borderColor: '#EAFFB1' },
  573. levelBadgeText: { fontSize: 12, textAlign: 'center' },
  574. activityName: { fontSize: 12, color: '#333', marginTop: 4, textAlign: 'center' },
  575. // 空记录样式
  576. emptyRecord: { padding: 40, alignItems: 'center' },
  577. emptyRecordText: { fontSize: 14, color: '#999' },
  578. // 中奖记录样式
  579. recordScroll: { maxHeight: 220 },
  580. recordItem: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingVertical: 13, paddingHorizontal: 15, borderBottomWidth: 1, borderBottomColor: '#D8D8D8' },
  581. recordLeft: { flex: 1 },
  582. recordNickname: { fontSize: 12, fontWeight: 'bold', color: '#333' },
  583. recordTime: { fontSize: 12, color: '#666', marginVertical: 3 },
  584. recordPrize: { fontSize: 12, color: '#666' },
  585. recordPrizeName: { fontWeight: '500', color: '#FF5100' },
  586. recordLevelBadge: { paddingHorizontal: 12, paddingVertical: 4, borderRadius: 2 },
  587. recordLevelText: { fontSize: 12, fontWeight: 'bold', color: '#fff' },
  588. productGrid: { margin: 10, backgroundColor: 'rgba(0,0,0,0.3)', borderRadius: 15, padding: 15 },
  589. gridTitle: { color: '#fff', fontSize: 16, fontWeight: 'bold', marginBottom: 15 },
  590. gridContent: { flexDirection: 'row', flexWrap: 'wrap', marginHorizontal: -5 },
  591. gridItem: { width: '33.33%', paddingHorizontal: 5, marginBottom: 10 },
  592. gridItemBg: { width: '100%', aspectRatio: 0.75, padding: 8, alignItems: 'center' },
  593. gridImageBox: { width: '100%', aspectRatio: 1, borderRadius: 5, overflow: 'hidden', backgroundColor: 'rgba(255,255,255,0.1)' },
  594. gridImage: { width: '100%', height: '100%' },
  595. gridName: { color: '#fff', fontSize: 10, marginTop: 5, textAlign: 'center', height: 26 },
  596. gridLevel: { color: '#FBC400', fontSize: 9, marginTop: 2 },
  597. gridPrice: { color: '#ff6600', fontSize: 10, marginTop: 2 },
  598. bottomBar: { position: 'absolute', bottom: 0, left: 0, right: 0, height: 69, paddingHorizontal: 5 },
  599. bottomBtns: { flexDirection: 'row', height: 64, alignItems: 'center', justifyContent: 'center' },
  600. btnItemFull: { width: 200 },
  601. btnBg: { width: '100%', height: 54, justifyContent: 'center', alignItems: 'center' },
  602. btnText: { fontSize: 18, fontWeight: 'bold', color: '#fff' },
  603. });