Просмотр исходного кода

refactor: 替换NewbieActivityModal为SuperAdModal,更新活动服务和配置

zbb 2 дней назад
Родитель
Сommit
0d37459900
4 измененных файлов с 125 добавлено и 96 удалено
  1. 6 3
      app.json
  2. 0 84
      components/NewbieActivityModal.tsx
  3. 117 0
      components/SuperAdModal.tsx
  4. 2 9
      services/activity.ts

+ 6 - 3
app.json

@@ -5,14 +5,17 @@
     "version": "1.0.6",
     "version": "1.0.6",
     "orientation": "portrait",
     "orientation": "portrait",
     "icon": "./assets/images/icon.png",
     "icon": "./assets/images/icon.png",
-    "scheme": ["asios", "alipay2021005175632205"],
+    "scheme": [
+      "asios",
+      "alipay2021005175632205"
+    ],
     "userInterfaceStyle": "automatic",
     "userInterfaceStyle": "automatic",
     "newArchEnabled": true,
     "newArchEnabled": true,
     "ios": {
     "ios": {
       "supportsTablet": false,
       "supportsTablet": false,
       "bundleIdentifier": "com.asios",
       "bundleIdentifier": "com.asios",
       "appleTeamId": "Y9ZVX3FRX6",
       "appleTeamId": "Y9ZVX3FRX6",
-      "buildNumber": "35",
+      "buildNumber": "36",
       "infoPlist": {
       "infoPlist": {
         "CFBundleDisplayName": "艾斯潮盒",
         "CFBundleDisplayName": "艾斯潮盒",
         "ITSAppUsesNonExemptEncryption": false,
         "ITSAppUsesNonExemptEncryption": false,
@@ -61,4 +64,4 @@
       }
       }
     }
     }
   }
   }
-}
+}

+ 0 - 84
components/NewbieActivityModal.tsx

@@ -1,84 +0,0 @@
-import { Image } from "expo-image";
-import React from "react";
-import {
-  Modal,
-  Pressable,
-  StyleSheet,
-  TouchableOpacity,
-  View,
-} from "react-native";
-
-const POSTER_URI =
-  "https://cdn.acetoys.cn/kai_xin_ma_te/resource/magic/award/activity_new.webp";
-
-interface Props {
-  visible: boolean;
-  onClose: () => void;
-}
-
-export function NewbieActivityModal({ visible, onClose }: Props) {
-  return (
-    <Modal visible={visible} transparent animationType="fade" onRequestClose={onClose}>
-      <Pressable style={styles.overlay} onPress={onClose}>
-        <View style={styles.wrapper}>
-          <Image
-            source={{ uri: POSTER_URI }}
-            style={styles.poster}
-            contentFit="contain"
-          />
-          <TouchableOpacity
-            style={styles.closeBtn}
-            onPress={onClose}
-            activeOpacity={0.8}
-            hitSlop={16}
-          >
-            <View style={styles.closeCircle}>
-              <View style={[styles.closeLine, styles.closeLineA]} />
-              <View style={[styles.closeLine, styles.closeLineB]} />
-            </View>
-          </TouchableOpacity>
-        </View>
-      </Pressable>
-    </Modal>
-  );
-}
-
-const styles = StyleSheet.create({
-  overlay: {
-    flex: 1,
-    backgroundColor: "rgba(0,0,0,0.6)",
-    justifyContent: "center",
-    alignItems: "center",
-  },
-  wrapper: {
-    alignItems: "center",
-  },
-  poster: {
-    width: 275,
-    height: 300,
-  },
-  closeBtn: {
-    marginTop: 16,
-  },
-  closeCircle: {
-    width: 30,
-    height: 30,
-    borderRadius: 15,
-    borderWidth: 1.5,
-    borderColor: "#fff",
-    justifyContent: "center",
-    alignItems: "center",
-  },
-  closeLine: {
-    position: "absolute",
-    width: 14,
-    height: 1.5,
-    backgroundColor: "#fff",
-  },
-  closeLineA: {
-    transform: [{ rotate: "45deg" }],
-  },
-  closeLineB: {
-    transform: [{ rotate: "-45deg" }],
-  },
-});

+ 117 - 0
components/SuperAdModal.tsx

@@ -0,0 +1,117 @@
+import { Image } from "expo-image";
+import { useRouter } from "expo-router";
+import React, { useState } from "react";
+import {
+  Dimensions,
+  Modal,
+  Pressable,
+  StyleSheet,
+  TouchableOpacity,
+  View,
+} from "react-native";
+
+const { width: SCREEN_WIDTH } = Dimensions.get("window");
+
+export interface AdElement {
+  cover: string;
+  path?: { schema?: string; url?: string; params?: any };
+  title?: string;
+  subtitle?: string;
+}
+
+interface Props {
+  elements: AdElement[];
+  onClose: () => void;
+}
+
+export function SuperAdModal({ elements, onClose }: Props) {
+  const router = useRouter();
+  const [index, setIndex] = useState(0);
+
+  if (!elements || elements.length === 0) return null;
+  const current = elements[index];
+  if (!current) return null;
+
+  const handleClose = () => {
+    if (index < elements.length - 1) {
+      setIndex(index + 1);
+    } else {
+      setIndex(0);
+      onClose();
+    }
+  };
+
+  const handleImagePress = () => {
+    const url = current.path?.url;
+    if (!url) return;
+    if (url.startsWith("http")) {
+      return;
+    }
+    router.push(url as any);
+  };
+
+  return (
+    <Modal
+      visible
+      transparent
+      animationType="fade"
+      onRequestClose={handleClose}
+    >
+      <View style={styles.overlay}>
+        <Pressable style={StyleSheet.absoluteFill} onPress={handleClose} />
+        <Pressable onPress={handleImagePress}>
+          <Image
+            source={{ uri: current.cover }}
+            style={styles.image}
+            contentFit="contain"
+          />
+        </Pressable>
+        <TouchableOpacity
+          style={styles.closeBtn}
+          onPress={handleClose}
+          activeOpacity={0.8}
+          hitSlop={16}
+        >
+          <View style={[styles.closeLine, styles.closeLineA]} />
+          <View style={[styles.closeLine, styles.closeLineB]} />
+        </TouchableOpacity>
+      </View>
+    </Modal>
+  );
+}
+
+const styles = StyleSheet.create({
+  overlay: {
+    flex: 1,
+    backgroundColor: "rgba(0,0,0,0.6)",
+    justifyContent: "center",
+    alignItems: "center",
+  },
+  image: {
+    width: SCREEN_WIDTH,
+    height: SCREEN_WIDTH * 1.2,
+  },
+  closeBtn: {
+    position: "absolute",
+    bottom: 80,
+    alignSelf: "center",
+    width: 32,
+    height: 32,
+    borderRadius: 16,
+    backgroundColor: "#d8d8d8",
+    justifyContent: "center",
+    alignItems: "center",
+  },
+  closeLine: {
+    position: "absolute",
+    width: 14,
+    height: 1.5,
+    backgroundColor: "#000",
+  },
+  closeLineA: {
+    transform: [{ rotate: "45deg" }],
+  },
+  closeLineB: {
+    transform: [{ rotate: "-45deg" }],
+  },
+});

+ 2 - 9
services/activity.ts

@@ -1,18 +1,11 @@
-// 活动服务 - 新人大礼包、优惠券等
-import { get, post, postL } from './http';
+// 活动服务 - 优惠券等
+import { post, postL } from './http';
 
 
 const apis = {
 const apis = {
-  NEWBIE_GIFT_BAG: '/api/activity/newbieGiftBag/info',
   COUPON_LIST_VALID: '/api/coupon/listValidCoupon',
   COUPON_LIST_VALID: '/api/coupon/listValidCoupon',
   COUPON_BATCH_RECEIVE: '/api/coupon/batchReceive',
   COUPON_BATCH_RECEIVE: '/api/coupon/batchReceive',
 };
 };
 
 
-// 新人大礼包信息
-export const getNewbieGiftBagInfo = async () => {
-  const res = await get<any>(apis.NEWBIE_GIFT_BAG);
-  return res.success && res.data ? res.data : null;
-};
-
 // 获取可领优惠券列表
 // 获取可领优惠券列表
 export interface CouponItem {
 export interface CouponItem {
   id: string;
   id: string;