ソースを参照

修复签到页面

zbb 3 ヶ月 前
コミット
651111206a
4 ファイル変更129 行追加10 行削除
  1. 63 4
      app/integral/index.tsx
  2. 1 0
      app/wallet/index.tsx
  3. 2 0
      services/api.ts
  4. 63 6
      services/wallet.ts

+ 63 - 4
app/integral/index.tsx

@@ -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',
   },
 });
+

+ 1 - 0
app/wallet/index.tsx

@@ -103,6 +103,7 @@ export default function WalletScreen() {
         headerStyle: { backgroundColor: 'transparent' }, 
         headerTransparent: true,
         headerTintColor: '#fff', 
+        headerBackTitleVisible: false,
       }} />
 
       <SafeAreaView style={{ flex: 1, marginTop: 100 }}>

+ 2 - 0
services/api.ts

@@ -20,6 +20,7 @@ import awardService from './award';
 import baseService from './base';
 import mallService from './mall';
 import userService from './user';
+import walletService from './wallet'; // Add import
 
 export const services = {
   mall: mallService,
@@ -27,6 +28,7 @@ export const services = {
   base: baseService,
   address: addressService,
   user: userService,
+  wallet: walletService, // Add export
 };
 
 export default services;

+ 63 - 6
services/wallet.ts

@@ -1,9 +1,21 @@
-import { get, post } from './http';
+import { get, post, postL } from './http';
 
 const apis = {
     PRE_ONE_KEY: '/api/substituteOrder/preOneKeySubmit',
     COUPON: '/api/coupon/pageMyValidCoupon',
     BILL: '/api/wallet/bill',
+    
+    WITHDRAW_PRE: '/api/wallet/withdrawPre',
+    WITHDRAW: '/api/wallet/withdraw',
+    WITHDRAW_INFO: '/api/user/withdraw/info', // Bank info
+    WITHDRAW_SAVE: '/api/user/withdraw/save',
+
+    RECHARGE_GENERATE_LINK: '/api/user/recharge/generatePaymentLink',
+    RECHARGE_CHECK_PAYMENT_STATUS: '/api/user/recharge/checkPaymentStatus',
+    
+    INFO: '/api/wallet/getByType',
+    
+    NEW_USER_PROMOTION: '/api/activity/newUserPromotion',
 };
 
 export const preOneKeySubmit = async () => {
@@ -12,19 +24,64 @@ export const preOneKeySubmit = async () => {
 };
 
 export const info = async (type: string, loading = false) => {
-    const res = await get('/api/wallet/getByType', { type }, { loading });
+    // loading handled manually if needed, or pass header
+    const res = await get(apis.INFO, { type }, { loading });
+    return res.data;
+};
+
+export const bill = async (current: number, size: number, walletType: string, type: string) => {
+    const res = await post(apis.BILL, { current, size, walletType, type });
+    return res.data;
+};
+
+export const withdrawPre = async (type: string, walletType: string) => {
+    const res = await get(apis.WITHDRAW_PRE, { type, walletType });
+    return res.data;
+};
+
+export const getWithdraw = async () => {
+    const res = await get(apis.WITHDRAW_INFO);
+    return res.data;
+};
+
+export const saveWithdraw = async (data: any) => {
+    const res = await post(apis.WITHDRAW_SAVE, data);
+    return res.success;
+};
+
+export const withdraw = async (data: any) => {
+    const res = await postL(apis.WITHDRAW, data);
+    return res.success;
+};
+
+export const generatePaymentLink = async (amount: number, payType: string, walletType: string) => {
+    const res = await postL(apis.RECHARGE_GENERATE_LINK, { amount, payType, walletType });
+    return res;
+};
+
+export const checkPaymentStatus = async (data: { tradeNo: string }) => {
+    const res = await post(apis.RECHARGE_CHECK_PAYMENT_STATUS, data);
+    return res;
+};
+
+export const getNewUserPromotion = async () => {
+    const res = await get(apis.NEW_USER_PROMOTION);
     return res.data;
 };
 
 export default {
     preOneKeySubmit,
     info,
+    bill,
+    withdrawPre,
+    getWithdraw,
+    saveWithdraw,
+    withdraw,
+    generatePaymentLink,
+    checkPaymentStatus,
+    getNewUserPromotion,
     coupons: async (size = 30) => {
         const res = await post(apis.COUPON, { size }, { loading: true });
         return res.data;
     },
-    bill: async (current: number, size: number, walletType: string, type: string) => {
-        const res = await post(apis.BILL, { current, size, walletType, type });
-        return res.data;
-    },
 };