Leon 1 rok pred
rodič
commit
a106170575

+ 11 - 387
src/features/trackTimeDuration/components/DayNightCard.tsx

@@ -66,6 +66,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
     const [dayDate, setDayDate] = useState(new Date())
     const dispatch = useDispatch();
     const { t } = useTranslation()
+    const isMember = true;
     let navigation;
     if (useNavigation) {
         navigation = useNavigation()
@@ -143,10 +144,10 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
     }, [props.count])
 
     useEffect(() => {
-        if (user.test_user && joingMember) {
-            auth()
-        }
-        if (!user.test_user) {
+        // if (user.test_user && joingMember) {
+        //     auth()
+        // }
+        if (!isMember) {
             lastNightInfo = null
             lastDayInfo = null
             locationDetail = null
@@ -154,7 +155,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
             setSunriseTime('06:00')
             setSunriseTmrTime('06:00')
             setSunsetTime('18:00')
-            dispatch(updateMember({ isMember: user.test_user, gpsInfo: null }))
+            dispatch(updateMember({ isMember: isMember, gpsInfo: null }))
 
 
             dispatch(setDayRingData({
@@ -184,7 +185,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         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 (user.test_user && data && data.daylights && data.daylights.length > 0) {
+        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)
@@ -257,7 +258,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
             setSunriseTime('06:00')
             setSunriseTmrTime('06:00')
             setSunsetTime('18:00')
-            dispatch(updateMember({ isMember: user.test_user, gpsInfo: null }))
+            dispatch(updateMember({ isMember: isMember, gpsInfo: null }))
 
 
             dispatch(setDayRingData({
@@ -281,7 +282,6 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         ) {
             return
         }
-        debugger
         lastNightInfo = {
             date,
             sunrise,
@@ -313,64 +313,6 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         }))
     }
 
-    async function getStorage(key: string) {
-        try {
-            const res = await Taro.getStorage({ key });
-            return res.data;
-        } catch {
-            return '';
-        }
-    }
-
-    function footer(e) {
-        return <View className='day_night_card_footer' onClick={tapFooter}>
-            <Text style={{ color: '#9E9E9E', fontSize: rpxToPx(20) }}>{
-                // !isMember ? t('feature.track_time_duration.third_ring.member_desc') :
-                authInfo && (authInfo as any).lat ? t('feature.track_time_duration.third_ring.base_location_desc') :
-                    t('feature.track_time_duration.third_ring.enter_location_desc')
-            }</Text>
-            {
-                authInfo && (authInfo as any).lat && <Text style={{ color: '#9E9E9E', fontSize: rpxToPx(20) }} onClick={(e) => {
-                    e.stopPropagation()
-                    auth(e)
-                }}>Edit Location</Text>
-            }
-        </View>
-    }
-
-    function tapFooter(e) {
-        if (process.env.TARO_ENV == 'weapp') {
-            e.stopPropagation()
-        }
-        if (!user.isLogin) {
-            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
-            return
-        }
-        if (props.isNight && !nightStore.showNightRing || !props.isNight && !dayStore.showDayRing) {
-            return
-        }
-        var list = ['Current location Info',
-            'Choose a new location']
-        if (user.test_user) {
-            list.push('clear location data')
-        }
-        Taro.showActionSheet({
-            itemList: list
-        }).then(res => {
-            switch (res.tapIndex) {
-                case 0:
-                    setShowDetailModal(true)
-                    break
-                case 1:
-                    auth()
-                    break;
-                case 2:
-                    clearData()
-                    break;
-            }
-        })
-    }
-
     function tapCard(e) {
         // if (process.env.TARO_ENV == 'weapp') {
         //     e.stopPropagation()
@@ -419,7 +361,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
                         key: 'gps',
                         data: JSON.stringify(data as any)
                     })
-                    dispatch(updateMember({ isMember: user.test_user, gpsInfo: (data as any) }))
+                    dispatch(updateMember({ isMember: isMember, gpsInfo: (data as any) }))
                 })
 
             },
@@ -451,133 +393,6 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         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 lowTimeColor() {
-        var now = new Date()
-        if (props.isNight) {
-            if (now.getTime() < sunsetDate.getTime() && now.getTime() > sunriseDate.getTime()) {
-                return true
-            }
-            return false
-        } else {
-
-            if (now.getTime() > sunriseDate.getTime() && now.getTime() < sunsetDate.getTime()) {
-                return false
-            }
-            return true
-
-
-        }
-    }
-
-    function timeCount() {
-        var now = new Date()
-        if (props.isNight) {
-            if (now.getTime() < sunriseTmrDate.getTime()) {
-                return TimeFormatter.countdown(sunsetDate.getTime())
-            }
-            return TimeFormatter.countdown(sunsetDate.getTime())
-        } else {
-
-            if (now.getTime() < sunsetDate.getTime()) {
-                return TimeFormatter.countdown(sunriseDate.getTime())
-            }
-            return TimeFormatter.countdown(sunriseTmrDate.getTime())
-
-
-        }
-    }
-
-    function timeCount2() {
-        var now = new Date()
-        if (props.isNight) {
-
-            if (now.getTime() < sunsetDate.getTime()) {
-                return TimeFormatter.countdown(sunriseTmrDate.getTime())
-            }
-            return TimeFormatter.countdown(sunriseTmrDate.getTime())
-
-        } else {
-            return TimeFormatter.countdown(sunsetDate.getTime())
-        }
-    }
-
-    function showExtraData() {
-        var now = new Date()
-        if (props.isNight) {
-            if (sunsetDate.getTime() > now.getTime()) {
-                return false
-            }
-            return true
-        }
-        if (sunriseDate.getTime() < now.getTime() && now.getTime() < sunsetDate.getTime()) {
-            return true;
-        }
-        return false
-    }
-
-    function timeDesc() {
-        var now = new Date()
-        if (props.isNight) {
-            var list = sunsetTime.split(':')
-            var hour = parseInt(list[0])
-            var min = parseInt(list[1])
-            var second = list.length == 3 ? parseInt(list[2]) : 0
-            now.setHours(hour)
-            now.setMinutes(min)
-            now.setSeconds(second)
-
-            var sunriseDate = new Date()
-            var list2 = sunriseTmrTime.split(':')
-            var hour2 = parseInt(list2[0])
-            var min2 = parseInt(list2[1])
-            var second2 = list2.length == 3 ? parseInt(list2[2]) : 0
-            sunriseDate.setHours(hour2)
-            sunriseDate.setMinutes(min2)
-            sunriseDate.setSeconds(second2)
-            if (sunriseDate.getTime() > new Date().getTime()) {
-                return t('feature.day_night.time_past_sunset')//'Time past Sunset'
-            }
-
-            if (now.getTime() < new Date().getTime()) {
-                return t('feature.day_night.time_past_sunset')//'Time past Sunset'
-            }
-            return t('feature.day_night.time_to_sunset')//'Time to Sunset'
-        }
-        else {
-            var list = sunriseTime.split(':')
-            var hour = parseInt(list[0])
-            var min = parseInt(list[1])
-            var second = list.length == 3 ? parseInt(list[2]) : 0
-            now.setHours(hour)
-            now.setMinutes(min)
-            now.setSeconds(second)
-
-            var sunsetDate = new Date()
-            var list2 = sunsetTime.split(':')
-            var hour2 = parseInt(list2[0])
-            var min2 = parseInt(list2[1])
-            var second2 = list2.length == 3 ? parseInt(list2[2]) : 0
-            sunsetDate.setHours(hour2)
-            sunsetDate.setMinutes(min2)
-            sunsetDate.setSeconds(second2)
-
-            if (new Date().getTime() > sunsetDate.getTime()) {
-                return t('feature.day_night.time_to_sunrise')//'Time to Sunrise'
-            }
-            if (now.getTime() < new Date().getTime()) {
-                return t('feature.day_night.time_past_sunrise')//'Time past Sunrise'
-            }
-            return t('feature.day_night.time_to_sunrise')//'Time to Sunrise'
-        }
-    }
-
-    function timeDesc2() {
-        if (props.isNight) {
-            return t('feature.day_night.time_to_sunrise')//'Time to Sunrise'
-        }
-        return t('feature.day_night.time_to_sunset')//'Time to Sunset'
-    }
-
     function clearData() {
         Taro.showModal({
             title: '提示',
@@ -612,7 +427,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         setSunriseTime('06:00')
         setSunriseTmrTime('06:00')
         setSunsetTime('18:00')
-        dispatch(updateMember({ isMember: user.test_user, gpsInfo: null }))
+        dispatch(updateMember({ isMember: isMember, gpsInfo: null }))
 
 
         dispatch(setDayRingData({
@@ -779,40 +594,6 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         }
     }
 
-
-    function nightDurationDesc() {
-        if (!authInfo || !(authInfo as any).lat) {
-            if (new Date().getHours() >= 6) {
-                return `${t('feature.day_night.tonight', { time: sunsetTime })} - ${t('feature.day_night.tomorrow_morning', { time: sunriseTmrTime })}`
-            }
-            return `${t('feature.day_night.last_night', { time: sunsetTime })} - ${t('feature.day_night.this_morning', { time: sunriseTmrTime })}`
-            // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
-        }
-        if (nightDate.getDate() == new Date().getDate()) {
-            return `${t('feature.day_night.tonight', { time: sunsetTime })} - ${t('feature.day_night.tomorrow_morning', { time: sunriseTmrTime })}`
-        }
-        return `${t('feature.day_night.last_night', { time: sunsetTime })} - ${t('feature.day_night.this_morning', { time: sunriseTmrTime })}`
-        //`Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
-    }
-
-    function dayDurationDesc() {
-        if (!authInfo || !(authInfo as any).lat) {
-            if (new Date().getHours() >= 18) {
-                return `${t('feature.day_night.tomorrow', { time: sunriseTime })} - ${sunsetTime}`
-
-                // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
-            }
-            return `${t('feature.day_night.today', { time: sunriseTime })} - ${sunsetTime}`
-            // return `Today ${sunriseTime} - ${sunsetTime}`
-        }
-        if (dayDate.getDate() == new Date().getDate()) {
-            return `${t('feature.day_night.today', { time: sunriseTime })} - ${sunsetTime}`
-            // return `Today ${sunriseTime} - ${sunsetTime}`
-        }
-        return `${t('feature.day_night.tomorrow', { time: sunriseTime })} - ${sunsetTime}`
-        // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
-    }
-
     function nightDuration() {
         if (!authInfo || !(authInfo as any).lat) {
             if (new Date().getHours() >= 6) {
@@ -851,19 +632,6 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
             return t('feature.day_night.sunset_to_sunrise')
         }
         return t('feature.day_night.night_tip')
-
-        // if (!authInfo || !(authInfo as any).lat) {
-        //     if (new Date().getHours() >= 6) {
-        //         return `${t('feature.day_night.tonight')}${t('feature.day_night.to')}${t('feature.day_night.tomorrow_morning')}`
-        //     }
-        //     return `${t('feature.day_night.last_night')}${t('feature.day_night.to')}${t('feature.day_night.this_morning')}`
-        //     // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
-        // }
-        // if (nightDate.getDate() == new Date().getDate()) {
-        //     return `${t('feature.day_night.tonight')}${t('feature.day_night.to')}${t('feature.day_night.tomorrow_morning')}`
-        // }
-        // return `${t('feature.day_night.last_night')}${t('feature.day_night.to')}${t('feature.day_night.this_morning')}`
-        // //`Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
     }
 
     function dayDurationDesc1() {
@@ -871,31 +639,6 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
             return t('feature.day_night.sunrise_to_sunset')
         }
         return t('feature.day_night.day_tip')
-        // if (!authInfo || !(authInfo as any).lat) {
-        //     if (new Date().getHours() >= 18) {
-        //         return `${t('feature.day_night.tomorrow')}`
-
-        //         // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
-        //     }
-        //     return `${t('feature.day_night.today')}`
-        //     // return `Today ${sunriseTime} - ${sunsetTime}`
-        // }
-        // if (dayDate.getDate() == new Date().getDate()) {
-        //     return `${t('feature.day_night.today')}`
-        //     // return `Today ${sunriseTime} - ${sunsetTime}`
-        // }
-        // return `${t('feature.day_night.tomorrow')}`
-        // // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
-    }
-
-    function buy(e) {
-        if (process.env.TARO_ENV == 'weapp') {
-            e.stopPropagation()
-        }
-        joingMember = true
-        Taro.navigateTo({
-            url: '/pages/account/Member'
-        })
     }
 
     function longClick() {
@@ -907,7 +650,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         if (process.env.TARO_ENV == 'weapp') {
             e.stopPropagation()
         }
-        if (user.test_user && authInfo && authInfo.lat) {
+        if (isMember && authInfo && authInfo.lat) {
             tapCard(e)
             return
         }
@@ -1019,40 +762,6 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
                         </View>
                     </View>
                 }
-                {/* {
-                    user.isLogin && dayStore.showDayRing && <View style={{ marginTop: rpxToPx(12), marginBottom: rpxToPx(14), backgroundColor: 'pink' }}>
-                        <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }} onClick={showLocationAlert}>
-                            <View style={{ flexDirection: 'row', display: 'flex', alignItems: 'center' }}>
-                                {
-                                    user.test_user && authInfo && authInfo.lat ? props.isNight ? <IconNight width={rpxToPx(30)} color={ColorType.night} /> : <IconDay width={rpxToPx(30)} color={ColorType.day} /> :
-                                        <IconInfo width={rpxToPx(30)} color={props.isNight ? ColorType.night : ColorType.day} />
-                                }
-                                <Text className='day_night_value' style={{ color: props.isNight ? ColorType.night : ColorType.day, marginLeft: rpxToPx(10) }}>{props.isNight ? nightDuration() : dayDuration()}</Text>
-                            </View>
-
-                            <Text className='day_night_desc'>{props.isNight ? nightDurationDesc1() : dayDurationDesc1()}</Text>
-
-                        </View>
-
-                        <View style={{ marginTop: rpxToPx(40), marginBottom: rpxToPx(20) }}>
-                            {
-                                !user.test_user ? <View className={props.isNight ? 'day_night_card_btn buy_night' : 'day_night_card_btn buy_day'} onClick={buy}>{
-                                    props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')
-                                }</View> :
-                                    authInfo && authInfo.lat ?
-                                        <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
-                                            <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'} onClick={auth}>{getLocation()}</View>
-                                        </View>
-                                        :
-                                        <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
-                                            <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 >
@@ -1063,89 +772,4 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
             showDetailModal && modalContent2()
         }
     </View >
-
-    /*
-    return <View style={{ color: '#fff' }}>
-        <Box onClick={tapCard}>
-            <View>
-                <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 }} />
-                    <Switch checked={props.isNight ? nightStore.showNightRing : dayStore.showDayRing}
-                        color={props.isNight ? ColorType.night : ColorType.day}
-                        onClick={(e) => { e.stopPropagation() }}
-                        onChange={(e) => {
-                            e.stopPropagation()
-                            // setExpand(e.detail.value)
-                            // if (props.isNight) {
-                            dispatch(showNight(e.detail.value))
-                            // }
-                            // else {
-                            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 })
-                                // if (props.isNight) {
-                                //     uploadPerm({ show_night_ring: e.detail.value })
-                                // }
-                                // else {
-                                //     uploadPerm({ show_day_ring: e.detail.value })
-                                // }
-                            }
-
-
-                        }}
-                    />
-                </View>
-                {
-                    user.isLogin && ((props.isNight && nightStore.showNightRing) || (!props.isNight && dayStore.showDayRing)) && <View>
-                        <View style={{ display: 'flex', flexDirection: 'column' }}>
-                            <Text className='day_night_value' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? nightDurationDesc() : dayDurationDesc()}</Text>
-                            <Text className='day_night_desc'>{props.isNight ? t('feature.day_night.sunset_to_sunrise') : t('feature.day_night.sunrise_to_sunset')}</Text>
-                            <View style={{ display: 'flex', flexDirection: 'row', marginTop: rpxToPx(32) }}>
-                                <View style={{ display: 'flex', flexDirection: 'column', width: rpxToPx(300) }}>
-                                    <Text className='day_night_value' style={{ color: lowTimeColor() ? ColorType.ring : props.isNight ? ColorType.night : ColorType.day, }}>{timeCount()}</Text>
-                                    <Text className='day_night_desc'>{timeDesc()}</Text>
-                                </View>
-                                {
-                                    showExtraData() && <View style={{ display: 'flex', flexDirection: 'column', width: rpxToPx(300) }}>
-                                        <Text className='day_night_value' style={{ color: props.isNight ? ColorType.night : ColorType.day, opacity: 0.6 }}>{timeCount2()}</Text>
-                                        <Text className='day_night_desc'>{timeDesc2()}</Text>
-                                    </View>
-                                }
-                            </View>
-
-                        </View>
-                        {
-                            footer()
-                        }
-                    </View>
-                }
-
-            </View>
-        </Box>
-        {
-            showDetailModal && modalContent()
-        }
-    </View>*/
 }

+ 1118 - 0
src/features/trackTimeDuration/components/DayNightCard的副本.tsx

@@ -0,0 +1,1118 @@
+import { PageContainer, Switch, Text, View } 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'
+
+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 => {
+                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 {
+            var gps = Taro.getStorageSync('gps')
+            if (gps) {
+                locationDetail = JSON.parse(gps)
+                global.locationDetail = JSON.parse(gps)
+            }
+        }
+    }, [user.test_user])
+
+    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
+        }
+        debugger
+        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
+        }))
+    }
+
+    async function getStorage(key: string) {
+        try {
+            const res = await Taro.getStorage({ key });
+            return res.data;
+        } catch {
+            return '';
+        }
+    }
+
+    function footer(e) {
+        return <View className='day_night_card_footer' onClick={tapFooter}>
+            <Text style={{ color: '#9E9E9E', fontSize: rpxToPx(20) }}>{
+                // !isMember ? t('feature.track_time_duration.third_ring.member_desc') :
+                authInfo && (authInfo as any).lat ? t('feature.track_time_duration.third_ring.base_location_desc') :
+                    t('feature.track_time_duration.third_ring.enter_location_desc')
+            }</Text>
+            {
+                authInfo && (authInfo as any).lat && <Text style={{ color: '#9E9E9E', fontSize: rpxToPx(20) }} onClick={(e) => {
+                    e.stopPropagation()
+                    auth(e)
+                }}>Edit Location</Text>
+            }
+        </View>
+    }
+
+    function tapFooter(e) {
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
+        if (!user.isLogin) {
+            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+            return
+        }
+        if (props.isNight && !nightStore.showNightRing || !props.isNight && !dayStore.showDayRing) {
+            return
+        }
+        var list = ['Current location Info',
+            'Choose a new location']
+        if (isMember) {
+            list.push('clear location data')
+        }
+        Taro.showActionSheet({
+            itemList: list
+        }).then(res => {
+            switch (res.tapIndex) {
+                case 0:
+                    setShowDetailModal(true)
+                    break
+                case 1:
+                    auth()
+                    break;
+                case 2:
+                    clearData()
+                    break;
+            }
+        })
+    }
+
+    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()
+        }
+        joingMember = false;
+        Taro.chooseLocation({
+            latitude: authInfo && authInfo.lat ? authInfo.lat : undefined,
+            longitude: authInfo && authInfo.lat ? authInfo.lng : undefined,
+            success: function (res) {
+                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: 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)
+                    })
+                    dispatch(updateMember({ isMember: isMember, gpsInfo: (data as any) }))
+                })
+
+            },
+            fail(res) {
+                Taro.showToast({
+                    title: '位置修改失败!\n请重新选择就近位置',
+                    icon: 'none'
+                })
+            },
+        })
+
+    }
+
+    function getLocation() {
+        var city = ''
+        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')
+        }
+        // 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 lowTimeColor() {
+        var now = new Date()
+        if (props.isNight) {
+            if (now.getTime() < sunsetDate.getTime() && now.getTime() > sunriseDate.getTime()) {
+                return true
+            }
+            return false
+        } else {
+
+            if (now.getTime() > sunriseDate.getTime() && now.getTime() < sunsetDate.getTime()) {
+                return false
+            }
+            return true
+
+
+        }
+    }
+
+    function timeCount() {
+        var now = new Date()
+        if (props.isNight) {
+            if (now.getTime() < sunriseTmrDate.getTime()) {
+                return TimeFormatter.countdown(sunsetDate.getTime())
+            }
+            return TimeFormatter.countdown(sunsetDate.getTime())
+        } else {
+
+            if (now.getTime() < sunsetDate.getTime()) {
+                return TimeFormatter.countdown(sunriseDate.getTime())
+            }
+            return TimeFormatter.countdown(sunriseTmrDate.getTime())
+
+
+        }
+    }
+
+    function timeCount2() {
+        var now = new Date()
+        if (props.isNight) {
+
+            if (now.getTime() < sunsetDate.getTime()) {
+                return TimeFormatter.countdown(sunriseTmrDate.getTime())
+            }
+            return TimeFormatter.countdown(sunriseTmrDate.getTime())
+
+        } else {
+            return TimeFormatter.countdown(sunsetDate.getTime())
+        }
+    }
+
+    function showExtraData() {
+        var now = new Date()
+        if (props.isNight) {
+            if (sunsetDate.getTime() > now.getTime()) {
+                return false
+            }
+            return true
+        }
+        if (sunriseDate.getTime() < now.getTime() && now.getTime() < sunsetDate.getTime()) {
+            return true;
+        }
+        return false
+    }
+
+    function timeDesc() {
+        var now = new Date()
+        if (props.isNight) {
+            var list = sunsetTime.split(':')
+            var hour = parseInt(list[0])
+            var min = parseInt(list[1])
+            var second = list.length == 3 ? parseInt(list[2]) : 0
+            now.setHours(hour)
+            now.setMinutes(min)
+            now.setSeconds(second)
+
+            var sunriseDate = new Date()
+            var list2 = sunriseTmrTime.split(':')
+            var hour2 = parseInt(list2[0])
+            var min2 = parseInt(list2[1])
+            var second2 = list2.length == 3 ? parseInt(list2[2]) : 0
+            sunriseDate.setHours(hour2)
+            sunriseDate.setMinutes(min2)
+            sunriseDate.setSeconds(second2)
+            if (sunriseDate.getTime() > new Date().getTime()) {
+                return t('feature.day_night.time_past_sunset')//'Time past Sunset'
+            }
+
+            if (now.getTime() < new Date().getTime()) {
+                return t('feature.day_night.time_past_sunset')//'Time past Sunset'
+            }
+            return t('feature.day_night.time_to_sunset')//'Time to Sunset'
+        }
+        else {
+            var list = sunriseTime.split(':')
+            var hour = parseInt(list[0])
+            var min = parseInt(list[1])
+            var second = list.length == 3 ? parseInt(list[2]) : 0
+            now.setHours(hour)
+            now.setMinutes(min)
+            now.setSeconds(second)
+
+            var sunsetDate = new Date()
+            var list2 = sunsetTime.split(':')
+            var hour2 = parseInt(list2[0])
+            var min2 = parseInt(list2[1])
+            var second2 = list2.length == 3 ? parseInt(list2[2]) : 0
+            sunsetDate.setHours(hour2)
+            sunsetDate.setMinutes(min2)
+            sunsetDate.setSeconds(second2)
+
+            if (new Date().getTime() > sunsetDate.getTime()) {
+                return t('feature.day_night.time_to_sunrise')//'Time to Sunrise'
+            }
+            if (now.getTime() < new Date().getTime()) {
+                return t('feature.day_night.time_past_sunrise')//'Time past Sunrise'
+            }
+            return t('feature.day_night.time_to_sunrise')//'Time to Sunrise'
+        }
+    }
+
+    function timeDesc2() {
+        if (props.isNight) {
+            return t('feature.day_night.time_to_sunrise')//'Time to Sunrise'
+        }
+        return t('feature.day_night.time_to_sunset')//'Time to Sunset'
+    }
+
+    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 nightDurationDesc() {
+        if (!authInfo || !(authInfo as any).lat) {
+            if (new Date().getHours() >= 6) {
+                return `${t('feature.day_night.tonight', { time: sunsetTime })} - ${t('feature.day_night.tomorrow_morning', { time: sunriseTmrTime })}`
+            }
+            return `${t('feature.day_night.last_night', { time: sunsetTime })} - ${t('feature.day_night.this_morning', { time: sunriseTmrTime })}`
+            // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+        }
+        if (nightDate.getDate() == new Date().getDate()) {
+            return `${t('feature.day_night.tonight', { time: sunsetTime })} - ${t('feature.day_night.tomorrow_morning', { time: sunriseTmrTime })}`
+        }
+        return `${t('feature.day_night.last_night', { time: sunsetTime })} - ${t('feature.day_night.this_morning', { time: sunriseTmrTime })}`
+        //`Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+    }
+
+    function dayDurationDesc() {
+        if (!authInfo || !(authInfo as any).lat) {
+            if (new Date().getHours() >= 18) {
+                return `${t('feature.day_night.tomorrow', { time: sunriseTime })} - ${sunsetTime}`
+
+                // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
+            }
+            return `${t('feature.day_night.today', { time: sunriseTime })} - ${sunsetTime}`
+            // return `Today ${sunriseTime} - ${sunsetTime}`
+        }
+        if (dayDate.getDate() == new Date().getDate()) {
+            return `${t('feature.day_night.today', { time: sunriseTime })} - ${sunsetTime}`
+            // return `Today ${sunriseTime} - ${sunsetTime}`
+        }
+        return `${t('feature.day_night.tomorrow', { time: sunriseTime })} - ${sunsetTime}`
+        // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
+    }
+
+    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 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')
+
+        // if (!authInfo || !(authInfo as any).lat) {
+        //     if (new Date().getHours() >= 6) {
+        //         return `${t('feature.day_night.tonight')}${t('feature.day_night.to')}${t('feature.day_night.tomorrow_morning')}`
+        //     }
+        //     return `${t('feature.day_night.last_night')}${t('feature.day_night.to')}${t('feature.day_night.this_morning')}`
+        //     // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+        // }
+        // if (nightDate.getDate() == new Date().getDate()) {
+        //     return `${t('feature.day_night.tonight')}${t('feature.day_night.to')}${t('feature.day_night.tomorrow_morning')}`
+        // }
+        // return `${t('feature.day_night.last_night')}${t('feature.day_night.to')}${t('feature.day_night.this_morning')}`
+        // //`Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+    }
+
+    function dayDurationDesc1() {
+        if (authInfo && authInfo.lat) {
+            return t('feature.day_night.sunrise_to_sunset')
+        }
+        return t('feature.day_night.day_tip')
+        // if (!authInfo || !(authInfo as any).lat) {
+        //     if (new Date().getHours() >= 18) {
+        //         return `${t('feature.day_night.tomorrow')}`
+
+        //         // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
+        //     }
+        //     return `${t('feature.day_night.today')}`
+        //     // return `Today ${sunriseTime} - ${sunsetTime}`
+        // }
+        // if (dayDate.getDate() == new Date().getDate()) {
+        //     return `${t('feature.day_night.today')}`
+        //     // return `Today ${sunriseTime} - ${sunsetTime}`
+        // }
+        // return `${t('feature.day_night.tomorrow')}`
+        // // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
+    }
+
+    function buy(e) {
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
+        joingMember = true
+        Taro.navigateTo({
+            url: '/pages/account/Member'
+        })
+    }
+
+    function longClick() {
+        if (user.isLogin && 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: t('feature.day_night.note'),
+            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)
+                }
+            }
+        })
+    }
+
+    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) => {
+                                e.stopPropagation()
+                                // setExpand(e.detail.value)
+                                // if (props.isNight) {
+                                dispatch(showNight(e.detail.value))
+                                // }
+                                // else {
+                                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 >
+
+    /*
+    return <View style={{ color: '#fff' }}>
+        <Box onClick={tapCard}>
+            <View>
+                <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 }} />
+                    <Switch checked={props.isNight ? nightStore.showNightRing : dayStore.showDayRing}
+                        color={props.isNight ? ColorType.night : ColorType.day}
+                        onClick={(e) => { e.stopPropagation() }}
+                        onChange={(e) => {
+                            e.stopPropagation()
+                            // setExpand(e.detail.value)
+                            // if (props.isNight) {
+                            dispatch(showNight(e.detail.value))
+                            // }
+                            // else {
+                            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 })
+                                // if (props.isNight) {
+                                //     uploadPerm({ show_night_ring: e.detail.value })
+                                // }
+                                // else {
+                                //     uploadPerm({ show_day_ring: e.detail.value })
+                                // }
+                            }
+
+
+                        }}
+                    />
+                </View>
+                {
+                    user.isLogin && ((props.isNight && nightStore.showNightRing) || (!props.isNight && dayStore.showDayRing)) && <View>
+                        <View style={{ display: 'flex', flexDirection: 'column' }}>
+                            <Text className='day_night_value' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? nightDurationDesc() : dayDurationDesc()}</Text>
+                            <Text className='day_night_desc'>{props.isNight ? t('feature.day_night.sunset_to_sunrise') : t('feature.day_night.sunrise_to_sunset')}</Text>
+                            <View style={{ display: 'flex', flexDirection: 'row', marginTop: rpxToPx(32) }}>
+                                <View style={{ display: 'flex', flexDirection: 'column', width: rpxToPx(300) }}>
+                                    <Text className='day_night_value' style={{ color: lowTimeColor() ? ColorType.ring : props.isNight ? ColorType.night : ColorType.day, }}>{timeCount()}</Text>
+                                    <Text className='day_night_desc'>{timeDesc()}</Text>
+                                </View>
+                                {
+                                    showExtraData() && <View style={{ display: 'flex', flexDirection: 'column', width: rpxToPx(300) }}>
+                                        <Text className='day_night_value' style={{ color: props.isNight ? ColorType.night : ColorType.day, opacity: 0.6 }}>{timeCount2()}</Text>
+                                        <Text className='day_night_desc'>{timeDesc2()}</Text>
+                                    </View>
+                                }
+                            </View>
+
+                        </View>
+                        {
+                            footer()
+                        }
+                    </View>
+                }
+
+            </View>
+        </Box>
+        {
+            showDetailModal && modalContent()
+        }
+    </View>*/
+}

+ 0 - 1
src/features/trackTimeDuration/components/Discovery.scss

@@ -23,7 +23,6 @@
     font-size: 32px;
     line-height: 32px;
     color: #fff;
-    opacity: 0.6;
     font-weight: 400;
 }
 

+ 2 - 2
src/features/trackTimeDuration/components/IndexConsole.tsx

@@ -626,7 +626,7 @@ export default function IndexConsole(props: { record: any }) {
                     {
                         status == 'ONGOING1' ?
                             <Text>{TimeFormatter.countdown(currentRecord.fast.real_start_time)}</Text> :
-                            <Text>{TimeFormatter.countdown(currentRecord.fast.real_start_time, currentRecord.sleep.real_start_time)}</Text>
+                            <Text>{TimeFormatter.calculateTimeDifference(currentRecord.fast.real_start_time, currentRecord.sleep.real_start_time)}</Text>
                     }
 
                 </View>
@@ -647,7 +647,7 @@ export default function IndexConsole(props: { record: any }) {
                 <Text style={{ flex: 1 }}>{t('feature.track_time_duration.stage.b')}</Text>
                 {
                     status == 'ONGOING2' ? <Text>{TimeFormatter.countdown(currentRecord.sleep.real_start_time)}</Text> :
-                        <Text>{TimeFormatter.countdown(currentRecord.sleep.real_start_time, currentRecord.sleep.real_end_time)}</Text>
+                        <Text>{TimeFormatter.calculateTimeDifference(currentRecord.sleep.real_start_time, currentRecord.sleep.real_end_time)}</Text>
                 }
 
 

+ 0 - 1
src/features/trackTimeDuration/components/IndexItem.scss

@@ -48,7 +48,6 @@
     font-size: 32px;
     line-height: 32px;
     color: #fff;
-    opacity: 0.6;
     font-weight: 400;
 }
 

+ 1 - 2
src/features/trackTimeDuration/components/IndexItem.tsx

@@ -284,7 +284,6 @@ export default function Component(props: { type: string, data: any, time: any, s
         var sunRise = 24 * 60 + 6 * 60
         var sunSet = 18 * 60
 
-        // if (dayNight.gpsInfo && user.test_user) {
         var sunRiseObj = dayNight.nightRingSunrise
         var sunSetObj = dayNight.nightRingSunset
         sunRise = 24 * 60 + parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
@@ -377,7 +376,7 @@ export default function Component(props: { type: string, data: any, time: any, s
         if (!record.fast) {
             return ''
         }
-        if (!user.isLogin) {
+        if (!user.isLogin && record.sleep) {
             var count = 0
             if (stageList[0]) {
 

+ 9 - 0
src/features/trackTimeDuration/components/RecordFastSleep.tsx

@@ -71,6 +71,15 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number })
             setSelIndex(0)
 
         }
+
+        if (props.index==-20000){
+            global.refreshRecent = ()=>{
+                setCount((index)=>index+1)
+            }
+            setTimeout(()=>{
+                setCount((index)=>index+1)
+            },100)
+        }
         // console.log(sqrt(-4).toString())
     }, [props.data])
 

+ 1 - 0
src/pages/clock/Clock.scss

@@ -30,6 +30,7 @@
     -webkit-background-clip: text;
     background-clip: text;
     color: transparent;
+    font-weight: bold;
 }
 /* #endif */
 

+ 19 - 9
src/pages/clock/Clock.tsx

@@ -49,6 +49,7 @@ let useNavigation;
 let timer
 let pauseTimer = false;
 let AppState;
+let needScroll = false;
 
 if (process.env.TARO_ENV == 'rn') {
     AppState = require("react-native").AppState
@@ -186,6 +187,9 @@ export default function Page() {
             }).catch(e => {
                 Taro.stopPullDownRefresh()
             })
+            if (global.refreshRecent){
+                global.refreshRecent()
+            }
         }
         setTimeout(() => {
             checkVersionUpdate();
@@ -302,10 +306,23 @@ export default function Page() {
         Promise.all([getClocks(), getPlans()]).then((list) => {
             setErrorPage(false)
             setCheckData(list)
+
+            if (needScroll){
+                needScroll = false
+                setTimeout(() => {
+                    Taro.createSelectorQuery().select('#latest').boundingClientRect((rect) => {
+                        Taro.pageScrollTo({
+                            scrollTop: (rect as any).top,
+                            duration: 150
+                        })
+                    }).exec()
+                }, 100)
+            }
         }).catch((e) => {
             setErrorPage(true)
             var list = JSON.parse(defaultValue)
             setCheckData(list)
+            needScroll = false
         })
 
         getHistory()
@@ -549,15 +566,8 @@ export default function Page() {
     }
 
     global.scrollToLatest = () => {
-        setTimeout(() => {
-            Taro.createSelectorQuery().select('#latest').boundingClientRect((rect) => {
-                Taro.pageScrollTo({
-                    scrollTop: (rect as any).top,
-                    duration: 100
-                })
-                debugger
-            }).exec()
-        }, 1000)
+        needScroll = true;
+        
 
     }
 

+ 1 - 1
src/services/http/api.js

@@ -1,4 +1,4 @@
-let online = process.env.TARO_ENV == 'rn' ? false : false;
+let online = process.env.TARO_ENV == 'rn' ? false : true;
 export let baseUrl = online ? 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';
 export let imgUrl = online
     ? 'https://api.fast.liveplus.fun/static/image/'