leon 1 rok pred
rodič
commit
ccd563b7dc

+ 6 - 1
src/context/locales/en.js

@@ -349,7 +349,12 @@ export default {
                 real_sleep_end_tip:'Expected wake-up time: {{time}}',
                 target: 'Target',
                 lock_fast_tip:'Start fasting first.',
-                lock_sleep_tip:'Start sleeping first.'
+                lock_sleep_tip:'Start sleeping first.',
+                no_duration_available:'Unpredictable duration',
+                predicted:'Predicted',
+                predicted_alert_title:'Off Schedule ',
+                predicted_alert_content:'Unpredictable duration due to deviation from scheduled timeline.',
+                predicted_alert_btn:'Got it'
                 
             },
             schedule: {

+ 6 - 1
src/context/locales/zh.js

@@ -352,7 +352,12 @@ export default {
                 real_sleep_end_tip:'原定于{{time}} 起床',
                 target: '目标',
                 lock_fast_tip:'请先开始断食',
-                lock_sleep_tip:'请先开始睡眠'
+                lock_sleep_tip:'请先开始睡眠',
+                no_duration_available:'无法预估时长',
+                predicted:'预估',
+                predicted_alert_title:'计划外',
+                predicted_alert_content:'与计划日程相差较大, 导致该阶段时长无法预估。',
+                predicted_alert_btn:'我知道了'
             },
             schedule: {
                 section_title: '今天',

+ 13 - 0
src/features/trackTimeDuration/components/CircadianDetailPopup.scss

@@ -182,4 +182,17 @@
     font-size: 36px;
     line-height: 48px;
     font-weight: bold;
+}
+
+.free {
+    height: 36px;
+    line-height: 35px;
+    border-radius: 18px;
+    font-size: 20px;
+    display: flex;
+    // align-items: center;
+    // justify-content: center;
+    padding-left: 16px;
+    padding-right: 16px;
+    margin-left: 6px;
 }

+ 103 - 28
src/features/trackTimeDuration/components/CircadianDetailPopup.tsx

@@ -4,7 +4,7 @@ import { useEffect, useRef, useState } from 'react'
 import TimelineFastSleep from './TimelineFastSleep'
 import { RealRing } from "@/features/trackTimeDuration/components/Rings";
 import Rings from "./Rings";
-import { bigRingRadius, getBgRing, getCommon, ringWidth } from '../hooks/RingData';
+import { bigRingRadius, getBgRing, getCommon, getDot, ringWidth } from '../hooks/RingData';
 import { ColorType } from '@/context/themes/color';
 import { useTranslation } from 'react-i18next';
 import { TimeFormatter } from '@/utils/time_format';
@@ -15,7 +15,7 @@ import Modal from '@/components/layout/Modal.weapp';
 import { updateRecord } from '@/services/trackTimeDuration';
 import PickerViews from '@/components/input/PickerViews';
 import Taro from '@tarojs/taro';
-import { IconMinus, IconPlus } from '@/components/basic/Icons';
+import { IconInfo, IconMinus, IconPlus } from '@/components/basic/Icons';
 
 export default function CircadianDetailPopup(props: { record: any, schedule?: any, onClose: Function, stageIndex?: number, onlyStage?: boolean }) {
     const [tabIndex, setTabIndex] = useState(0)
@@ -217,9 +217,10 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
                 break;
         }
         if (start > end) {
-            return '-' + TimeFormatter.durationFormate2(start, end)
+            return t('feature.track_time_duration.console.no_duration_available')
+            // return '-' + TimeFormatter.durationFormate2(start, end)
         }
-        return TimeFormatter.durationFormate2(start, end)
+        return TimeFormatter.calculateTimeDifference(start, end)
     }
 
     function completedOverView() {
@@ -556,6 +557,15 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
         </View>
     }
 
+    function showPredictedAlert() {
+        Taro.showModal({
+            title: t('feature.track_time_duration.console.predicted_alert_title'),
+            content: t('feature.track_time_duration.console.predicted_alert_content'),
+            showCancel: false,
+            confirmText: t('feature.track_time_duration.console.predicted_alert_btn')
+        })
+    }
+
     function stage() {
         var bgRing = getBgRing()
         var common = getCommon(null, false)
@@ -563,6 +573,12 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
         common.lineWidth = ringWidth;
         var timestamp, timestamp2, timestamp3
         var duration, duration2, duration3;
+
+        var predicted2 = false; //预估
+        var predicted3 = false;
+        var currentDot = getDot(null, true)
+        var currentDot2 = getDot(null, true)
+        var currentDot3 = getDot(null, true)
         if (props.record.status == 'WAIT_FOR_START') {
             var date = new Date()
             date.setSeconds(0)
@@ -590,7 +606,12 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
             duration = durationArc(props.record.fast.target_start_time, props.record.sleep.target_start_time)
             duration2 = durationArc(props.record.sleep.target_start_time, props.record.sleep.target_end_time)
             duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time)
+
+            currentDot = null
+            currentDot2 = null
+            currentDot3 = null
         }
+
         else if (props.record.status == 'ONGOING1') {
             var date = new Date()
             timestamp = props.record.fast.real_start_time
@@ -599,6 +620,13 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
             duration = durationArc(props.record.fast.real_start_time, date.getTime())
             duration2 = durationArc(props.record.sleep.target_start_time, props.record.sleep.target_end_time)
             duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time)
+
+            predicted2 = true
+            predicted3 = true
+
+            currentDot.color = ColorType.fast
+            currentDot2 = null
+            currentDot3 = null
         }
         else if (props.record.status == 'ONGOING2') {
             var date = new Date()
@@ -608,6 +636,13 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
             duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time)
             duration2 = durationArc(props.record.sleep.real_start_time, date.getTime())
             duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time)
+
+            predicted2 = false
+            predicted3 = true
+
+            currentDot = null
+            currentDot2.color = ColorType.sleep
+            currentDot3 = null
         }
         else if (props.record.status == 'ONGOING3') {
             var date = new Date()
@@ -617,6 +652,10 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
             duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time)
             duration2 = durationArc(props.record.sleep.real_start_time, props.record.sleep.real_end_time)
             duration3 = durationArc(props.record.sleep.real_end_time, date.getTime())
+
+            currentDot = null
+            currentDot2 = null
+            currentDot3.color = ColorType.fast
         }
         else {
             timestamp = TimeFormatter.transferTimestamp(props.record.fast.real_start_time, props.record.fast.real_end_time_zone)
@@ -625,6 +664,9 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
             duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time)
             duration2 = durationArc(props.record.sleep.real_start_time, props.record.sleep.real_end_time)
             duration3 = durationArc(props.record.sleep.real_end_time, props.record.fast.real_end_time)
+            currentDot = null
+            currentDot2 = null
+            currentDot3 = null
         }
 
         const preRing: RealRing = {
@@ -632,36 +674,54 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
             startArc: startArc(timestamp),
             durationArc: duration
         }
-        const sleepRing: RealRing = {
+        let sleepRing: RealRing = {
             color: global.sleepColor ? global.sleepColor : ColorType.sleep,
             startArc: startArc(timestamp2),
             durationArc: duration2
         }
-        const wakeRing: RealRing = {
+        let wakeRing: RealRing = {
             color: global.fastColor ? global.fastColor : ColorType.fast,
             startArc: startArc(timestamp3),
             durationArc: duration3
         }
+
+        if (duration2 < 0) {
+            sleepRing = null
+        }
+        if (duration3 < 0) {
+            wakeRing = null
+        }
         return <View>
             <View className='pop_ring_bg'>
-                <Rings common={common} bgRing={bgRing} canvasId={'pre_sleep_ring'} realRing={preRing} />
+                <Rings common={common} bgRing={bgRing} canvasId={'pre_sleep_ring'} realRing={preRing} currentDot={currentDot}/>
                 <View className="pop_duration_bg">
                     <Text className="pop_duration_title">{t('feature.track_time_duration.stage.a')}</Text>
                     <Text className="pop_duration_value" style={{ color: ColorType.fast }}>{getStageDuration(0)}</Text>
                 </View>
             </View>
             <View className='pop_ring_bg'>
-                <Rings common={common} bgRing={bgRing} canvasId={'sleeping_ring'} realRing={sleepRing} />
+                <Rings common={common} bgRing={bgRing} canvasId={'sleeping_ring'} realRing={sleepRing}  currentDot={currentDot2}/>
                 <View className="pop_duration_bg">
                     <Text className="pop_duration_title">{t('feature.track_time_duration.stage.b')}</Text>
-                    <Text className="pop_duration_value" style={{ color: ColorType.sleep }}>{getStageDuration(1)}</Text>
+                    <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
+                        <Text className="pop_duration_value" style={{ color: ColorType.sleep, marginBottom: 0 }}>{getStageDuration(1)}</Text>
+                        {
+                            predicted2 ? !sleepRing ? <View style={{ marginLeft: 5 }} onClick={showPredictedAlert}><IconInfo width={20} color={ColorType.sleep} /></View> : <View className='free' style={{ backgroundColor: ColorType.sleep, color: '#fff' }}>{t('feature.track_time_duration.console.predicted')}</View> : null
+                        }
+                    </View>
+
                 </View>
             </View>
             <View className='pop_ring_bg'>
-                <Rings common={common} bgRing={bgRing} canvasId={'later_sleep_ring'} realRing={wakeRing} />
+                <Rings common={common} bgRing={bgRing} canvasId={'later_sleep_ring'} realRing={wakeRing}  currentDot={currentDot3}/>
                 <View className="pop_duration_bg">
                     <Text className="pop_duration_title">{t('feature.track_time_duration.stage.c')}</Text>
-                    <Text className="pop_duration_value" style={{ color: ColorType.fast }}>{getStageDuration(2)}</Text>
+                    <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
+                        <Text className="pop_duration_value" style={{ color: ColorType.fast, marginBottom: 0 }}>{getStageDuration(2)}</Text>
+                        {
+                            predicted3 ? !wakeRing ? <View style={{ marginLeft: 5 }} onClick={showPredictedAlert}><IconInfo width={20} color={ColorType.fast} /></View> : <View className='free' style={{ backgroundColor: ColorType.fast, color: '#fff' }}>{t('feature.track_time_duration.console.predicted')}</View> : null
+                        }
+                    </View>
                 </View>
             </View>
         </View>
@@ -855,6 +915,8 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
 
         var timestamp, timestamp2, timestamp3
         var duration, duration2, duration3;
+
+        var currentDot = getDot(null, true)
         if (props.record.status == 'WAIT_FOR_START') {
             var date = new Date()
             date.setSeconds(0)
@@ -882,6 +944,8 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
             duration = durationArc(props.record.fast.target_start_time, props.record.sleep.target_start_time)
             duration2 = durationArc(props.record.sleep.target_start_time, props.record.sleep.target_end_time)
             duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time)
+
+            currentDot = null;
         }
         else if (props.record.status == 'ONGOING1') {
             var date = new Date()
@@ -891,6 +955,13 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
             duration = durationArc(props.record.fast.real_start_time, date.getTime())
             duration2 = durationArc(props.record.sleep.target_start_time, props.record.sleep.target_end_time)
             duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time)
+
+            if (props.stageIndex == 0) {
+                currentDot.color = ColorType.fast
+            }
+            else {
+                currentDot = null
+            }
         }
         else if (props.record.status == 'ONGOING2') {
             var date = new Date()
@@ -900,6 +971,12 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
             duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time)
             duration2 = durationArc(props.record.sleep.real_start_time, date.getTime())
             duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time)
+            if (props.stageIndex == 1) {
+                currentDot.color = ColorType.sleep
+            }
+            else {
+                currentDot = null
+            }
         }
         else if (props.record.status == 'ONGOING3') {
             var date = new Date()
@@ -909,6 +986,12 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
             duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time)
             duration2 = durationArc(props.record.sleep.real_start_time, props.record.sleep.real_end_time)
             duration3 = durationArc(props.record.sleep.real_end_time, date.getTime())
+            if (props.stageIndex == 2) {
+                currentDot.color = ColorType.fast
+            }
+            else {
+                currentDot = null
+            }
         }
         else {
             timestamp = TimeFormatter.transferTimestamp(props.record.fast.real_start_time, props.record.fast.real_end_time_zone)
@@ -917,6 +1000,7 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
             duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time)
             duration2 = durationArc(props.record.sleep.real_start_time, props.record.sleep.real_end_time)
             duration3 = durationArc(props.record.sleep.real_end_time, props.record.fast.real_end_time)
+            currentDot = null
         }
 
         const preRing: RealRing = {
@@ -936,11 +1020,11 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
         }
 
         return <View className='detail_container'>
-            <Text className='detail_popup_title'>{getTitle()}<Text className='detail_popup_subttitle'> {getSubTitle()}</Text></Text>
-            <View style={{ marginTop: rpxToPx(40) }}>
+            {/* <Text className='detail_popup_title'>{getTitle()}<Text className='detail_popup_subttitle'> {getSubTitle()}</Text></Text> */}
+            <View style={{ marginTop: rpxToPx(0) }}>
                 {
-                    props.stageIndex == 0 && <View className='pop_ring_bg'>
-                        <Rings common={common} bgRing={bgRing} canvasId={'pre_sleep_ring'} realRing={preRing} />
+                    props.stageIndex == 0 && <View className='pop_ring_bg' style={{ borderTopColor: 'transparent' }}>
+                        <Rings common={common} bgRing={bgRing} canvasId={'pre_sleep_ring'} realRing={preRing} currentDot={currentDot} />
                         <View className="pop_duration_bg">
                             <Text className="pop_duration_title">{t('feature.track_time_duration.stage.a')}</Text>
                             <Text className="pop_duration_value" style={{ color: ColorType.fast }}>{getStageDuration(0)}</Text>
@@ -948,8 +1032,8 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
                     </View>
                 }
                 {
-                    props.stageIndex == 1 && <View className='pop_ring_bg'>
-                        <Rings common={common} bgRing={bgRing} canvasId={'sleeping_ring'} realRing={sleepRing} />
+                    props.stageIndex == 1 && <View className='pop_ring_bg' style={{ borderTopColor: 'transparent' }}>
+                        <Rings common={common} bgRing={bgRing} canvasId={'sleeping_ring'} realRing={sleepRing} currentDot={currentDot} />
                         <View className="pop_duration_bg">
                             <Text className="pop_duration_title">{t('feature.track_time_duration.stage.b')}</Text>
                             <Text className="pop_duration_value" style={{ color: ColorType.sleep }}>{getStageDuration(1)}</Text>
@@ -957,8 +1041,8 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
                     </View>
                 }
                 {
-                    props.stageIndex == 2 && <View className='pop_ring_bg'>
-                        <Rings common={common} bgRing={bgRing} canvasId={'later_sleep_ring'} realRing={wakeRing} />
+                    props.stageIndex == 2 && <View className='pop_ring_bg' style={{ borderTopColor: 'transparent' }}>
+                        <Rings common={common} bgRing={bgRing} canvasId={'later_sleep_ring'} realRing={wakeRing} currentDot={currentDot} />
                         <View className="pop_duration_bg">
                             <Text className="pop_duration_title">{t('feature.track_time_duration.stage.c')}</Text>
                             <Text className="pop_duration_value" style={{ color: ColorType.fast }}>{getStageDuration(2)}</Text>
@@ -966,15 +1050,6 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
                     </View>
                 }
             </View>
-            <View className='detail_bottom'>
-                <View className='detail_bottom_btn' onClick={(e) => {
-                    if (process.env.TARO_ENV == 'weapp') {
-                        e.stopPropagation()
-                    }
-                    global.updateFastSleepData(detail)
-                    props.onClose();
-                }}>{getBottomText()}</View>
-            </View>
         </View>
     }
 

+ 216 - 219
src/features/trackTimeDuration/components/DayNightCard.tsx

@@ -19,7 +19,9 @@ import { IconDay, IconInfo, IconNight } from '@/components/basic/Icons'
 import { getClocks } from '@/services/trackTimeDuration'
 import { request } from '@/services/http/request'
 import { API_USER_LOCATION } from '@/services/http/api'
-import { bigRingRadius, ringWidth } from '../hooks/RingData'
+import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
+import Rings from "./Rings";
+import { bigRingRadius, getBgRing, getCommon, getDot, ringWidth } from '../hooks/RingData'
 
 let useNavigation;
 if (process.env.TARO_ENV == 'rn') {
@@ -52,6 +54,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
     const user = useSelector((state: any) => state.user);
     const dayStore = useSelector((state: any) => state.day);
     const nightStore = useSelector((state: any) => state.night);
+    const time = useSelector((state: any) => state.time);
     const [authInfo, setAuthInfo] = useState(global.locationDetail ? global.locationDetail : null)
     const [sunriseTime, setSunriseTime] = useState('06:00')
     const [sunriseTmrTime, setSunriseTmrTime] = useState('06:00')
@@ -480,7 +483,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
 
     function getLocation() {
         var city = ''
-        if ((authInfo as any).address){
+        if ((authInfo as any).address) {
             if ((authInfo as any).address.city.length > 0) {
                 city = (authInfo as any).address.city
             }
@@ -702,20 +705,6 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         }
     }
 
-    function nightDuration() {
-        if (!authInfo || !(authInfo as any).lat) {
-            if (new Date().getHours() >= 6) {
-                return `${t('feature.day_night.tonight')} ${sunsetTime} - ${t('feature.day_night.tomorrow_morning')} ${sunriseTmrTime}`
-            }
-            return `${t('feature.day_night.last_night')} ${sunsetTime} - ${t('feature.day_night.this_morning')} ${sunriseTmrTime}`
-            // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
-        }
-        if (nightDate.getDate() == new Date().getDate()) {
-            return `${t('feature.day_night.tonight')} ${sunsetTime.substring(0, 5)} - ${t('feature.day_night.tomorrow_morning')} ${sunriseTmrTime.substring(0, 5)}`
-        }
-        return `${t('feature.day_night.last_night')} ${sunsetTime.substring(0, 5)} - ${t('feature.day_night.this_morning')} ${sunriseTmrTime.substring(0, 5)}`
-        //`Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
-    }
 
     function getSunsetTime() {
         if (props.isNight) {
@@ -733,18 +722,19 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         }
         if (!authInfo || !(authInfo as any).lat) {
             if (new Date().getHours() >= 18) {
-                return `${sunriseTime}`
+                return `${sunsetTime}`
 
                 // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
             }
-            return `${sunriseTime}`
+            return `${sunsetTime}`
             // return `Today ${sunriseTime} - ${sunsetTime}`
         }
         if (dayDate.getDate() == new Date().getDate()) {
-            return `${sunriseTime.substring(0, 5)}`
+            return `${sunsetTime.substring(0, 5)}`
             // return `Today ${sunriseTime} - ${sunsetTime}`
         }
-        return `${sunriseTime.substring(0, 5)}`
+        return `${sunsetTime.substring(0, 5)}`
+
     }
 
     function getSunriseTime() {
@@ -763,51 +753,20 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         }
         if (!authInfo || !(authInfo as any).lat) {
             if (new Date().getHours() >= 18) {
-                return `${sunsetTime}`
-
-                // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
-            }
-            return `${sunsetTime}`
-            // return `Today ${sunriseTime} - ${sunsetTime}`
-        }
-        if (dayDate.getDate() == new Date().getDate()) {
-            return `${sunsetTime.substring(0, 5)}`
-            // return `Today ${sunriseTime} - ${sunsetTime}`
-        }
-        return `${sunsetTime.substring(0, 5)}`
-    }
-
-    function dayDuration() {
-        if (!authInfo || !(authInfo as any).lat) {
-            if (new Date().getHours() >= 18) {
-                return `${t('feature.day_night.tomorrow')} ${sunriseTime} - ${sunsetTime}`
+                return `${sunriseTime}`
 
                 // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
             }
-            return `${t('feature.day_night.today')} ${sunriseTime} - ${sunsetTime}`
+            return `${sunriseTime}`
             // return `Today ${sunriseTime} - ${sunsetTime}`
         }
         if (dayDate.getDate() == new Date().getDate()) {
-            return `${t('feature.day_night.today')} ${sunriseTime.substring(0, 5)} - ${sunsetTime.substring(0, 5)}`
+            return `${sunriseTime.substring(0, 5)}`
             // return `Today ${sunriseTime} - ${sunsetTime}`
         }
-        return `${t('feature.day_night.tomorrow')} ${sunriseTime.substring(0, 5)} - ${sunsetTime.substring(0, 5)}`
-        // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
-    }
-
-    function nightDurationDesc1() {
-        if (authInfo && authInfo.lat) {
-            return t('feature.day_night.sunset_to_sunrise')
-        }
-        return t('feature.day_night.night_tip')
+        return `${sunriseTime.substring(0, 5)}`
     }
 
-    function dayDurationDesc1() {
-        if (authInfo && authInfo.lat) {
-            return t('feature.day_night.sunrise_to_sunset')
-        }
-        return t('feature.day_night.day_tip')
-    }
 
     function longClick() {
         if (user.isLogin && user.test_user && authInfo)
@@ -955,82 +914,224 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
 
     }
 
-    return <Box><View style={{position:'relative'}}>
+    function nightRing() {
+        var common = getCommon(null, true)
+        common.radius = bigRingRadius;
+        common.lineWidth = ringWidth;
+        var bgRing = getBgRing()
+
+        let realRingBig: RealRing = {
+            color: ColorType.night + '66',
+            startArc: 0,
+            durationArc: 2
+        }
+        var sunRise = 24 * 60 + 6 * 60
+        var sunSet = 18 * 60
+
+        var sunRiseObj = nightStore.nightRingSunrise
+        var sunSetObj = nightStore.nightRingSunset
+        sunRise = 24 * 60 + parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
+        sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
+        if (sunSetObj.indexOf('PM') != -1) {
+            sunSet += 12 * 60
+        }
+        // }
+        var duration = sunRise - sunSet
+        realRingBig.startArc = (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
+        realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
+
+        var currentDot = getDot(null, false)
+        currentDot.color = ColorType.night
+
+        var now = new Date()
+        var t = now.getHours() * 60 + now.getMinutes()
+        var duration2 = t - sunSet
+        if (duration2 < 0) {
+            duration2 += 24 * 60
+        }
+        let realRing: RealRing = {
+            color: ColorType.night,
+            startArc: (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0,
+            durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
+        }
+
+        if (nightStore.nightRingDate) {
+            if (new Date(nightStore.nightRingDate).getDate() == new Date().getDate() && new Date().getHours() < 12) {
+
+                realRing = null;
+            }
+        }
+
+        if (!user.isLogin) {
+            currentDot = null;
+            realRing = null;
+        }
+
+
+        return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} realRing={duration2 > duration ? null : realRing} currentDot={currentDot} canvasId={'dddd' + 'index_day'} />
+
+    }
+
+    function dayRing() {
+        var common = getCommon(null, true)
+        common.radius = bigRingRadius;
+        common.lineWidth = ringWidth;
+        var bgRing = getBgRing()
+
+        const realRingBig: RealRing = {
+            color: ColorType.day + '66',
+            startArc: 0,
+            durationArc: 2
+        }
+        var sunRise = 6 * 60
+        var sunSet = 18 * 60
+
+
+
+        var sunRiseObj = dayStore.dayRingSunrise
+        var sunSetObj = dayStore.dayRingSunset
+        sunRise = parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
+        sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
+
+
+        var duration = sunSet - sunRise
+
+        realRingBig.startArc = (sunRise * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
+        realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
+
+        var currentDot = getDot(null, false)
+        var date = new Date()
+        var minutes = date.getHours() * 60 + date.getMinutes()
+        if (minutes < sunRise) {
+            minutes += 1440
+        }
+
+        currentDot.color = ColorType.day
+
+
+        var now = new Date()
+        var t = now.getHours() * 60 + now.getMinutes()
+        var duration2 = t - sunRise
+        if (duration2 < 0) {
+            duration2 += 24 * 60
+        }
+        var realRing: RealRing = {
+            color: ColorType.day,
+            startArc: (sunRise * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0,
+            durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
+        }
+        if (dayStore.dayRingDate) {
+            if (new Date(dayStore.dayRingDate).getDate() != new Date().getDate()) {
+                realRing = null;
+            }
+        }
+
+        if (!user.isLogin) {
+            currentDot = null
+            realRing = null
+        }
+
+        return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} realRing={duration2 <= duration ? realRing : null} currentDot={currentDot} canvasId={'day_day2'} />
+
+    }
+
+    function getSunsetDuration() {
+
+        var now = new Date()
+        if (props.isNight && sunriseTmrDate) {
+            if (now.getTime() < sunriseTmrDate.getTime()) {
+                return TimeFormatter.countdown(sunsetDate.getTime())
+            }
+            // return TimeFormatter.countdown(sunsetDate.getTime())
+        }
+
+
+        var sunRiseObj = nightStore.nightRingSunrise
+        var sunSetObj = nightStore.nightRingSunset
+        var sunRise = 24 * 60 + parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
+        var sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
+        if (sunSetObj.indexOf('PM') != -1) {
+            sunSet += 12 * 60
+        }
+
+        var duration = (sunRise - sunSet) * 60 * 1000
+
+        return TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
+
+        // //COMPLETED
+        // if (time.last_real_check_time && time.status != 'WAIT_FOR_START' && time.status != 'COMPLETED') {
+        //     var target_end_time;
+        //     if (time.scenario == 'SLEEP') {
+        //         target_end_time = time.sleep.target_end_time
+        //     }
+        //     else {
+        //         target_end_time = time.fast.target_end_time
+        //     }
+
+        //     if (new Date().getTime > target_end_time) {
+        //         //超时
+        //     }
+        // }
+
+        // //WFS
+        // //ONGOING 显示正计时
+        // return ''
+    }
+
+    return <Box><View style={{ position: 'relative' }}>
         {
             !user.isLogin && <View style={{ color: '#fff' }} onClick={tapShow}>{props.isNight ? '显示当地夜晚时间' : '显示当地白天时间'}</View>
         }
         {
             user.isLogin && !dayStore.showDayRing && <View style={{ color: '#fff' }} onClick={auth}>{props.isNight ? '显示当地夜晚时间' : '显示当地白天时间'}</View>
         }
-        {/* {
-            user.isLogin && dayStore.showDayRing && <Map className='myMap' latitude={80} longitude={80}/>
-        } */}
         {
-            user.isLogin && dayStore.showDayRing && <View style={{ display: 'flex', flexDirection: 'column',zIndex:1 }} onClick={showLocationAlert} onLongPress={longClick}>
+            user.isLogin && dayStore.showDayRing && <View style={{ display: 'flex', flexDirection: 'column', zIndex: 1 }} onClick={showLocationAlert} onLongPress={longClick}>
 
                 <View style={{
-                    display: 'flex', flexDirection: 'row',
-                    alignItems: 'center', justifyContent: 'space-between',
-                    // paddingRight: 14,
-                    marginRight: rpxToPx(8)
+                    marginLeft: rpxToPx(-40),
+                    marginRight: rpxToPx(-40),
+                    marginTop: rpxToPx(-40),
+                    padding: rpxToPx(48),
+                    paddingBottom: 0
                 }}>
-                    <View style={{ display: 'flex', flexDirection: 'column' }}>
-                        <View style={{
-                            marginLeft: rpxToPx(-40),
-                            paddingLeft: rpxToPx(48),
-                        }}>
-                            <View className='sunrise_item' style={{
-                                marginLeft: -6,
-                                paddingLeft: 14,
-                            }}>
-                                <View className='sunicon_bg' style={{
-                                    display: 'flex', flexDirection: 'column',
-                                    marginLeft: 0,
-                                    marginRight: rpxToPx(68)
-                                }}>
-                                    <View className='content_icon_bg' style={{ width: bigRingRadius * 2 + ringWidth }}>
-                                        <Image className='sunicon' src={props.isNight ? require('@assets/images/sunset.png') :
-                                            require('@assets/images/sunrise.png')} />
-                                    </View>
-                                </View>
-                                <View style={{ display: 'flex', flexDirection: 'column',  flexShrink: 0 }}>
-                                    <Text className='duration_title2'>{props.isNight ? '日落' : '日出'}</Text>
-                                    <Text className='duration_value22' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? getSunsetTime() : getSunriseTime()}</Text>
 
-                                </View>
-                            </View>
-                        </View>
+                    <View style={{
+                        display: 'flex',
+                        flexDirection: 'row',
+                        marginTop: 0,
+                        marginBottom: 0,
+                        padding: 0,
+                        alignItems: 'center'
+                    }}>
+                        {
+                            props.isNight ? nightRing() : dayRing()
+                        }
+                        <View style={{ display: 'flex', flexDirection: 'column', flexShrink: 0, flex: 1, marginLeft: rpxToPx(52) }}>
+                            <Text className='duration_title2'>{props.isNight ? t('feature.common.overnight') : t('feature.common.day')}</Text>
+                            <Text className='duration_value22' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? getSunsetDuration() : getSunriseTime()}</Text>
+                            <Text className='duration_title2' style={{ marginTop: 4 }}>{!props.isNight ? t('feature.common.overnight') : t('feature.common.day')}</Text>
+                            <Text className='duration_value22' style={{ color: !props.isNight ? ColorType.night : ColorType.day }}>{!props.isNight ? getSunsetTime() : getSunriseTime()}</Text>
 
-                        <View style={{
-                            marginLeft: rpxToPx(-40),
-                            paddingLeft: rpxToPx(48),
-                            marginTop: rpxToPx(20)
-                        }}>
-                            <View className='sunrise_item' style={{
-                                marginLeft: -6,
-                                paddingLeft: 14,
-                            }}>
-                                <View className='sunicon_bg' style={{
-                                    display: 'flex', flexDirection: 'column',
-                                    marginLeft: 0,
-                                    marginRight: rpxToPx(68)
-                                }}>
-                                    <View className='content_icon_bg' style={{ width: bigRingRadius * 2 + ringWidth }}>
-                                        <Image className='sunicon' src={!props.isNight ? require('@assets/images/sunset.png') :
-                                            require('@assets/images/sunrise.png')} />
-                                    </View>
+                        </View>
+                        {/* <Image className="arrow2" src={require('@/assets/images/arrow3.png')} /> */}
+                        <View style={{position:'absolute',right:-rpxToPx(20),bottom:-rpxToPx(20)}}>
+                        {
+                            authInfo && authInfo.lat ?
+                                <View style={{ display: 'flex', flexDirection: 'row' }} onClick={operate}>
+                                    <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'}>{getLocation()}</View>
                                 </View>
-                                <View style={{ display: 'flex', flexDirection: 'column', flexShrink: 0 }}>
-                                    <Text className='duration_title2'>{!props.isNight ? '日落' : '日出'}</Text>
-                                    <Text className='duration_value22' style={{ color: !props.isNight ? ColorType.night : ColorType.day }}>{!props.isNight ? getSunsetTime() : getSunriseTime()}</Text>
-
+                                :
+                                <View style={{ display: 'flex', flexDirection: 'row' }} onClick={operate}>
+                                    <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'} >
+                                        {props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')}
+                                    </View>
                                 </View>
-                            </View>
+                        }
                         </View>
                     </View>
-                    <Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
                 </View>
-                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginTop: rpxToPx(36) }}>
+                {/* <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginTop: rpxToPx(36) }}>
 
                     {
                         authInfo && authInfo.lat ?
@@ -1044,7 +1145,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
                                 </View>
                             </View>
                     }
-                </View>
+                </View> */}
             </View>
         }
         {
@@ -1055,108 +1156,4 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         }
     </View>
     </Box>
-
-
-    /*
-        return <View style={{ color: '#fff' }} onLongPress={longClick}>
-            <Box onClick={tapCard}>
-                <View style={{ marginTop: -rpxToPx(14), marginBottom: -rpxToPx(14) }}>
-                    <View className='day_night_top'>
-                        {
-                            user.isLogin ? <Text className='day_night_title'>{props.isNight ? t('feature.day_night.night_ring_login') : t('feature.day_night.day_ring_login')}</Text> :
-                                <Text className='day_night_title'>{props.isNight ? t('feature.day_night.night_ring') : t('feature.day_night.day_ring')}</Text>
-                        }
-    
-                        {
-                            user.isLogin && <View className='free' style={{ backgroundColor: props.isNight ? ColorType.night : ColorType.day, color: props.isNight ? '#fff' : '#1C1C1C' }}>{t('feature.day_night.limited_free')}</View>
-                        }
-    
-                        <View style={{ flex: 1 }} />
-                        <View style={{ height: rpxToPx(50), display: 'flex', alignItems: 'center', flexDirection: 'row' }}>
-                            <Switch checked={props.isNight ? dayStore.showDayRing : dayStore.showDayRing}
-                                className='switch'
-                                color={props.isNight ? ColorType.night : ColorType.day}
-                                onClick={(e) => { e.stopPropagation() }}
-                                onChange={(e) => {
-                                    if (process.env.TARO_ENV == 'weapp') {
-                                        e.stopPropagation()
-                                    }
-    
-                                    dispatch(showNight(e.detail.value))
-      
-                                    dispatch(showDay(e.detail.value))
-    
-    
-                                    Taro.setStorage({
-                                        key: 'showNightRing',
-                                        data: e.detail.value
-                                    })
-                                    Taro.setStorage({
-                                        key: 'showDayRing',
-                                        data: e.detail.value
-                                    })
-    
-    
-                                    if (user.isLogin) {
-                                        uploadPerm({ show_ring: e.detail.value })
-                                    }
-                                    else {
-    
-                                        if (e.detail.value) {
-                                            setTimeout(() => {
-                                                Taro.showModal({
-                                                    title: props.isNight ?
-                                                        t('feature.day_night.night_alert_title') :
-                                                        t('feature.day_night.day_alert_title'),
-                                                    content: props.isNight ?
-                                                        t('feature.day_night.night_alert_content') :
-                                                        t('feature.day_night.day_alert_content'),
-                                                    showCancel: false,
-                                                    confirmText: t('feature.day_night.got_it')
-                                                })
-                                            }, 500)
-                                        }
-    
-                                    }
-    
-    
-                                }}
-                            />
-                        </View>
-                    </View>
-                    {
-                        user.isLogin && dayStore.showDayRing && <View className='day_night_detail' onClick={showLocationAlert}>
-                            <View className='day_night_detail_icon'>
-                                {
-                                    props.isNight ? <IconNight width={rpxToPx(48)} color={ColorType.night} /> : <IconDay width={rpxToPx(48)} color={ColorType.day} />
-                                }
-                            </View>
-                            <View style={{ display: 'flex', flexDirection: 'column', paddingTop: rpxToPx(8) }}>
-                                <Text className='day_night_value' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? nightDuration() : dayDuration()}</Text>
-                                <Text className='day_night_desc'>{props.isNight ? nightDurationDesc1() : dayDurationDesc1()}</Text>
-                                {
-                                    authInfo && authInfo.lat ?
-                                        <View style={{ display: 'flex', flexDirection: 'row', marginTop: rpxToPx(18) }} onClick={auth}>
-                                            <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'} onClick={auth}>{getLocation()}</View>
-                                        </View>
-                                        :
-                                        <View style={{ display: 'flex', flexDirection: 'row', marginTop: rpxToPx(18) }} onClick={auth}>
-                                            <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'} onClick={auth}>
-                                                {props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')}
-                                            </View>
-                                        </View>
-                                }
-                            </View>
-                        </View>
-                    }
-    
-                </View>
-            </Box >
-            {
-                showDetailPopup && modalContent()
-            }
-            {
-                showDetailModal && modalContent2()
-            }
-        </View >*/
 }

+ 1244 - 0
src/features/trackTimeDuration/components/DayNightCard_副本.tsx

@@ -0,0 +1,1244 @@
+import { PageContainer, Switch, Text, View, Image } from '@tarojs/components'
+import './DayNightCard.scss'
+import { ColorType } from '@/context/themes/color'
+import { useEffect, useState } from 'react'
+import Box from '@/components/layout/Box'
+import Taro, { useDidShow } from '@tarojs/taro'
+import { clearLocation, getPerm, latestLocation, uploadPerm } from '@/services/user'
+import { useDispatch, useSelector } from 'react-redux'
+import { useTranslation } from 'react-i18next'
+import { TimeFormatter } from '@/utils/time_format'
+import { systemLocation } from '@/services/common'
+import { setDayRingData, showDay } from '@/store/day'
+import { setNightRingData, showNight, updateMember } from '@/store/night'
+import Modal from '@/components/layout/Modal.weapp'
+import { rpxToPx } from '@/utils/tools'
+import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
+import DayNightDetailPopup from './DayNightDetailPopup'
+import { IconDay, IconInfo, IconNight } from '@/components/basic/Icons'
+import { getClocks } from '@/services/trackTimeDuration'
+import { request } from '@/services/http/request'
+import { API_USER_LOCATION } from '@/services/http/api'
+import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
+import Rings from "./Rings";
+import { bigRingRadius, getBgRing, getCommon, getDot, ringWidth } from '../hooks/RingData'
+
+let useNavigation;
+if (process.env.TARO_ENV == 'rn') {
+    useNavigation = require("@react-navigation/native").useNavigation
+}
+
+let locationDetail;
+
+let sunriseA = new Date()
+sunriseA.setHours(6)
+sunriseA.setMinutes(0)
+sunriseA.setSeconds(0)
+sunriseA.setMilliseconds(0)
+const sunsetA = new Date()
+sunsetA.setHours(18)
+sunsetA.setMinutes(0)
+sunsetA.setSeconds(0)
+sunsetA.setMilliseconds(0)
+
+const sunriseB = new Date()
+sunriseB.setHours(6)
+sunriseB.setMinutes(0)
+sunriseB.setSeconds(0)
+sunriseB.setMilliseconds(0)
+
+let lastDayInfo: any = null;
+let lastNightInfo: any = null;
+let joingMember = false
+export default function DayNightCard(props: { isNight: boolean, count: number }) {
+    const user = useSelector((state: any) => state.user);
+    const dayStore = useSelector((state: any) => state.day);
+    const nightStore = useSelector((state: any) => state.night);
+    const [authInfo, setAuthInfo] = useState(global.locationDetail ? global.locationDetail : null)
+    const [sunriseTime, setSunriseTime] = useState('06:00')
+    const [sunriseTmrTime, setSunriseTmrTime] = useState('06:00')
+    const [sunsetTime, setSunsetTime] = useState('18:00')
+
+    const [sunriseDate, setSunriseDate] = useState<any>(sunriseA)
+    const [sunriseTmrDate, setSunriseTmrDate] = useState<any>(new Date(sunriseB.getTime() + 24 * 3600 * 1000))
+    const [sunsetDate, setSunsetDate] = useState<any>(sunsetA)
+
+
+    const [showDetailModal, setShowDetailModal] = useState(false)
+    const [showDetailPopup, setShowDetailPopup] = useState(false)
+    // const [locationDetail, setLocationDetail] = useState(null)
+
+    const [nightDate, setNightDate] = useState(new Date())
+    const [dayDate, setDayDate] = useState(new Date())
+    const dispatch = useDispatch();
+    const { t } = useTranslation()
+    const isMember = true;
+    let navigation;
+    if (useNavigation) {
+        navigation = useNavigation()
+    }
+
+    useEffect(() => {
+
+
+        if (user.isLogin) {
+            if (global.locationDetail) {
+                locationDetail = global.locationDetail
+                setAuthInfo(locationDetail)
+            }
+
+            var today = new Date()
+            var yesterday = new Date(today.getTime() - 24 * 3600 * 1000)
+            var tomorrow = new Date(today.getTime() + 24 * 3600 * 1000 * 3)
+            var strYesterday = `${yesterday.getFullYear()}-${TimeFormatter.padZero(yesterday.getMonth() + 1)}-${TimeFormatter.padZero(yesterday.getDate())}`
+            var strTomorrow = `${tomorrow.getFullYear()}-${TimeFormatter.padZero(tomorrow.getMonth() + 1)}-${TimeFormatter.padZero(tomorrow.getDate())}`
+            latestLocation({
+                date_start: strYesterday, date_end: strTomorrow
+            }).then(data => {
+                console.log(data)
+                setAuthInfo(data as any)
+                updateDate(data)
+                locationDetail = data
+                global.locationDetail = locationDetail
+                Taro.setStorage({
+                    key: 'gps',
+                    data: JSON.stringify(data as any)
+                })
+            })
+
+        } else {
+            setSunriseTime('06:00');
+            setSunriseTmrTime('06:00')
+            setSunsetTime('18:00')
+            setSunriseDate(sunriseA)
+            setSunriseTmrDate(new Date(sunriseB.getTime() + 24 * 3600 * 1000))
+            setSunsetDate(sunsetA)
+        }
+    }, [user.isLogin])
+
+    useEffect(() => {
+        locationDetail = global.locationDetail
+        setAuthInfo(locationDetail)
+    }, [global.locationDetail])
+
+    useEffect(() => {
+        if (locationDetail)
+            updateDate(locationDetail)
+        if (props.isNight) {
+            global.clearNightLocation = () => {
+                clearCacheData()
+            }
+        }
+        else {
+            global.clearDayLocation = () => {
+                clearCacheData()
+            }
+        }
+    }, [])
+
+    useEffect(() => {
+        if (locationDetail) {
+            var detail: any = locationDetail
+            var now = new Date()
+            if (now.getHours() == 0 && now.getMinutes() == 0 && now.getSeconds() == 0) {
+                detail.daylights.splice(0, 1)
+            }
+            locationDetail = detail
+
+            // setLocationDetail(detail)
+            updateDate(detail)
+        }
+    }, [props.count])
+
+    useEffect(() => {
+        // if (user.test_user && joingMember) {
+        //     auth()
+        // }
+        if (!isMember) {
+            lastNightInfo = null
+            lastDayInfo = null
+            locationDetail = null
+            setAuthInfo(null)
+            setSunriseTime('06:00')
+            setSunriseTmrTime('06:00')
+            setSunsetTime('18:00')
+            dispatch(updateMember({ isMember: isMember, gpsInfo: null }))
+
+
+            dispatch(setDayRingData({
+                date: new Date().getTime(),
+                sunrise: '06:00',
+                sunset: '18:00'
+            }))
+            dispatch(setNightRingData({
+                date: new Date().getTime(),
+                sunrise: '06:00',
+                sunset: '18:00'
+            }))
+        }
+        else {
+            getGPSCache()
+        }
+    }, [user.test_user])
+
+    useDidShow(() => {
+        if (!user.isLogin) {
+            dispatch(showNight(false))
+            dispatch(showDay(false))
+            Taro.setStorage({
+                key: 'showNightRing',
+                data: false
+            })
+            Taro.setStorage({
+                key: 'showDayRing',
+                data: false
+            })
+        }
+    })
+
+    async function getGPSCache() {
+        var gps = await getStorage('gps')
+        if (gps && gps.length > 0) {
+            locationDetail = JSON.parse(gps)
+            global.locationDetail = JSON.parse(gps)
+        }
+    }
+
+    async function getStorage(key: string) {
+        try {
+            const res = await Taro.getStorage({ key });
+            return res.data;
+        } catch {
+            return '';
+        }
+    }
+
+    function updateDate(data) {
+
+        var today = new Date()
+        // var yesterday = new Date(today.getTime() - 24 * 3600 * 1000)
+        var tomorrow = new Date(today.getTime() + 24 * 3600 * 1000)
+        // var strYesterday = `${yesterday.getFullYear()}-${TimeFormatter.padZero(yesterday.getMonth() + 1)}-${TimeFormatter.padZero(yesterday.getDate())}`
+        // var strTomorrow = `${tomorrow.getFullYear()}-${TimeFormatter.padZero(tomorrow.getMonth() + 1)}-${TimeFormatter.padZero(tomorrow.getDate())}`
+        if (isMember && data && data.daylights && data.daylights.length > 0) {
+            var yesterdayDate = new Date(data.daylights[0].date + 'T' + data.daylights[0].sunset)
+            var todaySunriseDate = new Date(data.daylights[1].date + 'T' + data.daylights[1].sunrise)
+            var todaySunsetDate = new Date(data.daylights[1].date + 'T' + data.daylights[1].sunset)
+            var tomorrowSunriseDate = new Date(data.daylights[2].date + 'T' + data.daylights[2].sunrise)
+            var tomorrowSunsetDate = new Date(data.daylights[2].date + 'T' + data.daylights[2].sunset)
+
+            // var tomorrowSunsetDate = new Date(data.daylights[2].date + 'T' + data.daylights[2].sunset)
+            //今天凌晨日出前
+            if (yesterdayDate.getTime() < today.getTime() && today.getTime() < todaySunriseDate.getTime()) {
+                setNightDate(yesterdayDate)
+                setDayDate(today)
+                if (props.isNight) {
+                    setSunsetTime(data.daylights[0].sunset)
+                    setSunriseTmrTime(data.daylights[1].sunrise)
+                    setSunsetDate(yesterdayDate)
+                    setSunriseTmrDate(todaySunriseDate)
+
+                }
+                else {
+                    setSunriseTime(data.daylights[1].sunrise)
+                    setSunsetTime(data.daylights[1].sunset)
+                    setSunriseDate(todaySunriseDate)
+                    setSunsetDate(todaySunsetDate)
+                }
+                updateNightStore(yesterdayDate, data.daylights[1].sunrise, data.daylights[0].sunset)
+                updateDayStore(today, data.daylights[1].sunrise, data.daylights[1].sunset)
+            }
+            //今天白天(今天出日后-日落前)
+            else if (todaySunriseDate.getTime() < today.getTime() && today.getTime() < todaySunsetDate.getTime()) {
+                setNightDate(todaySunsetDate)
+                setDayDate(todaySunriseDate)
+                if (props.isNight) {
+                    setSunsetTime(data.daylights[1].sunset)
+                    setSunriseTmrTime(data.daylights[2].sunrise)
+                    setSunsetDate(todaySunsetDate)
+                    setSunriseTmrDate(tomorrowSunriseDate)
+                }
+                else {
+                    setSunriseTime(data.daylights[1].sunrise)
+                    setSunsetTime(data.daylights[1].sunset)
+                    setSunsetDate(todaySunsetDate)
+                    setSunriseDate(todaySunriseDate)
+                }
+                updateNightStore(today, data.daylights[2].sunrise, data.daylights[1].sunset)
+                updateDayStore(today, data.daylights[1].sunrise, data.daylights[1].sunset)
+            }
+            //今天夜晚
+            else if (today.getTime() > todaySunsetDate.getTime() && today.getTime() < tomorrowSunriseDate.getTime()) {
+                setNightDate(todaySunsetDate)
+                setDayDate(tomorrowSunriseDate)
+                if (props.isNight) {
+                    setSunsetTime(data.daylights[1].sunset)
+                    setSunriseTmrTime(data.daylights[2].sunrise)
+                    setSunsetDate(todaySunsetDate)
+                    setSunriseTmrDate(tomorrowSunriseDate)
+                }
+                else {
+                    setSunriseTime(data.daylights[2].sunrise)
+                    setSunsetTime(data.daylights[2].sunset)
+                    setSunriseDate(tomorrowSunriseDate)
+                    setSunsetDate(tomorrowSunsetDate)
+                }
+                updateNightStore(today, data.daylights[2].sunrise, data.daylights[1].sunset)
+                updateDayStore(tomorrowSunriseDate, data.daylights[2].sunrise, data.daylights[2].sunset)
+            }
+        }
+        else {
+            locationDetail = null
+            setAuthInfo(null)
+            setSunriseTime('06:00')
+            setSunriseTmrTime('06:00')
+            setSunsetTime('18:00')
+            dispatch(updateMember({ isMember: isMember, gpsInfo: null }))
+
+
+            dispatch(setDayRingData({
+                date: new Date().getTime(),
+                sunrise: '06:00',
+                sunset: '18:00'
+            }))
+            dispatch(setNightRingData({
+                date: new Date().getTime(),
+                sunrise: '06:00',
+                sunset: '18:00'
+            }))
+        }
+
+    }
+
+    function updateNightStore(date, sunrise, sunset) {
+        if (lastNightInfo && lastNightInfo.date.getDate() == new Date(date).getDate() &&
+            lastNightInfo.sunrise == sunrise &&
+            lastNightInfo.sunset == sunset
+        ) {
+            return
+        }
+        lastNightInfo = {
+            date,
+            sunrise,
+            sunset
+        }
+        dispatch(setNightRingData({
+            date: date.getTime(),
+            sunrise: sunrise,
+            sunset: sunset
+        }))
+    }
+
+    function updateDayStore(date, sunrise, sunset) {
+        if (lastDayInfo && lastDayInfo.date.getDate() == new Date(date).getDate() &&
+            lastDayInfo.sunrise == sunrise &&
+            lastDayInfo.sunset == sunset
+        ) {
+            return
+        }
+        lastDayInfo = {
+            date,
+            sunrise,
+            sunset
+        }
+        dispatch(setDayRingData({
+            date: date.getTime(),
+            sunrise: sunrise,
+            sunset: sunset
+        }))
+    }
+
+    function tapCard(e) {
+        // if (process.env.TARO_ENV == 'weapp') {
+        //     e.stopPropagation()
+        // }
+        if (!user.isLogin) {
+            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+            return
+        }
+        if (!dayStore.showDayRing) {
+            return
+        }
+        setShowDetailPopup(true)
+    }
+
+    function auth(e?: any) {
+        if (e && process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
+        var today = new Date()
+        var yesterday = new Date(today.getTime() - 24 * 3600 * 1000)
+        var tomorrow = new Date(today.getTime() + 24 * 3600 * 1000 * 3)
+        var strYesterday = `${yesterday.getFullYear()}-${TimeFormatter.padZero(yesterday.getMonth() + 1)}-${TimeFormatter.padZero(yesterday.getDate())}`
+        var strTomorrow = `${tomorrow.getFullYear()}-${TimeFormatter.padZero(tomorrow.getMonth() + 1)}-${TimeFormatter.padZero(tomorrow.getDate())}`
+        // systemLocation({
+        //     lat: 77,
+        //     lng: 20,
+        //     date_start: strYesterday,
+        //     date_end: strTomorrow,
+        //     coordinate_system_standard: 'GCJ-02'
+        // }).then(data => {
+        // })
+        // return
+
+        if (process.env.TARO_ENV == 'rn') {
+            Taro.getLocation({
+                success(res) {
+                    systemLocation({
+                        lat: res.latitude,
+                        lng: res.longitude,
+                        // name: 'app test',
+                        // address: 'app test',
+                        date_start: strYesterday,
+                        date_end: strTomorrow,
+                        // coordinate_system_standard: 'GCJ-02'
+                    }).then(data => {
+                        console.log('get Location', data)
+                        updateDate(data);
+                        locationDetail = data;
+                        global.locationDetail = locationDetail
+                        setAuthInfo(data as any)
+                        setSunriseTime((data as any).daylights[0].sunrise)
+                        setSunriseTmrTime((data as any).daylights[1].sunrise)
+                        setSunsetTime((data as any).daylights[0].sunset)
+                        Taro.setStorage({
+                            key: 'gps',
+                            data: JSON.stringify(data as any)
+                        })
+                        dispatch(updateMember({ isMember: isMember, gpsInfo: (data as any) }))
+                        showRing()
+                    })
+                },
+                fail(res) {
+                    if (res.errMsg == 'Permissions denied!') {
+                        alert('aaa')
+                    }
+                    console.log(res)
+                    showRing()
+                },
+                complete(res) {
+
+                }
+            })
+            return
+        }
+        joingMember = false;
+        Taro.chooseLocation({
+            latitude: authInfo && authInfo.lat ? authInfo.lat : undefined,
+            longitude: authInfo && authInfo.lat ? authInfo.lng : undefined,
+            success: function (res) {
+
+                systemLocation({
+                    lat: res.latitude,
+                    lng: res.longitude,
+                    name: res.name,
+                    address: res.address,
+                    date_start: strYesterday,
+                    date_end: strTomorrow,
+                    coordinate_system_standard: 'GCJ-02'
+                }).then(data => {
+                    updateDate(data);
+                    locationDetail = data;
+                    global.locationDetail = locationDetail
+                    setAuthInfo(data as any)
+                    setSunriseTime((data as any).daylights[0].sunrise)
+                    setSunriseTmrTime((data as any).daylights[1].sunrise)
+                    setSunsetTime((data as any).daylights[0].sunset)
+                    Taro.setStorage({
+                        key: 'gps',
+                        data: JSON.stringify(data as any)
+                    })
+                    showRing()
+                    dispatch(updateMember({ isMember: isMember, gpsInfo: (data as any) }))
+                })
+
+            },
+            fail(res) {
+                Taro.showToast({
+                    title: '位置修改失败!\n请重新选择就近位置',
+                    icon: 'none'
+                })
+                showRing()
+            },
+            complete(res) {
+
+            }
+        })
+
+    }
+
+    function showRing() {
+        dispatch(showNight(true))
+        dispatch(showDay(true))
+        Taro.setStorage({
+            key: 'showNightRing',
+            data: true
+        })
+        Taro.setStorage({
+            key: 'showDayRing',
+            data: true
+        })
+    }
+
+    function getLocation() {
+        var city = ''
+        if ((authInfo as any).address) {
+            if ((authInfo as any).address.city.length > 0) {
+                city = (authInfo as any).address.city
+            }
+            else if ((authInfo as any).address.province.length > 0) {
+                city = (authInfo as any).address.province
+            }
+            else if ((authInfo as any).address.country.length > 0) {
+                city = (authInfo as any).address.country
+            }
+            else {
+                city = t('feature.track_time_duration.third_ring.unknown')
+            }
+        }
+        else {
+            city = t('feature.track_time_duration.third_ring.unknown')
+        }
+        // return city +' | '+parseInt(authInfo.lat)+'°'+ ' '+parseInt(authInfo.lng)
+        return `${city} | ${Math.abs(parseInt(authInfo.lat))}°${parseInt(authInfo.lat) < 0 ? 'S' : 'N'} ${Math.abs(parseInt(authInfo.lng))}°${parseInt(authInfo.lng) < 0 ? 'W' : 'E'}`
+    }
+
+    function clearData() {
+        Taro.showModal({
+            title: '提示',
+            content: '确认清除位置数据?',
+            success: function (res) {
+                if (res.confirm) {
+                    clearLocation().then(res => {
+                        if (global.clearNightLocation) {
+                            global.clearNightLocation()
+                        }
+                        if (global.clearDayLocation) {
+                            global.clearDayLocation()
+                        }
+                        lastNightInfo = null
+                        lastDayInfo = null
+                    })
+                } else if (res.cancel) {
+                    console.log('用户点击取消')
+                }
+            }
+        })
+    }
+
+
+
+
+
+    function clearCacheData() {
+        locationDetail = null
+        Taro.removeStorage({ key: 'gps' })
+        setAuthInfo(null)
+        setSunriseTime('06:00')
+        setSunriseTmrTime('06:00')
+        setSunsetTime('18:00')
+        dispatch(updateMember({ isMember: isMember, gpsInfo: null }))
+
+
+        dispatch(setDayRingData({
+            date: new Date().getTime(),
+            sunrise: '06:00',
+            sunset: '18:00'
+        }))
+        dispatch(setNightRingData({
+            date: new Date().getTime(),
+            sunrise: '06:00',
+            sunset: '18:00'
+        }))
+    }
+
+    function detailModalContent() {
+        var split = new Date().toString().split(' ');
+        var timezone = split[split.length - 2];
+        if (!authInfo || !(authInfo as any).lat) {
+            return <View style={{ height: 100, display: 'flex', alignItems: 'center', justifyContent: 'center', width: rpxToPx(750) }}>
+                <Text>暂无位置信息</Text>
+            </View>
+        }
+        return <View style={{ display: 'flex', flexDirection: 'column' }}>
+            {
+                <View className="cell_bg">
+                    {
+                        <View className="cell_full">
+                            <Text className="cell_title">{t('feature.track_time_duration.third_ring.location')}</Text>
+                            <Text className="cell_value">{authInfo ? getLocation() : t('feature.track_time_duration.third_ring.enter')}</Text>
+                        </View>
+                    }
+                    <View className="cell_line" style={{ height: 1 }} />
+
+
+                    {
+                        <View className="cell_full" >
+                            <Text className="cell_title">{t('feature.track_time_duration.third_ring.latitude')}</Text>
+
+                            <Text className="cell_value">{(authInfo as any).lat}</Text>
+
+
+                        </View>
+                    }
+                    <View className="cell_line" style={{ height: 1 }} />
+
+                    <View className="cell_full">
+                        <Text className="cell_title" >{t('feature.track_time_duration.third_ring.longitude')}</Text>
+
+                        <Text className="cell_value">{(authInfo as any).lng}</Text>
+
+                    </View>
+                    <View className="cell_line" style={{ height: 1 }} />
+                    <View className="cell_full">
+                        <Text className="cell_title">{t('feature.track_time_duration.third_ring.timezone')}</Text>
+
+                        <Text className="cell_value">{timezone}</Text>
+
+                    </View>
+
+
+
+                </View>
+
+            }
+
+            <Text onClick={() => {
+                clearData()
+                setShowDetailModal(false)
+            }} style={{ width: '100%', textAlign: 'center', marginBottom: 50, color: '#fff', marginTop: 20 }}>清除位置</Text>
+        </View>
+    }
+
+    function modalContent2() {
+        if (process.env.TARO_ENV == 'weapp') {
+            return <Modal
+                testInfo={null}
+                dismiss={() => {
+                    setShowDetailModal(false)
+                }}
+                confirm={() => { }}>
+                {
+                    detailModalContent()
+                }
+            </Modal>
+        }
+        else if (process.env.TARO_ENV == 'rn') {
+            return <PageContainer style={{ backgroundColor: '#1c1c1c' }}
+                // overlayStyle='background-color:rgba(0,0,0,0.9)'
+                // custom-style='background-color:#1c1c1c'
+                overlayStyle={{ backgroundColor: 'rgba(0,0,0,0.9)' }}
+                customStyle={{ backgroundColor: '#1c1c1c' }}
+                closeOnSlideDown={false}
+                onBeforeEnter={() => {
+
+                }}
+                onBeforeLeave={() => {
+                }}
+                onClick={() => { alert('b') }}
+                onClickOverlay={() => { alert('a') }}
+                onAfterLeave={() => { setShowDetailModal(false) }}
+                show={showDetailModal} round={true} overlay={true} position='bottom'
+            >
+                {
+                    detailModalContent()
+                }
+            </PageContainer>
+        }
+    }
+
+    function modalContent() {
+        if (process.env.TARO_ENV == 'weapp') {
+            return <Modal
+                testInfo={null}
+                dismiss={() => {
+                    setShowDetailPopup(false)
+                }}
+                confirm={() => { }}>
+                <DayNightDetailPopup
+                    sunsetDate={sunsetDate}
+                    sunriseDate={sunriseDate}
+                    sunriseTmrDate={sunriseTmrDate}
+                    sunsetTime={sunsetTime}
+                    sunriseTime={sunriseTime}
+                    sunriseTmrTime={sunriseTmrTime}
+                    isNight={props.isNight}
+                    authInfo={authInfo}
+                    nightDate={nightDate}
+                    dayDate={dayDate}
+                    onClose={() => { setShowDetailPopup(false) }}
+                />
+            </Modal>
+        }
+        else if (process.env.TARO_ENV == 'rn') {
+            return <PageContainer style={{ backgroundColor: '#1c1c1c' }}
+                // overlayStyle='background-color:rgba(0,0,0,0.9)'
+                // custom-style='background-color:#1c1c1c'
+                overlayStyle={{ backgroundColor: 'rgba(0,0,0,0.9)' }}
+                customStyle={{ backgroundColor: '#1c1c1c' }}
+                closeOnSlideDown={false}
+                onBeforeEnter={() => {
+
+                }}
+                onBeforeLeave={() => {
+                }}
+                onClick={() => { alert('b') }}
+                onClickOverlay={() => { alert('a') }}
+                onAfterLeave={() => { setShowDetailPopup(false) }}
+                show={showDetailModal} round={true} overlay={true} position='bottom'
+            >
+                <DayNightDetailPopup
+                    sunsetDate={sunsetDate}
+                    sunriseDate={sunriseDate}
+                    sunriseTmrDate={sunriseTmrDate}
+                    sunsetTime={sunsetTime}
+                    sunriseTime={sunriseTime}
+                    sunriseTmrTime={sunriseTmrTime}
+                    isNight={props.isNight}
+                    authInfo={authInfo}
+                    nightDate={nightDate}
+                    dayDate={dayDate}
+                    onClose={() => { setShowDetailPopup(false) }}
+                />
+            </PageContainer>
+        }
+    }
+
+    function nightDuration() {
+        if (!authInfo || !(authInfo as any).lat) {
+            if (new Date().getHours() >= 6) {
+                return `${t('feature.day_night.tonight')} ${sunsetTime} - ${t('feature.day_night.tomorrow_morning')} ${sunriseTmrTime}`
+            }
+            return `${t('feature.day_night.last_night')} ${sunsetTime} - ${t('feature.day_night.this_morning')} ${sunriseTmrTime}`
+            // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+        }
+        if (nightDate.getDate() == new Date().getDate()) {
+            return `${t('feature.day_night.tonight')} ${sunsetTime.substring(0, 5)} - ${t('feature.day_night.tomorrow_morning')} ${sunriseTmrTime.substring(0, 5)}`
+        }
+        return `${t('feature.day_night.last_night')} ${sunsetTime.substring(0, 5)} - ${t('feature.day_night.this_morning')} ${sunriseTmrTime.substring(0, 5)}`
+        //`Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+    }
+
+    function getSunsetTime() {
+        if (props.isNight) {
+            if (!authInfo || !(authInfo as any).lat) {
+                if (new Date().getHours() >= 6) {
+                    return `${sunsetTime}`
+                }
+                return `${sunsetTime}`
+                // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+            }
+            if (nightDate.getDate() == new Date().getDate()) {
+                return `${sunsetTime.substring(0, 5)}`
+            }
+            return `${sunsetTime.substring(0, 5)}`
+        }
+        if (!authInfo || !(authInfo as any).lat) {
+            if (new Date().getHours() >= 18) {
+                return `${sunriseTime}`
+
+                // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
+            }
+            return `${sunriseTime}`
+            // return `Today ${sunriseTime} - ${sunsetTime}`
+        }
+        if (dayDate.getDate() == new Date().getDate()) {
+            return `${sunriseTime.substring(0, 5)}`
+            // return `Today ${sunriseTime} - ${sunsetTime}`
+        }
+        return `${sunriseTime.substring(0, 5)}`
+    }
+
+    function getSunriseTime() {
+        if (props.isNight) {
+            if (!authInfo || !(authInfo as any).lat) {
+                if (new Date().getHours() >= 6) {
+                    return `${sunriseTmrTime}`
+                }
+                return `${sunriseTmrTime}`
+                // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+            }
+            if (nightDate.getDate() == new Date().getDate()) {
+                return `${sunriseTmrTime.substring(0, 5)}`
+            }
+            return `${sunriseTmrTime.substring(0, 5)}`
+        }
+        if (!authInfo || !(authInfo as any).lat) {
+            if (new Date().getHours() >= 18) {
+                return `${sunsetTime}`
+
+                // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
+            }
+            return `${sunsetTime}`
+            // return `Today ${sunriseTime} - ${sunsetTime}`
+        }
+        if (dayDate.getDate() == new Date().getDate()) {
+            return `${sunsetTime.substring(0, 5)}`
+            // return `Today ${sunriseTime} - ${sunsetTime}`
+        }
+        return `${sunsetTime.substring(0, 5)}`
+    }
+
+    function dayDuration() {
+        if (!authInfo || !(authInfo as any).lat) {
+            if (new Date().getHours() >= 18) {
+                return `${t('feature.day_night.tomorrow')} ${sunriseTime} - ${sunsetTime}`
+
+                // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
+            }
+            return `${t('feature.day_night.today')} ${sunriseTime} - ${sunsetTime}`
+            // return `Today ${sunriseTime} - ${sunsetTime}`
+        }
+        if (dayDate.getDate() == new Date().getDate()) {
+            return `${t('feature.day_night.today')} ${sunriseTime.substring(0, 5)} - ${sunsetTime.substring(0, 5)}`
+            // return `Today ${sunriseTime} - ${sunsetTime}`
+        }
+        return `${t('feature.day_night.tomorrow')} ${sunriseTime.substring(0, 5)} - ${sunsetTime.substring(0, 5)}`
+        // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
+    }
+
+    function nightDurationDesc1() {
+        if (authInfo && authInfo.lat) {
+            return t('feature.day_night.sunset_to_sunrise')
+        }
+        return t('feature.day_night.night_tip')
+    }
+
+    function dayDurationDesc1() {
+        if (authInfo && authInfo.lat) {
+            return t('feature.day_night.sunrise_to_sunset')
+        }
+        return t('feature.day_night.day_tip')
+    }
+
+    function longClick() {
+        if (user.isLogin && user.test_user && authInfo)
+            setShowDetailModal(true)
+    }
+
+    function showLocationAlert(e) {
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
+        if (isMember && authInfo && authInfo.lat) {
+            tapCard(e)
+            return
+        }
+        Taro.showModal({
+            title: props.isNight ? t('feature.day_night.alert_required_night') : t('feature.day_night.alert_required_day'),
+            content: props.isNight ? t('feature.day_night.alert_night_content') : t('feature.day_night.alert_day_content'),
+            confirmText: t('feature.day_night.choose_location'),
+            cancelText: t('feature.day_night.view_more'),
+            success: function (res) {
+                if (res.confirm) {
+                    auth()
+                    // console.log('用户点击确定')
+                } else if (res.cancel) {
+                    setShowDetailPopup(true)
+                }
+            }
+        })
+    }
+
+    function tapShow() {
+        dispatch(showNight(true))
+        dispatch(showDay(true))
+        Taro.showModal({
+            title: 'Login Required',
+            content: props.isNight ? 'Log in to see your daily local nighttime from sunset to sunrise.' : 'Log in to see your daily local daytime from sunrise to sunset.',
+            cancelText: 'Later',
+            confirmText: 'Login',
+            success: function (res) {
+                if (res.confirm) {
+                    Taro.setStorage({
+                        key: 'showNightRing',
+                        data: true
+                    })
+                    Taro.setStorage({
+                        key: 'showDayRing',
+                        data: true
+                    })
+                    if (!user.isLogin) {
+                        jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+                        return
+                    }
+
+                } else if (res.cancel) {
+                    dispatch(showNight(false))
+                    dispatch(showDay(false))
+                    Taro.setStorage({
+                        key: 'showNightRing',
+                        data: false
+                    })
+                    Taro.setStorage({
+                        key: 'showDayRing',
+                        data: false
+                    })
+                }
+            }
+        })
+    }
+
+    function operate(e) {
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
+        Taro.showActionSheet({
+            itemList: ['选择位置', '重置'],
+            success: function (res) {
+                switch (res.tapIndex) {
+                    case 0:
+                        auth()
+                        break;
+                    case 1:
+                        reset()
+                        break;
+                }
+            },
+            fail: function (res) {
+                console.log(res.errMsg)
+            }
+        })
+    }
+
+    function reset() {
+        var content = ''
+        if (props.isNight) {
+            if (authInfo && authInfo.lat) {
+                content = 'Local times for sunset and sunrise, together with the nighttime ring will turn off, and your location data will be cleared. '
+            }
+            else {
+                content = 'Sunset and sunrise times, together with the nighttime ring will turn off.'
+            }
+        }
+        else {
+            if (authInfo && authInfo.lat) {
+                content = 'Local times for sunrise and sunset, together with the daytime ring will turn off, and your location data will be cleared. '
+            }
+            else {
+                content = 'Sunrise and sunset times, together with the daytime ring will turn off.'
+            }
+        }
+        Taro.showModal({
+            title: 'Reset Alert',
+            content: content,
+            success: function (res) {
+                if (res.confirm) {
+                    if (user.isLogin) {
+                        uploadPerm({ show_ring: false })
+                    }
+                    clearLocation().then(res => {
+                        if (global.clearNightLocation) {
+                            global.clearNightLocation()
+                        }
+                        if (global.clearDayLocation) {
+                            global.clearDayLocation()
+                        }
+                        lastNightInfo = null
+                        lastDayInfo = null
+
+                        dispatch(showNight(false))
+                        dispatch(showDay(false))
+                        Taro.setStorage({
+                            key: 'showNightRing',
+                            data: false
+                        })
+                        Taro.setStorage({
+                            key: 'showDayRing',
+                            data: false
+                        })
+                    })
+                } else if (res.cancel) {
+                    console.log('用户点击取消')
+                }
+            }
+
+        })
+
+    }
+
+    function bigRing() {
+        var common = getCommon(null, true)
+        common.radius = bigRingRadius;
+        common.lineWidth = ringWidth;
+        var bgRing = getBgRing()
+
+        let realRingBig: RealRing = {
+            color: ColorType.night + '66',
+            startArc: 0,
+            durationArc: 2
+        }
+        var sunRise = 24 * 60 + 6 * 60
+        var sunSet = 18 * 60
+
+        var sunRiseObj = nightStore.nightRingSunrise
+        var sunSetObj = nightStore.nightRingSunset
+        sunRise = 24 * 60 + parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
+        sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
+        if (sunSetObj.indexOf('PM') != -1) {
+            sunSet += 12 * 60
+        }
+        // }
+        var duration = sunRise - sunSet
+        realRingBig.startArc = (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
+        realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
+
+        var currentDot = getDot(null, false)
+        currentDot.color = ColorType.night
+
+        var now = new Date()
+        var t = now.getHours() * 60 + now.getMinutes()
+        var duration2 = t - sunSet
+        if (duration2 < 0) {
+            duration2 += 24 * 60
+        }
+        let realRing: RealRing = {
+            color: ColorType.night,
+            startArc: (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0,
+            durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
+        }
+
+        if (nightStore.nightRingDate) {
+            if (new Date(nightStore.nightRingDate).getDate() == new Date().getDate() && new Date().getHours() < 12) {
+
+                realRing = null;
+            }
+        }
+
+        if (!user.isLogin) {
+            currentDot = null;
+            realRing = null;
+        }
+
+
+        return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} realRing={duration2 > duration ? null : realRing} currentDot={currentDot} canvasId={'dddd' + 'index_day'} />
+
+    }
+
+    return <Box><View style={{ position: 'relative' }}>
+        {
+            !user.isLogin && <View style={{ color: '#fff' }} onClick={tapShow}>{props.isNight ? '显示当地夜晚时间' : '显示当地白天时间'}</View>
+        }
+        {
+            user.isLogin && !dayStore.showDayRing && <View style={{ color: '#fff' }} onClick={auth}>{props.isNight ? '显示当地夜晚时间' : '显示当地白天时间'}</View>
+        }
+        {/* {
+            user.isLogin && dayStore.showDayRing && <Map className='myMap' latitude={80} longitude={80}/>
+        } */}
+        {
+            user.isLogin && dayStore.showDayRing && <View style={{ display: 'flex', flexDirection: 'column', zIndex: 1 }} onClick={showLocationAlert} onLongPress={longClick}>
+
+                <View style={{
+                    display: 'flex', flexDirection: 'row',
+                    alignItems: 'center', justifyContent: 'space-between',
+                    // paddingRight: 14,
+                    marginRight: rpxToPx(8)
+                }}>
+                    <View style={{
+                        position: 'relative', zIndex: 1,
+                        marginLeft: 0,
+                    }}>
+                        {
+                            props.isNight && bigRing()
+                        }
+                    </View>
+                    <View style={{ display: 'flex', flexDirection: 'column', flexShrink: 0 }}>
+                        <Text className='duration_title2'>{props.isNight ? '日落' : '日出'}</Text>
+                        <Text className='duration_value22' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? getSunsetTime() : getSunriseTime()}</Text>
+                        <Text className='duration_title2'>{!props.isNight ? '日落' : '日出'}</Text>
+                        <Text className='duration_value22' style={{ color: !props.isNight ? ColorType.night : ColorType.day }}>{!props.isNight ? getSunsetTime() : getSunriseTime()}</Text>
+
+                    </View>
+                </View>
+                <View style={{
+                    display: 'flex', flexDirection: 'row',
+                    alignItems: 'center', justifyContent: 'space-between',
+                    // paddingRight: 14,
+                    marginRight: rpxToPx(8)
+                }}>
+                    <View style={{ display: 'flex', flexDirection: 'column' }}>
+                        <View style={{
+                            marginLeft: rpxToPx(-40),
+                            paddingLeft: rpxToPx(48),
+                        }}>
+                            <View className='sunrise_item' style={{
+                                marginLeft: -6,
+                                paddingLeft: 14,
+                            }}>
+                                <View className='sunicon_bg' style={{
+                                    display: 'flex', flexDirection: 'column',
+                                    marginLeft: 0,
+                                    marginRight: rpxToPx(68)
+                                }}>
+                                    <View className='content_icon_bg' style={{ width: bigRingRadius * 2 + ringWidth }}>
+                                        <Image className='sunicon' src={props.isNight ? require('@assets/images/sunset.png') :
+                                            require('@assets/images/sunrise.png')} />
+                                    </View>
+                                </View>
+                                <View style={{ display: 'flex', flexDirection: 'column', flexShrink: 0 }}>
+                                    <Text className='duration_title2'>{props.isNight ? '日落' : '日出'}</Text>
+                                    <Text className='duration_value22' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? getSunsetTime() : getSunriseTime()}</Text>
+
+                                </View>
+                            </View>
+                        </View>
+
+                        <View style={{
+                            marginLeft: rpxToPx(-40),
+                            paddingLeft: rpxToPx(48),
+                            marginTop: rpxToPx(20)
+                        }}>
+                            <View className='sunrise_item' style={{
+                                marginLeft: -6,
+                                paddingLeft: 14,
+                            }}>
+                                <View className='sunicon_bg' style={{
+                                    display: 'flex', flexDirection: 'column',
+                                    marginLeft: 0,
+                                    marginRight: rpxToPx(68)
+                                }}>
+                                    <View className='content_icon_bg' style={{ width: bigRingRadius * 2 + ringWidth }}>
+                                        <Image className='sunicon' src={!props.isNight ? require('@assets/images/sunset.png') :
+                                            require('@assets/images/sunrise.png')} />
+                                    </View>
+                                </View>
+                                <View style={{ display: 'flex', flexDirection: 'column', flexShrink: 0 }}>
+                                    <Text className='duration_title2'>{!props.isNight ? '日落' : '日出'}</Text>
+                                    <Text className='duration_value22' style={{ color: !props.isNight ? ColorType.night : ColorType.day }}>{!props.isNight ? getSunsetTime() : getSunriseTime()}</Text>
+
+                                </View>
+                            </View>
+                        </View>
+                    </View>
+                    <Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
+                </View>
+                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginTop: rpxToPx(36) }}>
+
+                    {
+                        authInfo && authInfo.lat ?
+                            <View style={{ display: 'flex', flexDirection: 'row' }} onClick={operate}>
+                                <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'}>{getLocation()}</View>
+                            </View>
+                            :
+                            <View style={{ display: 'flex', flexDirection: 'row' }} onClick={operate}>
+                                <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'} >
+                                    {props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')}
+                                </View>
+                            </View>
+                    }
+                </View>
+            </View>
+        }
+        {
+            showDetailPopup && modalContent()
+        }
+        {
+            showDetailModal && modalContent2()
+        }
+    </View>
+    </Box>
+
+
+    /*
+        return <View style={{ color: '#fff' }} onLongPress={longClick}>
+            <Box onClick={tapCard}>
+                <View style={{ marginTop: -rpxToPx(14), marginBottom: -rpxToPx(14) }}>
+                    <View className='day_night_top'>
+                        {
+                            user.isLogin ? <Text className='day_night_title'>{props.isNight ? t('feature.day_night.night_ring_login') : t('feature.day_night.day_ring_login')}</Text> :
+                                <Text className='day_night_title'>{props.isNight ? t('feature.day_night.night_ring') : t('feature.day_night.day_ring')}</Text>
+                        }
+    
+                        {
+                            user.isLogin && <View className='free' style={{ backgroundColor: props.isNight ? ColorType.night : ColorType.day, color: props.isNight ? '#fff' : '#1C1C1C' }}>{t('feature.day_night.limited_free')}</View>
+                        }
+    
+                        <View style={{ flex: 1 }} />
+                        <View style={{ height: rpxToPx(50), display: 'flex', alignItems: 'center', flexDirection: 'row' }}>
+                            <Switch checked={props.isNight ? dayStore.showDayRing : dayStore.showDayRing}
+                                className='switch'
+                                color={props.isNight ? ColorType.night : ColorType.day}
+                                onClick={(e) => { e.stopPropagation() }}
+                                onChange={(e) => {
+                                    if (process.env.TARO_ENV == 'weapp') {
+                                        e.stopPropagation()
+                                    }
+    
+                                    dispatch(showNight(e.detail.value))
+      
+                                    dispatch(showDay(e.detail.value))
+    
+    
+                                    Taro.setStorage({
+                                        key: 'showNightRing',
+                                        data: e.detail.value
+                                    })
+                                    Taro.setStorage({
+                                        key: 'showDayRing',
+                                        data: e.detail.value
+                                    })
+    
+    
+                                    if (user.isLogin) {
+                                        uploadPerm({ show_ring: e.detail.value })
+                                    }
+                                    else {
+    
+                                        if (e.detail.value) {
+                                            setTimeout(() => {
+                                                Taro.showModal({
+                                                    title: props.isNight ?
+                                                        t('feature.day_night.night_alert_title') :
+                                                        t('feature.day_night.day_alert_title'),
+                                                    content: props.isNight ?
+                                                        t('feature.day_night.night_alert_content') :
+                                                        t('feature.day_night.day_alert_content'),
+                                                    showCancel: false,
+                                                    confirmText: t('feature.day_night.got_it')
+                                                })
+                                            }, 500)
+                                        }
+    
+                                    }
+    
+    
+                                }}
+                            />
+                        </View>
+                    </View>
+                    {
+                        user.isLogin && dayStore.showDayRing && <View className='day_night_detail' onClick={showLocationAlert}>
+                            <View className='day_night_detail_icon'>
+                                {
+                                    props.isNight ? <IconNight width={rpxToPx(48)} color={ColorType.night} /> : <IconDay width={rpxToPx(48)} color={ColorType.day} />
+                                }
+                            </View>
+                            <View style={{ display: 'flex', flexDirection: 'column', paddingTop: rpxToPx(8) }}>
+                                <Text className='day_night_value' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? nightDuration() : dayDuration()}</Text>
+                                <Text className='day_night_desc'>{props.isNight ? nightDurationDesc1() : dayDurationDesc1()}</Text>
+                                {
+                                    authInfo && authInfo.lat ?
+                                        <View style={{ display: 'flex', flexDirection: 'row', marginTop: rpxToPx(18) }} onClick={auth}>
+                                            <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'} onClick={auth}>{getLocation()}</View>
+                                        </View>
+                                        :
+                                        <View style={{ display: 'flex', flexDirection: 'row', marginTop: rpxToPx(18) }} onClick={auth}>
+                                            <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'} onClick={auth}>
+                                                {props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')}
+                                            </View>
+                                        </View>
+                                }
+                            </View>
+                        </View>
+                    }
+    
+                </View>
+            </Box >
+            {
+                showDetailPopup && modalContent()
+            }
+            {
+                showDetailModal && modalContent2()
+            }
+        </View >*/
+}

+ 9 - 9
src/features/trackTimeDuration/components/Discovery.tsx

@@ -192,7 +192,7 @@ export default function Discovery() {
             durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
         }
 
-        if (ring.current_record && ring.current_record.scenario == 'SLEEP'){
+        if (ring.current_record && ring.current_record.scenario == 'SLEEP') {
             realRing.color = ColorType.activity
             currentDot.color = ColorType.activity
         }
@@ -465,7 +465,7 @@ export default function Discovery() {
     function rings() {
         return <View style={{
             position: 'relative', zIndex: 1,
-            marginLeft: day.showDayRing ? -6 : 0,
+            marginLeft: day.showDayRing && false ? -6 : 0,
         }}>
             {
                 bigRing()
@@ -478,7 +478,7 @@ export default function Discovery() {
                 </View>
             }
             {
-                day.showDayRing && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
+                day.showDayRing && false && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
                     {
                         dayRing()
                     }
@@ -507,21 +507,21 @@ export default function Discovery() {
                     <View style={{
                         display: 'flex',
                         flexDirection: 'row',
-                        marginTop: day.showDayRing ? -6 : 0,
-                        marginBottom: day.showDayRing ? -6 : 0,
-                        padding: day.showDayRing ? 14 : 0,
+                        marginTop: day.showDayRing && false ? -6 : 0,
+                        marginBottom: day.showDayRing && false ? -6 : 0,
+                        padding: day.showDayRing && false ? 14 : 0,
                         alignItems: 'center'
                     }}>
                         {
                             schedule && rings()
                         }
                         {schedule && <View className="duration_bg3"
-                            style={{ marginLeft: day.showDayRing ? rpxToPx(68) : rpxToPx(52), height: bigRingRadius * 2, overflow: 'visible' }}>
+                            style={{ marginLeft: day.showDayRing && false ? rpxToPx(68) : rpxToPx(52), height: bigRingRadius * 2, overflow: 'visible' }}>
                             {
-                                day.showDayRing && <Text className="duration_title2">{t('feature.common.day')}</Text>
+                                day.showDayRing && false && <Text className="duration_title2">{t('feature.common.day')}</Text>
                             }
                             {
-                                day.showDayRing &&
+                                day.showDayRing && false &&
                                 <Text className="duration_value2" style={{ color: ColorType.day }}>{dayDuration()}</Text>
                             }
                             {

+ 18 - 18
src/features/trackTimeDuration/components/IndexItem.tsx

@@ -80,7 +80,7 @@ export default function Component(props: { type: string, data: any, time: any, s
 
         var currentDot1 = getDot(record, true)
         var targetBigRing1 = getTarget(record, true)
-        targetBigRing1.color = record.scenario=='SLEEP'?ColorType.sleep+'66':ColorType.fast+'66'
+        targetBigRing1.color = record.scenario == 'SLEEP' ? ColorType.sleep + '66' : ColorType.fast + '66'
         if (record.status == 'ONGOING') {
             var realRing1 = getReal(record, true, false)
             // debugger
@@ -195,7 +195,7 @@ export default function Component(props: { type: string, data: any, time: any, s
                 realRing.durationArc = durationArc(record.sleep.target_start_time, (new Date()).getTime())
                 return <Rings common={common} bgRing={bgRing} currentDot={currentDot} canvasId={props.type + 'index_small'} targetRing={targetBigRing1} realRing={realRing} />
             }
-            else if (record.status == 'WAIT_FOR_START'||record.status == 'ONGOING1') {
+            else if (record.status == 'WAIT_FOR_START' || record.status == 'ONGOING1') {
 
                 var scenario = JSON.parse(JSON.stringify(props.data.scenario))
                 // if (record.status == 'ONGOING1') {
@@ -215,20 +215,20 @@ export default function Component(props: { type: string, data: any, time: any, s
                 // }
 
 
-                if (record.status == 'WAIT_FOR_START'){
+                if (record.status == 'WAIT_FOR_START') {
                     realRing = getSchedule(scenario, false, true, record.status == 'WAIT_FOR_START')//getSchedule(record, false, true)
-                    
+
                 }
                 else {
                     realRing.startArc = startArc(record.sleep.target_start_time)
                     realRing.durationArc = durationArc(record.sleep.target_start_time, record.sleep.target_end_time)
                 }
-                
+
                 realRing.color = ColorType.sleep + '66'
 
                 var currentDot = getDot(record, false)
-                
-                if (!user.isLogin ) {
+
+                if (!user.isLogin) {
                     currentDot = null
                 }
 
@@ -331,7 +331,7 @@ export default function Component(props: { type: string, data: any, time: any, s
     function rings() {
         return <View style={{
             position: 'relative', zIndex: 1,
-            marginLeft: !props.showStage && global.showNightRing === true ? -6 : 0,
+            marginLeft: !props.showStage && global.showNightRing === true && false ? -6 : 0,
         }}>
             {
                 bigRing()
@@ -344,7 +344,7 @@ export default function Component(props: { type: string, data: any, time: any, s
                 </View>
             }
             {
-                !props.showStage && day.showDayRing === true && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
+                !props.showStage && day.showDayRing === true && false && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
                     {
                         dayRing()
                     }
@@ -392,7 +392,7 @@ export default function Component(props: { type: string, data: any, time: any, s
             if (count == 0) {
                 return t('feature.track_time_duration.stage.no_stage_selected')
             }
-            return TimeFormatter.durationFormate(new Date().getTime(), new Date().getTime()+count)//`${count}小时`
+            return TimeFormatter.durationFormate(new Date().getTime(), new Date().getTime() + count)//`${count}小时`
         }
         if (record.fast.status == 'WAIT_FOR_END') {
             return TimeFormatter.countdown(record.fast.real_start_time)
@@ -498,26 +498,26 @@ export default function Component(props: { type: string, data: any, time: any, s
         marginRight: rpxToPx(-40),
         marginTop: rpxToPx(-40),
         padding: rpxToPx(48),
-        
+
     }}>
         <View className="time_operate_item1" onClick={goDetail}>
             <View className="fast_sleep_item" style={{
-                marginTop: !props.showStage && day.showDayRing === true ? -6 : 0,
-                marginBottom: !props.showStage && day.showDayRing === true ? -6 : 0,
-                marginLeft: !props.showStage && day.showDayRing === true ? -6 : 0,
-                padding: !props.showStage && day.showDayRing === true ? 14 : 0,
+                marginTop: !props.showStage && day.showDayRing === true && false ? -6 : 0,
+                marginBottom: !props.showStage && day.showDayRing === true && false ? -6 : 0,
+                marginLeft: !props.showStage && day.showDayRing === true && false ? -6 : 0,
+                padding: !props.showStage && day.showDayRing === true && false ? 14 : 0,
                 paddingRight: 0,
             }}>
                 {
                     rings()
                 }
-                <View className="duration_bg2" style={{ marginLeft: !props.showStage && day.showDayRing === true ? rpxToPx(68) : rpxToPx(52), height: bigRingRadius * 2, overflow: 'visible' }}>
+                <View className="duration_bg2" style={{ marginLeft: (!props.showStage && day.showDayRing === true && false) ? rpxToPx(68) : rpxToPx(52), height: bigRingRadius * 2, overflow: 'visible' }}>
                     {
-                        !props.showStage && day.showDayRing === true &&
+                        !props.showStage && day.showDayRing === true && false &&
                         <Text className="duration_title2">{t('feature.common.overnight')}</Text>
                     }
                     {
-                        !props.showStage && day.showDayRing === true &&
+                        !props.showStage && day.showDayRing === true && false &&
                         <Text className="duration_value2" style={{ color: ColorType.night }}>{nightDuration()}</Text>
                     }
                     {

+ 10 - 9
src/features/trackTimeDuration/components/WeekCalendarItem.tsx

@@ -127,15 +127,7 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
         </View>
 
         <View className="chart_detail">
-            {
-                showCurrentTime && <View className="currentLine" style={{
-                    position: 'absolute',
-                    left: position.left,
-                    top: position.top,
-                    width: rpxToPx(94),
-                    backgroundColor: 'red'
-                }} />
-            }
+            
             <View className="verticalLine" style={{ left: 0 }} />
             <View className="verticalLine" style={{ left: parseInt(rpxToPx(94 * 1) + '') }} />
             <View className="verticalLine" style={{ left: parseInt(rpxToPx(94 * 2) + '') }} />
@@ -181,6 +173,15 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
                     </View>
                 })
             }
+            {
+                showCurrentTime && <View className="currentLine" style={{
+                    position: 'absolute',
+                    left: position.left,
+                    top: position.top,
+                    width: rpxToPx(94),
+                    backgroundColor: 'red'
+                }} />
+            }
         </View>
         <View style={{ height: parseInt(rpxToPx(60) + '') }}>
             <View className="chart_bottom_week">