Leon 2 년 전
부모
커밋
a0d3137609

+ 1 - 1
src/components/basic/Buttons.tsx

@@ -2,7 +2,7 @@ import { Button, View, Text } from "@tarojs/components";
 import './Buttons.scss'
 import { ButtonType, ComponentStatus } from "../../utils/types";
 
-import { Button as RNButton } from 'react-native';
+// import { Button as RNButton } from 'react-native';
 import { AtActivityIndicator } from 'taro-ui';
 import "taro-ui/dist/style/components/activity-indicator.scss";
 import 'taro-ui/dist/style/components/loading.scss';

+ 1 - 37
src/features/trackTimeDuration/components/Schedule.tsx

@@ -20,10 +20,6 @@ import { ColorType } from "@/context/themes/color";
 import { getThemeColor, jumpPage } from "../hooks/Common";
 import TableCell from "@/components/layout/TableCell";
 import TimelineStage from "./TimelineStage";
-import { useFocusEffect } from "@react-navigation/native";
-import React from "react";
-import { AppState } from "react-native";
-import JPush from 'jpush-react-native';
 
 
 export default function Component(props: { type?: string, data?: any, delSuccess?: Function }) {
@@ -39,37 +35,6 @@ export default function Component(props: { type?: string, data?: any, delSuccess
         console.log('push', global.pushEnable)
     }, [global.pushEnable])
 
-    const handleAppStateChange = (nextAppState) => {
-        checkPushStatus()
-    };
-
-    useEffect(() => {
-        AppState.addEventListener('change', handleAppStateChange);
-
-        return () => {
-            AppState.removeEventListener('change', handleAppStateChange);
-        };
-    }, []);
-
-    // useReady(() => {
-    //     alert('sss')
-    //     if (process.env.TARO_ENV == 'rn') {
-    //         const JPush = require('jpush-react-native')
-    //         JPush.isNotificationEnabled(obj => {
-    //             alert(obj)
-    //         })
-    //     }
-    // })
-
-    useFocusEffect(React.useCallback(() => {
-        checkPushStatus()
-    }, []))
-
-    function checkPushStatus() {
-        JPush.isNotificationEnabled(obj => {
-            setPushEnable(obj)
-        })
-    }
 
     function all() {
         if (props.type == 'latest') {
@@ -321,8 +286,7 @@ export default function Component(props: { type?: string, data?: any, delSuccess
             <View className="box_header" style={{ marginRight: 20, backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
                 <Text className="box_title">{t('feature.track_time_duration.schedule.section_title')}</Text>
                 {
-                    process.env.TARO_ENV == 'weapp' ? <Switch isOn={permission.wxPubFollow} onClick={() => followWxPub()} /> :
-                        <Switch isOn={!pushEnable} onClick={() => getSetting()} />
+                    <Switch isOn={permission.wxPubFollow} onClick={() => followWxPub()} />
                 }
 
 

+ 0 - 0
src/features/trackTimeDuration/components/TimelineStage.tsx → src/features/trackTimeDuration/components/TimelineStage.rn.tsx


+ 121 - 0
src/features/trackTimeDuration/components/TimelineStage.weapp.tsx

@@ -0,0 +1,121 @@
+import { View, Text } from '@tarojs/components'
+import './TimelineStage.scss'
+import { useEffect, useState } from 'react';
+import Segment from '@/components/navigation/Segment';
+import TimelineFastSleep from './TimelineFastSleep';
+import Stage from './Stage';
+import { useTranslation } from 'react-i18next';
+import Switch from '@/components/input/Switch';
+import { useSelector } from 'react-redux';
+import Taro from '@tarojs/taro';
+import { jumpPage } from '../hooks/Common';
+import { rpxToPx } from '@/utils/tools';
+
+
+
+export default function Component(props: { data: any, title?: string, subTitle?: string, isSchedule?: boolean,first_real_check_time?:number }) {
+    // debugger
+    const [segmentIndex, setSegmentIndex] = useState(0)
+    const permission = useSelector((state: any) => state.permission);
+    const common = useSelector((state: any) => state.common);
+    const [pushEnable, setPushEnable] = useState(true)
+
+    const handleAppStateChange = (nextAppState) => {
+        checkPushStatus()
+    };
+
+
+
+    const { t } = useTranslation()
+
+    function followWxPub() {
+        const resource = common.resources.filter((item: any) => {
+            return item.code == 'follow_wx_pub'
+        })
+
+        const title = permission.wxPubFollow ?t('feature.track_time_duration.follow_wx_pub.h5_followed_title'):
+        t('feature.track_time_duration.follow_wx_pub.h5_unfollowed_title')
+
+        Taro.showModal({
+            title: permission.wxPubFollow ? t('feature.track_time_duration.follow_wx_pub.modal_followed_title') :
+                t('feature.track_time_duration.follow_wx_pub.modal_unfollowed_title'),
+            content: permission.wxPubFollow ? t('feature.track_time_duration.follow_wx_pub.modal_followed_content') :
+                t('feature.track_time_duration.follow_wx_pub.modal_unfollowed_content'),
+            showCancel: true,
+            cancelText: permission.wxPubFollow ? t('feature.track_time_duration.follow_wx_pub.modal_followed_cancel_btn') :
+                t('feature.track_time_duration.follow_wx_pub.modal_unfollowed_cancel_btn'),
+            confirmText: permission.wxPubFollow ? t('feature.track_time_duration.follow_wx_pub.modal_followed_confirm_btn') :
+                t('feature.track_time_duration.follow_wx_pub.modal_unfollowed_confirm_btn'),
+            success(result) {
+                if (result.confirm) {
+                    global.forceRefreshWXPub = true
+                    jumpPage('/pages/common/H5?title=' + title + '&url=' + resource[0].url)
+                }
+            },
+        })
+    }
+
+    return <View style={{ display: 'flex', flexDirection: 'column', width: rpxToPx(578) }}>
+        {/* <Text className='box_title'>{props.title ? props.title : 'Title'}</Text> */}
+        <View className="box_header" style={{ backgroundColor: global.isDebug ? 'pink' : 'transparent' }}>
+            <Text className="box_title" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>{props.title ? props.title : 'Title'}</Text>
+            {
+                props.isSchedule && process.env.TARO_ENV=='weapp' &&
+                <Switch isOn={permission.wxPubFollow} onClick={() => followWxPub()} />
+            }
+        </View>
+        <Text className='box_subtitle'>{props.subTitle ? props.subTitle : 'subTitle'}</Text>
+        <View className="segment_detail" style={{
+            display: 'flex', alignItems: 'center',
+            flexDirection: 'column', justifyContent: 'center'
+        }}>
+            <View style={{
+                position: 'relative', width: '100%', display: 'flex', alignItems: 'center',
+                flexDirection: 'column', justifyContent: 'center'
+            }}>
+                {/* <View style={{ backgroundColor: 'pink' }}>
+                    {
+                        segmentIndex == 0 ? <TimelineFastSleep data={props.data} /> : <Stage data={props.data} />
+                    }
+                </View> */}
+
+                <View style={{ position: 'relative' }}>
+                    <View style={{ opacity: segmentIndex == 0 ? 1 : 0 }}>
+                        <TimelineFastSleep data={props.data} first_real_check_time={props.first_real_check_time}/>
+                    </View>
+                    {props.data.scenario == 'FAST_SLEEP' && <View style={{
+                        opacity: segmentIndex == 1 ? 1 : 0,
+                        position: 'absolute', left: 0, top: 0, right: 0, bottom: 0,
+                    }}>
+                        <Stage data={props.data} />
+                    </View>}
+                </View>
+
+
+                {/* <View style={{ opacity: segmentIndex == 0 ? 1 : 0 }}>
+                    <TimelineFastSleep data={props.data} />
+                </View>
+                {
+                    props.data.scenario == 'FAST_SLEEP' && <View style={{
+                        position: 'absolute', left: 0, top: 0, right: 0, bottom: 0,
+                        opacity: segmentIndex == 1 ? 1 : 0
+                    }}>
+                        <Stage data={props.data} />
+                    </View>
+                } */}
+
+            </View>
+        </View>
+        {
+            props.data.scenario == 'FAST_SLEEP' &&
+            <View style={{ marginBottom: 0 }}>
+                <Segment titles={[props.isSchedule ? t('feature.track_time_duration.schedule.timeline') :
+                    t('feature.track_time_duration.record_fast_sleep.timeline'),
+                t('feature.track_time_duration.schedule.stage')]} changed={(e) => {
+                    setSegmentIndex(e);
+                    global.segmentIndex = e
+                }} />
+            </View>
+        }
+    </View>
+}