Leon 1 vuosi sitten
vanhempi
commit
fad3b11bd0

+ 3 - 1
src/_health/components/fast_sleep_card.scss

@@ -4,7 +4,9 @@
     height: 224px;
     margin-right: 38px;
     flex-shrink: 0;
-    background-color: palegoldenrod;
+    display: flex;
+    align-items: center;
+    justify-content: center;
 }
 
 .right_content{

+ 218 - 1
src/_health/components/fast_sleep_card.tsx

@@ -3,9 +3,222 @@ import './fast_sleep_card.scss'
 import { rpxToPx } from '@/utils/tools'
 import { MainColorType } from '@/context/themes/color';
 import { TimeFormatter } from '@/utils/time_format';
+import Rings, { RingCommon, BgRing, TargetRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
+import { getDurationArc, getStartArc } from '@/features/health/hooks/health_hooks';
 
 export default function FastSleepCard(props: { step: number, data: any }) {
 
+    const common: RingCommon = {
+        useCase: 'ChooseScenario',
+        radius: 37,
+        lineWidth: 14,
+        isFast: true,
+        status: 'WAIT_FOR_START'
+    }
+
+    const common2: RingCommon = {
+        useCase: 'ChooseScenario',
+        radius: 20,
+        lineWidth: 14,
+        isFast: true,
+        status: 'WAIT_FOR_START'
+    }
+
+    const bgRing: BgRing = {
+        color: MainColorType.ringBg
+    }
+
+    function target0BigRing() {
+        const { fast } = props.data
+        return {
+            color: MainColorType.fastLight,
+            startArc: getStartArc(fast.target.start_timestamp),
+            durationArc: getDurationArc(fast.target.start_timestamp, fast.target.end_timestamp)
+        }
+    }
+
+    function target0SmallRing() {
+        const { sleep } = props.data
+        return {
+            color: MainColorType.sleepLight,
+            startArc: getStartArc(sleep.target.start_timestamp),
+            durationArc: getDurationArc(sleep.target.start_timestamp, sleep.target.end_timestamp)
+        }
+    }
+
+
+
+    function target1BigRing() {
+        const { fast, sleep } = props.data
+        return {
+            color: MainColorType.fastLight,
+            startArc: getStartArc(fast.target.start_timestamp),
+            durationArc: getDurationArc(fast.target.start_timestamp, sleep.target.start_timestamp)
+        }
+    }
+
+    function target2BigRing() {
+        const { sleep } = props.data
+        return {
+            color: MainColorType.sleepLight,
+            startArc: getStartArc(sleep.target.start_timestamp),
+            durationArc: getDurationArc(sleep.target.start_timestamp, sleep.target.end_timestamp)
+        }
+    }
+
+    function target3BigRing() {
+        const { fast, sleep } = props.data
+        return {
+            color: MainColorType.fastLight,
+            startArc: getStartArc(sleep.target.end_timestamp),
+            durationArc: getDurationArc(sleep.target.end_timestamp, fast.target.end_timestamp)
+        }
+    }
+
+    function real0BigRing() {
+        const { fast, sleep, status } = props.data
+        if (status == 'WFS' || status == 'OG2_NO1') {
+            return null;
+        }
+        return {
+            color: MainColorType.fast,
+            startArc: getStartArc(fast.real.start_timestamp),
+            durationArc: getDurationArc(fast.real.start_timestamp, new Date().getTime())
+        }
+    }
+
+    function real0SmallRing() {
+        const { sleep } = props.data
+        if (!sleep.real) {
+            return null;
+        }
+        return {
+            color: MainColorType.sleep,
+            startArc: getStartArc(sleep.real.start_timestamp),
+            durationArc: getDurationArc(sleep.real.start_timestamp, new Date().getTime())
+        }
+    }
+
+    function real1BigRing() {
+        const { fast, sleep, status } = props.data
+        if (fast.real) {
+            if (status == 'OG1') {
+                return {
+                    color: MainColorType.fast,
+                    startArc: getStartArc(fast.real.start_timestamp),
+                    durationArc: getDurationArc(fast.real.start_timestamp, new Date().getTime())
+                }
+            }
+            return {
+                color: MainColorType.fast,
+                startArc: getStartArc(fast.real.start_timestamp),
+                durationArc: getDurationArc(fast.real.start_timestamp, sleep.real.start_timestamp)
+            }
+        }
+        return null;
+    }
+    function real2BigRing() {
+        const { sleep } = props.data
+        if (!sleep.real) {
+            return null;
+        }
+        return {
+            color: MainColorType.sleep,
+            startArc: getStartArc(sleep.real.start_timestamp),
+            durationArc: getDurationArc(sleep.real.start_timestamp, sleep.real.end_timestamp ? sleep.real.end_timestamp : new Date().getTime())
+        }
+    }
+    function real3BigRing() {
+        const { fast, sleep } = props.data
+        if (!sleep.real || !sleep.real.end_timestamp) {
+            return null;
+        }
+        return {
+            color: MainColorType.fast,
+            startArc: getStartArc(sleep.real.end_timestamp),
+            durationArc: getDurationArc(sleep.real.end_timestamp, new Date().getTime())
+        }
+    }
+
+
+    function circle0() {
+        return <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', width: '100%', height: '100%', position: 'relative' }}>
+            <Rings common={common}
+                bgRing={bgRing}
+                targetRing={target0BigRing()}
+                realRing={real0BigRing()}
+                canvasId={'circle0_big'}
+            // currentDot={currentDot()}
+            />
+
+            <View style={{
+                position: 'absolute',
+                display: 'flex',
+                alignItems: 'center',
+                justifyContent: 'center',
+                left: 0,
+                right: 0,
+                top: 0,
+                bottom: 0
+            }}>
+                <Rings common={common2}
+                    bgRing={bgRing}
+                    targetRing={target0SmallRing()}
+                    realRing={real0SmallRing()}
+                    canvasId={'circle0_small'}
+                // currentDot={currentDot()}
+                />
+            </View>
+        </View>
+
+    }
+
+    function circle1() {
+        return <Rings common={common}
+            bgRing={bgRing}
+            targetRing={target1BigRing()}
+            realRing={real1BigRing()}
+            canvasId={'circle1_big'}
+        // currentDot={currentDot()}
+
+        />
+    }
+
+    function circle2() {
+        return <Rings common={common}
+            bgRing={bgRing}
+            targetRing={target2BigRing()}
+            realRing={real2BigRing()}
+            canvasId={'circle2_big'}
+        // currentDot={currentDot()}
+
+        />
+    }
+
+    function circle3() {
+        return <Rings common={common}
+            bgRing={bgRing}
+            targetRing={target3BigRing()}
+            realRing={real3BigRing()}
+            canvasId={'circle3_big'}
+        // currentDot={currentDot()}
+
+        />
+    }
+
+    function circleContent() {
+        switch (props.step) {
+            case 0:
+                return circle0()
+            case 1:
+                return circle1()
+            case 2:
+                return circle2()
+            case 3:
+                return circle3()
+        }
+    }
+
     function statusBar() {
         var title = ''
         var hide = false;
@@ -201,7 +414,11 @@ export default function FastSleepCard(props: { step: number, data: any }) {
         {
             statusBar()
         }
-        <View className='circle_content' />
+        <View className='circle_content'>
+            {
+                circleContent()
+            }
+        </View>
         {
             statusDetail()
         }

+ 1 - 1
src/_health/pages/fast_sleep.tsx

@@ -58,7 +58,7 @@ export default function FastSleep() {
         />
         <Swiper indicatorColor='#999'
             indicatorActiveColor='#333'
-            style={{ height: rpxToPx(344), marginBottom: 20 }}
+            style={{ height: rpxToPx(344), marginBottom: 20,flexShrink:0 }}
             indicatorDots>
             <SwiperItem>
                 <Card>

+ 2 - 0
src/_health/pages/log_time.tsx

@@ -185,6 +185,8 @@ export default function LogTime() {
         var now = new Date()
         now.setHours(hour)
         now.setMinutes(minute)
+        now.setSeconds(0)
+        now.setMilliseconds(0)
         var timestamp = now.getTime()
         if (!today) {
             timestamp -= 24 * 3600 * 1000

+ 157 - 13
src/_health/pages/long_fast.tsx

@@ -5,10 +5,127 @@ import './long_fast.scss'
 import { MainColorType } from "@/context/themes/color";
 import { rpxToPx } from "@/utils/tools";
 import NewButton, { NewButtonType } from "../base/new_button";
-import { getThemeColor } from "@/features/health/hooks/health_hooks";
+import { getScenario, getThemeColor } from "@/features/health/hooks/health_hooks";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
+import MainHistory from "@/features/health/MainHistory";
+import { useSelector } from "react-redux";
+import showAlert from "@/components/basic/Alert";
+import { clockTimes, updateFast } from "@/services/health";
+import { useEffect, useState } from "react";
+import { TimeFormatter } from "@/utils/time_format";
+import dayjs from "dayjs";
 
 export default function LongFast() {
+    const health = useSelector((state: any) => state.health);
+    const long_fast = health.long_fast
+    const [count, setCount] = useState(1)
+
+    useEffect(() => {
+        var timer = setInterval(() => {
+            setCount(count => count + 1)
+        }, 1000)
+
+        return () => {
+            clearInterval(timer)
+        }
+    }, [])
+
+    function tapStart() {
+        const fast = getScenario(health.windows, 'FAST')
+        if (fast.status == 'OG') {
+            showAlert({
+                title: '断食进行中',
+                content: '当前有一个正在进行的间歇性断食记录,要转换为长断食吗?',
+                showCancel: true,
+                cancelText: '取消',
+                confirmText: '转换',
+                confirm: () => {
+                    // 
+                    updateFast({ fast_type: 'LF' }).then(res => {
+                        global.refreshWindow()
+                    })
+                }
+            })
+        }
+        else {
+            jumpPage('./long_fast_setting')
+        }
+    }
+
+    function tapLog() {
+        var item = long_fast.timeline[0]
+        jumpPage(`/_health/pages/add_moment?moment=${JSON.stringify(item)}&title=${item.title}&schedule_id=${item.schedule_id}&event_id=${item.event_id}`)
+    }
+
+    function tapEnd() {
+        global.set_time = new Date().getTime()
+        var count = Math.floor((new Date().getTime() - long_fast.real.start_timestamp) / 1000)
+        if (count >= 24 * 3600) {
+            showAlert({
+                title: 'Saving as Long Fast',
+                content: 'Fasting that lasts more than 24 hours will be saved as Long Fast. ',
+                showCancel: true,
+                cancelText: '取消',
+                confirmText: '保存',
+                confirm: () => {
+                    save()
+                }
+            })
+        }
+        else {
+            showAlert({
+                title: 'Saving as Intermittent Fasting',
+                content: 'Fasting that lasts fewer than 24 hours will be saved as Intermittent Fasting.',
+                showCancel: true,
+                cancelText: '取消',
+                confirmText: '保存',
+                confirm: () => {
+                    save()
+                }
+            })
+        }
+    }
+
+    function save() {
+
+        clockTimes({
+            check_items: [{
+                schedule_id: long_fast.timeline[1].schedule_id,
+                date: dayjs().format('YYYYMMDD'),
+                timestamp: new Date().getTime(),
+                extra: {
+                    set_time: global.set_time ? global.set_time : new Date().getTime(),
+                    confirm_time: new Date().getTime()
+                }
+            }]
+        }).then(res => {
+            global.refreshWindow()
+            global.refreshHistory()
+        }).catch(e => {
+        })
+    }
+
+    function timeText() {
+        if (long_fast.status == 'OG') {
+            return TimeFormatter.countdown(long_fast.real.start_timestamp)
+        }
+        return '00:00:00'
+    }
+
+    function goal() {
+        var hours = long_fast.extra.long_fast_goal/60
+        var days = Math.floor(hours / 24)
+        var left = hours % 24
+        var str = ''
+        if (days > 0) {
+            str = days + '天'
+        }
+        if (left > 0) {
+            str += left + '小时'
+        }
+        return str
+    }
+
     return <View className="page_container">
         <NewHeader type={NewHeaderType.left_subtitle}
             title="Long Fast "
@@ -16,20 +133,47 @@ export default function LongFast() {
         />
         <Card>
             <View className="long_fast_card">
-                <View className="h50 bold">00:00:00</View>
-                <View className="h24" style={{ color: MainColorType.g02 }}>Goal 24 hours</View>
+                <View className="h50 bold">{timeText()}</View>
+                <View className="h24" style={{ color: MainColorType.g02 }}>Goal {goal()}</View>
                 <View style={{ height: rpxToPx(33) }} />
-                <NewButton
-                    type={NewButtonType.fill}
-                    width={rpxToPx(538)}
-                    height={rpxToPx(96)}
-                    color={getThemeColor('FAST')}
-                    title="Start fast"
-                    onClick={() => {
-                        jumpPage('./long_fast_setting')
-                    }}
-                />
+                {
+                    long_fast.status == 'WFS' ? <NewButton
+                        type={NewButtonType.fill}
+                        width={rpxToPx(538)}
+                        height={rpxToPx(96)}
+                        color={getThemeColor('FAST')}
+                        title="Start fast"
+                        onClick={() => {
+                            tapStart()
+                            // 
+                        }}
+                    /> :
+                        <NewButton
+                            type={NewButtonType.alpha}
+                            width={rpxToPx(538)}
+                            height={rpxToPx(96)}
+                            color={getThemeColor('FAST')}
+                            title="How are you feeling?"
+                            onClick={() => {
+                                tapLog()
+                            }}
+                        />
+                }
+
             </View>
         </Card>
+
+        <View style={{ position: 'relative', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
+            <NewButton
+                type={NewButtonType.link}
+                height={rpxToPx(96)}
+                title='End fast'
+                onClick={() => {
+                    tapEnd()
+                }}
+            />
+        </View>
+
+        <MainHistory type='FAST' fast_type="LF" />
     </View>
 }

+ 45 - 10
src/_health/pages/long_fast_setting.tsx

@@ -5,15 +5,24 @@ import NewButton, { NewButtonType } from "../base/new_button";
 import { getThemeColor } from "@/features/health/hooks/health_hooks";
 import { rpxToPx } from "@/utils/tools";
 import { MainColorType } from "@/context/themes/color";
-import { useState } from "react";
+import { useEffect, useState } from "react";
 import NewDurationPicker, { DurationPickerType } from "../base/new_durationpicker";
 import dayjs from "dayjs";
 import NewTimePicker from "../base/new_timepicker";
+import { useSelector } from "react-redux";
+import { clockTimes } from "@/services/health";
+import Taro from "@tarojs/taro";
 
 export default function LongFastSetting() {
     const [showGoal, setShowGoal] = useState(true)
     const [isToday, setIsToday] = useState(true)
     const [duration, setDuration] = useState(24)
+    const [time, setTime] = useState(dayjs().format('HH:mm'))
+    const health = useSelector((state: any) => state.health);
+
+    useEffect(() => {
+        global.set_time = new Date().getTime()
+    }, [])
 
     function getDuration() {
         var day = Math.floor(duration / 24)
@@ -25,6 +34,32 @@ export default function LongFastSetting() {
             str += hour + '小时'
         return str
     }
+
+    function commit() {
+
+        let now = new Date(dayjs().format('YYYY-MM-DDT')+time+':00').getTime()
+        if (!isToday){
+            now = now - 24*3600*1000
+        }
+
+        clockTimes({
+            check_items: [{
+                schedule_id: health.long_fast.timeline[0].schedule_id,
+                date: dayjs(now).format('YYYYMMDD'),
+                timestamp: now,
+                extra: {
+                    long_fast_goal:duration*60,
+                    set_time: global.set_time ? global.set_time : new Date().getTime(),
+                    confirm_time: new Date().getTime()
+                }
+            }]
+        }).then(res => {
+            global.refreshWindow()
+            global.refreshHistory()
+            Taro.navigateBack()
+        }).catch(e => {
+        })
+    }
     return <View className="page_container">
         <Card>
             <View style={{ position: 'relative' }}>
@@ -43,12 +78,12 @@ export default function LongFastSetting() {
                     />
                 </View>
                 {
-                    showGoal && <NewDurationPicker color={MainColorType.fast} 
-                    type={DurationPickerType.long} 
-                    value={duration}
-                    onChange={(e)=>{
-                        setDuration(e)
-                    }}
+                    showGoal && <NewDurationPicker color={MainColorType.fast}
+                        type={DurationPickerType.long}
+                        value={duration}
+                        onChange={(e) => {
+                            setDuration(e)
+                        }}
                     />
                 }
                 <View className="long_fast_card_footer">
@@ -79,7 +114,7 @@ export default function LongFastSetting() {
                         color={getThemeColor('FAST')}
                         width={rpxToPx(196)}
                         height={rpxToPx(84)}
-                        title={dayjs().format('HH:mm')}
+                        title={time}
                         onClick={() => {
                             setShowGoal(false)
                         }}
@@ -87,7 +122,7 @@ export default function LongFastSetting() {
                 </View>
                 {
                     !showGoal && <NewTimePicker color={MainColorType.fast} onChange={(e) => {
-
+                        setTime(e)
                     }} />
                 }
             </View>
@@ -100,7 +135,7 @@ export default function LongFastSetting() {
                 height={rpxToPx(96)}
                 title="开始"
                 onClick={() => {
-
+                    commit()
                 }}
             />
         </View>

+ 1 - 1
src/features/health/History.scss

@@ -1,4 +1,4 @@
-.history_item {
+.history_item2 {
     display: flex;
     flex-direction: row;
     width: 750px;

+ 52 - 9
src/features/health/HistoryItem.tsx

@@ -12,7 +12,16 @@ import { IconMore } from "@/components/basic/Icons";
 import showActionSheet from "@/components/basic/ActionSheet";
 import { makeDone } from "@/services/health";
 
-export default function HistoryItem(props: { data: any, preData: any, index: number, onClick: Function, isArchived?: boolean, refresh?: Function }) {
+export default function HistoryItem(props: {
+    data: any,
+    preData: any,
+    index: number,
+    onClick: Function,
+    isArchived?: boolean,
+    refresh?: Function,
+    mode: string,
+    fast_type?: string
+}) {
     const health = useSelector((state: any) => state.health);
     let showActionSheetWithOptions;
     function preview(obj) {
@@ -60,13 +69,37 @@ export default function HistoryItem(props: { data: any, preData: any, index: num
 
         const realRing = {
             hideBg: true,
-            color: getThemeColor(health.mode),
+            color: props.mode == 'FAST,SLEEP'?getThemeColor('FAST'):getThemeColor(health.mode),
             startArc: startArc(props.data.window_range.start_timestamp),
             durationArc: durationArc(props.data.window_range.start_timestamp, props.data.window_range.end_timestamp)
         }
+        const canvasId = props.mode == 'FAST,SLEEP'?'history_fast_sleep' + props.index:'history_' + props.index
+        return <Rings common={common} bgRing={bgRing} realRing={realRing} canvasId={canvasId} />
+    }
 
+    function ring2() {
+        const common: RingCommon = {
+            useCase: 'ChooseScenario',
+            radius: 10,
+            lineWidth: 3,
+            isFast: true,
+            status: 'WAIT_FOR_START'
+        }
 
-        return <Rings common={common} bgRing={bgRing} realRing={realRing} canvasId={'history_' + props.index} />
+        const bgRing: BgRing = {
+            color: MainColorType.ringBg
+        }
+
+        const realRing = {
+            hideBg: true,
+            color: getThemeColor('SLEEP'),
+            startArc: startArc(props.data.events[1].time.timestamp),
+            durationArc: durationArc(props.data.events[1].time.timestamp, props.data.events[2].time.timestamp)
+        }
+
+        
+        const canvasId = 'history2_props_mode' + props.index
+        return <Rings common={common} bgRing={bgRing} realRing={realRing} canvasId={canvasId} />
     }
 
     function mediaCount() {
@@ -93,7 +126,7 @@ export default function HistoryItem(props: { data: any, preData: any, index: num
         return dayjs(props.data.window_range.start_timestamp).format('D')
     }
 
-    return <View className="history_item">
+    return <View className="history_item2">
         <View className="history_date">{historyDate()}</View>
         <View className="history_content">
 
@@ -103,8 +136,8 @@ export default function HistoryItem(props: { data: any, preData: any, index: num
                         return <Text key={index}>
                             <Text className="history_item_title">{item.time && dayjs(item.time.timestamp).format('HH:mm')} {getTitle(item)} </Text>
                             {
-                                item.moments && item.moments.map((moment,i)=>{
-                                    return <Text className="history_item_desc" key={i*1000}>{moment.description}</Text>
+                                item.moments && item.moments.map((moment, i) => {
+                                    return <Text className="history_item_desc" key={i * 1000}>{moment.description}</Text>
                                 })
                             }
                         </Text>
@@ -114,8 +147,8 @@ export default function HistoryItem(props: { data: any, preData: any, index: num
             <View className="media" style={{ marginTop: mediaCount() > 0 ? 9 : -10, marginRight: mediaCount() == 4 ? 80 : 0 }}>
                 {
                     props.data.events.map((item) => {
-                        if (item.moments){
-                            return item.moments.map(moment=>{
+                        if (item.moments) {
+                            return item.moments.map(moment => {
                                 return moment.media.map((obj, j) => {
                                     return <Image className="media_item" mode="aspectFill" onClick={() => preview(obj)} src={obj.url} key={j * 10} />
                                 })
@@ -127,12 +160,22 @@ export default function HistoryItem(props: { data: any, preData: any, index: num
             </View>
             <View className="history_duration_bg">
                 {
-                    ring()
+                    props.fast_type != 'LF' && ring()
                 }
                 {
                     props.data.window_range.end_timestamp && <Text className="history_item_duration">{formatMilliseconds(props.data.window_range.end_timestamp - props.data.window_range.start_timestamp)}</Text>
                 }
             </View>
+            {
+                props.mode == 'FAST,SLEEP' && props.data.events.length>2 && <View className="history_duration_bg" style={{marginTop:0}}>
+                    {
+                        props.fast_type != 'LF' && ring2()
+                    }
+                    {
+                        props.data.window_range.end_timestamp && <Text className="history_item_duration">{formatMilliseconds(props.data.events[2].time.timestamp - props.data.events[1].time.timestamp)}</Text>
+                    }
+                </View>
+            }
             {
                 props.isArchived && <View className="history_archived_row">
                     <View className="history_archived" onClick={(e) => {

+ 39 - 11
src/features/health/MainConsole.tsx

@@ -8,7 +8,7 @@ import { jumpPage } from "../trackTimeDuration/hooks/Common";
 import Modal from "@/components/layout/Modal.weapp";
 import { MainColorType } from "@/context/themes/color";
 import ConsolePicker from "../trackTimeDuration/components/ConsolePicker";
-import { clockTimes, makeDone, updateEventDuration, updateSchedule, updateTarget } from "@/services/health";
+import { clockTimes, makeDone, updateEventDuration, updateFast, updateSchedule, updateTarget } from "@/services/health";
 import TimePicker from "../common/TimePicker";
 import showActionSheet from "@/components/basic/ActionSheet";
 import { rpxToPx } from "@/utils/tools";
@@ -22,6 +22,7 @@ import { TimeFormatter } from "@/utils/time_format";
 import { clearLocation } from "@/services/user";
 import OnBoard from "@/_health/components/onboard";
 import NewButton, { NewButtonType } from "@/_health/base/new_button";
+import showAlert from "@/components/basic/Alert";
 
 let useNavigation;
 let min = 0
@@ -79,6 +80,20 @@ export default function MainConsole(props: { type: WindowType }) {
             return
         }
 
+        if (item.event == 'FAST_START' && health.long_fast.status == 'OG') {
+            showAlert({
+                title: '长断食进行中',
+                content: '当前有一个正在进行的长断食记录,要转换为间歇性断食吗?',
+                showCancel: true,
+                cancelText: '取消',
+                confirmText: '确定',
+                confirm: () => {
+                    changeToIF();
+                }
+            })
+            return
+        }
+
         setSelItem(item)
 
         switch (item.action) {
@@ -415,16 +430,29 @@ export default function MainConsole(props: { type: WindowType }) {
         }
         global.scenario = 'FAST'
         setBtnDisable(true)
+
+        save(t1)
+
+    }
+
+    function changeToIF(){
+        updateFast({ fast_type: 'IF' }).then(res => {
+            global.refreshWindow()
+        })
+    }
+
+    function save(t1: number) {
+        var params:any = {
+            schedule_id: selItem.schedule_id,
+            date: dayjs(t1).format('YYYYMMDD'),
+            timestamp: t1,
+            extra: {
+                set_time: global.set_time ? global.set_time : new Date().getTime(),
+                confirm_time: new Date().getTime()
+            }
+        }
         clockTimes({
-            check_items: [{
-                schedule_id: selItem.schedule_id,
-                date: dayjs(t1).format('YYYYMMDD'),
-                timestamp: t1,
-                extra: {
-                    set_time: global.set_time ? global.set_time : new Date().getTime(),
-                    confirm_time: new Date().getTime()
-                }
-            }]
+            check_items: [params]
         }).then(res => {
             dispatch(setShowActionTip({
                 isShow: true,
@@ -799,7 +827,7 @@ export default function MainConsole(props: { type: WindowType }) {
                 str = 'Fast after Wake Up'
                 break
         }
-        return <View className="h28" style={{color:MainColorType.g01}}>{str}</View>
+        return <View className="h28" style={{ color: MainColorType.g01 }}>{str}</View>
     }
 
     return <View className="main-console-bg">

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

@@ -12,7 +12,7 @@ import { getThemeColor } from "./hooks/health_hooks";
 import { TimeFormatter } from "@/utils/time_format";
 
 let lastMode = ''
-export default function MainHistory(props: { type?: string }) {
+export default function MainHistory(props: { type?: string, fast_type?: string }) {
     const [list, setList] = useState<any>([])
     const [page, setPage] = useState(1)
     const [total, setTotal] = useState(0)
@@ -26,11 +26,11 @@ export default function MainHistory(props: { type?: string }) {
         refresh()
     }
 
-    useEffect(()=>{
-        if (props.type){
+    useEffect(() => {
+        if (props.type) {
             loadData(1)
         }
-    },[props.type])
+    }, [props.type])
 
 
     useEffect(() => {
@@ -54,12 +54,15 @@ export default function MainHistory(props: { type?: string }) {
     }
 
     function loadData(index: number) {
-        // return
-        records({
-            window: props.type?props.type:health.mode,
+        var params: any = {
+            window: props.type ? props.type : health.mode,
             limit: 10,
             page: index
-        }).then(res => {
+        }
+        if (props.fast_type) {
+            params.fast_type = props.fast_type
+        }
+        records(params).then(res => {
             setLoaded(true)
             if (index == 1) {
                 setList((res as any).data)
@@ -136,6 +139,8 @@ export default function MainHistory(props: { type?: string }) {
                         data={item}
                         preData={index > 0 ? list[index - 1] : null}
                         index={index}
+                        mode={props.type ?? health.mode}
+                        fast_type={props.fast_type}
                         onClick={() => {
                             jumpPage('/_health/pages/moment_detail')
                         }} />

+ 2 - 1
src/pages/clock/ClockNew.tsx

@@ -12,7 +12,7 @@ import MainHistory from "@/features/health/MainHistory";
 import { WindowType } from "@/utils/types";
 import { getArchived, windows } from "@/services/health";
 import { useDispatch, useSelector } from "react-redux";
-import health, { setEatArchived, setFastWithSleep, setRefreshs, setTitle, setWindows } from "@/store/health";
+import health, { setEatArchived, setFastWithSleep, setLongFast, setRefreshs, setTitle, setWindows } from "@/store/health";
 import dayjs from "dayjs";
 import Modal from "@/components/layout/Modal.weapp";
 import Streak from "@/features/health/Streak";
@@ -119,6 +119,7 @@ export default function ClockNew() {
             }
             dispatch(setFastWithSleep((res as any).fast_with_sleep))
             dispatch(setWindows((res as any).windows))
+            dispatch(setLongFast((res as any).long_fast))
             dispatch(setRefreshs((res as any).refresh_timestamps))
         })
         archived()

+ 12 - 1
src/services/health.tsx

@@ -1,4 +1,4 @@
-import { API_ACTIVE_MOVES, API_ACTIVE_MOVES_CURRENT, API_ACTIVE_MOVES_SCHEDULES, API_HEALTH_ARCHIVED, API_HEALTH_CLOCK, API_HEALTH_EVENTS, API_HEALTH_FAST_SLEEP, API_HEALTH_LABELS_EVENT, API_HEALTH_LABELS_TIME, API_HEALTH_MOMENT, API_HEALTH_RECORD, API_HEALTH_SCHEDULES, API_HEALTH_STREAKS, API_HEALTH_TARGET, API_HEALTH_WINDOWS, API_ME_ALBUMS, API_ME_ALBUMS_STAT, API_ME_JOURNALS } from "./http/api";
+import { API_ACTIVE_MOVES, API_ACTIVE_MOVES_CURRENT, API_ACTIVE_MOVES_SCHEDULES, API_HEALTH_ARCHIVED, API_HEALTH_CLOCK, API_HEALTH_EVENTS, API_HEALTH_FAST_SLEEP, API_HEALTH_LABELS_EVENT, API_HEALTH_LABELS_TIME, API_HEALTH_MOMENT, API_HEALTH_RECORD, API_HEALTH_SCHEDULES, API_HEALTH_STREAKS, API_HEALTH_TARGET, API_HEALTH_WINDOWS, API_HEATH_FAST, API_ME_ALBUMS, API_ME_ALBUMS_STAT, API_ME_JOURNALS } from "./http/api";
 import { request } from "./http/request";
 
 export const getLabelsEvent = (params) => {
@@ -323,3 +323,14 @@ export const fastWithSleep = ()=>{
         })
     })
 }
+
+export const updateFast = (params)=>{
+    return new Promise((resolve) => {
+        request({
+            url: API_HEATH_FAST, method: 'POST', data: { ...params }
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        })
+    })
+}

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

@@ -108,6 +108,7 @@ export const API_HEALTH_CLOCK = `${baseUrl}/api/health/clocks`
 export const API_HEALTH_EVENTS = `${baseUrl}/api/health/events`
 export const API_HEALTH_ARCHIVED = `${baseUrl}/api/health/archived`
 export const API_HEATH_EVENTS = `${baseUrl}/api/health/events`
+export const API_HEATH_FAST = `${baseUrl}/api/health/fast`
 
 export const API_ACTIVE_MOVES_CURRENT = `${baseUrl}/api/health/active/moves/current`
 export const API_ACTIVE_MOVES_SCHEDULES = `${baseUrl}/api/health/schedules/active/move`

+ 6 - 1
src/store/health.tsx

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