CheckoutModal.tsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. import { Image } from 'expo-image';
  2. import { useRouter } from 'expo-router';
  3. import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
  4. import {
  5. ActivityIndicator,
  6. Alert,
  7. Dimensions,
  8. Modal,
  9. ScrollView,
  10. StyleSheet,
  11. Text,
  12. TouchableOpacity,
  13. View
  14. } from 'react-native';
  15. import { applyOrder, getApplyResult, previewOrder } from '@/services/award';
  16. import Alipay from 'expo-native-alipay';
  17. import { LotteryResultModal, LotteryResultModalRef } from './LotteryResultModal';
  18. const { width: SCREEN_WIDTH } = Dimensions.get('window');
  19. // 等级配置
  20. const LEVEL_MAP: Record<string, { title: string; color: string }> = {
  21. A: { title: '超神款', color: '#FF4444' },
  22. B: { title: '欧皇款', color: '#FF9600' },
  23. C: { title: '隐藏款', color: '#9B59B6' },
  24. D: { title: '普通款', color: '#666666' },
  25. };
  26. interface CheckoutModalProps {
  27. data: any;
  28. poolId: string;
  29. onSuccess: (param: { num: number; tradeNo: string }) => void;
  30. boxNumber?: string;
  31. }
  32. export interface CheckoutModalRef {
  33. show: (num: number, preview: any, boxNum?: string, seatNumbers?: number[], packFlag?: boolean) => void;
  34. showFreedom: () => void;
  35. close: () => void;
  36. }
  37. interface LotteryItem {
  38. id: string;
  39. name: string;
  40. cover: string;
  41. level: string;
  42. spu?: { marketPrice: number };
  43. }
  44. // 自由购买数量选项
  45. const FREEDOM_NUMS = [10, 20, 30, 40, 50];
  46. export const CheckoutModal = forwardRef<CheckoutModalRef, CheckoutModalProps>(
  47. ({ data, poolId, onSuccess, boxNumber }, ref) => {
  48. const router = useRouter();
  49. const lotteryResultRef = useRef<LotteryResultModalRef>(null);
  50. const [visible, setVisible] = useState(false);
  51. const [num, setNum] = useState(1);
  52. const [checked, setChecked] = useState(true);
  53. const [loading, setLoading] = useState(false);
  54. const [freedomNum, setFreedomNum] = useState(10);
  55. const [freedomSelectVisible, setFreedomSelectVisible] = useState(false);
  56. // 预览数据
  57. const [coin, setCoin] = useState<number | null>(null);
  58. const [couponAmount, setCouponAmount] = useState<number | null>(null);
  59. const [lastPrice, setLastPrice] = useState<number | null>(null);
  60. const [magic, setMagic] = useState<any>(null);
  61. const [cash, setCash] = useState<any>(null);
  62. const [cashChecked, setCashChecked] = useState(false);
  63. // 盒子相关
  64. const [boxNum, setBoxNum] = useState<string | undefined>(boxNumber);
  65. const [seatNumbers, setSeatNumbers] = useState<number[] | undefined>();
  66. const [packFlag, setPackFlag] = useState<boolean | undefined>();
  67. // 抽奖结果
  68. const [resultVisible, setResultVisible] = useState(false);
  69. const [resultLoading, setResultLoading] = useState(false);
  70. const [resultList, setResultList] = useState<LotteryItem[]>([]);
  71. // 设置预览数据
  72. const setPreviewData = (previewData: any) => {
  73. setCoin(previewData.magicAmount || null);
  74. setCouponAmount(previewData.couponAmount || null);
  75. setLastPrice(previewData.paymentAmount);
  76. setMagic(previewData.magic || null);
  77. if (previewData.cash && previewData.cash.balance > previewData.paymentAmount) {
  78. setCash(previewData.cash);
  79. setCashChecked(true);
  80. } else {
  81. setCash(previewData.cash || null);
  82. setCashChecked(false);
  83. }
  84. };
  85. useImperativeHandle(ref, () => ({
  86. show: (n: number, previewData: any = {}, bNum?: string, seats?: number[], pack?: boolean) => {
  87. setNum(n);
  88. setBoxNum(bNum);
  89. setSeatNumbers(seats);
  90. setPackFlag(pack || undefined);
  91. setPreviewData(previewData);
  92. setVisible(true);
  93. },
  94. showFreedom: () => {
  95. setFreedomNum(10);
  96. setFreedomSelectVisible(true);
  97. },
  98. close: () => {
  99. setVisible(false);
  100. setFreedomSelectVisible(false);
  101. setResultVisible(false);
  102. },
  103. }));
  104. const handleFreedomSelect = async (selectedNum: number) => {
  105. setFreedomSelectVisible(false);
  106. setLoading(true);
  107. try {
  108. const preview = await previewOrder(poolId, selectedNum);
  109. if (preview) {
  110. setNum(selectedNum);
  111. setFreedomNum(selectedNum);
  112. setPreviewData(preview);
  113. setVisible(true);
  114. }
  115. } catch (error: any) {
  116. Alert.alert('提示', error?.message || '获取订单信息失败');
  117. } finally {
  118. setLoading(false);
  119. }
  120. };
  121. const close = () => {
  122. setVisible(false);
  123. setFreedomSelectVisible(false);
  124. };
  125. const closeResult = () => {
  126. setResultVisible(false);
  127. setResultList([]);
  128. onSuccess({ tradeNo: '', num });
  129. };
  130. // 支付
  131. const pay = async () => {
  132. if (loading) return;
  133. if (!checked) {
  134. Alert.alert('提示', '请同意《宝箱服务协议》');
  135. return;
  136. }
  137. setLoading(true);
  138. try {
  139. let paymentType = '';
  140. // Prioritize Wallet if checked
  141. if (cashChecked) {
  142. paymentType = 'WALLET';
  143. } else {
  144. // Default to Alipay for now as per branch logic
  145. paymentType = 'ALIPAY_APP';
  146. }
  147. // If wallet is insufficient and logic requires mixed payment, it might be more complex
  148. // strictly following branch logic: if cashChecked use Wallet, else Alipay
  149. const payNum = packFlag ? 1 : num;
  150. const res = await applyOrder(poolId, payNum, paymentType, boxNum, seatNumbers, packFlag);
  151. // Handle Alipay Response
  152. if (res?.payInfo) {
  153. const result = await Alipay.pay(res.payInfo);
  154. console.log('Alipay Result:', result);
  155. const resultStatus = result?.resultStatus;
  156. if (resultStatus === '9000') {
  157. // Payment Success
  158. // Maybe verify payment here if needed, or just assume success
  159. const tradeNo = res.bizTradeNo || res.tradeNo; // Assuming tradeNo is in applyOrder response
  160. setVisible(false);
  161. router.push({
  162. pathname: '/lottery' as any,
  163. params: { tradeNo, num, poolId }
  164. });
  165. onSuccess({ tradeNo, num });
  166. } else {
  167. Alert.alert('提示', '支付未完成');
  168. }
  169. return;
  170. }
  171. if (res?.paySuccess || res?.bizTradeNo || res?.tradeNo) {
  172. const tradeNo = res.bizTradeNo || res.tradeNo;
  173. setVisible(false);
  174. // Navigation to Lottery Animation
  175. router.push({
  176. pathname: '/lottery' as any,
  177. params: { tradeNo, num, poolId }
  178. });
  179. // Trigger success callback (e.g. to refresh pool data)
  180. onSuccess({ tradeNo, num });
  181. } else {
  182. Alert.alert('提示', res?.message || '支付失败,请重试');
  183. }
  184. } catch (error: any) {
  185. console.error('Pay error:', error);
  186. Alert.alert('支付失败', error?.message || '请稍后重试');
  187. } finally {
  188. setLoading(false);
  189. }
  190. };
  191. // 获取抽奖结果(10发以下用弹窗)
  192. const fetchLotteryResult = async (tradeNo: string) => {
  193. setResultLoading(true);
  194. setResultVisible(true);
  195. setResultList([]);
  196. let attempts = 0;
  197. const maxAttempts = 5;
  198. const poll = async () => {
  199. try {
  200. const res = await getApplyResult(tradeNo);
  201. if (res?.inventoryList && res.inventoryList.length > 0) {
  202. setResultList(res.inventoryList);
  203. setResultLoading(false);
  204. // 不在这里调用 onSuccess,等用户关闭弹窗时再调用
  205. } else if (attempts < maxAttempts) {
  206. attempts++;
  207. setTimeout(poll, 1000);
  208. } else {
  209. setResultLoading(false);
  210. if (typeof window !== 'undefined') {
  211. Alert.alert('提示', '获取结果超时,请在仓库中查看');
  212. }
  213. }
  214. } catch {
  215. if (attempts < maxAttempts) {
  216. attempts++;
  217. setTimeout(poll, 1000);
  218. } else {
  219. setResultLoading(false);
  220. if (typeof window !== 'undefined') {
  221. Alert.alert('提示', '获取结果失败,请在仓库中查看');
  222. }
  223. }
  224. }
  225. };
  226. poll();
  227. };
  228. const displayPrice = lastPrice ?? (data?.price || 0) * num;
  229. return (
  230. <>
  231. {/* 10发以上的全屏抽奖结果弹窗 */}
  232. <LotteryResultModal
  233. ref={lotteryResultRef}
  234. onClose={() => {
  235. // 抽奖结果弹窗关闭后刷新数据
  236. onSuccess({ tradeNo: '', num });
  237. }}
  238. onGoStore={() => {
  239. onSuccess({ tradeNo: '', num });
  240. router.replace('/store' as any);
  241. }}
  242. />
  243. {/* 自由购买数量选择弹窗 */}
  244. <Modal visible={freedomSelectVisible} transparent animationType="fade" onRequestClose={() => setFreedomSelectVisible(false)}>
  245. <View style={styles.overlay}>
  246. <TouchableOpacity style={styles.mask} activeOpacity={1} onPress={() => setFreedomSelectVisible(false)} />
  247. <View style={styles.freedomContainer}>
  248. <View style={styles.header}>
  249. <Text style={styles.title}>购买多盒</Text>
  250. <TouchableOpacity onPress={() => setFreedomSelectVisible(false)} style={styles.closeBtn}>
  251. <Text style={styles.closeText}>×</Text>
  252. </TouchableOpacity>
  253. </View>
  254. <View style={styles.freedomContent}>
  255. <View style={styles.freedomBtnList}>
  256. {FREEDOM_NUMS.map((item) => (
  257. <TouchableOpacity
  258. key={item}
  259. style={[styles.freedomBtn, freedomNum === item && styles.freedomBtnActive]}
  260. onPress={() => setFreedomNum(item)}
  261. >
  262. <Text style={[styles.freedomBtnText, freedomNum === item && styles.freedomBtnTextActive]}>
  263. {item}<Text style={styles.freedomUnit}>盒</Text>
  264. </Text>
  265. {freedomNum === item && <Text style={styles.checkIcon}>✓</Text>}
  266. </TouchableOpacity>
  267. ))}
  268. </View>
  269. <TouchableOpacity
  270. style={[styles.freedomSubmitBtn, loading && styles.payBtnDisabled]}
  271. onPress={() => handleFreedomSelect(freedomNum)}
  272. disabled={loading}
  273. >
  274. {loading ? (
  275. <ActivityIndicator color="#fff" size="small" />
  276. ) : (
  277. <Text style={styles.freedomSubmitText}>确认 ¥{(data?.price || 0) * freedomNum}</Text>
  278. )}
  279. </TouchableOpacity>
  280. </View>
  281. </View>
  282. </View>
  283. </Modal>
  284. {/* 支付确认弹窗 */}
  285. <Modal visible={visible} transparent animationType="slide" onRequestClose={close}>
  286. <View style={styles.overlay}>
  287. <TouchableOpacity style={styles.mask} activeOpacity={1} onPress={close} />
  288. <View style={styles.container}>
  289. <View style={styles.header}>
  290. <Text style={styles.title}>{data?.name}</Text>
  291. <TouchableOpacity onPress={close} style={styles.closeBtn}>
  292. <Text style={styles.closeText}>×</Text>
  293. </TouchableOpacity>
  294. </View>
  295. <View style={styles.content}>
  296. <View style={styles.row}>
  297. <Text style={styles.label}>购买件数</Text>
  298. <Text style={styles.priceText}>¥{data?.price} x {num}</Text>
  299. </View>
  300. <View style={styles.row}>
  301. <Text style={styles.label}>优惠券</Text>
  302. <Text style={[styles.valueText, couponAmount ? styles.themeColor : {}]}>
  303. {couponAmount ? `已使用优惠¥${couponAmount}` : '暂无优惠券可选'}
  304. </Text>
  305. </View>
  306. {magic && magic.balance > 0 && (
  307. <View style={styles.row}>
  308. <View style={styles.rowLeft}>
  309. <Text style={styles.label}>果实</Text>
  310. <Text style={styles.balanceText}>(剩余:{magic.balance})</Text>
  311. </View>
  312. <Text style={styles.balanceText}>
  313. 已抵扣 <Text style={styles.themeColor}>¥{coin || 0}</Text>
  314. </Text>
  315. </View>
  316. )}
  317. {cash && (
  318. <View style={styles.row}>
  319. <View style={styles.rowLeft}>
  320. <Text style={styles.label}>钱包支付</Text>
  321. <Text style={styles.themeColor}>(余额:¥{cash.balance})</Text>
  322. </View>
  323. <TouchableOpacity
  324. style={[styles.radio, cashChecked && styles.radioChecked]}
  325. onPress={() => setCashChecked(!cashChecked)}
  326. >
  327. {cashChecked && <View style={styles.radioInner} />}
  328. </TouchableOpacity>
  329. </View>
  330. )}
  331. <View style={styles.agreementRow}>
  332. <View style={styles.agreementLeft}>
  333. <View style={styles.agreementTextContainer}>
  334. <Text style={styles.agreementText}>我已满18周岁,已阅读并同意</Text>
  335. <TouchableOpacity onPress={() => {
  336. setVisible(false);
  337. router.push({ pathname: '/agreement', params: { type: 'magic.html' } });
  338. }}>
  339. <Text style={styles.link}>《宝箱服务协议》</Text>
  340. </TouchableOpacity>
  341. </View>
  342. <Text style={styles.tips}>宝箱商品存在概率性,请谨慎消费</Text>
  343. </View>
  344. <TouchableOpacity
  345. style={[styles.radio, checked && styles.radioChecked]}
  346. onPress={() => setChecked(!checked)}
  347. >
  348. {checked && <View style={styles.radioInner} />}
  349. </TouchableOpacity>
  350. </View>
  351. </View>
  352. <View style={styles.footer}>
  353. <View style={styles.priceInfo}>
  354. <Text style={styles.totalLabel}>实付:</Text>
  355. <Text style={styles.totalPrice}>¥{displayPrice.toFixed(2)}</Text>
  356. </View>
  357. <TouchableOpacity
  358. style={[styles.payBtn, loading && styles.payBtnDisabled]}
  359. onPress={pay}
  360. disabled={loading}
  361. >
  362. {loading ? <ActivityIndicator color="#fff" size="small" /> : <Text style={styles.payBtnText}>立即支付</Text>}
  363. </TouchableOpacity>
  364. </View>
  365. </View>
  366. </View>
  367. </Modal>
  368. {/* 抽奖结果弹窗 */}
  369. <Modal visible={resultVisible} transparent animationType="fade" onRequestClose={closeResult}>
  370. <View style={styles.resultOverlay}>
  371. <View style={styles.resultContainer}>
  372. <View style={styles.resultHeader}>
  373. <Text style={styles.resultTitle}>🎉 恭喜您获得 🎉</Text>
  374. <TouchableOpacity onPress={closeResult} style={styles.resultCloseBtn}>
  375. <Text style={styles.closeText}>×</Text>
  376. </TouchableOpacity>
  377. </View>
  378. {resultLoading ? (
  379. <View style={styles.resultLoading}>
  380. <ActivityIndicator size="large" color="#ff9600" />
  381. <Text style={styles.resultLoadingText}>正在开启宝箱...</Text>
  382. </View>
  383. ) : (
  384. <ScrollView style={styles.resultScroll} showsVerticalScrollIndicator={false}>
  385. <View style={styles.resultList}>
  386. {resultList.map((item, index) => (
  387. <View key={item.id || index} style={styles.resultItem}>
  388. <View style={[styles.levelBadge, { backgroundColor: LEVEL_MAP[item.level]?.color || '#666' }]}>
  389. <Text style={styles.levelText}>{LEVEL_MAP[item.level]?.title || item.level}</Text>
  390. </View>
  391. <View style={styles.resultImageBox}>
  392. <Image source={{ uri: item.cover }} style={styles.resultImage} contentFit="contain" />
  393. </View>
  394. <Text style={styles.resultName} numberOfLines={2}>{item.name}</Text>
  395. {item.spu?.marketPrice && (
  396. <Text style={styles.resultPrice}>参考价:¥{item.spu.marketPrice}</Text>
  397. )}
  398. </View>
  399. ))}
  400. </View>
  401. </ScrollView>
  402. )}
  403. <View style={styles.resultFooter}>
  404. <TouchableOpacity style={styles.resultBtn} onPress={closeResult}>
  405. <Text style={styles.resultBtnText}>继续抽奖</Text>
  406. </TouchableOpacity>
  407. </View>
  408. </View>
  409. </View>
  410. </Modal>
  411. </>
  412. );
  413. }
  414. );
  415. const styles = StyleSheet.create({
  416. overlay: {
  417. flex: 1,
  418. backgroundColor: 'rgba(0,0,0,0.5)',
  419. justifyContent: 'flex-end',
  420. },
  421. mask: { flex: 1 },
  422. container: {
  423. backgroundColor: '#fff',
  424. borderTopLeftRadius: 20,
  425. borderTopRightRadius: 20,
  426. paddingBottom: 34,
  427. },
  428. header: {
  429. flexDirection: 'row',
  430. alignItems: 'center',
  431. justifyContent: 'center',
  432. padding: 15,
  433. borderBottomWidth: 1,
  434. borderBottomColor: '#eee',
  435. position: 'relative',
  436. },
  437. title: { fontSize: 16, fontWeight: '600', color: '#333' },
  438. closeBtn: { position: 'absolute', right: 15, top: 10 },
  439. closeText: { fontSize: 24, color: '#999' },
  440. content: { padding: 15 },
  441. row: {
  442. flexDirection: 'row',
  443. justifyContent: 'space-between',
  444. alignItems: 'center',
  445. paddingVertical: 10,
  446. },
  447. rowLeft: { flexDirection: 'row', alignItems: 'center', flex: 1 },
  448. label: { fontSize: 14, color: '#333' },
  449. priceText: { fontSize: 14, color: '#ff9600', fontWeight: '600' },
  450. valueText: { fontSize: 12, color: '#999' },
  451. themeColor: { color: '#ff9600' },
  452. balanceText: { fontSize: 12, color: '#999', marginLeft: 5 },
  453. radio: {
  454. width: 20,
  455. height: 20,
  456. borderRadius: 10,
  457. borderWidth: 2,
  458. borderColor: '#ddd',
  459. justifyContent: 'center',
  460. alignItems: 'center',
  461. },
  462. radioChecked: { borderColor: '#ff9600' },
  463. radioInner: { width: 10, height: 10, borderRadius: 5, backgroundColor: '#ff9600' },
  464. agreementRow: {
  465. flexDirection: 'row',
  466. justifyContent: 'space-between',
  467. alignItems: 'flex-start',
  468. paddingVertical: 10,
  469. marginTop: 10,
  470. },
  471. agreementLeft: { flex: 1, marginRight: 10 },
  472. agreementTextContainer: { flexDirection: 'row', alignItems: 'center', flexWrap: 'wrap' },
  473. agreementText: { fontSize: 12, color: '#333', lineHeight: 18 },
  474. link: { color: '#ff9600' },
  475. tips: { fontSize: 11, color: '#999', marginTop: 5 },
  476. footer: {
  477. flexDirection: 'row',
  478. alignItems: 'center',
  479. justifyContent: 'space-between',
  480. paddingHorizontal: 15,
  481. paddingTop: 15,
  482. borderTopWidth: 1,
  483. borderTopColor: '#eee',
  484. },
  485. priceInfo: { flexDirection: 'row', alignItems: 'center' },
  486. totalLabel: { fontSize: 14, color: '#333' },
  487. totalPrice: { fontSize: 20, color: '#ff9600', fontWeight: 'bold' },
  488. payBtn: {
  489. backgroundColor: '#ff9600',
  490. paddingHorizontal: 30,
  491. paddingVertical: 12,
  492. borderRadius: 25,
  493. },
  494. payBtnDisabled: { opacity: 0.6 },
  495. payBtnText: { color: '#fff', fontSize: 16, fontWeight: '600' },
  496. // 自由购买弹窗
  497. freedomContainer: {
  498. backgroundColor: '#fff',
  499. borderTopLeftRadius: 20,
  500. borderTopRightRadius: 20,
  501. paddingBottom: 34,
  502. },
  503. freedomContent: { padding: 20 },
  504. freedomBtnList: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'space-between' },
  505. freedomBtn: {
  506. width: '48%',
  507. height: 50,
  508. backgroundColor: '#fff',
  509. borderRadius: 8,
  510. justifyContent: 'center',
  511. alignItems: 'center',
  512. marginBottom: 12,
  513. borderWidth: 1,
  514. borderColor: '#eee',
  515. position: 'relative',
  516. },
  517. freedomBtnActive: { backgroundColor: '#F1423D', borderColor: '#F1423D' },
  518. freedomBtnText: { fontSize: 18, fontWeight: 'bold', color: '#333' },
  519. freedomBtnTextActive: { color: '#fff' },
  520. freedomUnit: { fontSize: 12, fontWeight: '500' },
  521. checkIcon: {
  522. position: 'absolute',
  523. bottom: 0,
  524. right: 0,
  525. backgroundColor: '#fff',
  526. color: '#F1423D',
  527. fontSize: 12,
  528. paddingHorizontal: 6,
  529. paddingVertical: 2,
  530. borderTopLeftRadius: 8,
  531. borderBottomRightRadius: 8,
  532. },
  533. freedomSubmitBtn: {
  534. backgroundColor: '#ff9600',
  535. height: 50,
  536. borderRadius: 25,
  537. justifyContent: 'center',
  538. alignItems: 'center',
  539. marginTop: 20,
  540. },
  541. freedomSubmitText: { color: '#fff', fontSize: 16, fontWeight: '600' },
  542. // 抽奖结果弹窗
  543. resultOverlay: {
  544. flex: 1,
  545. backgroundColor: 'rgba(0,0,0,0.7)',
  546. justifyContent: 'center',
  547. alignItems: 'center',
  548. padding: 20,
  549. },
  550. resultContainer: {
  551. width: '100%',
  552. maxHeight: '80%',
  553. backgroundColor: '#fff',
  554. borderRadius: 16,
  555. overflow: 'hidden',
  556. },
  557. resultHeader: {
  558. alignItems: 'center',
  559. padding: 20,
  560. backgroundColor: '#ff9600',
  561. position: 'relative',
  562. },
  563. resultTitle: {
  564. fontSize: 20,
  565. fontWeight: 'bold',
  566. color: '#fff',
  567. },
  568. resultCloseBtn: {
  569. position: 'absolute',
  570. right: 15,
  571. top: 15,
  572. width: 30,
  573. height: 30,
  574. backgroundColor: 'rgba(255,255,255,0.3)',
  575. borderRadius: 15,
  576. justifyContent: 'center',
  577. alignItems: 'center',
  578. },
  579. resultLoading: {
  580. padding: 60,
  581. alignItems: 'center',
  582. },
  583. resultLoadingText: {
  584. marginTop: 15,
  585. fontSize: 14,
  586. color: '#666',
  587. },
  588. resultScroll: {
  589. maxHeight: 400,
  590. },
  591. resultList: {
  592. flexDirection: 'row',
  593. flexWrap: 'wrap',
  594. padding: 10,
  595. justifyContent: 'space-between',
  596. },
  597. resultItem: {
  598. width: (SCREEN_WIDTH - 80) / 2,
  599. backgroundColor: '#f9f9f9',
  600. borderRadius: 10,
  601. padding: 10,
  602. marginBottom: 10,
  603. alignItems: 'center',
  604. },
  605. levelBadge: {
  606. paddingHorizontal: 10,
  607. paddingVertical: 3,
  608. borderRadius: 10,
  609. marginBottom: 8,
  610. },
  611. levelText: {
  612. color: '#fff',
  613. fontSize: 11,
  614. fontWeight: 'bold',
  615. },
  616. resultImageBox: {
  617. width: '100%',
  618. aspectRatio: 1,
  619. backgroundColor: '#fff',
  620. borderRadius: 8,
  621. overflow: 'hidden',
  622. },
  623. resultImage: {
  624. width: '100%',
  625. height: '100%',
  626. },
  627. resultName: {
  628. fontSize: 12,
  629. color: '#333',
  630. textAlign: 'center',
  631. marginTop: 8,
  632. lineHeight: 16,
  633. },
  634. resultPrice: {
  635. fontSize: 10,
  636. color: '#999',
  637. marginTop: 4,
  638. },
  639. resultFooter: {
  640. padding: 15,
  641. borderTopWidth: 1,
  642. borderTopColor: '#eee',
  643. },
  644. resultBtn: {
  645. backgroundColor: '#ff9600',
  646. height: 46,
  647. borderRadius: 23,
  648. justifyContent: 'center',
  649. alignItems: 'center',
  650. },
  651. resultBtnText: {
  652. color: '#fff',
  653. fontSize: 16,
  654. fontWeight: '600',
  655. },
  656. });