leon 1 vuosi sitten
vanhempi
commit
648021ee2b

+ 1 - 0
src/_health/base/new_button.tsx

@@ -135,6 +135,7 @@ export default function NewButton(props: {
                 display: 'flex',
                 display: 'flex',
                 alignItems: 'center',
                 alignItems: 'center',
                 justifyContent: 'center',
                 justifyContent: 'center',
+                boxSizing: 'border-box',
                 // opacity: props.disable ? 0.6 : 1,
                 // opacity: props.disable ? 0.6 : 1,
             }
             }
             // style = {
             // style = {

+ 107 - 23
src/_health/base/new_durationpicker.tsx

@@ -4,42 +4,126 @@ import { useEffect, useState } from "react";
 import './new_timepicker.scss'
 import './new_timepicker.scss'
 import dayjs from "dayjs";
 import dayjs from "dayjs";
 import { MainColorType } from "@/context/themes/color";
 import { MainColorType } from "@/context/themes/color";
+import { TimeFormatter } from "@/utils/time_format";
 
 
-export default function NewDurationPicker(props: { value?: any, onChange?: any, color?: string }) {
+export enum DurationPickerType {
+    moment = 'moment',
+    normal = 'normal',
+    long = 'long'
+}
+export default function NewDurationPicker(props: { value?: any, onChange?: any, color?: string, type?: DurationPickerType }) {
     const [items, setItems] = useState<any>([[0]])
     const [items, setItems] = useState<any>([[0]])
     const [values, setValues] = useState<any>([0])
     const [values, setValues] = useState<any>([0])
     const [loaded, setLoaded] = useState(false)
     const [loaded, setLoaded] = useState(false)
     useEffect(() => {
     useEffect(() => {
-        var hours: any = []
-        var tempValues: any = [props.value/5]
-
-        var array:any = []
-        for (var i=0;i<=12*3;i++){
-            var count = i*5;
-            var hour = Math.floor(count/60);
-            var minute = count%60;
-            var str = ''
-            if (hour>0){
-                str = hour+'小时'
-            }
-            if (minute>0){
-                str += minute+'分钟'
-            }
-            if (hour==0 && minute==0){
-                str = '0分钟'
-            }
-            array.push(str)
+        switch (props.type) {
+            case DurationPickerType.normal:
+                setItems(itemDatas())
+                setValues(itemValues())
+                break;
+            case DurationPickerType.long:
+                setItems(longDatas())
+                setValues(longValues())
+                break;
+            case DurationPickerType.moment:
+            default:
+                {
+                    var hours: any = []
+                    var tempValues: any = [props.value / 5]
+
+                    var array: any = []
+                    for (var i = 0; i <= 12 * 3; i++) {
+                        var count = i * 5;
+                        var hour = Math.floor(count / 60);
+                        var minute = count % 60;
+                        var str = ''
+                        if (hour > 0) {
+                            str = hour + '小时'
+                        }
+                        if (minute > 0) {
+                            str += minute + '分钟'
+                        }
+                        if (hour == 0 && minute == 0) {
+                            str = '0分钟'
+                        }
+                        array.push(str)
+                    }
+                    setItems([array])
+                    setValues(tempValues)
+                }
+                break;
         }
         }
-        setItems([array])
-        setValues(tempValues)
+
         setLoaded(true)
         setLoaded(true)
     }, [])
     }, [])
 
 
+    function itemDatas() {
+        var min: number = 1
+        var max: number = 23
+        var step: number = 5
+
+        // if (common.duration) {
+        min = 0//common.duration.min
+        max = 23//common.duration.max
+        step = 5//common.duration.step
+        // }
+        var minutes: string[] = []
+        for (let i = 0; i < 60; i += step) {
+            minutes.push(i + TimeFormatter.getMinutesUnit(i))
+        }
+        var hours: string[] = []
+        for (let i = min; i <= max; i++) {
+            hours.push(i + TimeFormatter.getHoursUnit(i))
+        }
+        return [hours, minutes]
+    }
+
+    function itemValues() {
+        const seconds = props.value / 1000
+        const hours = Math.floor(seconds / 3600)
+        const minutes = Math.floor((seconds % 3600) / 60)
+
+        return [hours, Math.floor(minutes / 5)]
+    }
+
+    function longDatas() {
+        var min = 1
+        var max = 99
+
+        var days: string[] = []
+
+        for (let i = min; i <= max; i++) {
+            days.push(i + '天')
+        }
+
+        var hours: string[] = []
+        for (var i = 0; i < 24; i++) {
+            hours.push(i + TimeFormatter.getHoursUnit(i))
+        }
+        return [days, hours]
+    }
+
+    function longValues() {
+        return [0, 0]
+    }
+
     function onPickerChange(e) {
     function onPickerChange(e) {
         setValues(e.detail.value)
         setValues(e.detail.value)
         if (props.onChange) {
         if (props.onChange) {
             var list = e.detail.value
             var list = e.detail.value
-            props.onChange(list[0]*5)
+            switch (props.type) {
+                case DurationPickerType.normal:
+                    props.onChange(list[0] * 3600 * 1000 + list[1] * 5 * 60 * 1000)
+                    break
+                case DurationPickerType.long:
+                    props.onChange(list[0]*24+list[1]+24)
+                    break
+                case DurationPickerType.moment:
+                default:
+                    props.onChange(list[0] * 5)
+                    break
+            }
+
         }
         }
     }
     }
 
 

+ 24 - 0
src/_health/base/new_timepicker.tsx

@@ -35,6 +35,30 @@ export default function NewTimePicker(props: { time?: string, onChange?: any, co
         setLoaded(true)
         setLoaded(true)
     }, [])
     }, [])
 
 
+    useEffect(() => {
+        var hours: any = []
+        var tempValues: any = [0, 0]
+        var str = props.time ? props.time : dayjs().format('HH:mm')
+        var tempHour = str.split(':')[0]
+        var tempMinute = str.split(':')[1]
+        for (var i = 0; i <= 23; i++) {
+            var str = (i + '').padStart(2, '0')
+            if (str == tempHour) {
+                tempValues[0] = i
+            }
+            hours.push(str)
+        }
+        var minutes: any = []
+        for (var i = 0; i <= 59; i++) {
+            var str = (i + '').padStart(2, '0')
+            if (str == tempMinute) {
+                tempValues[1] = i
+            }
+            minutes.push(str)
+        }
+        setValues(tempValues)
+    }, [props.time])
+
     function onPickerChange(e) {
     function onPickerChange(e) {
         setValues(e.detail.value)
         setValues(e.detail.value)
         if (props.onChange) {
         if (props.onChange) {

+ 97 - 15
src/_health/components/fast_sleep_card.tsx

@@ -2,6 +2,7 @@ import { View, Text } from '@tarojs/components'
 import './fast_sleep_card.scss'
 import './fast_sleep_card.scss'
 import { rpxToPx } from '@/utils/tools'
 import { rpxToPx } from '@/utils/tools'
 import { MainColorType } from '@/context/themes/color';
 import { MainColorType } from '@/context/themes/color';
+import { TimeFormatter } from '@/utils/time_format';
 
 
 export default function FastSleepCard(props: { step: number, data: any }) {
 export default function FastSleepCard(props: { step: number, data: any }) {
 
 
@@ -15,6 +16,10 @@ export default function FastSleepCard(props: { step: number, data: any }) {
                     if (status == 'WFS') {
                     if (status == 'WFS') {
                         title = 'Ready to start'
                         title = 'Ready to start'
                     }
                     }
+                    else if (status == 'OG2_NO1') {
+                        title = ''
+                        hide = true
+                    }
                     else {
                     else {
                         title = 'In progress'
                         title = 'In progress'
                     }
                     }
@@ -29,7 +34,7 @@ export default function FastSleepCard(props: { step: number, data: any }) {
                         title = 'Stage 1 in progress'
                         title = 'Stage 1 in progress'
                     }
                     }
                     else if (status == 'OG2_NO1') {
                     else if (status == 'OG2_NO1') {
-                        title = 'Stage 1'
+                        title = 'Stage 1 missing'
                     }
                     }
                     else {
                     else {
                         title = 'Stage 1 completed'
                         title = 'Stage 1 completed'
@@ -42,7 +47,7 @@ export default function FastSleepCard(props: { step: number, data: any }) {
                         title = 'Stage 2 in progress'
                         title = 'Stage 2 in progress'
                     }
                     }
                     else if (status == 'OG3' || status == 'OG2_NO1') {
                     else if (status == 'OG3' || status == 'OG2_NO1') {
-                        title = 'Stage 2 completed'
+                        title = 'Stage 2'
                     }
                     }
                     else {
                     else {
                         title = 'Stage 2'
                         title = 'Stage 2'
@@ -54,6 +59,9 @@ export default function FastSleepCard(props: { step: number, data: any }) {
                     if (status == 'OG3') {
                     if (status == 'OG3') {
                         title = 'Stage 3 in progress'
                         title = 'Stage 3 in progress'
                     }
                     }
+                    else if (status == 'OG2_NO1') {
+                        title = 'Stage 3 pending start'
+                    }
                     else {
                     else {
                         title = 'Stage 3'
                         title = 'Stage 3'
                     }
                     }
@@ -82,29 +90,103 @@ export default function FastSleepCard(props: { step: number, data: any }) {
         </View>
         </View>
     }
     }
 
 
-    function statusDetail(){
+    function fastTime() {
+        const { fast, status } = props.data
+        if (status == 'WFS' || status == 'OG2_NO1') {
+            var now = new Date().getTime()
+            return TimeFormatter.calculateTimeDifference(now, now + fast.target.duration)
+        }
+        return TimeFormatter.countdown(fast.real.start_timestamp)
+    }
+
+    function sleepTime() {
+        const { sleep, status } = props.data
+        if (status == 'WFS' || status == 'OG1') {
+            var now = new Date().getTime()
+            return TimeFormatter.calculateTimeDifference(now, now + sleep.target.duration)
+        }
+        return TimeFormatter.countdown(sleep.real.start_timestamp)
+    }
+
+    function step1() {
+        const { fast, sleep, status } = props.data
+        if (status == 'WFS') {
+            return TimeFormatter.calculateTimeDifference(fast.target.start_timestamp, sleep.target.start_timestamp)
+        }
+        else if (status == 'OG1') {
+            var now = new Date().getTime()
+            return TimeFormatter.countdown(fast.real.start_timestamp)
+        }
+        else if (status == 'OG2_NO1') {
+            var fastStarttoSleepDuration = 0
+            var time1 = sleep.period.start_time
+            var time2 = fast.period.start_time
+
+            var t1 = parseInt(time1.split(':')[0]) * 60 + parseInt(time1.split(':')[1])
+            var t2 = parseInt(time2.split(':')[0]) * 60 + parseInt(time2.split(':')[1])
+            fastStarttoSleepDuration = t1 - t2 > 0 ? (t1 - t2) * 60 * 1000 : (t1 - t2) * 60 * 1000 + 24 * 3600 * 1000
+
+            var now = new Date().getTime()
+            return TimeFormatter.calculateTimeDifference(now, now + fastStarttoSleepDuration)
+        }
+        return TimeFormatter.calculateTimeDifference(fast.real.start_timestamp, sleep.real.start_timestamp)
+    }
+
+    function step2() {
+        const { fast, sleep, status } = props.data
+        if (status == 'OG2_NO1' || status == 'OG2') {
+            return TimeFormatter.countdown(sleep.real.start_timestamp)
+        }
+        else if (status == 'OG3') {
+            return TimeFormatter.calculateTimeDifference(sleep.real.start_timestamp, sleep.real.end_timestamp)
+        }
+        return TimeFormatter.calculateTimeDifference(sleep.target.start_timestamp, sleep.target.end_timestamp)
+    }
+
+    function step3() {
+        const { fast, sleep, status } = props.data
+        if (status == 'OG3') {
+            return TimeFormatter.countdown(sleep.real.end_timestamp)
+        }
+        return diffentTime(sleep.period.end_time, fast.period.end_time)
+    }
+
+    function diffentTime(time2, time1) {
+        var duration = 0
+
+        var t1 = parseInt(time1.split(':')[0]) * 60 + parseInt(time1.split(':')[1])
+        var t2 = parseInt(time2.split(':')[0]) * 60 + parseInt(time2.split(':')[1])
+        duration = t1 - t2 > 0 ? (t1 - t2) * 60 * 1000 : (t1 - t2) * 60 * 1000 + 24 * 3600 * 1000
+
+        var now = new Date().getTime()
+        return TimeFormatter.calculateTimeDifference(now, now + duration)
+    }
+
+
+
+    function statusDetail() {
         switch (props.step) {
         switch (props.step) {
             case 0:
             case 0:
                 return <View className='right_content'>
                 return <View className='right_content'>
-                    <View className='h34' style={{color:MainColorType.g01}}>Fast</View>
-                    <View className='h50 bold' style={{color:MainColorType.fast}}>Fast</View>
-                    <View className='h34' style={{color:MainColorType.g01}}>Sleep</View>
-                    <View className='h50 bold' style={{color:MainColorType.sleep}}>Fast</View>
+                    <View className='h34' style={{ color: MainColorType.g01 }}>Fast</View>
+                    <View className='h50 bold' style={{ color: MainColorType.fast }}>{fastTime()}</View>
+                    <View className='h34' style={{ color: MainColorType.g01 }}>Sleep</View>
+                    <View className='h50 bold' style={{ color: MainColorType.sleep }}>{sleepTime()}</View>
                 </View>
                 </View>
             case 1:
             case 1:
                 return <View className='right_content'>
                 return <View className='right_content'>
-                    <View className='h34' style={{color:MainColorType.g01}}>Fast before Bedtime</View>
-                    <View className='h50 bold' style={{color:MainColorType.fast}}>Fast</View>
+                    <View className='h34' style={{ color: MainColorType.g01 }}>Fast before Bedtime</View>
+                    <View className='h50 bold' style={{ color: MainColorType.fast }}>{step1()}</View>
                 </View>
                 </View>
             case 2:
             case 2:
                 return <View className='right_content'>
                 return <View className='right_content'>
-                    <View className='h34' style={{color:MainColorType.g01}}>Fast while Sleeping</View>
-                    <View className='h50 bold' style={{color:MainColorType.sleep}}>Fast</View>
+                    <View className='h34' style={{ color: MainColorType.g01 }}>Fast while Sleeping</View>
+                    <View className='h50 bold' style={{ color: MainColorType.sleep }}>{step2()}</View>
                 </View>
                 </View>
             case 3:
             case 3:
                 return <View className='right_content'>
                 return <View className='right_content'>
-                    <View className='h34' style={{color:MainColorType.g01}}>Fast after Wake Up</View>
-                    <View className='h50 bold' style={{color:MainColorType.fast}}>Fast</View>
+                    <View className='h34' style={{ color: MainColorType.g01 }}>Fast after Wake Up</View>
+                    <View className='h50 bold' style={{ color: MainColorType.fast }}>{step3()}</View>
                 </View>
                 </View>
         }
         }
         return <View className='right_content'></View>
         return <View className='right_content'></View>
@@ -114,12 +196,12 @@ export default function FastSleepCard(props: { step: number, data: any }) {
         position: 'relative', display: 'flex', flexDirection: 'row',
         position: 'relative', display: 'flex', flexDirection: 'row',
         height: rpxToPx(366),
         height: rpxToPx(366),
         paddingTop: rpxToPx(66),
         paddingTop: rpxToPx(66),
-        boxSizing:'border-box'
+        boxSizing: 'border-box'
     }}>
     }}>
         {
         {
             statusBar()
             statusBar()
         }
         }
-        <View className='circle_content'/>
+        <View className='circle_content' />
         {
         {
             statusDetail()
             statusDetail()
         }
         }

+ 0 - 0
src/_health/components/fast_sleep_detail_card.scss


+ 112 - 0
src/_health/components/fast_sleep_detail_card.tsx

@@ -0,0 +1,112 @@
+import { View, Text } from '@tarojs/components'
+import './fast_sleep_detail_card.scss'
+import { MainColorType } from '@/context/themes/color'
+import { TimeFormatter } from '@/utils/time_format'
+import { rpxToPx } from '@/utils/tools'
+
+export default function FastSleepDetailCard(props: { data: any }) {
+
+    function total() {
+        const { fast } = props.data
+        return diffentTime(fast.period.start_time, fast.period.end_time)
+    }
+
+    function process() {
+        const { fast, status } = props.data
+        if (status == 'OG2_NO1' || status == 'WFS') {
+            return '-'
+        }
+        return TimeFormatter.countdown(fast.real.start_timestamp)
+    }
+
+    function step1() {
+        const { fast, sleep, status } = props.data
+        if (status == 'WFS') {
+            return ('-')
+        }
+        else if (status == 'OG1') {
+            return TimeFormatter.countdown(fast.real.start_timestamp)
+        }
+        else if (status == 'OG2_NO1') {
+            return ('-')
+        }
+        return TimeFormatter.calculateTimeDifference(fast.real.start_timestamp, sleep.real.start_timestamp)
+    }
+
+    function step2() {
+        const { fast, sleep, status } = props.data
+        if (status == 'WFS' || status == 'OG1') {
+            return '-'
+        }
+
+        if (status == 'OG2_NO1' || status == 'OG2') {
+            return TimeFormatter.countdown(sleep.real.start_timestamp)
+        }
+        else if (status == 'OG3') {
+            return TimeFormatter.calculateTimeDifference(sleep.real.start_timestamp, sleep.real.end_timestamp)
+        }
+        return TimeFormatter.calculateTimeDifference(sleep.target.start_timestamp, sleep.target.end_timestamp)
+    }
+
+    function step3() {
+        const { fast, sleep, status } = props.data
+        if (status == 'WFS' || status == 'OG1' || status == 'OG2_NO1' || status == 'OG2') {
+            return '-'
+        }
+        if (status == 'OG3') {
+            return TimeFormatter.countdown(sleep.real.end_timestamp)
+        }
+        return TimeFormatter.calculateTimeDifference(sleep.target.end_timestamp, fast.target.end_timestamp)
+    }
+
+    function diffentTime(time2, time1) {
+        var duration = 0
+
+        var t1 = parseInt(time1.split(':')[0]) * 60 + parseInt(time1.split(':')[1])
+        var t2 = parseInt(time2.split(':')[0]) * 60 + parseInt(time2.split(':')[1])
+        duration = t1 - t2 > 0 ? (t1 - t2) * 60 * 1000 : (t1 - t2) * 60 * 1000 + 24 * 3600 * 1000
+
+        var now = new Date().getTime()
+        return TimeFormatter.calculateTimeDifference(now, now + duration)
+    }
+
+    function total1() {
+        const { fast, sleep } = props.data
+        return diffentTime(fast.period.start_time, sleep.period.start_time)
+    }
+
+    function total2() {
+        const { sleep } = props.data
+        return diffentTime(sleep.period.start_time, sleep.period.end_time)
+    }
+
+    function total3() {
+        const { fast, sleep } = props.data
+        return diffentTime(sleep.period.end_time, fast.period.end_time)
+    }
+
+    return <View style={{ background: '#fff', marginBottom: 20 }}>
+        <Text>详情</Text>
+
+
+        <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
+            <View className='h22' style={{ color: MainColorType.g02 }}>断食</View>
+            <View>{process()}/{total()}</View>
+
+            <View style={{ display: 'flex', marginTop: 10, width: rpxToPx(750), flexDirection: 'row', alignItems: 'center', justifyContent: 'space-around' }}>
+                <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
+                    <View className='h22' style={{ color: MainColorType.g02 }}>睡前断食</View>
+                    <View style={{ color: props.data.status == 'OG1' ? MainColorType.fast : '#000' }}>{step1()}/{total1()}</View>
+                </View>
+                <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
+                    <View className='h22' style={{ color: MainColorType.g02 }}>睡眠期间断食</View>
+                    <View style={{ color: props.data.status == 'OG2'||props.data.status == 'OG2_NO1' ? MainColorType.sleep : '#000' }}>{step2()}/{total2()}</View>
+                </View>
+                <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
+                    <View className='h22' style={{ color: MainColorType.g02 }}>起床后断食</View>
+                    <View style={{ color: props.data.status == 'OG3' ? MainColorType.fast : '#000' }}>{step3()}/{total3()}</View>
+                </View>
+            </View>
+        </View>
+    </View>
+}

+ 2 - 2
src/_health/pages/add_moment.tsx

@@ -71,8 +71,8 @@ export default function AddMoment() {
     useEffect(() => {
     useEffect(() => {
         global.set_time = new Date().getTime()
         global.set_time = new Date().getTime()
         
         
-
-        getLabelsEvent({ window: health.mode }).then(res => {
+        
+        getLabelsEvent({ window: health.mode,use:is_temp?'ONE_RECORD':'' }).then(res => {
             setLabels((res as any).labels)
             setLabels((res as any).labels)
             if (is_temp && title == '') {
             if (is_temp && title == '') {
                 setShowTitlePicker(true)
                 setShowTitlePicker(true)

+ 9 - 0
src/_health/pages/fast_sleep.tsx

@@ -14,6 +14,8 @@ import Card from "../components/card";
 import FastSleepConsole from "../components/fast_sleep_console";
 import FastSleepConsole from "../components/fast_sleep_console";
 import { fastWithSleep } from "@/services/health";
 import { fastWithSleep } from "@/services/health";
 import FastSleepCard from "../components/fast_sleep_card";
 import FastSleepCard from "../components/fast_sleep_card";
+import FastSleepDetailCard from "../components/fast_sleep_detail_card";
+import MainHistory from "@/features/health/MainHistory";
 
 
 export default function FastSleep() {
 export default function FastSleep() {
     const health = useSelector((state: any) => state.health);
     const health = useSelector((state: any) => state.health);
@@ -35,6 +37,10 @@ export default function FastSleep() {
         }
         }
     }, [])
     }, [])
 
 
+    global.refreshFastSleep = () => {
+        getDatas()
+    }
+
 
 
     function getDatas() {
     function getDatas() {
         fastWithSleep().then(res => {
         fastWithSleep().then(res => {
@@ -76,7 +82,10 @@ export default function FastSleep() {
                 </Card>
                 </Card>
             </SwiperItem>
             </SwiperItem>
         </Swiper>
         </Swiper>
+
+        <FastSleepDetailCard data={data}/>
         <FastSleepConsole step={0} data={data} />
         <FastSleepConsole step={0} data={data} />
+        <MainHistory type='FAST,SLEEP' />
         {/* <NewButton type={NewButtonType.link} title="hello world" onClick={() => {
         {/* <NewButton type={NewButtonType.link} title="hello world" onClick={() => {
 
 
         }} />
         }} />

+ 256 - 26
src/_health/pages/log_time.tsx

@@ -12,6 +12,8 @@ import { useRouter } from "@tarojs/taro";
 import Card from "../components/card";
 import Card from "../components/card";
 import { MainColorType } from "@/context/themes/color";
 import { MainColorType } from "@/context/themes/color";
 import Taro from "@tarojs/taro";
 import Taro from "@tarojs/taro";
+import { clockTimes, fastWithSleep } from "@/services/health";
+import NewDurationPicker, { DurationPickerType } from "../base/new_durationpicker";
 
 
 let useRoute;
 let useRoute;
 let useNavigation;
 let useNavigation;
@@ -38,14 +40,14 @@ export default function LogTime() {
     const isSingle = router.params.single == '1'
     const isSingle = router.params.single == '1'
     const isFast = router.params.window == 'FAST'
     const isFast = router.params.window == 'FAST'
     const isStart = router.params.is_start == '1'
     const isStart = router.params.is_start == '1'
-    const data = JSON.parse(router.params.data)
+    const [data, setData] = useState<any>(null)
     const health = useSelector((state: any) => state.health);
     const health = useSelector((state: any) => state.health);
-    const [time, setTime] = useState(dayjs().format('HH:mm'))
-    const [isToday, setIsToday] = useState(true)
     const [showGoal, setShowGoal] = useState(false)
     const [showGoal, setShowGoal] = useState(false)
     const tapIndex = router.params.index ?? 0
     const tapIndex = router.params.index ?? 0
 
 
-    const [expandIndex, setExpandIndex] = useState(0)
+    const [expandIndex, setExpandIndex] = useState(tapIndex)
+    const [array, setArray] = useState<any>([])
+    const [loaded, setLoaded] = useState(false)
 
 
     useEffect(() => {
     useEffect(() => {
         if (isSingle) {
         if (isSingle) {
@@ -61,8 +63,113 @@ export default function LogTime() {
             }
             }
         }
         }
 
 
+        loadData()
+
     }, [])
     }, [])
 
 
+    function loadData() {
+        fastWithSleep().then(res => {
+            setData(res)
+            initDatas(res)
+        })
+
+    }
+
+    function initDatas(res = data) {
+        const { fast, sleep } = res
+        var list: any = []
+        if (isSingle) {
+            var timeline: any;
+            if (isFast) {
+                timeline = isStart ? fast.timeline[0] : fast.timeline[1]
+            }
+            else {
+                timeline = isStart ? sleep.timeline[0] : sleep.timeline[1]
+            }
+            list.push({
+                event_id: timeline.event_id,
+                schedule_id: timeline.schedule_id,
+                time: dayjs().format('HH:mm'),
+                today: true,
+                extra: {
+                    set_time: new Date().getTime(),
+                    confirm_time: new Date().getTime()
+                }
+            })
+            setExpandIndex(0)
+        }
+        else {
+            for (var i = 0; i <= tapIndex; i++) {
+                var timeline: any;
+                if (i == 0 || i == 3) {
+                    timeline = i == 0 ? fast.timeline[0] : fast.timeline[1]
+                }
+                else {
+                    timeline = i == 1 ? sleep.timeline[0] : sleep.timeline[1]
+                }
+                list.push({
+                    event_id: timeline.event_id,
+                    schedule_id: timeline.schedule_id,
+                    time: dayjs().format('HH:mm'),
+                    today: true,
+                    extra: {
+                        set_time: new Date().getTime(),
+                        confirm_time: new Date().getTime()
+                    }
+                })
+            }
+
+            //逆推初始化时间
+            var fastStartTime = new Date().getTime()
+            var fastEndTime = new Date().getTime()
+            var sleepStartTime = new Date().getTime()
+            var sleepEndTime = new Date().getTime()
+
+            fastStartTime = fastEndTime - fast.target.duration
+
+            var fastEndtoWakeDuration = 0
+            var time1 = fast.period.end_time
+            var time2 = sleep.period.end_time
+
+            var t1 = parseInt(time1.split(':')[0])*60+parseInt(time1.split(':')[1])
+            var t2 = parseInt(time2.split(':')[0])*60+parseInt(time2.split(':')[1])
+            fastEndtoWakeDuration = t1-t2>0?(t1-t2)*60*1000:(t1-t2)*60*1000+24*3600*1000
+
+            sleepEndTime = fastEndTime - fastEndtoWakeDuration//(fast.target.end_timestamp-sleep.target.end_timestamp)
+            sleepStartTime = sleepEndTime - sleep.target.duration
+
+            var isConflict = false;
+            if (fast.real && fast.real.start_timestamp && fast.real.start_timestamp > fastStartTime) {
+                isConflict = true;
+            }
+            else if (sleep.real && sleep.real.start_timestamp && sleep.real.start_timestamp > sleepStartTime) {
+                isConflict = true;
+            }
+            else if (sleep.real && sleep.real.end_timestamp && sleep.real.end_timestamp > sleepEndTime) {
+                isConflict = true;
+            }
+
+            if (!isConflict) {
+                var fastStartToday = new Date().getDate() == new Date(fastStartTime).getDate()
+                list[0].today = fastStartToday
+                list[0].time = dayjs(fastStartTime).format('HH:mm')
+
+                var sleepStartToday = new Date().getDate() == new Date(sleepStartTime).getDate()
+                list[1].today = sleepStartToday
+                list[1].time = dayjs(sleepStartTime).format('HH:mm')
+
+                var sleepEndToday = new Date().getDate() == new Date(sleepEndTime).getDate()
+                list[2].today = sleepEndToday
+                list[2].time = dayjs(sleepEndTime).format('HH:mm')
+            }
+
+
+        }
+        setArray(list)
+
+        setLoaded(true)
+    }
+
     function footerBtnColor() {
     function footerBtnColor() {
         if (isSingle) {
         if (isSingle) {
             return isFast ? MainColorType.fast : MainColorType.sleep
             return isFast ? MainColorType.fast : MainColorType.sleep
@@ -70,33 +177,134 @@ export default function LogTime() {
         return MainColorType.fast
         return MainColorType.fast
     }
     }
 
 
+    function getTimestamp(obj) {
+        var time = obj.time
+        var hour = parseInt(time.split(':')[0])
+        var minute = parseInt(time.split(':')[1])
+        var today = obj.today
+        var now = new Date()
+        now.setHours(hour)
+        now.setMinutes(minute)
+        var timestamp = now.getTime()
+        if (!today) {
+            timestamp -= 24 * 3600 * 1000
+        }
+        return timestamp
+    }
+
+    function commit() {
+        var list: any = []
+        if (isSingle) {
+            var obj = array[0]
+            var timestamp = getTimestamp(obj)
+            var params: any = {
+                schedule_id: obj.schedule_id,
+                extra: obj.extra,
+                date: dayjs(timestamp).format('YYYYMMDD'),
+                timestamp: timestamp,
+            }
+            if (isStart) {
+                params.duration = isFast ? data.fast.target.duration : data.sleep.target.duration
+            }
+            list.push(params)
+        }
+        else {
+            const { status } = data
+            for (var i = 0; i <= tapIndex; i++) {
+                if ((status == 'OG1' || status == 'OG2' || status == 'OG3') && i == 0) {
+                }
+                else if ((status == 'OG2' || status == 'OG3' || status == 'OG2_NO1') && i == 1) {
+                }
+                else if (status == 'OG3' && i == 2) {
+                }
+                else {
+                    var obj = array[i]
+                    var timestamp = getTimestamp(obj)
+                    list.push({
+                        schedule_id: obj.schedule_id,
+                        extra: obj.extra,
+                        date: dayjs(timestamp).format('YYYYMMDD'),
+                        timestamp: timestamp,
+                    })
+                }
+            }
+        }
+        clockTimes({
+            check_items: list
+        }).then(res => {
+            global.refreshWindow()
+            if (global.refreshFastSleep)
+                global.refreshFastSleep()
+            Taro.navigateBack({
+                delta: 1
+            })
+        })
+    }
+
+    function changeToScheduleTime(schedule_time, index) {
+        var nowTime = parseInt(dayjs().format('HHmm'))
+        var scheduleTime = parseInt(schedule_time.replace(':', ''))
+        var isToday = true
+        if (scheduleTime > nowTime) {
+            isToday = false
+        }
+        var list = JSON.parse(JSON.stringify(array))
+        list[index].today = isToday
+        list[index].time = schedule_time
+        setArray(list)
+    }
+
+    function durationTime() {
+        const { fast, sleep } = data
+        var seconds = isFast ? fast.target.duration / 1000 : sleep.target.duration / 1000
+        var hour = Math.floor(seconds / 3600)
+        var minutes = Math.floor((seconds % 3600) / 60)
+        var str = ''
+        if (hour > 0) {
+            str = hour + '小时'
+        }
+        if (minutes > 0) {
+            str += minutes + '分钟'
+        }
+        return str
+    }
+
     function logItem(index: number, iFast: boolean, iStart: boolean, showLine: boolean) {
     function logItem(index: number, iFast: boolean, iStart: boolean, showLine: boolean) {
-        const {fast,sleep} = data
+        const { fast, sleep } = data
         var schedule_time = ''
         var schedule_time = ''
-        if (iFast){
-            schedule_time = iStart?fast.period.start_time:fast.period.end_time
+        var title = ''
+        if (iFast) {
+            schedule_time = iStart ? fast.period.start_time : fast.period.end_time
+            title = iStart ? 'Fast starts' : 'Fast ends'
         }
         }
         else {
         else {
-            schedule_time = iStart?sleep.period.start_time:sleep.period.end_time
+            schedule_time = iStart ? sleep.period.start_time : sleep.period.end_time
+            title = iStart ? 'Bedtime' : 'Wake up'
         }
         }
         return <View style={{ position: 'relative' }}>
         return <View style={{ position: 'relative' }}>
             <View className="card_header">
             <View className="card_header">
-                <View style={{ flex: 1 }} />
+                {
+                    isSingle ? <View style={{ flex: 1 }} /> :
+                        <View className="h34" style={{ flex: 1 }}>{title}</View>
+                }
+
                 <NewButton
                 <NewButton
                     type={NewButtonType.gray}
                     type={NewButtonType.gray}
-                    title={isToday ? "Today" : "Yesterday"}
+                    title={array[index].today ? "Today" : "Yesterday"}
                     fontSize={rpxToPx(34)}
                     fontSize={rpxToPx(34)}
                     width={rpxToPx(196)}
                     width={rpxToPx(196)}
                     height={rpxToPx(84)}
                     height={rpxToPx(84)}
                     onClick={() => {
                     onClick={() => {
-                        setIsToday(!isToday)
+                        var list = JSON.parse(JSON.stringify(array))
+                        list[index].today = !list[index].today
+                        setArray(list)
                     }}
                     }}
                 />
                 />
                 <View style={{ width: rpxToPx(12) }} />
                 <View style={{ width: rpxToPx(12) }} />
                 <NewButton
                 <NewButton
-                    type={NewButtonType.alpha}
-                    color={iFast?MainColorType.fast:MainColorType.sleep}
-                    title={time}
+                    type={expandIndex == index ? NewButtonType.alpha : NewButtonType.gray}
+                    color={iFast ? MainColorType.fast : MainColorType.sleep}
+                    title={array[index].time}
                     fontSize={rpxToPx(34)}
                     fontSize={rpxToPx(34)}
                     width={rpxToPx(196)}
                     width={rpxToPx(196)}
                     height={rpxToPx(84)}
                     height={rpxToPx(84)}
@@ -104,17 +312,21 @@ export default function LogTime() {
                         setExpandIndex(index)
                         setExpandIndex(index)
                     }}
                     }}
                 />
                 />
-                <View style={{ flex: 1 }} />
+                {
+                    isSingle && <View style={{ flex: 1 }} />
+                }
                 <View className='border_footer_line' />
                 <View className='border_footer_line' />
             </View>
             </View>
             {
             {
-                expandIndex == index && <NewTimePicker time={time} onChange={(e) => {
-                    setTime(e)
-                }} color={iFast?MainColorType.fast:MainColorType.sleep} />
+                expandIndex == index && <NewTimePicker time={array[index].time} onChange={(e) => {
+                    var list = JSON.parse(JSON.stringify(array))
+                    list[index].time = e
+                    setArray(list)
+                }} color={iFast ? MainColorType.fast : MainColorType.sleep} />
             }
             }
 
 
             {
             {
-                expandIndex == index && <View className='card_footer'>
+                expandIndex == index && <View className='card_footer' onClick={() => changeToScheduleTime(schedule_time, index)}>
                     <IconCalendar width={rpxToPx(24)} color='#5C7099' />
                     <IconCalendar width={rpxToPx(24)} color='#5C7099' />
                     <Text style={{ color: '#5C7099', marginLeft: rpxToPx(12), fontSize: rpxToPx(26) }}>Scheduled for {schedule_time}</Text>
                     <Text style={{ color: '#5C7099', marginLeft: rpxToPx(12), fontSize: rpxToPx(26) }}>Scheduled for {schedule_time}</Text>
                 </View>
                 </View>
@@ -128,7 +340,7 @@ export default function LogTime() {
 
 
     function multiContent() {
     function multiContent() {
         const { status } = data
         const { status } = data
-        switch (parseInt(tapIndex+'')) {
+        switch (parseInt(tapIndex + '')) {
             case 1:
             case 1:
                 return <View style={{ position: 'relative' }}>
                 return <View style={{ position: 'relative' }}>
                     {
                     {
@@ -159,7 +371,7 @@ export default function LogTime() {
                         (status == 'WFS' || status == 'OG1') && logItem(1, false, true, true)
                         (status == 'WFS' || status == 'OG1') && logItem(1, false, true, true)
                     }
                     }
                     {
                     {
-                        (status == 'WFS' || status == 'OG1' || status == 'OG2'|| status == 'OG2_NO1') && logItem(2, false, false, true)
+                        (status == 'WFS' || status == 'OG1' || status == 'OG2' || status == 'OG2_NO1') && logItem(2, false, false, true)
                     }
                     }
                     {
                     {
                         logItem(3, true, false, false)
                         logItem(3, true, false, false)
@@ -168,6 +380,9 @@ export default function LogTime() {
         }
         }
         return <View style={{ position: 'relative' }}></View>
         return <View style={{ position: 'relative' }}></View>
     }
     }
+
+    if (!loaded) return <View />
+
     return <View className="page_container">
     return <View className="page_container">
         <Card>
         <Card>
             {
             {
@@ -199,10 +414,27 @@ export default function LogTime() {
                         <NewButton
                         <NewButton
                             type={NewButtonType.gray}
                             type={NewButtonType.gray}
                             height={rpxToPx(84)}
                             height={rpxToPx(84)}
-                            title="xxx"
-                            onClick={() => { }}
+                            title={durationTime()}
+                            onClick={() => { setExpandIndex(-1) }}
                         />
                         />
                     </View>
                     </View>
+                    {
+                        expandIndex == -1 && <NewDurationPicker
+                            type={DurationPickerType.normal}
+                            value={isFast ? data.fast.target.duration : data.sleep.target.duration}
+                            onChange={e => {
+                                var temp = JSON.parse(JSON.stringify(data))
+                                if (isFast) {
+                                    temp.fast.target.duration = e
+                                }
+                                else {
+                                    temp.sleep.target.duration = e
+                                }
+                                setData(temp)
+                            }}
+                            color={isFast ? MainColorType.fast : MainColorType.sleep} />
+                    }
+
                 </View>
                 </View>
             </Card>
             </Card>
         }
         }
@@ -215,9 +447,7 @@ export default function LogTime() {
                 width={rpxToPx(670)}
                 width={rpxToPx(670)}
                 height={rpxToPx(96)}
                 height={rpxToPx(96)}
                 bold={true}
                 bold={true}
-                onClick={() => {
-
-                }} />
+                onClick={commit} />
         </View>
         </View>
 
 
     </View>
     </View>

+ 22 - 4
src/_health/pages/long_fast_setting.tsx

@@ -6,13 +6,25 @@ import { getThemeColor } from "@/features/health/hooks/health_hooks";
 import { rpxToPx } from "@/utils/tools";
 import { rpxToPx } from "@/utils/tools";
 import { MainColorType } from "@/context/themes/color";
 import { MainColorType } from "@/context/themes/color";
 import { useState } from "react";
 import { useState } from "react";
-import NewDurationPicker from "../base/new_durationpicker";
+import NewDurationPicker, { DurationPickerType } from "../base/new_durationpicker";
 import dayjs from "dayjs";
 import dayjs from "dayjs";
 import NewTimePicker from "../base/new_timepicker";
 import NewTimePicker from "../base/new_timepicker";
 
 
 export default function LongFastSetting() {
 export default function LongFastSetting() {
     const [showGoal, setShowGoal] = useState(true)
     const [showGoal, setShowGoal] = useState(true)
     const [isToday, setIsToday] = useState(true)
     const [isToday, setIsToday] = useState(true)
+    const [duration, setDuration] = useState(24)
+
+    function getDuration() {
+        var day = Math.floor(duration / 24)
+        var hour = duration % 24
+        var str = ''
+        if (day > 0)
+            str = day + '天'
+        if (hour > 0)
+            str += hour + '小时'
+        return str
+    }
     return <View className="page_container">
     return <View className="page_container">
         <Card>
         <Card>
             <View style={{ position: 'relative' }}>
             <View style={{ position: 'relative' }}>
@@ -24,14 +36,20 @@ export default function LongFastSetting() {
                         color={getThemeColor('FAST')}
                         color={getThemeColor('FAST')}
                         width={rpxToPx(196)}
                         width={rpxToPx(196)}
                         height={rpxToPx(84)}
                         height={rpxToPx(84)}
-                        title="1天24小时"
+                        title={getDuration()}
                         onClick={() => {
                         onClick={() => {
                             setShowGoal(true)
                             setShowGoal(true)
                         }}
                         }}
                     />
                     />
                 </View>
                 </View>
                 {
                 {
-                    showGoal && <NewDurationPicker color={MainColorType.fast} />
+                    showGoal && <NewDurationPicker color={MainColorType.fast} 
+                    type={DurationPickerType.long} 
+                    value={duration}
+                    onChange={(e)=>{
+                        setDuration(e)
+                    }}
+                    />
                 }
                 }
                 <View className="long_fast_card_footer">
                 <View className="long_fast_card_footer">
                     <View className="h26" style={{ color: MainColorType.g02 }}>Expect to break fast at 10:00 tomorrow</View>
                     <View className="h26" style={{ color: MainColorType.g02 }}>Expect to break fast at 10:00 tomorrow</View>
@@ -75,7 +93,7 @@ export default function LongFastSetting() {
             </View>
             </View>
         </Card>
         </Card>
         <View style={{ flex: 1 }} />
         <View style={{ flex: 1 }} />
-        <View style={{marginBottom:rpxToPx(128),display:'flex',alignItems:'center',justifyContent:'center'}}>
+        <View style={{ marginBottom: rpxToPx(128), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
             <NewButton type={NewButtonType.fill}
             <NewButton type={NewButtonType.fill}
                 color={MainColorType.fast}
                 color={MainColorType.fast}
                 width={rpxToPx(670)}
                 width={rpxToPx(670)}

+ 38 - 4
src/features/health/MainConsole.tsx

@@ -440,6 +440,10 @@ export default function MainConsole(props: { type: WindowType }) {
     }
     }
 
 
     function more() {
     function more() {
+        if (!user.isLogin) {
+            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+            return
+        }
         var list: any = []
         var list: any = []
         switch (health.mode) {
         switch (health.mode) {
             case 'DAY':
             case 'DAY':
@@ -662,6 +666,10 @@ export default function MainConsole(props: { type: WindowType }) {
     }
     }
 
 
     function tapSwitchBtn() {
     function tapSwitchBtn() {
+        if (!user.isLogin) {
+            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+            return
+        }
         switch (health.mode) {
         switch (health.mode) {
             case 'FAST':
             case 'FAST':
                 dispatch(setMode('EAT'));
                 dispatch(setMode('EAT'));
@@ -765,13 +773,35 @@ export default function MainConsole(props: { type: WindowType }) {
         })
         })
     }
     }
 
 
+
+
     function timePointClass() {
     function timePointClass() {
         if (getWindowStatus(health.windows, health.mode) == WindowStatusType.process) {
         if (getWindowStatus(health.windows, health.mode) == WindowStatusType.process) {
             return 'time_point time_point_animation'
             return 'time_point time_point_animation'
         }
         }
         return 'time_point'
         return 'time_point'
     }
     }
-    
+
+    function fastWithSleepStatus() {
+        const { status } = health.fast_with_sleep
+        var str = ''
+        switch (status) {
+            case 'OG1':
+                str = 'Fast before Bedtime'
+                break;
+            case 'OG2_NO1':
+                str = 'Fast before Bedtime'
+                break;
+            case 'OG2':
+                str = 'Fast while Sleeping'
+                break;
+            case 'OG3':
+                str = 'Fast after Wake Up'
+                break
+        }
+        return <View className="h28" style={{color:MainColorType.g01}}>{str}</View>
+    }
+
     return <View className="main-console-bg">
     return <View className="main-console-bg">
         <Image className="main_arrow" src={require('@assets/images/center_arrow.png')} />
         <Image className="main_arrow" src={require('@assets/images/center_arrow.png')} />
         <View className="main_summary">
         <View className="main_summary">
@@ -827,7 +857,7 @@ export default function MainConsole(props: { type: WindowType }) {
             </View>
             </View>
         }
         }
         {
         {
-            health.mode == 'FAST' && <View className="console_active_bg" onClick={() => {
+            (health.mode == 'FAST' || health.mode == 'SLEEP') && <View className="console_active_bg" onClick={() => {
                 if (!user.isLogin) {
                 if (!user.isLogin) {
                     jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
                     jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
                     return
                     return
@@ -836,7 +866,11 @@ export default function MainConsole(props: { type: WindowType }) {
             }}>
             }}>
                 <View className="console_active">
                 <View className="console_active">
                     <Image className="active_icon" src={require('@assets/_health/fast.png')} />
                     <Image className="active_icon" src={require('@assets/_health/fast.png')} />
-                    <Text className="active_text">Fast with sleep</Text>
+                    <Text className="h34">Fast with sleep</Text>
+                    <View style={{ flex: 1 }} />
+                    {
+                        fastWithSleepStatus()
+                    }
                     <Image className="cell_arrow" src={require('@assets/_health/cell_arrow.png')} />
                     <Image className="cell_arrow" src={require('@assets/_health/cell_arrow.png')} />
                 </View>
                 </View>
 
 
@@ -852,7 +886,7 @@ export default function MainConsole(props: { type: WindowType }) {
             }}>
             }}>
                 <View className="console_active">
                 <View className="console_active">
                     <Image className="active_icon" src={require('@assets/_health/fast.png')} />
                     <Image className="active_icon" src={require('@assets/_health/fast.png')} />
-                    <Text className="active_text">Long fast</Text>
+                    <Text className="h34">Long fast</Text>
                     <Image className="cell_arrow" src={require('@assets/_health/cell_arrow.png')} />
                     <Image className="cell_arrow" src={require('@assets/_health/cell_arrow.png')} />
                 </View>
                 </View>
 
 

+ 8 - 6
src/features/health/MainHistory.tsx

@@ -1,9 +1,5 @@
 import { View, Text, Image } from "@tarojs/components";
 import { View, Text, Image } from "@tarojs/components";
 import { useEffect, useRef, useState } from "react";
 import { useEffect, useRef, useState } from "react";
-import HistoryEatItem from "./HistoryEatItem";
-import HistoryFastItem from "./HistoryFastItem";
-import HistoryActiveItem from "./HistoryActiveItem";
-import HistorySleepItem from "./HistorySleepItem";
 import { records } from "@/services/health";
 import { records } from "@/services/health";
 import './History.scss'
 import './History.scss'
 import Calendar from "./calendar";
 import Calendar from "./calendar";
@@ -16,7 +12,7 @@ import { getThemeColor } from "./hooks/health_hooks";
 import { TimeFormatter } from "@/utils/time_format";
 import { TimeFormatter } from "@/utils/time_format";
 
 
 let lastMode = ''
 let lastMode = ''
-export default function MainHistory(props: { type: string }) {
+export default function MainHistory(props: { type?: string }) {
     const [list, setList] = useState<any>([])
     const [list, setList] = useState<any>([])
     const [page, setPage] = useState(1)
     const [page, setPage] = useState(1)
     const [total, setTotal] = useState(0)
     const [total, setTotal] = useState(0)
@@ -30,6 +26,12 @@ export default function MainHistory(props: { type: string }) {
         refresh()
         refresh()
     }
     }
 
 
+    useEffect(()=>{
+        if (props.type){
+            loadData(1)
+        }
+    },[props.type])
+
 
 
     useEffect(() => {
     useEffect(() => {
         if (lastMode != health.mode) {
         if (lastMode != health.mode) {
@@ -54,7 +56,7 @@ export default function MainHistory(props: { type: string }) {
     function loadData(index: number) {
     function loadData(index: number) {
         // return
         // return
         records({
         records({
-            window: health.mode,
+            window: props.type?props.type:health.mode,
             limit: 10,
             limit: 10,
             page: index
             page: index
         }).then(res => {
         }).then(res => {

+ 4 - 1
src/pages/clock/Clock.tsx

@@ -24,6 +24,7 @@ export default function Clock() {
     const [loaded, setLoaded] = useState(false)
     const [loaded, setLoaded] = useState(false)
     const { t } = useTranslation()
     const { t } = useTranslation()
     const health = useSelector((state: any) => state.health);
     const health = useSelector((state: any) => state.health);
+    const user = useSelector((state: any) => state.user);
     const [showCalendar, setShowCalendar] = useState(false)
     const [showCalendar, setShowCalendar] = useState(false)
 
 
     const systemInfo: any = Taro.getSystemInfoSync();
     const systemInfo: any = Taro.getSystemInfoSync();
@@ -103,7 +104,9 @@ export default function Clock() {
     }
     }
 
 
     function haveStreaks() {
     function haveStreaks() {
-        if (health.windows) {
+
+
+        if (user.isLogin && health.windows) {
             const scenario = getScenario(health.windows, health.mode)
             const scenario = getScenario(health.windows, health.mode)
             if (scenario.current_streak) {
             if (scenario.current_streak) {
                 return true
                 return true

+ 3 - 3
src/pages/clock/ClockNew.tsx

@@ -12,7 +12,7 @@ import MainHistory from "@/features/health/MainHistory";
 import { WindowType } from "@/utils/types";
 import { WindowType } from "@/utils/types";
 import { getArchived, windows } from "@/services/health";
 import { getArchived, windows } from "@/services/health";
 import { useDispatch, useSelector } from "react-redux";
 import { useDispatch, useSelector } from "react-redux";
-import health, { setEatArchived, setRefreshs, setTitle, setWindows } from "@/store/health";
+import health, { setEatArchived, setFastWithSleep, setRefreshs, setTitle, setWindows } from "@/store/health";
 import dayjs from "dayjs";
 import dayjs from "dayjs";
 import Modal from "@/components/layout/Modal.weapp";
 import Modal from "@/components/layout/Modal.weapp";
 import Streak from "@/features/health/Streak";
 import Streak from "@/features/health/Streak";
@@ -117,7 +117,7 @@ export default function ClockNew() {
                     }
                     }
                 }
                 }
             }
             }
-
+            dispatch(setFastWithSleep((res as any).fast_with_sleep))
             dispatch(setWindows((res as any).windows))
             dispatch(setWindows((res as any).windows))
             dispatch(setRefreshs((res as any).refresh_timestamps))
             dispatch(setRefreshs((res as any).refresh_timestamps))
         })
         })
@@ -178,7 +178,7 @@ export default function ClockNew() {
                 <NewButton type={NewButtonType.border} color={getThemeColor('SLEEP')} disable title="hello world" />s
                 <NewButton type={NewButtonType.border} color={getThemeColor('SLEEP')} disable title="hello world" />s
             </View> */}
             </View> */}
 
 
-            <MainHistory type={type} />
+            <MainHistory />
             <View style={{ height: 2200 }} />
             <View style={{ height: 2200 }} />
         </ScrollView>
         </ScrollView>
     }
     }

+ 6 - 1
src/store/health.tsx

@@ -2,6 +2,7 @@ import { createSlice } from "@reduxjs/toolkit";
 
 
 interface HealthState {
 interface HealthState {
     windows: any;
     windows: any;
+    fast_with_sleep: any;
     mode: string;
     mode: string;
     selTab: number;
     selTab: number;
     refreshs: any; //刷新数据时间点
     refreshs: any; //刷新数据时间点
@@ -13,6 +14,7 @@ interface HealthState {
 
 
 const initialState: HealthState = {
 const initialState: HealthState = {
     windows: null,
     windows: null,
+    fast_with_sleep: null,
     mode: 'DAY',
     mode: 'DAY',
     selTab: 0,
     selTab: 0,
     refreshs: [],
     refreshs: [],
@@ -30,6 +32,9 @@ const healthSlice = createSlice({
         setWindows(state, action) {
         setWindows(state, action) {
             state.windows = action.payload
             state.windows = action.payload
         },
         },
+        setFastWithSleep(state, action) {
+            state.fast_with_sleep = action.payload
+        },
         setMode(state, action) {
         setMode(state, action) {
             state.mode = action.payload
             state.mode = action.payload
         },
         },
@@ -57,5 +62,5 @@ const healthSlice = createSlice({
 
 
 
 
 
 
-export const { setWindows, setMode, setTab, setRefreshs, setTitle, setEatArchived, setShowActionTip } = healthSlice.actions;
+export const { setWindows, setMode, setTab, setRefreshs, setTitle, setEatArchived, setShowActionTip, setFastWithSleep } = healthSlice.actions;
 export default healthSlice.reducer;
 export default healthSlice.reducer;