import {
View,
Text,
ScrollView,
Pressable,
ImageBackground,
ActivityIndicator
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { router } from 'expo-router';
import { CrossLogoSvg } from '../global/SVG';
import { useEffect, useState } from 'react';
import * as SecureStore from 'expo-secure-store';
import { walletService } from '../../service/walletService';
const coupons = [
{
title: '迎新優惠券',
price: '999',
detail: '這是一段有關迎新優惠券的說明',
date: '至14/3/2025'
},
{
title: '折扣優惠券',
price: '888',
detail: '這是另一段有關迎新優惠券的說明',
date: '至15/4/2025'
},
{
title: '三張優惠券',
price: '777',
detail: '這是第三段有關迎新優惠券的說明',
date: '至16/9/2026'
}
];
export const IndividualCouponComponent = ({
title,
price,
detail,
date
}: {
title: string;
price: string;
detail: string;
date: string;
}) => (
$
{price}
{title}
{/* //dash line */}
{title}
{detail}
有效期
{' '}
{date}
);
const WalletPageComponent = () => {
const [token, setToken] = useState(null);
const [walletBalance, setWalletBalance] = useState(null);
useEffect(() => {
const getToken = async () => {
const storedToken = await SecureStore.getItemAsync('accessToken');
setToken(storedToken);
};
getToken();
}, []);
useEffect(() => {
const fetchWalletBalance = async () => {
if (token) {
await new Promise((resolve) => setTimeout(resolve, 2000));
const balance = await walletService.getWalletBalance(token);
setWalletBalance(balance);
}
};
fetchWalletBalance();
}, [token]);
const formatMoney = (amount: any) => {
if (typeof amount !== 'number') {
amount = Number(amount);
}
return amount.toLocaleString('en-US');
};
return (
{
if (router.canGoBack()) {
router.back();
} else {
router.replace('/accountMainPage');
}
}}
>
錢包
餘額 (HKD)
{walletBalance ? (
formatMoney(walletBalance)
) : (
)}
{/* Format the wallet balance */}
console.log('增值')}
>
+ 增值
更多錢包資訊
優惠券
router.push('couponPage')}>
顯示所有
{coupons.slice(0, 2).map((coupon, index) => (
))}
);
};
export default WalletPageComponent;