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

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

@@ -0,0 +1,35 @@
+.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;
+    align-items: center;
+    padding-top: 20px;
+    margin-top: 20px;
+    border-top-style: solid;
+    border-top-color: #D8D8D852;
+    border-top-width: 1px;
+}

+ 386 - 0
src/features/trackSomething/components/DayNightCard.tsx

@@ -0,0 +1,386 @@
+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, 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 { updateMember } from '@/store/day_night'
+import Modal from '@/components/layout/Modal.weapp'
+import { rpxToPx } from '@/utils/tools'
+
+export default function DayNightCard(props: { isNight: boolean, switchChanged: Function }) {
+    const [expand, setExpand] = useState(false)
+    const user = useSelector((state: any) => state.user);
+    const [authInfo, setAuthInfo] = useState(null)
+    const [count, setCount] = useState(0)
+    const [sunriseTime, setSunriseTime] = useState('06:00')
+    const [sunriseTmrTime, setSunriseTmrTime] = useState('06:00')
+    const [sunsetTime, setSunsetTime] = useState('18:00')
+    const [showDetailModal, setShowDetailModal] = useState(false)
+    const dispatch = useDispatch();
+    const { t } = useTranslation()
+
+    useEffect(() => {
+        if (user.isLogin) {
+            getPerm({}).then(res => {
+                setExpand(props.isNight ? (res as any).show_night_ring : (res as any).show_day_ring)
+            })
+
+        }
+        getContent()
+    }, [user.isLogin])
+
+    useEffect(() => {
+        setInterval(() => {
+            setCount((prevCounter) => prevCounter + 1)
+        }, 1000)
+    }, [])
+
+    useDidShow(() => {
+        getContent()
+    })
+
+    async function getContent() {
+        const isShow = await getStorage(props.isNight ? 'showNightRing' : 'showDayRing') || false
+        setExpand(isShow)
+
+        const gpsInfo = await getStorage('gps') || null
+        if (gpsInfo) {
+            var data = JSON.parse(gpsInfo)
+            setAuthInfo(data)
+            setSunriseTime((data as any).daylights[0].sunrise)
+            setSunriseTmrTime((data as any).daylights[1].sunrise)
+            setSunsetTime((data as any).daylights[0].sunset)
+            dispatch(updateMember({ isMember: user.test_user, gpsInfo: data }))
+        }
+        else {
+            setSunriseTime('06:00')
+            setSunriseTmrTime('06:00')
+            setSunsetTime('18:00')
+            setAuthInfo(null)
+        }
+        if (props.isNight) {
+            global.showNightRing = isShow
+            global.refreshIndex()
+        }
+        else {
+            props.switchChanged(isShow)
+        }
+    }
+
+    async function getStorage(key: string) {
+        try {
+            const res = await Taro.getStorage({ key });
+            return res.data;
+        } catch {
+            return '';
+        }
+    }
+
+    function footer() {
+        return <View className='day_night_card_footer'>
+            <Text style={{color:'#9E9E9E',fontSize:rpxToPx(20)}}>{
+                // !isMember ? t('feature.track_time_duration.third_ring.member_desc') :
+                authInfo ? t('feature.track_time_duration.third_ring.base_location_desc') :
+                    t('feature.track_time_duration.third_ring.enter_location_desc')
+            }</Text>
+        </View>
+    }
+
+    function tapCard(e) {
+        if (!user.isLogin) {
+            return
+        }
+        Taro.showActionSheet({
+            itemList: [
+                'Current location Info',
+                'Choose a new location',
+                'clear location data'
+                //t('feature.track_time_duration.action_sheet.switch_scenario'),
+                //t('feature.track_time_duration.action_sheet.change_schedule')
+            ]
+        }).then(res => {
+            switch (res.tapIndex) {
+                case 0:
+                    setShowDetailModal(true)
+                    break
+                case 1:
+                    auth()
+                    break;
+                case 2:
+                    clearData()
+                    break;
+            }
+        })
+    }
+
+    function auth() {
+        Taro.chooseLocation({
+            success: function (res) {
+                console.log(res)
+                var today = new Date()
+                var tomorrow = new Date(today.getTime() + 24 * 3600 * 1000)
+                var strToday = `${today.getFullYear()}-${TimeFormatter.padZero(today.getMonth() + 1)}-${TimeFormatter.padZero(today.getDate())}`
+                var strTomorrow = `${tomorrow.getFullYear()}-${TimeFormatter.padZero(tomorrow.getMonth() + 1)}-${TimeFormatter.padZero(tomorrow.getDate())}`
+
+                systemLocation({ lat: res.latitude, lng: res.longitude, date_start: strToday, date_end: strTomorrow }).then(data => {
+                    console.log(data);
+                    (data as any).latitude = res.latitude;
+                    (data as any).longitude = res.longitude;
+                    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: user.test_user, gpsInfo: (data as any) }))
+                })
+
+            },
+            fail(res) {
+                Taro.showToast({
+                    title: '位置修改失败!\n请重新选择就近位置',
+                    icon: 'none'
+                })
+            },
+        })
+
+    }
+
+    function getLocation() {
+        if ((authInfo as any).address.city.length > 0) {
+            return (authInfo as any).address.city
+        }
+        if ((authInfo as any).address.province.length > 0) {
+            return (authInfo as any).address.province
+        }
+        if ((authInfo as any).address.country.length > 0) {
+            return (authInfo as any).address.country
+        }
+        return t('feature.track_time_duration.third_ring.unknown')
+
+    }
+
+    function timeCount() {
+        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)
+            return TimeFormatter.countdown(now.getTime())
+        } 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)
+            return TimeFormatter.countdown(now.getTime())
+        }
+    }
+
+    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)
+            if (now.getTime() < new Date().getTime()) {
+                return 'Time past Sunset'
+            }
+            return '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)
+            if (now.getTime() < new Date().getTime()) {
+                return 'Time past Sunrise'
+            }
+            return 'Time to Sunrise'
+        }
+    }
+
+    function clearData() {
+        Taro.showModal({
+            title: '提示',
+            content: '确认清除位置数据?',
+            success: function (res) {
+                if (res.confirm) {
+                    clearLocation().then(res => {
+                        Taro.removeStorage({ key: 'gps' })
+                        setAuthInfo(null)
+                        setSunriseTime('06:00')
+                        setSunriseTmrTime('06:00')
+                        setSunsetTime('18:00')
+                        dispatch(updateMember({ isMember: user.test_user, gpsInfo: null }))
+                    })
+                } else if (res.cancel) {
+                    console.log('用户点击取消')
+                }
+            }
+        })
+    }
+
+    function detailModalContent() {
+        var split = new Date().toString().split(' ');
+        var timezone = split[split.length - 2];
+        if (!authInfo) {
+            return <View>
+                <Text>暂时位置信息</Text>
+            </View>
+        }
+        return <View>
+            {
+                <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).latitude}</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).longitude}</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>
+            }
+        </View>
+    }
+
+    function modalContent() {
+        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>
+        }
+    }
+
+    return <View style={{ color: '#fff' }}>
+        <Box onClick={tapCard}>
+            <View>
+                <View className='day_night_top'>
+                    <Text className='day_night_title'>{props.isNight ? 'Overnight' : 'Day'}</Text>
+                    <View className='free'>限时免费</View>
+                    <View style={{ flex: 1 }} />
+                    <Switch checked={expand}
+                        color={props.isNight ? ColorType.night : ColorType.day}
+                        onClick={(e) => { e.stopPropagation() }}
+                        onChange={(e) => {
+                            props.switchChanged(e.detail.value)
+                            e.stopPropagation()
+                            setExpand(e.detail.value)
+                            if (props.isNight) {
+                                global.showNightRing = e.detail.value
+                                global.refreshIndex()
+                            }
+
+                            Taro.setStorage({
+                                key: props.isNight ? 'showNightRing' : 'showDayRing',
+                                data: e.detail.value
+                            })
+
+                            if (user.isLogin) {
+                                if (props.isNight) {
+                                    uploadPerm({ show_night_ring: e.detail.value })
+                                }
+                                else {
+                                    uploadPerm({ show_day_ring: e.detail.value })
+                                }
+                            }
+
+
+                        }}
+                    />
+                </View>
+                <View style={{ display: 'flex', flexDirection: 'column' }}>
+                    <Text style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? `Today ${sunsetTime} - Tomorrow ${sunriseTmrTime}` : `${sunriseTime} - ${sunsetTime}`}</Text>
+                    <Text>{props.isNight ? 'Sunset to Sunrise' : 'Sunrise to Sunset'}</Text>
+                    <Text style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{timeCount()}</Text>
+                    <Text>{timeDesc()}</Text>
+                </View>
+                {
+                    footer()
+                }
+            </View>
+        </Box>
+        {
+            showDetailModal && modalContent()
+        }
+    </View>
+}

+ 9 - 2
src/features/trackTimeDuration/components/CircadianDetailPopup.tsx

@@ -102,11 +102,18 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
 
 
     function getTitle() {
     function getTitle() {
         if (props.record.status == 'COMPLETED') {
         if (props.record.status == 'COMPLETED') {
-            return 'Thursday'
+            return TimeFormatter.getDayOfWeek(new Date().getDay(),true)
         }
         }
         return 'Schedule'
         return 'Schedule'
     }
     }
 
 
+    function getSubTitle(){
+        if (props.record.status == 'COMPLETED') {
+            return TimeFormatter.getMonthAndDayByTimestamp(props.record.first_real_check_time)
+        }
+        return ''
+    }
+
     function getBottomText() {
     function getBottomText() {
         if (props.record.status == 'WAIT_FOR_START') {
         if (props.record.status == 'WAIT_FOR_START') {
             return 'I\'m ready'
             return 'I\'m ready'
@@ -604,7 +611,7 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
 
 
 
 
     return <View className='detail_container'>
     return <View className='detail_container'>
-        <Text className='detail_popup_title'>{getTitle()}<Text className='detail_popup_subttitle'> dddd</Text></Text>
+        <Text className='detail_popup_title'>{getTitle()}<Text className='detail_popup_subttitle'> {getSubTitle()}</Text></Text>
         <View className='detail_tabbar'>
         <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'}>Overview</View>
             {
             {

+ 13 - 8
src/features/trackTimeDuration/components/ClockHeader.tsx

@@ -47,21 +47,26 @@ export default function ClockHeader(props: { homeData: any }) {
 
 
     useEffect(() => {
     useEffect(() => {
         if (props.homeData) {
         if (props.homeData) {
-            setCurrentRecord(props.homeData.fast_sleep.current_record)
+            setCurrentRecord(props.homeData.current_record)
             getStateDetail()
             getStateDetail()
         }
         }
 
 
     }, [props.homeData])
     }, [props.homeData])
 
 
     function getStateDetail() {
     function getStateDetail() {
-        var current_record = props.homeData.fast_sleep.current_record
-        var fastCount = current_record.fast.target_end_time - current_record.fast.target_start_time
-        setFastDuration(fastCount)
-        setFastPickerValue(durationIndex(current_record.fast.target_start_time, current_record.fast.target_end_time, common))
+        var current_record = props.homeData.current_record
+        if (current_record.fast){
+            var fastCount = current_record.fast.target_end_time - current_record.fast.target_start_time
+            setFastDuration(fastCount)
+            setFastPickerValue(durationIndex(current_record.fast.target_start_time, current_record.fast.target_end_time, common))
+        }
+        if (current_record.sleep){
+            var sleepCount = current_record.sleep.target_end_time - current_record.sleep.target_start_time
+            setSleepDuration(sleepCount)
+            setSleepPickerValue(durationIndex(current_record.sleep.target_start_time, current_record.sleep.target_end_time, common))
+        }
 
 
-        var sleepCount = current_record.sleep.target_end_time - current_record.sleep.target_start_time
-        setSleepDuration(sleepCount)
-        setSleepPickerValue(durationIndex(current_record.sleep.target_start_time, current_record.sleep.target_end_time, common))
+        
     }
     }
 
 
     function tapAddBtn() {
     function tapAddBtn() {

+ 14 - 13
src/features/trackTimeDuration/components/Discovery.tsx

@@ -13,6 +13,8 @@ import { useTranslation } from "react-i18next";
 import { TimeFormatter } from "@/utils/time_format";
 import { TimeFormatter } from "@/utils/time_format";
 import { getPerm, uploadPerm } from "@/services/user";
 import { getPerm, uploadPerm } from "@/services/user";
 import Box from "@/components/layout/Box";
 import Box from "@/components/layout/Box";
+import { getPlans } from "@/services/trackTimeDuration";
+import DayNightCard from "@/features/trackSomething/components/DayNightCard";
 
 
 
 
 let useNavigation;
 let useNavigation;
@@ -37,11 +39,14 @@ export default function Discovery() {
         getContent()
         getContent()
     }, [])
     }, [])
 
 
-    useEffect(() => {
-        setSchedule(global.homeData.scenarios)
-    }, [global.homeData])
+    // useEffect(() => {
+    //     setSchedule(global.homeData.scenarios)
+    // }, [global.homeData])
 
 
     useEffect(() => {
     useEffect(() => {
+        getPlans().then(res=>{
+            setSchedule((res as any).scenarios)
+        })
         if (user.isLogin) {
         if (user.isLogin) {
             getPerm({}).then(res => {
             getPerm({}).then(res => {
                 setShowRing((res as any).show_day_ring)
                 setShowRing((res as any).show_day_ring)
@@ -317,8 +322,12 @@ export default function Discovery() {
             </View>
             </View>
         </Box>
         </Box>
 
 
+        <DayNightCard isNight={false} switchChanged={(e)=>{
+            setShowRing(e)
+        }}/>
+
 
 
-        <View className="cell_bg" style={{ marginTop: 20 }}>
+        {/* <View className="cell_bg" style={{ marginTop: 20 }}>
             <View className="cell_full">
             <View className="cell_full">
                 <Text className="cell_title">{t('feature.common.day')}</Text>
                 <Text className="cell_title">{t('feature.common.day')}</Text>
                 <Switch checked={showRing}
                 <Switch checked={showRing}
@@ -356,15 +365,7 @@ export default function Discovery() {
                 </View>
                 </View>
             }
             }
 
 
-
-            {/* <View className="cell_line" style={{ height: 1 }} />
-            <View className="cell_full">
-                <Text className="cell_title">{t('feature.track_time_duration.third_ring.sunset_today')}</Text>
-                <Text className="cell_value" style={{ color: '#fff' }}>{
-                    dayNight.isMember && dayNight.gpsInfo ? dayNight.gpsInfo.daylights[0].sunset : '18:00'
-                }</Text>
-            </View> */}
-        </View>
+        </View> */}
 
 
     </View>
     </View>
 }
 }

+ 49 - 10
src/features/trackTimeDuration/components/IndexConsole.tsx

@@ -35,11 +35,18 @@ export default function IndexConsole(props: { record: any }) {
     }
     }
 
 
     useEffect(() => {
     useEffect(() => {
-        var fastCount = currentRecord.fast.target_end_time - currentRecord.fast.target_start_time
-        setFastDuration(fastCount)
+        if (currentRecord.fast) {
+            var fastCount = currentRecord.fast.target_end_time - currentRecord.fast.target_start_time
+            setFastDuration(fastCount)
+        }
+
+        if (currentRecord.sleep) {
+            var sleepCount = currentRecord.sleep.target_end_time - currentRecord.sleep.target_start_time
+            setSleepDuration(sleepCount)
+        }
+
+
 
 
-        var sleepCount = currentRecord.sleep.target_end_time - currentRecord.sleep.target_start_time
-        setSleepDuration(sleepCount)
     }, [props.record])
     }, [props.record])
 
 
 
 
@@ -59,7 +66,7 @@ export default function IndexConsole(props: { record: any }) {
             jumpPage('/pages/account/ChooseAuth', 'ChooseAuth')
             jumpPage('/pages/account/ChooseAuth', 'ChooseAuth')
             return
             return
         }
         }
-        if (status != 'ONGOING1') {
+        if (status != 'ONGOING1' && props.record.scenario.name == 'FAST_SLEEP') {
             vibrate()
             vibrate()
             return;
             return;
         }
         }
@@ -73,7 +80,7 @@ export default function IndexConsole(props: { record: any }) {
             jumpPage('/pages/account/ChooseAuth', 'ChooseAuth')
             jumpPage('/pages/account/ChooseAuth', 'ChooseAuth')
             return
             return
         }
         }
-        if (status != 'ONGOING2') {
+        if (status != 'ONGOING2' && status!='ONGOING') {
             vibrate()
             vibrate()
             return;
             return;
         }
         }
@@ -123,9 +130,7 @@ export default function IndexConsole(props: { record: any }) {
     }
     }
 
 
     function showPicker() {
     function showPicker() {
-        // setShowPageContainer(true)
-        // return
-        global.scenario = 'FAST_SLEEP'
+        // global.scenario = 'FAST_SLEEP'
         if (global.testInfotimer) {
         if (global.testInfotimer) {
             return
             return
         }
         }
@@ -184,7 +189,41 @@ export default function IndexConsole(props: { record: any }) {
         }
         }
     }
     }
 
 
-    return <View style={{marginTop:rpxToPx(40)}}>
+
+    if (props.record.scenario.name == 'FAST') {
+        return <View style={{ marginTop: rpxToPx(40) }}>
+            {
+                status == 'WAIT_FOR_START' &&
+                <View onClick={tapStartFast} className='console_btn'>
+                    <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.start_fast')}</Text>
+                </View>
+            }
+            {
+                status == 'WAIT_FOR_START' && <View className='btn_line' />
+            }
+            <View onClick={tapEndFast} className={status == 'ONGOING' ? 'console_btn' : 'console_btn btn_disable'}>
+                <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.end_fast')}</Text>
+            </View>
+        </View>
+    }
+    else if (props.record.scenario.name == 'SLEEP') {
+        return <View style={{ marginTop: rpxToPx(40) }}>
+            {
+                status == 'WAIT_FOR_START' &&
+                <View onClick={tapStartSleep} className='console_btn btn_sleep'>
+                    <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.start_sleep')}</Text>
+                </View>
+            }
+            {
+                status == 'WAIT_FOR_START' && <View className='btn_line' />
+            }
+            <View onClick={tapEndSleep} className={status == 'ONGOING' ? 'console_btn btn_sleep' : 'console_btn btn_sleep btn_disable'}>
+                <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.end_sleep')}</Text>
+            </View>
+        </View>
+    }
+
+    return <View style={{ marginTop: rpxToPx(40) }}>
         {
         {
             status == 'WAIT_FOR_START' ?
             status == 'WAIT_FOR_START' ?
                 <View onClick={tapStartFast} className='console_btn'>
                 <View onClick={tapStartFast} className='console_btn'>

+ 17 - 12
src/features/trackTimeDuration/components/IndexItem.tsx

@@ -76,15 +76,14 @@ export default function Component(props: { type: string, data: any, time: any, s
             return <Rings common={common} bgRing={bgRing} currentDot={currentDot1} realRing={realRing1} targetRing={targetBigRing1} canvasId={props.type + props.time + 'big'} />
             return <Rings common={common} bgRing={bgRing} currentDot={currentDot1} realRing={realRing1} targetRing={targetBigRing1} canvasId={props.type + props.time + 'big'} />
         }
         }
         if (record.status == 'WAIT_FOR_START') {
         if (record.status == 'WAIT_FOR_START') {
-            var realRing1 = getSchedule(props.data.scenario, props.type != 'SLEEP', true, true)//getSchedule(record, props.type != 'SLEEP', true)
+            var realRing1 = getSchedule(props.data.scenario, props.data.scenario.name != 'SLEEP', true, true)//getSchedule(record, props.type != 'SLEEP', true)
             var list: any = []
             var list: any = []
-            if (props.type == 'FAST_SLEEP') {
+            if (props.data.scenario.name == 'FAST_SLEEP') {
                 realRing1.color = ColorType.fast + '66'
                 realRing1.color = ColorType.fast + '66'
 
 
                 if (dotIsOuterRange(true, record.fast)) {
                 if (dotIsOuterRange(true, record.fast)) {
                     currentDot1.color = ColorType.ring
                     currentDot1.color = ColorType.ring
                 }
                 }
-
                 var detail = timeTotimestamp(props.data.scenario)
                 var detail = timeTotimestamp(props.data.scenario)
 
 
                 if (stageList[0]) {
                 if (stageList[0]) {
@@ -134,7 +133,7 @@ export default function Component(props: { type: string, data: any, time: any, s
         common.lineWidth = 9;
         common.lineWidth = 9;
         var bgRing = getBgRing()
         var bgRing = getBgRing()
         var realRing = getReal(record, false, false)
         var realRing = getReal(record, false, false)
-        if (props.type == 'SLEEP' || props.type == 'FAST_SLEEP') {
+        if (props.type == 'SLEEP' || props.data.scenario.name == 'FAST_SLEEP') {
             if (record.sleep.status == 'WAIT_FOR_END') {
             if (record.sleep.status == 'WAIT_FOR_END') {
                 var targetBigRing1 = getTarget(record, false)
                 var targetBigRing1 = getTarget(record, false)
                 targetBigRing1.color = ColorType.sleep + '66'
                 targetBigRing1.color = ColorType.sleep + '66'
@@ -228,14 +227,14 @@ export default function Component(props: { type: string, data: any, time: any, s
                 bigRing()
                 bigRing()
             }
             }
             {
             {
-                props.type == 'FAST_SLEEP' && <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
+                props.data.scenario.name == 'FAST_SLEEP' && <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
                     {
                     {
                         smallRing()
                         smallRing()
                     }
                     }
                 </View>
                 </View>
             }
             }
             {
             {
-                props.type == 'FAST_SLEEP' && !props.showStage && user.isLogin && global.showNightRing === true && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
+                !props.showStage && user.isLogin && global.showNightRing === true && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
                     {
                     {
                         dayRing()
                         dayRing()
                     }
                     }
@@ -265,6 +264,9 @@ export default function Component(props: { type: string, data: any, time: any, s
     }
     }
 
 
     function fastDuration() {
     function fastDuration() {
+        if (!record.fast){
+            return ''
+        }
         if (record.fast.status == 'WAIT_FOR_END') {
         if (record.fast.status == 'WAIT_FOR_END') {
 
 
             return TimeFormatter.formateTimeDifference(record.fast.real_start_time, new Date().getTime(), false)
             return TimeFormatter.formateTimeDifference(record.fast.real_start_time, new Date().getTime(), false)
@@ -284,6 +286,9 @@ export default function Component(props: { type: string, data: any, time: any, s
     }
     }
 
 
     function sleepDuration() {
     function sleepDuration() {
+        if (!record.sleep){
+            return ''
+        }
         if (record.sleep.status == 'WAIT_FOR_END') {
         if (record.sleep.status == 'WAIT_FOR_END') {
             return TimeFormatter.formateTimeDifference(record.sleep.real_start_time, new Date().getTime(), false)
             return TimeFormatter.formateTimeDifference(record.sleep.real_start_time, new Date().getTime(), false)
         }
         }
@@ -397,24 +402,24 @@ export default function Component(props: { type: string, data: any, time: any, s
             }
             }
             <View className="duration_bg">
             <View className="duration_bg">
                 {
                 {
-                    props.type == 'FAST_SLEEP' && !props.showStage && user.isLogin && global.showNightRing === true &&
+                     !props.showStage && user.isLogin && global.showNightRing === true &&
                     <Text className="duration_title">{t('feature.common.overnight')}</Text>
                     <Text className="duration_title">{t('feature.common.overnight')}</Text>
                 }
                 }
                 {
                 {
-                    props.type == 'FAST_SLEEP' && !props.showStage && user.isLogin && global.showNightRing === true &&
+                     !props.showStage && user.isLogin && global.showNightRing === true &&
                     <Text className="duration_value" style={{ color: ColorType.night }}>{nightDuration()}</Text>
                     <Text className="duration_value" style={{ color: ColorType.night }}>{nightDuration()}</Text>
                 }
                 }
                 {
                 {
-                    (props.type == 'FAST' || props.type == 'FAST_SLEEP') && <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.fast')}</Text>
+                    (props.data.scenario.name == 'FAST' || props.data.scenario.name == 'FAST_SLEEP') && <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.fast')}</Text>
                 }
                 }
                 {
                 {
-                    (props.type == 'FAST' || props.type == 'FAST_SLEEP') && <Text className="duration_value" style={{ color: global.fastColor ? global.fastColor : ColorType.fast }}>{fastDuration()}</Text>
+                    (props.data.scenario.name == 'FAST' || props.data.scenario.name == 'FAST_SLEEP') && <Text className="duration_value" style={{ color: global.fastColor ? global.fastColor : ColorType.fast }}>{fastDuration()}</Text>
                 }
                 }
                 {
                 {
-                    (props.type == 'SLEEP' || props.type == 'FAST_SLEEP') && <Text className="duration_title" >{t('feature.track_time_duration.record_fast_sleep.item.sleep')}</Text>
+                    (props.data.scenario.name == 'SLEEP' || props.data.scenario.name == 'FAST_SLEEP') && <Text className="duration_title" >{t('feature.track_time_duration.record_fast_sleep.item.sleep')}</Text>
                 }
                 }
                 {
                 {
-                    (props.type == 'SLEEP' || props.type == 'FAST_SLEEP') && <Text className="duration_value" style={{ color: global.sleepColor ? global.sleepColor : ColorType.sleep }}>{sleepDuration()}</Text>
+                    (props.data.scenario.name == 'SLEEP' || props.data.scenario.name == 'FAST_SLEEP') && <Text className="duration_value" style={{ color: global.sleepColor ? global.sleepColor : ColorType.sleep }}>{sleepDuration()}</Text>
                 }
                 }
             </View>
             </View>
             {
             {

+ 0 - 3
src/features/trackTimeDuration/components/Rings.weapp.tsx

@@ -122,9 +122,6 @@ export default function Rings(props: {
         const query = Taro.createSelectorQuery();
         const query = Taro.createSelectorQuery();
         query.select(`.${canvasId}`).fields({ node: true, size: true });
         query.select(`.${canvasId}`).fields({ node: true, size: true });
         query.exec((res) => {
         query.exec((res) => {
-            if (props.canvasId=='hello'){
-                debugger
-            }
             if (res[0] == null) {
             if (res[0] == null) {
                 drawCircle()
                 drawCircle()
                 return;
                 return;

+ 2 - 1
src/features/trackTimeDuration/components/SetSchedule.weapp.tsx

@@ -125,7 +125,8 @@ export default function Component() {
         }
         }
       }).then(res => {
       }).then(res => {
         setBtnDisable(false)
         setBtnDisable(false)
-        global.checkData()
+        // global.checkData()
+        global.indexPageRefresh()
         Taro.navigateBack({ delta: 3 })
         Taro.navigateBack({ delta: 3 })
       }).catch(e => {
       }).catch(e => {
         setBtnDisable(false)
         setBtnDisable(false)

+ 35 - 37
src/features/trackTimeDuration/components/TimelineFastSleep.tsx

@@ -73,30 +73,44 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
         var now = new Date()
         var now = new Date()
         var seconds = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()
         var seconds = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()
         if (obj.status == 'WAIT_FOR_START') {
         if (obj.status == 'WAIT_FOR_START') {
-            var list
-            if (isFastMode) {
-                if (isEnd) {
-                    list = scenario.schedule.fast.end_time.split(':')
-                }
-                else {
-                    list = scenario.schedule.fast.start_time.split(':')
+            if (props.data.scenario == 'SLEEP'){
+                if (isEnd){
+                    var count = TimeFormatter.timestringToSeconds(scenario.schedule.sleep.start_time)
+                    var count2 = TimeFormatter.timestringToSeconds(scenario.schedule.sleep.end_time)
+                    if (count2<count){
+                        return global.language == 'en' ? 'Tomorrow' : '明天'
+                    }
+                    return global.language == 'en' ? 'Today' : '今天'
                 }
                 }
             }
             }
             else {
             else {
-                if (isEnd) {
-                    list = scenario.schedule.sleep.end_time.split(':')
+                var count = TimeFormatter.timestringToSeconds(scenario.schedule.fast.start_time)
+                if (isFastMode){
+                    if (isEnd){
+                        var count2 = TimeFormatter.timestringToSeconds(scenario.schedule.fast.end_time)
+                        if (count2<count){
+                            return global.language == 'en' ? 'Tomorrow' : '明天'
+                        }
+                    }
+                    return global.language == 'en' ? 'Today' : '今天'
                 }
                 }
                 else {
                 else {
-                    list = scenario.schedule.sleep.start_time.split(':')
+                    if (isEnd){
+                        var count2 = TimeFormatter.timestringToSeconds(scenario.schedule.sleep.end_time)
+                        if (count2<count){
+                            return global.language == 'en' ? 'Tomorrow' : '明天'
+                        }
+                    }
+                    else {
+                        var count2 = TimeFormatter.timestringToSeconds(scenario.schedule.sleep.start_time)
+                        if (count2<count){
+                            return global.language == 'en' ? 'Tomorrow' : '明天'
+                        }
+                    }
+
+                    return global.language == 'en' ? 'Today' : '今天'
                 }
                 }
             }
             }
-            var t = parseInt(list[0]) * 3600 + parseInt(list[1])
-            if (t < seconds) {
-                return global.language == 'en' ? 'Tomorrow' : '明天'
-            }
-            else {
-                return global.language == 'en' ? 'Today' : '今天'
-            }
         }
         }
         if (isEnd) {
         if (isEnd) {
             if (obj.real_end_time) {
             if (obj.real_end_time) {
@@ -117,29 +131,13 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
 
 
     }
     }
 
 
-    function getWaitForStartDate(time: string) {
-        var strTime
-        if (scenario.name == 'SLEEP') {
-            strTime = scenario.schedule.sleep.start_time
-        }
-        else {
-            strTime = scenario.schedule.fast.start_time
-        }
-        var count = parseInt(strTime.split(':')[0]) * 60 + parseInt(strTime.split(':')[1])
-        var count2 = parseInt(time.split(':')[0]) * 60 + parseInt(time.split(':')[1])
-        if (count > count2) {
-            return global.language == 'en' ? 'Tomorrow' : '明天'
-        }
-        return ''
-    }
-
     var timelineItems: any = [];
     var timelineItems: any = [];
     /*
     /*
     attention:
     attention:
     status == 待开始时
     status == 待开始时
     timeline的时间不以时间戳进行处理,而是以target时间字符串进行显示
     timeline的时间不以时间戳进行处理,而是以target时间字符串进行显示
     */
     */
-    if (props.data.fast && scenario.name != 'SLEEP') {
+    if (props.data.fast && props.data.scenario != 'SLEEP') {
         var timeZone = ''
         var timeZone = ''
         if (props.data.fast.real_start_time_zone) {
         if (props.data.fast.real_start_time_zone) {
             timeZone = ' ' + props.data.fast.real_start_time_zone
             timeZone = ' ' + props.data.fast.real_start_time_zone
@@ -157,7 +155,7 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
             }
             }
         )
         )
     }
     }
-    if (props.data.sleep && scenario.name != 'FAST') {
+    if (props.data.sleep && props.data.scenario != 'FAST') {
         var timeZone = ''
         var timeZone = ''
         if (props.data.sleep.real_start_time_zone) {
         if (props.data.sleep.real_start_time_zone) {
             timeZone = ' ' + props.data.sleep.real_start_time_zone
             timeZone = ' ' + props.data.sleep.real_start_time_zone
@@ -178,7 +176,7 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
             }
             }
         )
         )
     }
     }
-    if (props.data.sleep && scenario.name != 'FAST') {
+    if (props.data.sleep && props.data.scenario != 'FAST') {
         var timeZone = ''
         var timeZone = ''
         if (props.data.sleep.real_end_time_zone) {
         if (props.data.sleep.real_end_time_zone) {
             timeZone = ' ' + props.data.sleep.real_end_time_zone
             timeZone = ' ' + props.data.sleep.real_end_time_zone
@@ -199,7 +197,7 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
             }
             }
         )
         )
     }
     }
-    if (props.data.fast && scenario.name != 'SLEEP') {
+    if (props.data.fast && props.data.scenario != 'SLEEP') {
         var timeZone = ''
         var timeZone = ''
         if (props.data.fast.real_end_time_zone) {
         if (props.data.fast.real_end_time_zone) {
             timeZone = ' ' + props.data.fast.real_end_time_zone
             timeZone = ' ' + props.data.fast.real_end_time_zone

+ 25 - 25
src/features/trackTimeDuration/hooks/RingData.tsx

@@ -84,31 +84,31 @@ export const getDot = (data: any, isBigRing: boolean) => {
 }
 }
 
 
 export const dotIsOuterRange = (isTargetRange: boolean, scheduleData?: any, dayLightData?: any) => {
 export const dotIsOuterRange = (isTargetRange: boolean, scheduleData?: any, dayLightData?: any) => {
-    var date = new Date()
-    var minutes = date.getHours() * 60 + date.getMinutes()
-    if (isTargetRange) {
-
-        var scheduleStart = new Date(scheduleData!.target_start_time)
-        var scheduleEnd = new Date(scheduleData!.target_end_time)
-        var startMinute = scheduleStart.getHours() * 60 + scheduleStart.getMinutes()
-        var endMinute = scheduleEnd.getHours() * 60 + scheduleEnd.getMinutes()
-        if (minutes < startMinute) {
-            minutes += 1440
-        }
-        if (endMinute < startMinute) {
-            endMinute += 1440
-        }
-        if (startMinute <= minutes && endMinute > minutes) {
-            return false;
-        }
-        return true;
-    }
-
-    var startMinute = parseInt(dayLightData.sunrise.split(':')[0]) * 60 + parseInt(dayLightData.sunrise.split(':')[1])
-    var endMinute = parseInt(dayLightData.sunset.split(':')[0]) * 60 + parseInt(dayLightData.sunset.split(':')[1])
-    if (startMinute <= minutes && endMinute > minutes) {
-        return true;
-    }
+    // var date = new Date()
+    // var minutes = date.getHours() * 60 + date.getMinutes()
+    // if (isTargetRange) {
+
+    //     var scheduleStart = new Date(scheduleData!.target_start_time)
+    //     var scheduleEnd = new Date(scheduleData!.target_end_time)
+    //     var startMinute = scheduleStart.getHours() * 60 + scheduleStart.getMinutes()
+    //     var endMinute = scheduleEnd.getHours() * 60 + scheduleEnd.getMinutes()
+    //     if (minutes < startMinute) {
+    //         minutes += 1440
+    //     }
+    //     if (endMinute < startMinute) {
+    //         endMinute += 1440
+    //     }
+    //     if (startMinute <= minutes && endMinute > minutes) {
+    //         return false;
+    //     }
+    //     return true;
+    // }
+
+    // var startMinute = parseInt(dayLightData.sunrise.split(':')[0]) * 60 + parseInt(dayLightData.sunrise.split(':')[1])
+    // var endMinute = parseInt(dayLightData.sunset.split(':')[0]) * 60 + parseInt(dayLightData.sunset.split(':')[1])
+    // if (startMinute <= minutes && endMinute > minutes) {
+    //     return true;
+    // }
     return false;
     return false;
 }
 }
 
 

+ 33 - 15
src/pages/clock/Index.tsx

@@ -33,6 +33,7 @@ import ClockHeader from "@/features/trackTimeDuration/components/ClockHeader";
 import DurationPicker from "@/features/trackTimeDuration/components/DurationPicker";
 import DurationPicker from "@/features/trackTimeDuration/components/DurationPicker";
 import SegmentPop from "@/features/trackTimeDuration/components/SegmentPop";
 import SegmentPop from "@/features/trackTimeDuration/components/SegmentPop";
 import Box from "@/components/layout/Box";
 import Box from "@/components/layout/Box";
+import DayNightCard from "@/features/trackSomething/components/DayNightCard";
 
 
 let GradientText
 let GradientText
 let useNavigation;
 let useNavigation;
@@ -134,15 +135,31 @@ export default function Page() {
     }
     }
 
 
     function getCheckData() {
     function getCheckData() {
-        clockHome().then(res => {
+        // clockHome().then(res => {
+        //     setHomeData(res as any)
+        //     global.homeData = res
+
+        //     if (user.isLogin) {
+        //         isPause = (res as any).fast_sleep.current_record.status == 'WAIT_FOR_START'
+        //         dispatch(updateScenario((res as any).fast_sleep.current_record))
+        //         dispatch(setConfigs((res as any).time_input_schema));
+        //         dispatch(setScenario((res as any).fast_sleep.scenario));
+        //     }
+        // })
+
+        // if (!user.isLogin){
+        //     return;
+        // }
+
+        getClocks().then(res => {
             setHomeData(res as any)
             setHomeData(res as any)
             global.homeData = res
             global.homeData = res
-
             if (user.isLogin) {
             if (user.isLogin) {
-                isPause = (res as any).fast_sleep.current_record.status == 'WAIT_FOR_START'
-                dispatch(updateScenario((res as any).fast_sleep.current_record))
+                isPause = (res as any).current_record.status == 'WAIT_FOR_START'
+                dispatch(updateScenario((res as any).current_record))
                 dispatch(setConfigs((res as any).time_input_schema));
                 dispatch(setConfigs((res as any).time_input_schema));
-                dispatch(setScenario((res as any).fast_sleep.scenario));
+                dispatch(setScenario((res as any).scenario));
+                global.scenario = (res as any).scenario.name;
             }
             }
         })
         })
 
 
@@ -177,7 +194,7 @@ export default function Page() {
     }
     }
 
 
     function bigRing() {
     function bigRing() {
-        var currentRecord = (homeData as any).fast_sleep.current_record
+        var currentRecord = (homeData as any).current_record
 
 
         var common = getCommon(null, true)
         var common = getCommon(null, true)
         common.radius = 42;
         common.radius = 42;
@@ -235,7 +252,7 @@ export default function Page() {
         common.radius = 28;
         common.radius = 28;
         common.lineWidth = 9;
         common.lineWidth = 9;
         var bgRing = getBgRing()
         var bgRing = getBgRing()
-        var realRing1 = getSchedule((homeData as any).fast_sleep.current_record, false, false)
+        var realRing1 = getSchedule((homeData as any).current_record, false, false)
         return <Rings common={common} bgRing={bgRing} realRing={realRing1} canvasId={'testB'} />
         return <Rings common={common} bgRing={bgRing} realRing={realRing1} canvasId={'testB'} />
     }
     }
 
 
@@ -277,7 +294,7 @@ export default function Page() {
 
 
     global.changeTargetDuration = (duration: number, isFast: boolean) => {
     global.changeTargetDuration = (duration: number, isFast: boolean) => {
         var obj = JSON.parse(JSON.stringify(homeData))
         var obj = JSON.parse(JSON.stringify(homeData))
-        var record = obj.fast_sleep.current_record
+        var record = obj.current_record
         if (isFast) {
         if (isFast) {
             record.fast.target_end_time = record.fast.target_start_time + duration * 60 * 1000
             record.fast.target_end_time = record.fast.target_start_time + duration * 60 * 1000
         }
         }
@@ -290,7 +307,7 @@ export default function Page() {
     global.updateFastSleepData = (data: any) => {
     global.updateFastSleepData = (data: any) => {
         if (data.id == (homeData as any).id) {
         if (data.id == (homeData as any).id) {
             var obj = JSON.parse(JSON.stringify(homeData))
             var obj = JSON.parse(JSON.stringify(homeData))
-            obj.fast_sleep.current_record = data
+            obj.current_record = data
             setHomeData(obj)
             setHomeData(obj)
         }
         }
 
 
@@ -376,14 +393,15 @@ export default function Page() {
 
 
                 <Box>
                 <Box>
                     <View>
                     <View>
-                        <IndexItem type="FAST_SLEEP" data={(homeData as any).fast_sleep} time={timestamp} showStage={false} />
-                        <IndexConsole record={(homeData as any).fast_sleep} />
+                        <IndexItem type="FAST_SLEEP" data={homeData} time={timestamp} showStage={false} />
+                        <IndexConsole record={homeData} />
                     </View>
                     </View>
                 </Box>
                 </Box>
 
 
-                {
+                {/* {
                     user.isLogin && <DayLight />
                     user.isLogin && <DayLight />
-                }
+                } */}
+                <DayNightCard isNight={true} switchChanged={(e)=>{}}/>
                 {
                 {
                     user.isLogin && records.length > 0 && <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
                     user.isLogin && records.length > 0 && <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
                         {
                         {
@@ -417,10 +435,10 @@ export default function Page() {
                 }
                 }
 
 
                 {
                 {
-                    homeData && <SegmentPop data={(homeData as any).fast_sleep} />
+                    homeData && <SegmentPop data={homeData} />
                 }
                 }
                 {
                 {
-                    homeData && <DurationPicker record={(homeData as any).fast_sleep.current_record} />
+                    homeData && <DurationPicker record={(homeData as any).current_record} />
                 }
                 }
                 <Tabbar index={0} />
                 <Tabbar index={0} />
             </View>
             </View>

+ 30 - 1
src/utils/time_format.ts

@@ -268,6 +268,29 @@ export class TimeFormatter {
     }
     }
   }
   }
 
 
+  static getMonthAndDayByTimestamp(num: number): string {
+    const dt = new Date(num);
+
+    const now = new Date();
+    debugger
+
+    const diff = now.getTime() - dt.getTime();
+    const day = 1000 * 60 * 60 * 24;
+
+    if (diff < day) {
+      return TimeFormatter.getTodayUnit();
+    } else if (diff < 2 * day) {
+      return TimeFormatter.getYesterdayUnit();
+    } else {
+      var month = dt.getMonth()+1
+      var date = dt.getDate()
+      if (global.language == 'en') {
+        return TimeFormatter.getMonth(month) + ' ' + date
+      }
+      return TimeFormatter.getMonth(month) + date + '日'
+    }
+  }
+
   static getTimeByTimestamp(num: number): string {
   static getTimeByTimestamp(num: number): string {
     const dt = new Date(num);
     const dt = new Date(num);
     var hour = dt.getHours()
     var hour = dt.getHours()
@@ -553,7 +576,7 @@ export class TimeFormatter {
     const now = new Date();
     const now = new Date();
     const currentDay = now.getDay(); // Get the current day of the week (0 for Sunday, 1 for Monday, etc.)
     const currentDay = now.getDay(); // Get the current day of the week (0 for Sunday, 1 for Monday, etc.)
     const startOfWeek = new Date(now); // Create a new Date object with the current date and time
     const startOfWeek = new Date(now); // Create a new Date object with the current date and time
-    
+
     // Calculate the difference in milliseconds to the beginning of the week
     // Calculate the difference in milliseconds to the beginning of the week
     const diffToMonday = (currentDay - 1) * 24 * 60 * 60 * 1000; // Subtract 1 day worth of milliseconds for each day after Monday
     const diffToMonday = (currentDay - 1) * 24 * 60 * 60 * 1000; // Subtract 1 day worth of milliseconds for each day after Monday
 
 
@@ -566,4 +589,10 @@ export class TimeFormatter {
     return timestamp
     return timestamp
   }
   }
 
 
+  //hh:mm转换成秒数
+  static timestringToSeconds = (strTime: string) => {
+    var list = strTime.split(':')
+    return parseInt(list[0]) * 3600 + parseInt(list[1])
+  }
+
 }
 }