|
|
@@ -23,7 +23,7 @@ import ProductSwiper from '@/components/award-detail-yfs/ProductSwiper';
|
|
|
import PurchaseBar from '@/components/award-detail-yfs/PurchaseBar';
|
|
|
import { RuleModal, RuleModalRef } from '@/components/award-detail-yfs/RuleModal';
|
|
|
import { Images } from '@/constants/images';
|
|
|
-import { getBoxDetail, getNextBox, getPoolDetail, getPreBox, poolIn, poolOut } from '@/services/award';
|
|
|
+import { getBoxDetail, getNextBox, getPoolDetail, getPreBox, lockBox, poolIn, poolOut, unlockBox } from '@/services/award';
|
|
|
import { CheckoutModal, CheckoutModalRef } from '../award-detail/components/CheckoutModal';
|
|
|
|
|
|
const { width } = Dimensions.get('window');
|
|
|
@@ -270,22 +270,15 @@ export default function AwardDetailYfsScreen() {
|
|
|
<View style={{ height: 180 }} />
|
|
|
|
|
|
<ProductSwiper
|
|
|
- products={data?.luckGoodsList?.map((item: any) => {
|
|
|
- let prob = '0%';
|
|
|
- const total = data.leftQuantity || 1;
|
|
|
- if (item.level === 'A') prob = ((data.leftQuantityA / total) * 100).toFixed(4) + '%';
|
|
|
- else if (item.level === 'B') prob = ((data.leftQuantityB / total) * 100).toFixed(4) + '%';
|
|
|
- else if (item.level === 'C') prob = ((data.leftQuantityC / total) * 100).toFixed(4) + '%';
|
|
|
- else if (item.level === 'D') prob = ((data.leftQuantityD / total) * 100).toFixed(4) + '%';
|
|
|
-
|
|
|
- return {
|
|
|
+ box={currentBox} // Pass current box
|
|
|
+ products={data?.luckGoodsList?.map((item: any) => ({
|
|
|
cover: item.spu.cover,
|
|
|
name: item.spu.name,
|
|
|
level: item.level,
|
|
|
- probability: prob,
|
|
|
- quantity: item.quantity
|
|
|
- };
|
|
|
- }) || []}
|
|
|
+ quantity: item.quantity,
|
|
|
+ id: item.id, // Ensure IDs are passed
|
|
|
+ spu: item.spu
|
|
|
+ })) || []}
|
|
|
/>
|
|
|
|
|
|
<ImageBackground
|
|
|
@@ -342,6 +335,39 @@ export default function AwardDetailYfsScreen() {
|
|
|
<Text style={styles.slantedR}>仓库</Text>
|
|
|
</ImageBackground>
|
|
|
</TouchableOpacity>
|
|
|
+
|
|
|
+ {/* Lock Button */}
|
|
|
+ <TouchableOpacity style={[styles.positionBut, { top: 300, right: 0 }]} onPress={() => {
|
|
|
+ if (!currentBox) return;
|
|
|
+ const isLocked = currentBox.lockTime && new Date(currentBox.lockTime).getTime() > Date.now();
|
|
|
+
|
|
|
+ Alert.alert('提示', isLocked ? '是否解锁盒子?' : '是否锁定盒子(锁定后他人无法购买)?', [
|
|
|
+ { text: '取消', style: 'cancel' },
|
|
|
+ { text: '确定', onPress: async () => {
|
|
|
+ try {
|
|
|
+ const poolId = getSafePoolId();
|
|
|
+ let success = false;
|
|
|
+ if (isLocked) {
|
|
|
+ success = await unlockBox(poolId, currentBox.number);
|
|
|
+ } else {
|
|
|
+ success = await lockBox(poolId, currentBox.number);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (success) {
|
|
|
+ Alert.alert('成功', isLocked ? '解锁成功' : '锁定成功');
|
|
|
+ loadBox(currentBox.number); // Refresh
|
|
|
+ }
|
|
|
+ // System handles error msg via interceptor, no need for manual alert
|
|
|
+ } catch (e) {
|
|
|
+ // console.error(e); // Silent error
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ ]);
|
|
|
+ }}>
|
|
|
+ <ImageBackground source={{ uri: Images.box.detail.positionBgRight }} style={styles.btnBg} resizeMode="contain">
|
|
|
+ <Text style={styles.slantedR}>{currentBox?.lockTime && new Date(currentBox.lockTime).getTime() > Date.now() ? '解锁' : '锁盒'}</Text>
|
|
|
+ </ImageBackground>
|
|
|
+ </TouchableOpacity>
|
|
|
|
|
|
<TouchableOpacity style={[styles.positionBut, styles.positionRefresh]} onPress={() => loadBox(currentBox?.number)}>
|
|
|
<ImageBackground source={{ uri: Images.box.detail.positionBgRight }} style={styles.btnBg} resizeMode="contain">
|