index.tsx 29 KB

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