Browse Source

fix: 转赠按钮显示条件兼容消费金额阈值返回 (shareOnState > 0)

zbb 2 tuần trước cách đây
mục cha
commit
6ec8ddf8e3
2 tập tin đã thay đổi với 24 bổ sung17 xóa
  1. 12 9
      app/cloud-warehouse/index.tsx
  2. 12 8
      app/store/index.tsx

+ 12 - 9
app/cloud-warehouse/index.tsx

@@ -173,9 +173,11 @@ export default function StoreScreen() {
     const fetchShareOn = async () => {
       try {
         const config = await getParamConfig('share_on');
-        setShareOnState(config?.state || 0);
+        console.log('[DEBUG-cloud] share_on config:', config);
+        setShareOnState(config?.state ?? 1);
       } catch (e) {
-        console.error('获取转赠开关失败:', e);
+        console.error('获取云仓转赠开关失败:', e);
+        setShareOnState(1); // 默认开启转赠
       }
     };
     fetchShareOn();
@@ -707,7 +709,7 @@ export default function StoreScreen() {
         )}
 
         {/* 转赠浮动按钮 */}
-        {mainTabIndex === 0 && shareOnState === 1 && list.length > 0 && (
+        {mainTabIndex === 0 && list.length > 0 && Number(shareOnState) > 0 && (
           <TouchableOpacity
             style={styles.transferFloatBtn}
             onPress={handleTransfer}
@@ -742,13 +744,14 @@ const styles = StyleSheet.create({
   background: { flex: 1 },
   transferFloatBtn: {
     position: "absolute",
-    bottom: 200,
-    right: 10,
-    width: 48,
-    height: 50,
-    zIndex: 100,
+    bottom: 220, // 跟普通仓库页保持一致高度防止遮挡
+    right: 15,
+    width: 50,
+    height: 52,
+    zIndex: 999, // 提高层级
+    elevation: 10,
   },
-  transferFloatImg: { width: 48, height: 50 },
+  transferFloatImg: { width: "100%", height: "100%" },
   headerBg: {
     position: "absolute",
     top: 0,

+ 12 - 8
app/store/index.tsx

@@ -156,9 +156,12 @@ export default function StoreScreen() {
     const fetchShareOn = async () => {
       try {
         const config = await getParamConfig('share_on');
-        setShareOnState(config?.state || 0);
+        console.log('[DEBUG] share_on config:', config);
+        // 如果未取到数据可能默认应显示,此处做兼容保留原有1状态,没配置也暂且视作1(开启)或以服务器为主
+        setShareOnState(config?.state ?? 1); 
       } catch (e) {
         console.error('获取转赠开关失败:', e);
+        setShareOnState(1); // 网络请求失败时降级开启转赠
       }
     };
     fetchShareOn();
@@ -474,7 +477,7 @@ export default function StoreScreen() {
         )}
         
         {/* 转赠浮动按钮 */}
-        {mainTabIndex === 0 && shareOnState === 1 && list.length > 0 && (
+        {mainTabIndex === 0 && list.length > 0 && Number(shareOnState) > 0 && (
           <TouchableOpacity
             style={styles.transferFloatBtn}
             onPress={handleTransfer}
@@ -509,13 +512,14 @@ const styles = StyleSheet.create({
   background: { flex: 1 },
   transferFloatBtn: {
     position: 'absolute',
-    bottom: 200,
-    right: 10,
-    width: 48,
-    height: 50,
-    zIndex: 100,
+    bottom: 220, // 调高一点防止跟提货按钮重叠遮挡
+    right: 15,
+    width: 50,
+    height: 52,
+    zIndex: 999, // 提高层级
+    elevation: 10,
   },
-  transferFloatImg: { width: 48, height: 50 },
+  transferFloatImg: { width: '100%', height: '100%' },
   headerBg: { position: 'absolute', top: 0, left: 0, width: '100%', height: 160 },
   header: { position: 'absolute', top: 0, left: 0, right: 0, zIndex: 100, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 10, paddingBottom: 10 },
   backBtn: { width: 40, height: 40, justifyContent: 'center', alignItems: 'center' },