CheckoutModal.tsx 23 KB

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