|
|
@@ -14,7 +14,7 @@ import {
|
|
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
|
|
|
|
import { Images } from '@/constants/images';
|
|
|
-import { getCreditRecord, getWalletInfo, signIn } from '@/services/user';
|
|
|
+import services from '@/services/api';
|
|
|
|
|
|
interface DayInfo {
|
|
|
text: string;
|
|
|
@@ -92,13 +92,26 @@ export default function IntegralScreen() {
|
|
|
// 获取积分信息
|
|
|
const getInfo = useCallback(async () => {
|
|
|
try {
|
|
|
- const info = await getWalletInfo('USER_CREDIT');
|
|
|
+ // Use wallet service info instead of user service getWalletInfo
|
|
|
+ const info = await services.wallet.info('USER_CREDIT');
|
|
|
setIntegral(info?.balance || 0);
|
|
|
} catch (error) {
|
|
|
console.error('获取积分失败:', error);
|
|
|
}
|
|
|
}, []);
|
|
|
|
|
|
+ // 获取积分规则
|
|
|
+ const showRule = async () => {
|
|
|
+ try {
|
|
|
+ const res = await services.user.getParamConfig('credit_sign');
|
|
|
+ if (res && res.data) {
|
|
|
+ Alert.alert('积分规则', res.data.replace(/<[^>]+>/g, '')); // Strip HTML tags for Alert
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取规则失败:', error);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
// 获取签到记录
|
|
|
const getData = useCallback(async (dateInfo: DayInfo[]) => {
|
|
|
try {
|
|
|
@@ -112,7 +125,7 @@ export default function IntegralScreen() {
|
|
|
createTime: `${y}-${padWithZeros(m, 2)}-${padWithZeros(d, 2)}`,
|
|
|
};
|
|
|
|
|
|
- const res = await getCreditRecord(param);
|
|
|
+ const res = await services.user.getCreditRecord(param);
|
|
|
const recordData = res?.data || [];
|
|
|
setRecord(recordData);
|
|
|
|
|
|
@@ -185,7 +198,7 @@ export default function IntegralScreen() {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- const res = await signIn();
|
|
|
+ const res = await services.user.signIn();
|
|
|
if (res?.code === 0) {
|
|
|
Alert.alert('提示', '签到成功');
|
|
|
setIstodaySignIn(true);
|
|
|
@@ -236,12 +249,25 @@ export default function IntegralScreen() {
|
|
|
style={styles.infoIcon}
|
|
|
contentFit="contain"
|
|
|
/>
|
|
|
+ {isTooltip && (
|
|
|
+ <ImageBackground
|
|
|
+ source={{uri: Images.integral?.tooltip }}
|
|
|
+ style={styles.tooltip}
|
|
|
+ resizeMode="stretch"
|
|
|
+ >
|
|
|
+ <Text style={styles.tooltipText}>消费积分与签到积分总和</Text>
|
|
|
+ </ImageBackground>
|
|
|
+ )}
|
|
|
</TouchableOpacity>
|
|
|
<View style={styles.todayBox}>
|
|
|
<Text style={styles.todayText}>
|
|
|
今日已获得<Text style={styles.todayNum}>{istodaySignIn ? todayIntegral : 0}</Text>积分
|
|
|
</Text>
|
|
|
</View>
|
|
|
+
|
|
|
+ <TouchableOpacity style={styles.ruleBtn} onPress={showRule}>
|
|
|
+ <Text style={styles.ruleText}>积分规则</Text>
|
|
|
+ </TouchableOpacity>
|
|
|
</ImageBackground>
|
|
|
|
|
|
<View style={styles.content}>
|
|
|
@@ -392,6 +418,7 @@ const styles = StyleSheet.create({
|
|
|
height: 283,
|
|
|
paddingTop: 100,
|
|
|
alignItems: 'center',
|
|
|
+ position: 'relative',
|
|
|
},
|
|
|
integralNum: {
|
|
|
fontSize: 48,
|
|
|
@@ -404,6 +431,7 @@ const styles = StyleSheet.create({
|
|
|
alignItems: 'center',
|
|
|
marginTop: 7,
|
|
|
marginBottom: 12,
|
|
|
+ position: 'relative',
|
|
|
},
|
|
|
allText: {
|
|
|
fontSize: 12,
|
|
|
@@ -414,6 +442,21 @@ const styles = StyleSheet.create({
|
|
|
height: 16,
|
|
|
marginLeft: 4,
|
|
|
},
|
|
|
+ tooltip: {
|
|
|
+ position: 'absolute',
|
|
|
+ width: 150,
|
|
|
+ height: 27,
|
|
|
+ top: 15,
|
|
|
+ left: 30, // Adjust execution based on design
|
|
|
+ justifyContent: 'center',
|
|
|
+ alignItems: 'center',
|
|
|
+ zIndex: 999,
|
|
|
+ paddingHorizontal: 5,
|
|
|
+ },
|
|
|
+ tooltipText: {
|
|
|
+ color: '#fff',
|
|
|
+ fontSize: 10,
|
|
|
+ },
|
|
|
todayBox: {
|
|
|
backgroundColor: 'rgba(0,0,0,0.08)',
|
|
|
borderRadius: 217,
|
|
|
@@ -428,6 +471,21 @@ const styles = StyleSheet.create({
|
|
|
fontWeight: '800',
|
|
|
color: '#5B460F',
|
|
|
},
|
|
|
+ ruleBtn: {
|
|
|
+ position: 'absolute',
|
|
|
+ right: 0,
|
|
|
+ top: 130, // Half of 260rpx approx
|
|
|
+ backgroundColor: '#fff',
|
|
|
+ borderTopLeftRadius: 20,
|
|
|
+ borderBottomLeftRadius: 20,
|
|
|
+ paddingHorizontal: 10,
|
|
|
+ paddingVertical: 6,
|
|
|
+ zIndex: 10,
|
|
|
+ },
|
|
|
+ ruleText: {
|
|
|
+ fontSize: 12,
|
|
|
+ color: '#333',
|
|
|
+ },
|
|
|
content: {
|
|
|
paddingHorizontal: 10,
|
|
|
marginTop: -50,
|
|
|
@@ -608,3 +666,4 @@ const styles = StyleSheet.create({
|
|
|
color: '#999',
|
|
|
},
|
|
|
});
|
|
|
+
|