leon пре 1 година
родитељ
комит
3e3aa6b270

+ 7 - 0
src/_health/base/new_durationpicker.tsx

@@ -104,6 +104,13 @@ export default function NewDurationPicker(props: { value?: any, onChange?: any,
     }
 
     function longValues() {
+        if (props.value){
+            var day = Math.floor(props.value/24)
+            var hour = props.value%24
+            return [day-1,hour]
+            
+
+        }
         return [0, 0]
     }
 

+ 47 - 11
src/_health/components/fast_sleep_card.tsx

@@ -4,7 +4,7 @@ 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';
+import { getDurationArc, getStartArc, getThemeColor } from '@/features/health/hooks/health_hooks';
 
 export default function FastSleepCard(props: { step: number, data: any }) {
 
@@ -39,6 +39,14 @@ export default function FastSleepCard(props: { step: number, data: any }) {
 
     function target0SmallRing() {
         const { sleep } = props.data
+        if (sleep.real && sleep.real.end_timestamp){
+            return {
+                color: MainColorType.sleepLight,
+                startArc: getStartArc(sleep.real.start_timestamp),
+                durationArc: getDurationArc(sleep.real.start_timestamp, sleep.real.end_timestamp)
+            }
+        }
+
         return {
             color: MainColorType.sleepLight,
             startArc: getStartArc(sleep.target.start_timestamp),
@@ -59,6 +67,13 @@ export default function FastSleepCard(props: { step: number, data: any }) {
 
     function target2BigRing() {
         const { sleep } = props.data
+        if (sleep.real && sleep.real.end_timestamp){
+            return {
+                color: MainColorType.sleepLight,
+                startArc: getStartArc(sleep.real.start_timestamp),
+                durationArc: getDurationArc(sleep.real.start_timestamp, sleep.real.end_timestamp)
+            }
+        }
         return {
             color: MainColorType.sleepLight,
             startArc: getStartArc(sleep.target.start_timestamp),
@@ -67,11 +82,11 @@ export default function FastSleepCard(props: { step: number, data: any }) {
     }
 
     function target3BigRing() {
-        const { fast, sleep } = props.data
+        const { fast, sleep,status } = props.data
         return {
             color: MainColorType.fastLight,
-            startArc: getStartArc(sleep.target.end_timestamp),
-            durationArc: getDurationArc(sleep.target.end_timestamp, fast.target.end_timestamp)
+            startArc: getStartArc(status=='OG3'?sleep.real.end_timestamp:sleep.target.end_timestamp),
+            durationArc: getDurationArc(status=='OG3'?sleep.real.end_timestamp:sleep.target.end_timestamp, fast.target.end_timestamp)
         }
     }
 
@@ -92,6 +107,13 @@ export default function FastSleepCard(props: { step: number, data: any }) {
         if (!sleep.real) {
             return null;
         }
+        if (sleep.real.end_timestamp){
+            return {
+                color: MainColorType.sleep,
+                startArc: getStartArc(sleep.real.start_timestamp),
+                durationArc: getDurationArc(sleep.real.start_timestamp, sleep.real.end_timestamp)
+            }
+        }
         return {
             color: MainColorType.sleep,
             startArc: getStartArc(sleep.real.start_timestamp),
@@ -140,6 +162,18 @@ export default function FastSleepCard(props: { step: number, data: any }) {
         }
     }
 
+    function currentDot(mode) {
+
+
+        return {
+            color: getThemeColor(mode),
+            lineWidth: 4,
+            borderColor: '#F5F5F5',
+            offset: 0
+        }
+
+    }
+
 
     function circle0() {
         return <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', width: '100%', height: '100%', position: 'relative' }}>
@@ -148,7 +182,7 @@ export default function FastSleepCard(props: { step: number, data: any }) {
                 targetRing={target0BigRing()}
                 realRing={real0BigRing()}
                 canvasId={'circle0_big'}
-            // currentDot={currentDot()}
+                currentDot={currentDot('FAST')}
             />
 
             <View style={{
@@ -166,7 +200,7 @@ export default function FastSleepCard(props: { step: number, data: any }) {
                     targetRing={target0SmallRing()}
                     realRing={real0SmallRing()}
                     canvasId={'circle0_small'}
-                // currentDot={currentDot()}
+                    currentDot={currentDot('SLEEP')}
                 />
             </View>
         </View>
@@ -179,8 +213,7 @@ export default function FastSleepCard(props: { step: number, data: any }) {
             targetRing={target1BigRing()}
             realRing={real1BigRing()}
             canvasId={'circle1_big'}
-        // currentDot={currentDot()}
-
+            currentDot={currentDot('FAST')}
         />
     }
 
@@ -190,7 +223,7 @@ export default function FastSleepCard(props: { step: number, data: any }) {
             targetRing={target2BigRing()}
             realRing={real2BigRing()}
             canvasId={'circle2_big'}
-        // currentDot={currentDot()}
+            currentDot={currentDot('SLEEP')}
 
         />
     }
@@ -201,7 +234,7 @@ export default function FastSleepCard(props: { step: number, data: any }) {
             targetRing={target3BigRing()}
             realRing={real3BigRing()}
             canvasId={'circle3_big'}
-        // currentDot={currentDot()}
+            currentDot={currentDot('FAST')}
 
         />
     }
@@ -318,6 +351,9 @@ export default function FastSleepCard(props: { step: number, data: any }) {
             var now = new Date().getTime()
             return TimeFormatter.calculateTimeDifference(now, now + sleep.target.duration)
         }
+        else if (status == 'OG3') {
+            return TimeFormatter.calculateTimeDifference(sleep.real.start_timestamp, sleep.real.end_timestamp)
+        }
         return TimeFormatter.countdown(sleep.real.start_timestamp)
     }
 
@@ -369,7 +405,7 @@ export default function FastSleepCard(props: { step: number, data: any }) {
 
         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
+        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)

+ 6 - 0
src/_health/components/fast_sleep_console.scss

@@ -55,4 +55,10 @@
 .timeline_thirdspace {
     height: 12px;
     margin-top: 5px;
+}
+
+.console_item_img {
+    width: 76px;
+    height: 76px;
+    border-radius: 12px;
 }

+ 90 - 11
src/_health/components/fast_sleep_console.tsx

@@ -5,6 +5,9 @@ import NewButton, { NewButtonType } from "../base/new_button";
 import { getThemeColor } from "@/features/health/hooks/health_hooks";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import dayjs from "dayjs";
+import { MainColorType } from "@/context/themes/color";
+import showAlert from "@/components/basic/Alert";
+import { delRecord } from "@/services/trackTimeDuration";
 
 export default function FastSleepConsole(props: { step: number, data: any }) {
 
@@ -67,11 +70,63 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
     */
     }
 
+    function goDetail(index) {
+        if (index == 0 && props.data.fast.status == 'OG') {
+            const { event_id, schedule_id } = props.data.fast.timeline[0]
+            jumpPage(`/_health/pages/timeline_detail?event_id=${event_id}&schedule_id=${schedule_id}`)
+        }
+        else if (index == 1 && (props.data.sleep.status == 'OG' || props.data.status == 'OG3')) {
+            const { event_id, schedule_id } = props.data.sleep.timeline[0]
+            jumpPage(`/_health/pages/timeline_detail?event_id=${event_id}&schedule_id=${schedule_id}`)
+        }
+
+    }
+
+    function delConfirm() {
+        const { fast, sleep } = props.data
+        let array: any = []
+        if (fast.window_id){
+            array.push(fast.window_id)
+        }
+        if (sleep.window_id) {
+            array.push(sleep.window_id)
+        }
+
+
+        showAlert({
+            title: 'del',
+            content: '确认删除此记录?',
+            showCancel: true,
+            confirm: () => {
+                delRecord(array[0], { ids: array }).then(res => {
+                    global.refreshWindow()
+                })
+            }
+        })
+    }
+
+    function getIconColor(index: number, finish: boolean) {
+        var color = '#D9D9D9'
+        if (index == 1 || index == 2) {
+            color = MainColorType.sleep
+        }
+        else {
+            color = MainColorType.fast
+        }
+        if (finish) {
+            color = '#D9D9D9'
+        }
+
+        return color;
+    }
+
+
     function timelineItem(item: any, index: number, count: number) {
         const { fast, sleep, status } = props.data
         var showBtn = true;
         var time = ''
         var hasDescription = item.moment && item.moment.description
+        var finish = false;
 
         switch (index) {
             case 0:
@@ -81,6 +136,7 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                     }
                     else {
                         showBtn = false;
+                        finish = true;
                     }
                     time = dayjs(fast.target.start_timestamp).format('HH:mm')
                 }
@@ -92,19 +148,29 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                     }
                     else {
                         showBtn = false
+                        finish = true;
+                    }
+                    if (status == 'OG3') {
+                        time = dayjs(sleep.real.start_timestamp).format('HH:mm')
+                    }
+                    else {
+                        time = dayjs(sleep.target.start_timestamp).format('HH:mm')
                     }
-                    time = dayjs(sleep.target.start_timestamp).format('HH:mm')
+
                 }
                 break;
             case 2:
                 {
                     if (status == 'OG3') {
                         showBtn = false
+                        finish = true;
+                        time = dayjs(sleep.real.end_timestamp).format('HH:mm')
                     }
                     else {
                         showBtn = true
+                        time = dayjs(sleep.target.end_timestamp).format('HH:mm')
                     }
-                    time = dayjs(sleep.target.end_timestamp).format('HH:mm')
+
                 }
                 break;
             case 3:
@@ -117,7 +183,9 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
         return <View key={index}
             className="timeline_item"
             // hoverClass='cell_hover' hoverStayTime={50}
-            onClick={() => { }}>
+            onClick={() => {
+                goDetail(index)
+            }}>
             <View className="timeline_left">
                 <View style={{
 
@@ -130,8 +198,13 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                         height: rpxToPx(28),
                         borderRadius: rpxToPx(14),
                         marginRight: rpxToPx(8),
-                        backgroundColor: 'gray'
-                    }} />
+                        display: 'flex',
+                        alignItems: 'center',
+                        justifyContent: 'center',
+                        backgroundColor: getIconColor(index, finish)
+                    }}>
+                        <Image style={{ width: rpxToPx(20), height: rpxToPx(20) }} src={finish ? require('@assets/_health/checked.png') : require('@assets/_health/ring.png')} />
+                    </View>
                     <Text className="timeline_time">{time}</Text>
                 </View>
 
@@ -179,32 +252,38 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
 
     return <View style={{ backgroundColor: '#fff' }}>
         {
-            timelineItem({
+            props.step != 2 && props.step != 3 && timelineItem({
                 title: 'Start Fast',
                 mode: 'FAST',
-                is_start: true
+                is_start: true,
+                moment: props.data.fast.timeline[0].moment
             }, 0, 4)
         }
         {
-            timelineItem({
+            props.step != 3 && timelineItem({
                 title: 'Go to bed',
                 mode: 'SLEEP',
-                is_start: true
+                is_start: true,
+                moment: props.data.sleep.timeline[0].moment
             }, 1, 4)
         }
         {
-            timelineItem({
+            props.step != 1 && timelineItem({
                 title: 'Wake up',
                 mode: 'SLEEP',
                 is_start: false
             }, 2, 4)
         }
         {
-            timelineItem({
+            props.step != 1 && props.step != 2 && timelineItem({
                 title: 'End Fast',
                 mode: 'FAST',
                 is_start: false
             }, 3, 4)
         }
+        {
+            props.data.status != 'WFS' && <Text onClick={delConfirm}>删除</Text>
+        }
+
     </View>
 }

+ 1 - 1
src/_health/components/fast_sleep_detail_card.tsx

@@ -64,7 +64,7 @@ export default function FastSleepDetailCard(props: { data: any }) {
 
         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
+        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)

+ 23 - 3
src/_health/pages/fast_sleep.tsx

@@ -24,12 +24,30 @@ export default function FastSleep() {
 
     const [loaded, setLoaded] = useState(false)
     const [data, setData] = useState<any>(null)
+    const [current, setCurrent] = useState(0)
 
     useEffect(() => {
+
         let timer = setInterval(() => {
             setCount(count => count + 1)
         }, 1000)
 
+        switch (health.fast_with_sleep.status) {
+            case 'WFS':
+            case 'OG2_NO1':
+                setCurrent(0)
+                break;
+            case 'OG1':
+                setCurrent(1)
+                break;
+            case 'OG2':
+                setCurrent(2)
+                break;
+            case 'OG3':
+                setCurrent(3)
+                break;
+        }
+
         getDatas()
 
         return () => {
@@ -58,7 +76,9 @@ export default function FastSleep() {
         />
         <Swiper indicatorColor='#999'
             indicatorActiveColor='#333'
-            style={{ height: rpxToPx(344), marginBottom: 20,flexShrink:0 }}
+            style={{ height: rpxToPx(344), marginBottom: 20, flexShrink: 0 }}
+            onChange={e => setCurrent(e.detail.current)}
+            current={current}
             indicatorDots>
             <SwiperItem>
                 <Card>
@@ -83,8 +103,8 @@ export default function FastSleep() {
             </SwiperItem>
         </Swiper>
 
-        <FastSleepDetailCard data={data}/>
-        <FastSleepConsole step={0} data={data} />
+        <FastSleepDetailCard data={data} />
+        <FastSleepConsole step={current} data={data} />
         <MainHistory type='FAST,SLEEP' />
         {/* <NewButton type={NewButtonType.link} title="hello world" onClick={() => {
 

+ 94 - 16
src/_health/pages/log_time.tsx

@@ -14,6 +14,7 @@ import { MainColorType } from "@/context/themes/color";
 import Taro from "@tarojs/taro";
 import { clockTimes, fastWithSleep } from "@/services/health";
 import NewDurationPicker, { DurationPickerType } from "../base/new_durationpicker";
+import showAlert from "@/components/basic/Alert";
 
 let useRoute;
 let useNavigation;
@@ -131,9 +132,9 @@ export default function LogTime() {
             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
+            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
@@ -158,12 +159,15 @@ export default function LogTime() {
                 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')
+                if (list.length > 2) {
+                    var sleepEndToday = new Date().getDate() == new Date(sleepEndTime).getDate()
+                    list[2].today = sleepEndToday
+                    list[2].time = dayjs(sleepEndTime).format('HH:mm')
+                }
             }
 
 
+
         }
         setArray(list)
 
@@ -194,7 +198,7 @@ export default function LogTime() {
         return timestamp
     }
 
-    function commit() {
+    function tapCommit() {
         var list: any = []
         if (isSingle) {
             var obj = array[0]
@@ -231,6 +235,33 @@ export default function LogTime() {
                 }
             }
         }
+
+        //检查断食时间是否超过24小时
+        const { fast } = data
+        if (fast.real) {
+            var t = fast.real.start_timestamp
+            var schedule_id = fast.timeline[1].schedule_id
+            if (list[list.length-1].schedule_id==schedule_id && list[list.length-1].timestamp-t>24*3600*1000){
+                showAlert({
+                    title: 'Saving as Long Fast',
+                    content: 'Fasting that lasts more than 24 hours will be saved as Long Fast. ',
+                    showCancel: true,
+                    cancelText: '取消',
+                    confirmText: '保存',
+                    cancel: () => {
+                    },
+                    confirm: () => {
+                        commit(list)
+                    }
+                })
+                return;
+            }
+        }
+        commit(list)
+
+    }
+
+    function commit(list) {
         clockTimes({
             check_items: list
         }).then(res => {
@@ -271,18 +302,63 @@ export default function LogTime() {
         return str
     }
 
-    function logItem(index: number, iFast: boolean, iStart: boolean, showLine: boolean) {
+    function logItem(index: number, iFast: boolean, iStart: boolean, showLine: boolean, disable = false) {
         const { fast, sleep } = data
         var schedule_time = ''
         var title = ''
+
+        var date = array[index].today ? "Today" : "Yesterday"
+        var time = array[index].time
+
+        const today = dayjs();
         if (iFast) {
             schedule_time = iStart ? fast.period.start_time : fast.period.end_time
+            if (!iStart && fast.status == 'OG') {
+                schedule_time = dayjs(fast.target.end_timestamp).format('HH:mm')
+            }
             title = iStart ? 'Fast starts' : 'Fast ends'
+
+
+
+            if (disable) {
+                var timestamp = iStart ? fast.real.start_timestamp : fast.real.end_timestamp
+                const dt = dayjs(timestamp);
+                const yesterday = today.subtract(1, 'day');
+                time = dayjs(timestamp).format('HH:mm')
+
+                if (dt.isSame(today, 'day')) {
+                    date = 'Today';
+                } else if (dt.isSame(yesterday, 'day')) {
+                    date = 'Yesterday';
+                } else {
+                    date = dt.format('MM-DD');
+                }
+            }
         }
         else {
             schedule_time = iStart ? sleep.period.start_time : sleep.period.end_time
+            if (!iStart && sleep.status == 'OG') {
+                schedule_time = dayjs(sleep.target.end_timestamp).format('HH:mm')
+            }
             title = iStart ? 'Bedtime' : 'Wake up'
+            if (disable) {
+                var timestamp = iStart ? sleep.real.start_timestamp : sleep.real.end_timestamp
+                const dt = dayjs(timestamp);
+                const yesterday = today.subtract(1, 'day');
+                time = dayjs(timestamp).format('HH:mm')
+
+                if (dt.isSame(today, 'day')) {
+                    date = 'Today';
+                } else if (dt.isSame(yesterday, 'day')) {
+                    date = 'Yesterday';
+                } else {
+                    date = dt.format('MM-DD');
+                }
+            }
         }
+
+
+
         return <View style={{ position: 'relative' }}>
             <View className="card_header">
                 {
@@ -292,10 +368,11 @@ export default function LogTime() {
 
                 <NewButton
                     type={NewButtonType.gray}
-                    title={array[index].today ? "Today" : "Yesterday"}
+                    title={date}
                     fontSize={rpxToPx(34)}
                     width={rpxToPx(196)}
                     height={rpxToPx(84)}
+                    disable={disable}
                     onClick={() => {
                         var list = JSON.parse(JSON.stringify(array))
                         list[index].today = !list[index].today
@@ -306,10 +383,11 @@ export default function LogTime() {
                 <NewButton
                     type={expandIndex == index ? NewButtonType.alpha : NewButtonType.gray}
                     color={iFast ? MainColorType.fast : MainColorType.sleep}
-                    title={array[index].time}
+                    title={time}
                     fontSize={rpxToPx(34)}
                     width={rpxToPx(196)}
                     height={rpxToPx(84)}
+                    disable={disable}
                     onClick={() => {
                         setExpandIndex(index)
                     }}
@@ -355,10 +433,10 @@ export default function LogTime() {
             case 2:
                 return <View style={{ position: 'relative' }}>
                     {
-                        (status == 'WFS' || status == 'OG2_NO1') && logItem(0, true, true, true)
+                        logItem(0, true, true, true, !(status == 'WFS' || status == 'OG2_NO1'))
                     }
                     {
-                        (status == 'WFS' || status == 'OG1') && logItem(1, false, true, true)
+                        logItem(1, false, true, true, !(status == 'WFS' || status == 'OG1'))
                     }
                     {
                         logItem(2, false, false, false)
@@ -367,13 +445,13 @@ export default function LogTime() {
             case 3:
                 return <View style={{ position: 'relative' }}>
                     {
-                        (status == 'WFS' || status == 'OG2_NO1') && logItem(0, true, true, true)
+                        logItem(0, true, true, true, !(status == 'WFS' || status == 'OG2_NO1'))
                     }
                     {
-                        (status == 'WFS' || status == 'OG1') && logItem(1, false, true, true)
+                        logItem(1, false, true, true, !(status == 'WFS' || status == 'OG1'))
                     }
                     {
-                        (status == 'WFS' || status == 'OG1' || status == 'OG2' || status == 'OG2_NO1') && logItem(2, false, false, true)
+                        logItem(2, false, false, true, !(status == 'WFS' || status == 'OG1' || status == 'OG2' || status == 'OG2_NO1'))
                     }
                     {
                         logItem(3, true, false, false)
@@ -449,7 +527,7 @@ export default function LogTime() {
                 width={rpxToPx(670)}
                 height={rpxToPx(96)}
                 bold={true}
-                onClick={commit} />
+                onClick={tapCommit} />
         </View>
 
     </View>

+ 134 - 32
src/_health/pages/long_fast.tsx

@@ -10,21 +10,37 @@ 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 { clockTimes, delRecord, updateFast } from "@/services/health";
 import { useEffect, useState } from "react";
 import { TimeFormatter } from "@/utils/time_format";
 import dayjs from "dayjs";
+import showActionSheet from "@/components/basic/ActionSheet";
+import NewModal from "../base/new_modal";
+import NewDurationPicker, { DurationPickerType } from "../base/new_durationpicker";
+
+let useActionSheet;
+if (process.env.TARO_ENV == 'rn') {
+    useActionSheet = require('@expo/react-native-action-sheet').useActionSheet
+}
 
 export default function LongFast() {
     const health = useSelector((state: any) => state.health);
     const long_fast = health.long_fast
     const [count, setCount] = useState(1)
+    const [editDuration, setEditDuration] = useState(false)
+    const [duration, setDuration] = useState(0)
+    let showActionSheetWithOptions;
+    if (process.env.TARO_ENV == 'rn') {
+        showActionSheetWithOptions = useActionSheet()
+    }
 
     useEffect(() => {
         var timer = setInterval(() => {
             setCount(count => count + 1)
         }, 1000)
 
+        setDuration(health.long_fast.extra.long_fast_goal / 60)
+
         return () => {
             clearInterval(timer)
         }
@@ -54,23 +70,26 @@ export default function LongFast() {
 
     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}`)
+        const { event_id, schedule_id } = item
+        jumpPage(`/_health/pages/timeline_detail?event_id=${event_id}&schedule_id=${schedule_id}`)
+        // 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()
-                }
-            })
+            // 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()
+            //     }
+            // })
+            save()
         }
         else {
             showAlert({
@@ -86,6 +105,39 @@ export default function LongFast() {
         }
     }
 
+    function tapMore() {
+        showActionSheet({
+            title: '选择操作',
+            showActionSheetWithOptions: showActionSheetWithOptions,
+            itemList: ['编辑目标', '删除记录'],
+            success: (res) => {
+                switch (res) {
+                    case 0:
+                        setEditDuration(true)
+                        break
+                    case 1:
+                        showAlert({
+                            title: '确定要放弃本次断食吗?',
+                            content: '放弃后断食不会本记录',
+                            showCancel: true,
+                            cancelText: '取消',
+                            confirmText: '确定',
+                            confirm: () => {
+                                del()
+                            }
+                        })
+                        break;
+                }
+            }
+        })
+    }
+
+    function del() {
+        delRecord(health.long_fast.window_id).then(res => {
+            global.refreshWindow()
+        })
+    }
+
     function save() {
 
         clockTimes({
@@ -113,17 +165,35 @@ export default function LongFast() {
     }
 
     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 + '小时'
+        var hours = long_fast.extra.long_fast_goal / 60
+        return hours +'小时'
+        // var days = Math.floor(hours / 24)
+        // var left = hours % 24
+        // var str = ''
+        // if (days > 0) {
+        //     str = days + '天'
+        // }
+        // if (left > 0) {
+        //     str += left + '小时'
+        // }
+        // return str
+    }
+
+    function moment() {
+        if (long_fast.timeline[0].moment) {
+            const moment = long_fast.timeline[0].moment
+            return <View style={{ marginTop: 20, display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }}>
+                {
+                    moment.media && moment.media.length > 0 && <Image
+                    src={moment.media[0].url}
+                    mode="aspectFill"
+                    style={{width:rpxToPx(28),height:rpxToPx(28),borderRadius:rpxToPx(4)}} />
+                }
+                <Text style={{marginLeft:10,marginRight:10}}>{moment.description}</Text>
+                <Text>{TimeFormatter.dateDescription(moment.time.timestamp)}</Text>
+            </View>
         }
-        return str
+        return <View />
     }
 
     return <View className="page_container">
@@ -159,21 +229,53 @@ export default function LongFast() {
                             }}
                         />
                 }
+                {
+                    moment()
+                }
 
             </View>
         </Card>
+        {
+            long_fast.status == 'OG' && <View style={{ position: 'relative', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
+                <NewButton
+                    type={NewButtonType.link}
+                    height={rpxToPx(96)}
+                    title='End fast'
+                    onClick={() => {
+                        tapEnd()
+                    }}
+                />
+            </View>
+        }
+        {
+            long_fast.status == 'OG' && <Text onClick={tapMore}>More</Text>
+        }
+
 
-        <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" />
+
+        {
+            editDuration && <NewModal
+                title='长断食时长'
+                dismiss={() => {
+                    setEditDuration(false)
+                }}
+                confirm={() => {
+
+                    updateFast({ fast_type: 'LF', long_fast_goal: duration * 60 }).then(res => {
+                        setEditDuration(false)
+                        global.refreshWindow()
+                    })
+                }}
+                themeColor={getThemeColor(health.mode)}>
+                <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center', marginBottom: 20 }}>
+                    <NewDurationPicker type={DurationPickerType.long}
+                        color={MainColorType.fast}
+                        value={duration}
+                        onChange={e => setDuration(e)} />
+                </View>
+            </NewModal>
+        }
     </View>
 }

BIN
src/assets/_health/checked.png


BIN
src/assets/_health/ring.png


+ 26 - 1
src/features/health/HistoryItem.tsx

@@ -10,7 +10,8 @@ import { MainColorType } from "@/context/themes/color";
 import { durationArc, startArc } from "./util";
 import { IconMore } from "@/components/basic/Icons";
 import showActionSheet from "@/components/basic/ActionSheet";
-import { makeDone } from "@/services/health";
+import { delRecord, makeDone } from "@/services/health";
+import showAlert from "@/components/basic/Alert";
 
 export default function HistoryItem(props: {
     data: any,
@@ -126,6 +127,28 @@ export default function HistoryItem(props: {
         return dayjs(props.data.window_range.start_timestamp).format('D')
     }
 
+    function tapDel(){
+        showAlert({
+            title: '确定要放弃本次断食吗?',
+            content: '放弃后断食不会本记录',
+            showCancel: true,
+            cancelText: '取消',
+            confirmText: '确定',
+            confirm: () => {
+                del()
+            }
+        })
+        
+    }
+
+    function del(){
+        const {window_id} = props.data
+        delRecord(window_id).then(res => {
+            global.refreshWindow()
+            global.refreshHistory()
+        })
+    }
+
     return <View className="history_item2">
         <View className="history_date">{historyDate()}</View>
         <View className="history_content">
@@ -207,7 +230,9 @@ export default function HistoryItem(props: {
                     </View>
                 </View>
             }
+            <Text onClick={tapDel}>删除</Text>
         </View>
+        
         <View className="seperate_light_line" />
     </View>
 }

+ 80 - 8
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, updateFast, updateSchedule, updateTarget } from "@/services/health";
+import { clockTimes, delRecord, makeDone, updateEventDuration, updateFast, updateSchedule, updateTarget } from "@/services/health";
 import TimePicker from "../common/TimePicker";
 import showActionSheet from "@/components/basic/ActionSheet";
 import { rpxToPx } from "@/utils/tools";
@@ -94,6 +94,7 @@ export default function MainConsole(props: { type: WindowType }) {
             return
         }
 
+
         setSelItem(item)
 
         switch (item.action) {
@@ -352,6 +353,8 @@ export default function MainConsole(props: { type: WindowType }) {
             }
         }
 
+
+
         updateSchedule({
             time: strTime,
             event: selItem.event,
@@ -431,18 +434,58 @@ export default function MainConsole(props: { type: WindowType }) {
         global.scenario = 'FAST'
         setBtnDisable(true)
 
+        if (selItem.event == 'FAST_END') {
+            const fast = getScenario(health.windows, 'FAST')
+            if (fast.status == 'OG') {
+                if (t1 - fast.real.start_timestamp > 24 * 3600 * 1000) {
+                    showAlert({
+                        title: 'Saving as Long Fast',
+                        content: 'Fasting that lasts more than 24 hours will be saved as Long Fast. ',
+                        showCancel: true,
+                        cancelText: '取消',
+                        confirmText: '保存',
+                        cancel: () => {
+                            setBtnDisable(false)
+                        },
+                        confirm: () => {
+                            save(t1)
+                        }
+                    })
+                }
+                else {
+                    save(t1)
+                    // showAlert({
+                    //     title: 'Saving as Intermittent Fasting',
+                    //     content: 'Fasting that lasts fewer than 24 hours will be saved as Intermittent Fasting.',
+                    //     showCancel: true,
+                    //     cancelText: '取消',
+                    //     confirmText: '保存',
+                    //     cancel: () => {
+                    //         setBtnDisable(false)
+                    //     },
+                    //     confirm: () => {
+                    //         save(t1)
+                    //     }
+                    // })
+                }
+            }
+            return
+        }
+
         save(t1)
 
     }
 
-    function changeToIF(){
+    function changeToIF() {
         updateFast({ fast_type: 'IF' }).then(res => {
             global.refreshWindow()
         })
     }
 
     function save(t1: number) {
-        var params:any = {
+
+
+        var params: any = {
             schedule_id: selItem.schedule_id,
             date: dayjs(t1).format('YYYYMMDD'),
             timestamp: t1,
@@ -483,10 +526,12 @@ export default function MainConsole(props: { type: WindowType }) {
                 {
                     const obj = getScenario(health.windows, health.mode)
                     if (obj.window_id) {
-                        list.push('编辑本次时长')
-                        if (obj.timeline && obj.timeline[0].moment) {
-                            list.push('删除本次记录')
-                        }
+                        // list.push('编辑本次时长')
+                        // if (obj.timeline && obj.timeline[0].moment) {
+                        //     list.push('删除本次记录')
+                        // }
+
+                        list.push('删除本次记录')
                     }
                     list.push('编辑日程列表')
 
@@ -546,7 +591,17 @@ export default function MainConsole(props: { type: WindowType }) {
                                 const obj = getScenario(health.windows, health.mode)
                                 if (obj.window_id) {
                                     //编辑本次时长
-                                    setDurationPicker(true)
+                                    // setDurationPicker(true)
+                                    showAlert({
+                                        title: 'del',
+                                        content: '确认删除此记录?',
+                                        showCancel: true,
+                                        confirm: () => {
+                                            delRecord(obj.window_id).then(res => {
+                                                global.refreshWindow()
+                                            })
+                                        }
+                                    })
                                 }
                                 else {
                                     jumpPage('/_health/pages/schedules?mode=' + health.mode)
@@ -890,6 +945,22 @@ export default function MainConsole(props: { type: WindowType }) {
                     jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
                     return
                 }
+                if (health.long_fast.status == 'OG') {
+                    showAlert({
+                        title: '长断食进行中',
+                        content: '当前有一个正在进行的长断食记录,要转换为间歇性断食吗?',
+                        showCancel: true,
+                        cancelText: '取消',
+                        confirmText: '确定',
+                        confirm: () => {
+                            updateFast({ fast_type: 'IF' }).then(res => {
+                                global.refreshWindow()
+                                jumpPage('/_health/pages/fast_sleep')
+                            })
+                        }
+                    })
+                    return
+                }
                 jumpPage('/_health/pages/fast_sleep')
             }}>
                 <View className="console_active">
@@ -915,6 +986,7 @@ export default function MainConsole(props: { type: WindowType }) {
                 <View className="console_active">
                     <Image className="active_icon" src={require('@assets/_health/fast.png')} />
                     <Text className="h34">Long fast</Text>
+                    <View style={{ flex: 1 }} />
                     <Image className="cell_arrow" src={require('@assets/_health/cell_arrow.png')} />
                 </View>
 

+ 57 - 45
src/services/health.tsx

@@ -1,10 +1,10 @@
-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 { 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_EVENTS, 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) => {
     return new Promise((resolve, reject) => {
         request({
-            url: API_HEALTH_LABELS_EVENT, method: 'GET', data: {...params}
+            url: API_HEALTH_LABELS_EVENT, method: 'GET', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -17,7 +17,7 @@ export const getLabelsEvent = (params) => {
 export const getLabelsTime = (params) => {
     return new Promise((resolve, reject) => {
         request({
-            url: API_HEALTH_LABELS_TIME, method: 'GET', data: {...params}
+            url: API_HEALTH_LABELS_TIME, method: 'GET', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -30,7 +30,7 @@ export const getLabelsTime = (params) => {
 export const getSchedules = (params) => {
     return new Promise((resolve, reject) => {
         request({
-            url: API_HEALTH_SCHEDULES, method: 'GET', data: {...params}
+            url: API_HEALTH_SCHEDULES, method: 'GET', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -43,7 +43,7 @@ export const getSchedules = (params) => {
 export const createSchedule = (params) => {
     return new Promise((resolve, reject) => {
         request({
-            url: API_HEALTH_SCHEDULES, method: 'POST', data: {...params}
+            url: API_HEALTH_SCHEDULES, method: 'POST', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -53,10 +53,10 @@ export const createSchedule = (params) => {
     })
 }
 
-export const updateSchedule = (params,id) => {
+export const updateSchedule = (params, id) => {
     return new Promise((resolve, reject) => {
         request({
-            url: `${API_HEALTH_SCHEDULES}/${id}`, method: 'PUT', data: {...params}
+            url: `${API_HEALTH_SCHEDULES}/${id}`, method: 'PUT', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -66,7 +66,7 @@ export const updateSchedule = (params,id) => {
     })
 }
 
-export const delSchedule = (code:string) => {
+export const delSchedule = (code: string) => {
     return new Promise((resolve, reject) => {
         request({
             url: `${API_HEALTH_SCHEDULES}/${code}`, method: 'DELETE', data: {}
@@ -79,10 +79,10 @@ export const delSchedule = (code:string) => {
     })
 }
 
-export const delSchedules = (ids:any) => {
+export const delSchedules = (ids: any) => {
     return new Promise((resolve, reject) => {
         request({
-            url: API_HEALTH_SCHEDULES, method: 'DELETE', data: {ids}
+            url: API_HEALTH_SCHEDULES, method: 'DELETE', data: { ids }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -92,10 +92,10 @@ export const delSchedules = (ids:any) => {
     })
 }
 
-export const updateTarget = (timestamp,id) =>{
+export const updateTarget = (timestamp, id) => {
     return new Promise((resolve, reject) => {
         request({
-            url: `${API_HEALTH_TARGET}/${id}/duration`, method: 'PUT', data: {target_end_timestamp:timestamp}
+            url: `${API_HEALTH_TARGET}/${id}/duration`, method: 'PUT', data: { target_end_timestamp: timestamp }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -105,10 +105,10 @@ export const updateTarget = (timestamp,id) =>{
     })
 }
 
-export const records = (params:any)=>{
+export const records = (params: any) => {
     return new Promise((resolve, reject) => {
         request({
-            url: API_HEALTH_RECORD, method: 'GET', data: {...params}
+            url: API_HEALTH_RECORD, method: 'GET', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -118,10 +118,10 @@ export const records = (params:any)=>{
     })
 }
 
-export const streaks = (params:any)=>{
+export const streaks = (params: any) => {
     return new Promise((resolve, reject) => {
         request({
-            url: API_HEALTH_STREAKS, method: 'GET', data: {...params}
+            url: API_HEALTH_STREAKS, method: 'GET', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -131,7 +131,7 @@ export const streaks = (params:any)=>{
     })
 }
 
-export const windows = ()=>{
+export const windows = () => {
     return new Promise((resolve, reject) => {
         request({
             url: API_HEALTH_WINDOWS, method: 'GET', data: {}
@@ -144,10 +144,10 @@ export const windows = ()=>{
     })
 }
 
-export const getArchived = (mode)=>{
+export const getArchived = (mode) => {
     return new Promise((resolve, reject) => {
         request({
-            url: API_HEALTH_ARCHIVED, method: 'GET', data: {window:mode}
+            url: API_HEALTH_ARCHIVED, method: 'GET', data: { window: mode }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -157,7 +157,7 @@ export const getArchived = (mode)=>{
     })
 }
 
-export const createMoment = (params) =>{
+export const createMoment = (params) => {
     return new Promise((resolve) => {
         request({
             url: API_HEALTH_MOMENT, method: 'POST', data: { ...params }
@@ -168,10 +168,10 @@ export const createMoment = (params) =>{
     })
 }
 
-export const updateEventDuration = (id,duration)=>{
+export const updateEventDuration = (id, duration) => {
     return new Promise((resolve) => {
         request({
-            url: API_HEALTH_EVENTS+`/${id}/duration`, method: 'PUT', data: { target_duration:duration }
+            url: API_HEALTH_EVENTS + `/${id}/duration`, method: 'PUT', data: { target_duration: duration }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -179,21 +179,23 @@ export const updateEventDuration = (id,duration)=>{
     })
 }
 
-export const clockTimes = (params) =>{
-    return new Promise((resolve) => {
+export const clockTimes = (params) => {
+    return new Promise((resolve,reject) => {
         request({
             url: API_HEALTH_CLOCK, method: 'POST', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
+        }).catch(e=>{
+            reject(e)
         })
     })
 }
 
-export const makeDone = (id)=>{
+export const makeDone = (id) => {
     return new Promise((resolve) => {
         request({
-            url: API_HEALTH_WINDOWS+`/${id}/done`, method: 'POST', data: {}
+            url: API_HEALTH_WINDOWS + `/${id}/done`, method: 'POST', data: {}
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -201,10 +203,10 @@ export const makeDone = (id)=>{
     })
 }
 
-export const getActiveMovesCurrent = () =>{
+export const getActiveMovesCurrent = () => {
     return new Promise((resolve) => {
         request({
-            url: API_ACTIVE_MOVES_CURRENT, method: 'GET', data: {  }
+            url: API_ACTIVE_MOVES_CURRENT, method: 'GET', data: {}
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -212,10 +214,10 @@ export const getActiveMovesCurrent = () =>{
     })
 }
 
-export const getActiveMoves = ()=>{
+export const getActiveMoves = () => {
     return new Promise((resolve) => {
         request({
-            url: API_ACTIVE_MOVES, method: 'GET', data: {  }
+            url: API_ACTIVE_MOVES, method: 'GET', data: {}
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -223,7 +225,7 @@ export const getActiveMoves = ()=>{
     })
 }
 
-export const uploadActiveMoves = (params) =>{
+export const uploadActiveMoves = (params) => {
     return new Promise((resolve) => {
         request({
             url: API_ACTIVE_MOVES, method: 'POST', data: { ...params }
@@ -234,10 +236,10 @@ export const uploadActiveMoves = (params) =>{
     })
 }
 
-export const getActiveMoveDetail = (id)=>{
+export const getActiveMoveDetail = (id) => {
     return new Promise((resolve) => {
         request({
-            url: API_ACTIVE_MOVES+'/'+id, method: 'GET', data: {  }
+            url: API_ACTIVE_MOVES + '/' + id, method: 'GET', data: {}
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -246,7 +248,7 @@ export const getActiveMoveDetail = (id)=>{
 }
 
 
-export const getJournals = (params) =>{
+export const getJournals = (params) => {
     return new Promise((resolve) => {
         request({
             url: API_ME_JOURNALS, method: 'GET', data: { ...params }
@@ -257,7 +259,7 @@ export const getJournals = (params) =>{
     })
 }
 
-export const getAlbums = (params) =>{
+export const getAlbums = (params) => {
     return new Promise((resolve) => {
         request({
             url: API_ME_ALBUMS, method: 'GET', data: { ...params }
@@ -268,10 +270,10 @@ export const getAlbums = (params) =>{
     })
 }
 
-export const getAlbumsStat = () =>{
+export const getAlbumsStat = () => {
     return new Promise((resolve) => {
         request({
-            url: API_ME_ALBUMS_STAT, method: 'GET', data: { }
+            url: API_ME_ALBUMS_STAT, method: 'GET', data: {}
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -280,10 +282,10 @@ export const getAlbumsStat = () =>{
 }
 
 
-export const getMoveSchedules = ()=>{
+export const getMoveSchedules = () => {
     return new Promise((resolve) => {
         request({
-            url: API_ACTIVE_MOVES_SCHEDULES, method: 'GET', data: {  }
+            url: API_ACTIVE_MOVES_SCHEDULES, method: 'GET', data: {}
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -291,7 +293,7 @@ export const getMoveSchedules = ()=>{
     })
 }
 
-export const setMoveSchedules = (params)=>{
+export const setMoveSchedules = (params) => {
     return new Promise((resolve) => {
         request({
             url: API_ACTIVE_MOVES_SCHEDULES, method: 'POST', data: { ...params }
@@ -302,10 +304,10 @@ export const setMoveSchedules = (params)=>{
     })
 }
 
-export const getEvents = (id)=>{
+export const getEvents = (id) => {
     return new Promise((resolve) => {
         request({
-            url: API_HEALTH_EVENTS+'/'+id, method: 'GET', data: {  }
+            url: API_HEALTH_EVENTS + '/' + id, method: 'GET', data: {}
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -313,10 +315,10 @@ export const getEvents = (id)=>{
     })
 }
 
-export const fastWithSleep = ()=>{
+export const fastWithSleep = () => {
     return new Promise((resolve) => {
         request({
-            url: API_HEALTH_FAST_SLEEP, method: 'GET', data: {  }
+            url: API_HEALTH_FAST_SLEEP, method: 'GET', data: {}
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -324,7 +326,7 @@ export const fastWithSleep = ()=>{
     })
 }
 
-export const updateFast = (params)=>{
+export const updateFast = (params) => {
     return new Promise((resolve) => {
         request({
             url: API_HEATH_FAST, method: 'POST', data: { ...params }
@@ -334,3 +336,13 @@ export const updateFast = (params)=>{
         })
     })
 }
+
+export const delRecord = (id) => {
+    return new Promise((resolve) => {
+        request({
+            url: API_HEALTH_WINDOWS + '/' + id, method: 'DELETE'
+        }).then(res => {
+            resolve(res)
+        })
+    })
+}

+ 2 - 2
src/services/trackTimeDuration.tsx

@@ -129,10 +129,10 @@ export const updateRecord = (params: any, id: any) => {
     })
 }
 
-export const delRecord = (id: string) => {
+export const delRecord = (id: string,params?:any) => {
     return new Promise((resolve) => {
         request({
-            url: API_CLOCK_RECORDS + '/' + id, method: 'DELETE', data: {}
+            url: API_CLOCK_RECORDS + '/' + id, method: 'DELETE', data: {...params}
         }).then(res => {
             resolve(res);
         })