Leon 1 год назад
Родитель
Сommit
459e02a094

+ 36 - 19
src/context/locales/en.js

@@ -118,9 +118,9 @@ export default {
             become_pro: 'Become Pro',
             overnight: 'Overnight',
             day: 'Day',
-            eat:'Eat',
-            move:'Move',
-            show_more:'Show More',
+            eat: 'Eat',
+            move: 'Move',
+            show_more: 'Show More',
             toast: {
                 min_value: 'Cannot go any lower',
                 max_value: 'Cannot go any higher',
@@ -178,7 +178,7 @@ export default {
                 input_password_placeholder: 'Password',
                 footer_desc: 'Don\'t have an account?',
                 footer_sign_up: 'Sign up',
-                login_now:'Log in now'
+                login_now: 'Log in now'
             },
             create_password: {
                 title: 'Create password',
@@ -191,22 +191,36 @@ export default {
         day_night: {
             night_ring: 'OverNight Ring',
             day_ring: 'Day Ring',
-            limited_free:'Limited Offer',
-            tonight:'Tonight, {{time}}',
-            tomorrow_morning:'Tmrw morning, {{time}}',
-            last_night:'Last night, {{time}}',
-            this_morning:'This morning, {{time}}',
-            tomorrow:'Tomorrow, {{time}}',
-            today:'Today, {{time}}',
-            sunset_to_sunrise:'Sunset to sunrise',
-            sunrise_to_sunset:'Sunrise to sunset',
-            time_to_sunset:'Time to sunset',
-            time_to_sunrise:'Time to sunrise',
-            time_past_sunset:'Time past sunset',
-            time_past_sunrise:'Time past sunrise'
+            night_ring_login: 'Nighttime',
+            day_ring_login: 'Daytime',
+            night_popover: "Overnight",
+            day_popover: "Day",
+            limited_free: 'Limited Offer',
+            tonight: 'Tonight',
+            tomorrow_morning: 'Tomorrow',//英文过长,简化
+            last_night: 'Last night',
+            this_morning: 'Today',//英文过长,简化
+            tomorrow: 'Tomorrow',
+            today: 'Today',
+            sunset_to_sunrise: 'Sunset to sunrise',
+            sunrise_to_sunset: 'Sunrise to sunset',
+            time_to_sunset: 'Time to sunset',
+            time_to_sunrise: 'Time to sunrise',
+            time_past_sunset: 'Time past sunset',
+            time_past_sunrise: 'Time past sunrise',
+            night_duration: 'Length',
+            day_duration: 'Length',
+            overview: 'Overview',
+            events: 'Events',
+            stages: 'Stages',
+            get_local_time: 'Get local sunrise and sunset times',
+            get_local_time_sunrise: 'Get local sunset and sunrise times',
+            to:' to '
         },
         track_time_duration: {
             common: {
+                schedule: 'Schedule',
+                current_schedule: 'Current Schedule',
                 share_title: 'My Fasting Sleep Diary',
                 start_fast: 'Start fasting',//正常态
                 started_fasting: 'Started fasting',//完成时
@@ -217,6 +231,9 @@ export default {
                 end_sleep: 'End sleeping',
                 ended_sleeping: 'Ended sleeping',
                 start_fasting_first: 'Start fasting first.',
+                okay: 'Okay',
+                im_ready: 'I\'m ready',
+                got_it: 'Got it'
             },
             third_ring: {
                 night_ring: 'Night ring',
@@ -373,8 +390,8 @@ export default {
                 wait_for_start: 'Awaiting start',
                 not_completed: 'Not completed',
                 not_started: 'Not started',
-                no_stage_selected:'No stage selected',
-                multi_selection:'Multiple Selection'
+                no_stage_selected: 'No stage selected',
+                multi_selection: 'Multiple Selection'
             },
         },
         food: {

+ 30 - 14
src/context/locales/zh.js

@@ -196,23 +196,36 @@ export default {
         day_night: {
             night_ring: '夜间环',
             day_ring: '白天环',
-            limited_free:'限时免费',
-            tonight:'今晚 {{time}}',
-            tomorrow_morning:'明早 {{time}}',
-            last_night:'昨晚 {{time}}',
-            this_morning:'今早 {{time}}',
-            tomorrow:'明天 {{time}}',
-            today:'今天 {{time}}',
-            sunset_to_sunrise:'日落到日出',
-            sunrise_to_sunset:'日出到日落',
-            time_to_sunset:'距日落',
-            time_to_sunrise:'距日出',
-            time_past_sunset:'已日落',
-            time_past_sunrise:'已日出'
-            
+            night_ring_login: '夜晚时间',
+            day_ring_login: '白天时间',
+            night_popover: "夜间",
+            day_popover: "白天",
+            limited_free: '限时免费',
+            tonight: '今晚',
+            tomorrow_morning: '明天',//英文过长,简化
+            last_night: '昨晚',
+            this_morning: '今天',//英文过长,简化
+            tomorrow: '明天',
+            today: '今天',
+            sunset_to_sunrise: '日落到日出',
+            sunrise_to_sunset: '日出到日落',
+            time_to_sunset: '距日落',
+            time_to_sunrise: '距日出',
+            time_past_sunset: '已日落',
+            time_past_sunrise: '已日出',
+            night_duration: '时长',
+            day_duration: '时长',
+            overview: '概览',
+            events: '事件',
+            stages: '阶段',
+            get_local_time: '获取当前日落日出时间',
+            get_local_time_sunrise: '获取当前日出日落时间',
+            to:'至'
         },
         track_time_duration: {
             common: {
+                schedule: '日程',
+                current_schedule: '当前进程',
                 share_title: '我的断食睡眠日记',
                 start_fast: '开始断食',//正常态
                 started_fasting: '开始断食',//完成时
@@ -223,6 +236,9 @@ export default {
                 end_sleep: '结束睡眠',
                 ended_sleeping: '结束睡眠',
                 start_fasting_first: '开始断食后可设置',
+                okay: '好的',
+                im_ready: '我准备好了',
+                got_it: '好的'
             },
             third_ring: {
                 night_ring: '夜间',

+ 0 - 50
src/features/trackSomething/components/DayNightCard.scss

@@ -1,50 +0,0 @@
-.day_night_top{
-    display: flex;
-    flex-direction: row;
-    align-items: center;
-    color: #fff;
-}
-
-.day_night_title{
-    font-size: 32px;
-    line-height: 32px;
-    font-weight: bold;
-    
-}
-
-.free {
-    height: 36px;
-    border-radius: 18px;
-    font-size: 20px;
-    display: flex;
-    align-items: center;
-    justify-content: center;
-    padding-left: 16px;
-    padding-right: 16px;
-    margin-left: 16px;
-}
-
-.day_night_card_footer{
-    display: flex;
-    flex-direction: row;
-    justify-content: space-between;
-    align-items: center;
-    padding-top: 20px;
-    margin-top: 20px;
-    border-top-style: solid;
-    border-top-color: #D8D8D852;
-    border-top-width: 1px;
-}
-
-.day_night_value{
-    font-size: 36px;
-    font-weight: bold;
-    left: 0;
-    letter-spacing: -2px;
-}
-
-.day_night_desc{
-    font-size: 20px;
-    color: #fff;
-    opacity: 0.6;
-}

+ 10 - 7
src/features/trackTimeDuration/components/CircadianDetailPopup.tsx

@@ -104,7 +104,10 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
         if (props.record.status == 'COMPLETED') {
             return TimeFormatter.getDayOfWeek(new Date().getDay(), true)
         }
-        return 'Schedule'
+        if (props.record.status == 'WAIT_FOR_START') {
+            return t('feature.track_time_duration.common.schedule')
+        }
+        return t('feature.track_time_duration.common.current_schedule')
     }
 
     function getSubTitle() {
@@ -116,12 +119,12 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
 
     function getBottomText() {
         if (props.record.status == 'WAIT_FOR_START') {
-            return 'I\'m ready'
+            return t('feature.track_time_duration.common.im_ready')
         }
         if (props.record.status == 'COMPLETED') {
-            return 'Got it'
+            return t('feature.track_time_duration.common.got_it')
         }
-        return 'Okay'
+        return t('feature.track_time_duration.common.okay')
     }
     const startArc = (time: number) => {
         var date = new Date(time);
@@ -625,14 +628,14 @@ 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 className='detail_tabbar'>
-            <View onClick={() => { setTabIndex(0) }} className={tabIndex == 0 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>Overview</View>
+            <View onClick={() => { setTabIndex(0) }} className={tabIndex == 0 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>{t('feature.day_night.overview')}</View>
             {
                 props.record.status == 'COMPLETED' &&
                 (props.record.sleep && props.record.sleep.status == 'COMPLETED') &&
                 props.record.scenario == 'FAST_SLEEP' &&
-                <View onClick={() => { setTabIndex(1) }} className={tabIndex == 1 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>Stage</View>
+                <View onClick={() => { setTabIndex(1) }} className={tabIndex == 1 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>{t('feature.day_night.stages')}</View>
             }
-            <View onClick={() => { setTabIndex(2) }} className={tabIndex == 2 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>Events</View>
+            <View onClick={() => { setTabIndex(2) }} className={tabIndex == 2 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>{t('feature.day_night.events')}</View>
         </View>
         <View className='detail_content'>
             {

+ 104 - 0
src/features/trackTimeDuration/components/DayNightCard.scss

@@ -0,0 +1,104 @@
+@import '@/utils/common.scss';
+
+.day_night_top {
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    color: #fff;
+}
+
+.day_night_title {
+    font-size: 32px;
+    line-height: 32px;
+    font-weight: bold;
+
+}
+
+.free {
+    height: 36px;
+    border-radius: 18px;
+    font-size: 20px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    padding-left: 16px;
+    padding-right: 16px;
+    margin-left: 16px;
+}
+
+.day_night_card_footer {
+    display: flex;
+    flex-direction: row;
+    justify-content: space-between;
+    align-items: center;
+    padding-top: 20px;
+    margin-top: 20px;
+    border-top-style: solid;
+    border-top-color: #D8D8D852;
+    border-top-width: 1px;
+}
+
+.day_night_value {
+    font-size: 36px;
+    line-height: 36px;
+    font-weight: bold;
+    left: 0;
+}
+
+.day_night_desc {
+    font-size: 20px;
+    line-height: 20px;
+    color: #fff;
+    opacity: 0.6;
+    margin-top: 14px;
+}
+
+.day_night_card_btn {
+    // width: 598px;
+    height: 88px;
+    border-radius: 44px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    color: #000;
+    font-size: 28px;
+    font-weight: bold;
+}
+
+.buy_night {
+    background: linear-gradient(to right, #1446B9, #AAFF00);
+}
+
+.buy_day {
+    background: linear-gradient(to right, #C9DAFF, #AAFF00);
+}
+
+.day_location_btn {
+    background-color: #C9DAFF33;
+    color: #C9DAFF;
+    height: 58px;
+    padding-left: 32px;
+    padding-right: 32px;
+    border-radius: 29px;
+    text-align: center;
+    font-size: 20px;
+    font-weight: bold;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.night_location_btn {
+    background-color: #1446B933;
+    color: #1446B9;
+    height: 58px;
+    padding-left: 32px;
+    padding-right: 32px;
+    border-radius: 29px;
+    text-align: center;
+    font-size: 20px;
+    font-weight: bold;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}

+ 314 - 13
src/features/trackSomething/components/DayNightCard.tsx → src/features/trackTimeDuration/components/DayNightCard.tsx

@@ -14,6 +14,7 @@ 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'
 
 let useNavigation;
 if (process.env.TARO_ENV == 'rn') {
@@ -41,6 +42,7 @@ 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);
@@ -56,7 +58,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
 
 
     const [showDetailModal, setShowDetailModal] = useState(false)
-    const [showStageDetail, setShowStageDetail] = useState(false)
+    const [showDetailPopup, setShowDetailPopup] = useState(false)
     // const [locationDetail, setLocationDetail] = useState(null)
 
     const [nightDate, setNightDate] = useState(new Date())
@@ -105,6 +107,11 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         }
     }, [user.isLogin])
 
+    useEffect(() => {
+        locationDetail = global.locationDetail
+        setAuthInfo(locationDetail)
+    }, [global.locationDetail])
+
     useEffect(() => {
         if (locationDetail)
             updateDate(locationDetail)
@@ -134,6 +141,41 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         }
     }, [props.count])
 
+    useEffect(() => {
+        if (user.test_user && joingMember) {
+            auth()
+        }
+        if (!user.test_user) {
+            lastNightInfo = null
+            lastDayInfo = null
+            locationDetail = null
+            setAuthInfo(null)
+            setSunriseTime('06:00')
+            setSunriseTmrTime('06:00')
+            setSunsetTime('18:00')
+            dispatch(updateMember({ isMember: user.test_user, 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()
@@ -141,7 +183,8 @@ 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 (data && data.daylights && data.daylights.length > 0) {
+        if (user.test_user && data && data.daylights && data.daylights.length > 0) {
+            debugger
             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)
@@ -209,6 +252,24 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
             }
         }
         else {
+            locationDetail = null
+            setAuthInfo(null)
+            setSunriseTime('06:00')
+            setSunriseTmrTime('06:00')
+            setSunsetTime('18:00')
+            dispatch(updateMember({ isMember: user.test_user, 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'
+            }))
         }
 
     }
@@ -220,6 +281,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         ) {
             return
         }
+        debugger
         lastNightInfo = {
             date,
             sunrise,
@@ -260,7 +322,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         }
     }
 
-    function footer() {
+    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') :
@@ -270,7 +332,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
             {
                 authInfo && (authInfo as any).lat && <Text style={{ color: '#9E9E9E', fontSize: rpxToPx(20) }} onClick={(e) => {
                     e.stopPropagation()
-                    auth()
+                    auth(e)
                 }}>Edit Location</Text>
             }
         </View>
@@ -310,19 +372,24 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
     }
 
     function tapCard(e) {
-        if (process.env.TARO_ENV == 'weapp') {
-            e.stopPropagation()
-        }
+        // 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) {
+        if (!dayStore.showDayRing) {
             return
         }
+        setShowDetailPopup(true)
     }
 
-    function auth() {
+    function auth(e?: any) {
+        if (e && process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
+        joingMember = false;
         Taro.chooseLocation({
             success: function (res) {
                 var today = new Date()
@@ -518,6 +585,8 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
                         if (global.clearDayLocation) {
                             global.clearDayLocation()
                         }
+                        lastNightInfo = null
+                        lastDayInfo = null
                     })
                 } else if (res.cancel) {
                     console.log('用户点击取消')
@@ -560,7 +629,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
                 <Text>暂无位置信息</Text>
             </View>
         }
-        return <View>
+        return <View style={{ display: 'flex', flexDirection: 'column' }}>
             {
                 <View className="cell_bg">
                     {
@@ -600,11 +669,17 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
 
 
                 </View>
+
             }
+
+            <Text onClick={() => {
+                clearData()
+                setShowDetailModal(false)
+            }} style={{ width: '100%', textAlign: 'center', marginBottom: 50, color: '#fff', marginTop: 20 }}>清除位置</Text>
         </View>
     }
 
-    function modalContent() {
+    function modalContent2() {
         if (process.env.TARO_ENV == 'weapp') {
             return <Modal
                 testInfo={null}
@@ -641,6 +716,64 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         }
     }
 
+    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) {
@@ -674,13 +807,181 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
     }
 
+    function nightDuration() {
+        if (!authInfo || !(authInfo as any).lat) {
+            if (new Date().getHours() >= 6) {
+                return `${sunsetTime} - ${sunriseTmrTime}`
+            }
+            return `${sunsetTime} - ${sunriseTmrTime}`
+            // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+        }
+        if (nightDate.getDate() == new Date().getDate()) {
+            return `${sunsetTime} - ${sunriseTmrTime}`
+        }
+        return `${sunsetTime} - ${sunriseTmrTime}`
+        //`Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+    }
+
+    function dayDuration() {
+        if (!authInfo || !(authInfo as any).lat) {
+            if (new Date().getHours() >= 18) {
+                return `${sunriseTime} - ${sunsetTime}`
+
+                // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
+            }
+            return `${sunriseTime} - ${sunsetTime}`
+            // return `Today ${sunriseTime} - ${sunsetTime}`
+        }
+        if (dayDate.getDate() == new Date().getDate()) {
+            return `${sunriseTime} - ${sunsetTime}`
+            // return `Today ${sunriseTime} - ${sunsetTime}`
+        }
+        return `${sunriseTime} - ${sunsetTime}`
+        // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
+    }
+
+    function nightDurationDesc1() {
+        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 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)
+    }
 
+    return <View style={{ color: '#fff' }} onLongPress={longClick}>
+        <Box onClick={tapCard}>
+            <View style={{marginTop:-rpxToPx(16)}}>
+                <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 ? dayStore.showDayRing : 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 })
+                            }
+
+
+                        }}
+                    />
+                </View>
+                {
+                    user.isLogin && dayStore.showDayRing && <View style={{ marginTop:rpxToPx(40) }}>
+                        <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
+                            <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>
+
+                        </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 className='day_night_card_btn' style={{ backgroundColor: props.isNight ? ColorType.night : ColorType.day }} onClick={auth}>{
+                                            props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')
+                                        }</View>
+
+
+                            }
+                        </View>
+                    </View>
+                }
+
+            </View>
+        </Box >
+        {
+            showDetailPopup && modalContent()
+        }
+        {
+            showDetailModal && modalContent2()
+        }
+    </View >
+
+    /*
     return <View style={{ color: '#fff' }}>
         <Box onClick={tapCard}>
             <View>
                 <View className='day_night_top'>
-                    <Text className='day_night_title'>{props.isNight ? t('feature.day_night.night_ring') : t('feature.day_night.day_ring')}</Text>
+                    {
+                        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>
                     }
@@ -754,5 +1055,5 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         {
             showDetailModal && modalContent()
         }
-    </View>
+    </View>*/
 }

+ 298 - 0
src/features/trackTimeDuration/components/DayNightDetailPopup.tsx

@@ -0,0 +1,298 @@
+import { View, Text } from '@tarojs/components'
+import './CircadianDetailPopup.scss'
+import { useTranslation } from 'react-i18next'
+import { useState } from 'react'
+import { rpxToPx } from '@/utils/tools'
+import { TimeFormatter } from '@/utils/time_format'
+import { useSelector } from 'react-redux'
+import { ColorType } from '@/context/themes/color'
+import Timeline from '@/components/view/Timeline'
+
+export default function DayNightDetailPopup(props: {
+    isNight: boolean,
+    authInfo: any,
+    sunsetDate: any,
+    sunriseDate: any,
+    sunriseTmrDate: any,
+    sunsetTime: any,
+    sunriseTime: any,
+    sunriseTmrTime: any,
+    nightDate:any,
+    dayDate:any,
+    onClose: Function
+}) {
+    const dayNight = useSelector((state: any) => state.night);
+    const day = useSelector((state: any) => state.day);
+    const [tabIndex, setTabIndex] = useState(0)
+    const { t } = useTranslation()
+
+    function getTitle() {
+        return props.isNight ? t('feature.day_night.night_popover') : t('feature.day_night.day_popover')
+    }
+
+    function nightDuration() {
+
+        var sunRiseObj = dayNight.nightRingSunrise
+        var sunSetObj = dayNight.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);
+    }
+
+    function dayDuration() {
+        var sunRiseObj = day.dayRingSunrise
+        var sunSetObj = day.dayRingSunset
+        var sunRise = 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 = (sunSet - sunRise) * 60 * 1000
+
+        return TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
+    }
+
+    function showExtraData() {
+        var now = new Date()
+        if (props.isNight) {
+            if (props.sunsetDate.getTime() > now.getTime()) {
+                return false
+            }
+            return true
+        }
+        if (props.sunriseDate.getTime() < now.getTime() && now.getTime() < props.sunsetDate.getTime()) {
+            return true;
+        }
+        return false
+    }
+
+    function timeCount() {
+        var now = new Date()
+        if (props.isNight) {
+            if (now.getTime() < props.sunriseTmrDate.getTime()) {
+                return TimeFormatter.countdown(props.sunsetDate.getTime())
+            }
+            return TimeFormatter.countdown(props.sunsetDate.getTime())
+        } else {
+
+            if (now.getTime() < props.sunsetDate.getTime()) {
+                return TimeFormatter.countdown(props.sunriseDate.getTime())
+            }
+            return TimeFormatter.countdown(props.sunriseTmrDate.getTime())
+
+
+        }
+    }
+
+    function timeCount2() {
+        var now = new Date()
+        if (props.isNight) {
+
+            if (now.getTime() < props.sunsetDate.getTime()) {
+                return TimeFormatter.countdown(props.sunriseTmrDate.getTime())
+            }
+            return TimeFormatter.countdown(props.sunriseTmrDate.getTime())
+
+        } else {
+            return TimeFormatter.countdown(props.sunsetDate.getTime())
+        }
+    }
+
+    function timeDesc() {
+        var now = new Date()
+        if (props.isNight) {
+            var list = props.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 = props.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 = props.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 = props.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 overview() {
+        return <View className='pop_ring_bg pop_overview_bg'>
+            <Text className='pop_duration_title'>{props.isNight ? t('feature.day_night.night_duration') : t('feature.day_night.day_duration')}</Text>
+            <View style={{ flexDirection: 'row', alignItems: 'center', marginTop: rpxToPx(8), display: 'flex', width: '100%' }}>
+                <Text className='pop_duration_txt'>{props.isNight ? nightDuration() : dayDuration()}</Text>
+            </View>
+            <View style={{ marginTop: rpxToPx(20), display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
+                <View className='countdown_time_bg'>
+                    <Text className='title'>{timeDesc()}</Text>
+                    <Text className='value' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{timeCount()}</Text>
+                </View>
+                {
+                    showExtraData() && <View className='countdown_time_bg'>
+                        <Text className='title'>{timeDesc2()}</Text>
+                        <Text className='value' style={{ opacity: 0.4, color: props.isNight ? ColorType.night : ColorType.day }}>{timeCount2()}</Text>
+                    </View>
+                }
+
+            </View>
+        </View>
+    }
+
+    function nightDurationDesc() {
+        if (!props.authInfo || !(props.authInfo as any).lat) {
+            if (new Date().getHours() >= 6) {
+                return [t('feature.day_night.tonight'),t('feature.day_night.tomorrow_morning')]
+            }
+            return [t('feature.day_night.last_night'),t('feature.day_night.this_morning')]
+            // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+        }
+        if (props.nightDate.getDate() == new Date().getDate()) {
+            return [t('feature.day_night.tonight'),t('feature.day_night.tomorrow_morning')]
+        }
+        return [t('feature.day_night.last_night'),t('feature.day_night.this_morning')]
+        //`Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
+    }
+
+    function dayDurationDesc() {
+        if (!props.authInfo || !(props.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 (props.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 events() {
+        let timelineItems: any = []
+        
+        if (props.isNight) {
+            var list = nightDurationDesc()
+            timelineItems.push(
+                {
+                    status: showExtraData() ? 'done' : 'padding',
+                    title: '日落',//list[0],
+                    content: list[0]+props.sunsetTime,
+                    date: '',
+                    color: ColorType.night
+                }
+            )
+
+            timelineItems.push(
+                {
+                    status: 'padding',
+                    title: '日出',//list[1],
+                    content: list[1]+props.sunriseTmrTime,
+                    date: '',
+                    color: ColorType.night
+                }
+            )
+        }
+        else {
+            timelineItems.push(
+                {
+                    status: showExtraData() ? 'done' : 'padding',
+                    title: '日出',//dayDurationDesc(),
+                    content: dayDurationDesc()+props.sunriseTime,
+                    date: '',
+                    color: ColorType.day
+                }
+            )
+
+            timelineItems.push(
+                {
+                    status: 'padding',
+                    title: '日落',//dayDurationDesc(),
+                    content: dayDurationDesc()+props.sunsetTime,
+                    date: '',
+                    color: ColorType.day
+                }
+            )
+        }
+        return <View style={{ display: 'flex', flexDirection: 'row' }}>
+            <Timeline items={timelineItems} title='' width={468} />
+        </View>
+    }
+
+    return <View className='detail_container'>
+        <Text className='detail_popup_title'>{getTitle()}</Text>
+        <View className='detail_tabbar'>
+            <View onClick={() => { setTabIndex(0) }} className={tabIndex == 0 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>{t('feature.day_night.overview')}</View>
+            <View onClick={() => { setTabIndex(1) }} className={tabIndex == 1 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>{t('feature.day_night.events')}</View>
+        </View>
+
+        <View className='detail_content'>
+            {
+                tabIndex == 0 ? overview() : events()
+            }
+        </View>
+        <View className='detail_bottom'>
+            <View className='detail_bottom_btn' onClick={(e) => {
+                if (process.env.TARO_ENV == 'weapp') {
+                    e.stopPropagation()
+                }
+                props.onClose();
+            }}>{t('feature.track_time_duration.common.okay')}</View>
+        </View>
+    </View>
+}

+ 41 - 21
src/features/trackTimeDuration/components/Discovery.tsx

@@ -13,9 +13,12 @@ import { useTranslation } from "react-i18next";
 import { TimeFormatter } from "@/utils/time_format";
 import { getPerm, uploadPerm } from "@/services/user";
 import Box from "@/components/layout/Box";
-import { getPlans } from "@/services/trackTimeDuration";
-import DayNightCard from "@/features/trackSomething/components/DayNightCard";
+import { getPlans, setPlan } from "@/services/trackTimeDuration";
+import DayNightCard from "@/features/trackTimeDuration/components/DayNightCard";
 import { clearDayStore } from "@/store/day";
+import { AtActivityIndicator } from "taro-ui";
+import NoData from "@/components/view/NoData";
+// import AtActivityIndicator from "taro-ui/types/activity-indicator";
 
 
 let useNavigation;
@@ -25,6 +28,8 @@ if (process.env.TARO_ENV == 'rn') {
 
 let pauseTimer = false
 
+const defaultValue = `{"scenarios":[{"name":"FAST","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"}}},{"name":"SLEEP","count":0,"schedule":{"sleep":{"start_time":"22:00","end_time":"07:00"}}},{"name":"FAST_SLEEP","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"},"sleep":{"start_time":"22:00","end_time":"07:00"}}}],"select_count":0,"theme_color":{"fast":"#00FFFF","sleep":"#8183FF"}}`
+
 export default function Discovery() {
     const user = useSelector((state: any) => state.user);
     const day = useSelector((state: any) => state.day);
@@ -32,6 +37,7 @@ export default function Discovery() {
     const [schedule, setSchedule] = useState(null)
     const [count, setCount] = useState(0)
     const [loaded, setLoaded] = useState(false)
+    const [showErrorPage, setErrorPage] = useState(false)
     const dispatch = useDispatch();
     const { t } = useTranslation()
 
@@ -53,7 +59,7 @@ export default function Discovery() {
     }, [])
 
     useDidShow(() => {
-        setCount(pre=>pre+1)
+        setCount(pre => pre + 1)
         //resume timer
         pauseTimer = false
     })
@@ -63,23 +69,32 @@ export default function Discovery() {
         pauseTimer = true
     })
 
-    useEffect(()=>{
+    useEffect(() => {
         if (!user.isLogin) {
             dispatch(clearDayStore());
         }
-    },[user.isLogin])
+    }, [user.isLogin])
 
     // useEffect(() => {
     //     setSchedule(global.homeData.scenarios)
     // }, [global.homeData])
 
     useEffect(() => {
+        getPlanData()
+        setCount(pre => pre + 1)
+    }, [user.isLogin])
+
+    function getPlanData() {
         getPlans().then(res => {
             setSchedule((res as any).scenarios)
             setLoaded(true)
+            setErrorPage(false)
+        }).catch(e => {
+            setSchedule(JSON.parse(defaultValue))
+            setLoaded(true)
+            setErrorPage(true)
         })
-        setCount(pre=>pre+1)
-    }, [user.isLogin])
+    }
 
     function getFoodTime() {
         if (ring.schedule) {
@@ -391,23 +406,23 @@ export default function Discovery() {
 
     function activityDuration() {
         var list = getActivityTime()
-        var start = parseInt(list[0].split(':')[0]) * 3600 + parseInt(list[0].split(':')[1])*60
-        var end = parseInt(list[1].split(':')[0]) * 3600 + parseInt(list[1].split(':')[1])*60
+        var start = parseInt(list[0].split(':')[0]) * 3600 + parseInt(list[0].split(':')[1]) * 60
+        var end = parseInt(list[1].split(':')[0]) * 3600 + parseInt(list[1].split(':')[1]) * 60
         if (ring.current_record) {
             if (ring.current_record.scenario == 'SLEEP') {
                 if (ring.current_record.status == 'ONGOING') {
                     var startDate = new Date(ring.current_record.sleep.target_start_time)
                     var endDate = new Date(ring.current_record.sleep.target_end_time)
-                    end = startDate.getHours() * 3600 + startDate.getMinutes()*60+startDate.getSeconds()
-                    start = endDate.getHours() * 3600 + endDate.getMinutes()*60+endDate.getSeconds()
+                    end = startDate.getHours() * 3600 + startDate.getMinutes() * 60 + startDate.getSeconds()
+                    start = endDate.getHours() * 3600 + endDate.getMinutes() * 60 + endDate.getSeconds()
                 }
             }
             else {
                 if (ring.current_record.status == 'ONGOING2') {
                     var startDate = new Date(ring.current_record.sleep.target_start_time)
                     var endDate = new Date(ring.current_record.sleep.target_end_time)
-                    end = startDate.getHours() * 3600 + startDate.getMinutes()*60+startDate.getSeconds()
-                    start = endDate.getHours() * 3600 + endDate.getMinutes()*60+endDate.getSeconds()
+                    end = startDate.getHours() * 3600 + startDate.getMinutes() * 60 + startDate.getSeconds()
+                    start = endDate.getHours() * 3600 + endDate.getMinutes() * 60 + endDate.getSeconds()
                 }
                 else if (ring.current_record.status == 'ONGOING3') {
                     //睡眠已完成时,睡眠小于24小时,使用真实的real_end_time-real_start_time
@@ -415,19 +430,19 @@ export default function Discovery() {
                     if (ring.current_record.sleep.real_end_time - ring.current_record.sleep.real_start_time < 24 * 3600 * 1000) {
                         var startDate = new Date(ring.current_record.sleep.real_start_time)
                         var endDate = new Date(ring.current_record.sleep.real_end_time)
-                        end = startDate.getHours() * 3600 + startDate.getMinutes()*60+startDate.getSeconds()
-                        start = endDate.getHours() * 3600 + endDate.getMinutes()*60+endDate.getSeconds()
+                        end = startDate.getHours() * 3600 + startDate.getMinutes() * 60 + startDate.getSeconds()
+                        start = endDate.getHours() * 3600 + endDate.getMinutes() * 60 + endDate.getSeconds()
                     }
                     else {
                         var startDate = new Date(ring.current_record.sleep.real_end_time)
                         var durationTemp = start - end//ring.current_record.sleep.target_end_time-ring.current_record.sleep.target_start_time
-                        
+
                         if (durationTemp < 0) {
                             durationTemp += 24 * 3600
                         }
-                        var endDate = new Date(startDate.getTime() + durationTemp*1000 )
-                        end = startDate.getHours() * 3600 + startDate.getMinutes()*60+startDate.getSeconds()
-                        start = endDate.getHours() * 3600 + endDate.getMinutes()*60+endDate.getSeconds()
+                        var endDate = new Date(startDate.getTime() + durationTemp * 1000)
+                        end = startDate.getHours() * 3600 + startDate.getMinutes() * 60 + startDate.getSeconds()
+                        start = endDate.getHours() * 3600 + endDate.getMinutes() * 60 + endDate.getSeconds()
                         debugger
                         console.log('active', end, start, durationTemp)
                     }
@@ -438,7 +453,7 @@ export default function Discovery() {
         if (end < start) {
             end += 24 * 3600
         }
-        var duration = (end - start)*1000
+        var duration = (end - start) * 1000
         return TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
     }
 
@@ -469,7 +484,9 @@ export default function Discovery() {
     }
 
     if (!loaded) {
-        return <View />
+        return <View style={{ width: rpxToPx(750), height: rpxToPx(900), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
+            <AtActivityIndicator size={40} color="#fff" />
+        </View>
     }
 
     return <View style={{ display: 'flex', flexDirection: 'column' }}>
@@ -529,6 +546,9 @@ export default function Discovery() {
         </Box>
 
         <DayNightCard isNight={false} count={count} />
+        {
+            showErrorPage && <NoData refresh={() => { getPlanData() }} />
+        }
 
     </View>
 }

+ 9 - 8
src/features/trackTimeDuration/components/IndexItem.tsx

@@ -26,6 +26,7 @@ export default function Component(props: { type: string, data: any, time: any, s
     const [record, setRecord] = useState(props.data.current_record);
     const user = useSelector((state: any) => state.user);
     const dayNight = useSelector((state: any) => state.night);
+    const day = useSelector((state: any) => state.day);
     const ring = useSelector((state: any) => state.ring);
     const [stageList, setStageList] = useState([true, false, false])
     const [isStageMode, setIsStageMode] = useState(false)
@@ -334,7 +335,7 @@ export default function Component(props: { type: string, data: any, time: any, s
                 </View>
             }
             {
-                !props.showStage && dayNight.showNightRing === true && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
+                !props.showStage && day.showDayRing === true && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
                     {
                         dayRing()
                     }
@@ -491,23 +492,23 @@ export default function Component(props: { type: string, data: any, time: any, s
     }}>
         <View className="time_operate_item1" onClick={goDetail}>
             <View className="fast_sleep_item" style={{
-                marginTop: !props.showStage && dayNight.showNightRing === true ? -6 : 0,
-                marginBottom: !props.showStage && dayNight.showNightRing === true ? -6 : 0,
-                marginLeft: !props.showStage && dayNight.showNightRing === true ? -6 : 0,
-                padding: !props.showStage && dayNight.showNightRing === true ? 14 : 0,
+                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,
                 paddingRight: 0,
 
             }}>
                 {
                     rings()
                 }
-                <View className="duration_bg2" style={{ marginLeft: !props.showStage && dayNight.showNightRing === true ? rpxToPx(68) : rpxToPx(52), height: bigRingRadius * 2, overflow: 'visible' }}>
+                <View className="duration_bg2" style={{ marginLeft: !props.showStage && day.showDayRing === true ? rpxToPx(68) : rpxToPx(52), height: bigRingRadius * 2, overflow: 'visible' }}>
                     {
-                        !props.showStage && dayNight.showNightRing === true &&
+                        !props.showStage && day.showDayRing === true &&
                         <Text className="duration_title2">{t('feature.common.overnight')}</Text>
                     }
                     {
-                        !props.showStage && dayNight.showNightRing === true &&
+                        !props.showStage && day.showDayRing === true &&
                         <Text className="duration_value2" style={{ color: ColorType.night }}>{nightDuration()}</Text>
                     }
                     {

+ 5 - 0
src/features/trackTimeDuration/components/WeekCalendarItem.scss

@@ -65,6 +65,11 @@
     height: 2px;
 }
 
+.currentLine{
+    -webkit-transform: scaleY(0.5);
+    transform: scaleY(0.5);
+    height: 2px;
+}
 .lineContent{
     position: absolute;
     top: 0;

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

@@ -110,12 +110,11 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
 
         <View className="chart_detail">
             {
-                showCurrentTime && <View style={{
+                showCurrentTime && <View className="currentLine" style={{
                     position: 'absolute',
                     left: position.left,
                     top: position.top,
                     width: rpxToPx(94),
-                    height: 1,
                     backgroundColor: 'red'
                 }} />
             }

+ 21 - 16
src/pages/clock/Index.tsx

@@ -33,7 +33,7 @@ import ClockHeader from "@/features/trackTimeDuration/components/ClockHeader";
 import DurationPicker from "@/features/trackTimeDuration/components/DurationPicker";
 import SegmentPop from "@/features/trackTimeDuration/components/SegmentPop";
 import Box from "@/components/layout/Box";
-import DayNightCard from "@/features/trackSomething/components/DayNightCard";
+import DayNightCard from "@/features/trackTimeDuration/components/DayNightCard";
 import StageSelector from "@/features/trackTimeDuration/components/StageSelector";
 import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
 import { clearNightStore, showNight } from "@/store/night";
@@ -85,7 +85,7 @@ export default function Page() {
     const [records, setRecords] = useState([])
 
 
-
+    const nightStore = useSelector((state: any) => state.night);
 
 
     useEffect(() => {
@@ -136,14 +136,14 @@ export default function Page() {
 
         }
 
-        if (process.env.TARO_ENV == 'weapp') {
-            useShareAppMessage((e) => {
-                return {
-                    title: t('feature.track_time_duration.common.share_title'),
-                    path: 'pages/clock/Clock'
-                }
-            })
-        }
+        // if (process.env.TARO_ENV == 'weapp') {
+        //     useShareAppMessage((e) => {
+        //         return {
+        //             title: t('feature.track_time_duration.common.share_title'),
+        //             path: 'pages/clock/Clock'
+        //         }
+        //     })
+        // }
 
     })
 
@@ -152,6 +152,14 @@ export default function Page() {
         setCount(pre => pre + 1)
         //resume timer
         pauseTimer = false
+
+        if (user.isLogin){
+            getInfo().then(res => {
+                dispatch(getInfoSuccess(res))
+            }).catch(e => {
+                Taro.stopPullDownRefresh()
+            })
+        }
     })
 
     useDidHide(() => {
@@ -201,7 +209,8 @@ export default function Page() {
         clientInfo({
             client: {
                 client_type: process.env.TARO_ENV == 'weapp' ? 'MP' : 'APP',
-                client_version: process.env.TARO_ENV == 'weapp' ? Taro.getAccountInfoSync().miniProgram.version : '1.0'//'1.0'
+                client_version: process.env.TARO_ENV == 'weapp' ? Taro.getAccountInfoSync().miniProgram.version : '1.0',//'1.0'
+                wx_version:process.env.TARO_ENV == 'weapp' ?systemInfo.version:'_'
             },
             meta: {
                 language: systemInfo.language,
@@ -422,11 +431,6 @@ export default function Page() {
             return '';
         }
     }
-    if (!homeData) {
-        return <View>
-            <Tabbar index={0} />
-        </View>
-    }
 
     function more() {
         jumpPage('/pages/common/RecordsHistory?type=time&title=time', 'RecordsHistory', navigation, {
@@ -452,6 +456,7 @@ export default function Page() {
         if (!loaded) {
             return <View style={{ width: rpxToPx(750), height: rpxToPx(900), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                 <AtActivityIndicator size={40} color="#fff"/>
+                <Tabbar index={0} />
             </View>
         }
         return <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>

+ 3 - 1
src/services/trackTimeDuration.tsx

@@ -4,11 +4,13 @@ import { API_FAST_PLANS, API_FAST_CHECKS, API_FAST_CLOCKS, API_CLOCK_RECORDS, AP
 import { request } from './http/request';
 
 export const getPlans = () => {
-    return new Promise((resolve) => {
+    return new Promise((resolve,reject) => {
         request({
             url: API_FAST_PLANS, method: 'GET', data: {}
         }).then(res => {
             resolve(res);
+        }).catch(e=>{
+            reject(e)
         })
     })
 }

+ 5 - 5
src/store/day.tsx

@@ -1,7 +1,7 @@
 import { createSlice } from "@reduxjs/toolkit";
 
 
-interface dayNightState {
+interface dayState {
     sunRise: string | '06:00',
     sunSet: string | '18:00',
     sunRiseTomorrow: string | '06:00',
@@ -14,7 +14,7 @@ interface dayNightState {
     dayRingDate: any | null,
 }
 
-const initialState: dayNightState = {
+const initialState: dayState = {
     sunRise: '06:00',
     sunSet: '18:00',
     sunRiseTomorrow: '06:00',
@@ -27,7 +27,7 @@ const initialState: dayNightState = {
     dayRingDate: 0,
 }
 
-const dayNightSlice = createSlice({
+const daySlice = createSlice({
     name: 'day',
     initialState,
     reducers: {
@@ -73,5 +73,5 @@ const dayNightSlice = createSlice({
     }
 });
 
-export default dayNightSlice.reducer;
-export const { showDay, updateMember, setDayRingData, clearDayStore } = dayNightSlice.actions;
+export default daySlice.reducer;
+export const { showDay, updateMember, setDayRingData, clearDayStore } = daySlice.actions;

+ 7 - 5
src/store/night.tsx

@@ -1,7 +1,7 @@
 import { createSlice } from "@reduxjs/toolkit";
 
 
-interface dayNightState {
+interface nightState {
     sunRise: string | '06:00',
     sunSet: string | '18:00',
     sunRiseTomorrow: string | '06:00',
@@ -14,7 +14,7 @@ interface dayNightState {
     nightRingDate: any | null
 }
 
-const initialState: dayNightState = {
+const initialState: nightState = {
     sunRise: '06:00',
     sunSet: '18:00',
     sunRiseTomorrow: '06:00',
@@ -27,12 +27,14 @@ const initialState: dayNightState = {
     nightRingDate: 0,
 }
 
-const dayNightSlice = createSlice({
+const nightSlice = createSlice({
     name: 'night',
     initialState,
     reducers: {
         showNight(state, action) {
             state.showNightRing = action.payload;
+
+            debugger
         },
         setNightRingData(state, action) {
             const { sunrise, sunset, date } = action.payload
@@ -73,5 +75,5 @@ const dayNightSlice = createSlice({
     }
 });
 
-export default dayNightSlice.reducer;
-export const { showNight, updateMember, setNightRingData, clearNightStore } = dayNightSlice.actions;
+export default nightSlice.reducer;
+export const { showNight, updateMember, setNightRingData, clearNightStore } = nightSlice.actions;