Leon 1 anno fa
parent
commit
453f193397

+ 2 - 2
src/_health/base/new_button.tsx

@@ -130,8 +130,8 @@ export default function NewButton(props: {
             style = {
                 height: props.height ?? rpxToPx(72),
                 minWidth: props.width ?? rpxToPx(198),
-                paddingLeft: 15,
-                paddingRight: 15,
+                paddingLeft: props.width ? 0 : 15,
+                paddingRight: props.width ? 0 : 15,
                 borderRadius: props.height ? props.height / 4 : rpxToPx(72 / 4),
                 backgroundColor: isTouched ? '#b2b2b240' : '#b2b2b210',
                 color: props.disable ? '#b2b2b2' : '#000000',

+ 1 - 0
src/_health/components/card.scss

@@ -5,4 +5,5 @@
     margin-left: 40px;
     width: 670px;
     flex-direction: column;
+    overflow: hidden;
 }

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

@@ -5,9 +5,11 @@ 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, getThemeColor } from '@/features/health/hooks/health_hooks';
+import { useSelector } from 'react-redux';
 
 export default function FastSleepCard(props: { step: number, data: any }) {
-
+    const health = useSelector((state: any) => state.health);
+    
     const common: RingCommon = {
         useCase: 'ChooseScenario',
         radius: 37,
@@ -285,6 +287,7 @@ export default function FastSleepCard(props: { step: number, data: any }) {
                     else {
                         title = 'Stage 1 completed'
                     }
+                    
                 }
                 break;
             case 2:
@@ -358,6 +361,9 @@ export default function FastSleepCard(props: { step: number, data: any }) {
     }
 
     function step1() {
+        if (health.fast_with_sleep.status == 'OG2_MISALIGNED'){
+            return 'Not Available'
+        }
         const { fast, sleep, status } = props.data
         if (status == 'WFS') {
             return TimeFormatter.calculateTimeDifference(fast.target.start_timestamp, sleep.target.start_timestamp)
@@ -382,6 +388,9 @@ export default function FastSleepCard(props: { step: number, data: any }) {
     }
 
     function step2() {
+        if (health.fast_with_sleep.status == 'OG2_MISALIGNED'){
+            return 'Not Meaningful'
+        }
         const { fast, sleep, status } = props.data
         if (status == 'OG2_NO1' || status == 'OG2') {
             return TimeFormatter.countdown(sleep.real.start_timestamp)

+ 61 - 19
src/_health/components/fast_sleep_console.tsx

@@ -7,10 +7,12 @@ 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";
 import { IconCellArrow, IconNotification, IconNotificationOff } from "@/components/basic/Icons";
+import { useSelector } from "react-redux";
+import { delRecord } from "@/services/health";
 
-export default function FastSleepConsole(props: { step: number, data: any }) {
+export default function FastSleepConsole(props: { step: number, data: any,del:any }) {
+    const health = useSelector((state: any) => state.health);
 
     function tapLogBtn(index: number) {
         const { fast, sleep, status } = props.data
@@ -63,7 +65,7 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                 break;
         }
 
-        jumpPage(`/_health/pages/log_time?is_fast_with_sleep=1&index=${index}&single=${single}&is_start=${is_start}&window=${window}&data=${JSON.stringify(props.data)}`)
+        jumpPage(`/_health/pages/log_time?is_fast_with_sleep=1&index=${index}&single=${index == 0 ? 1 : 0}&is_start=${is_start}&window=${window}&data=${JSON.stringify(props.data)}`)
         /*
             const isSingle = router.params.single == '1'
     const isFast = router.params.window == 'FAST'
@@ -99,8 +101,9 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
             content: '确认删除此记录?',
             showCancel: true,
             confirm: () => {
-                delRecord(array[0], { ids: array }).then(res => {
+                delRecord(array[0], { ids: array.join(',') }).then(res => {
                     global.refreshWindow()
+                    props.del()
                 })
             }
         })
@@ -121,6 +124,19 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
         return color;
     }
 
+    function processIcon(item, finish, isError) {
+        if (isError) {
+            return <Image style={{ width: rpxToPx(20), height: rpxToPx(20) }} src={require('@assets/_health/tip_error.png')} />
+        }
+        if (finish) {
+            return <Image style={{ width: rpxToPx(20), height: rpxToPx(20) }} src={require('@assets/_health/checked.png')} />
+        }
+        if (item.timeline.reminder) {
+            return <IconNotification color="#fff" width={rpxToPx(20)} />
+        }
+        return <IconNotificationOff color="#fff" width={rpxToPx(20)} />
+    }
+
 
     function timelineItem(item: any, index: number, count: number) {
         const { fast, sleep, status } = props.data
@@ -181,6 +197,10 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                 }
                 break;
         }
+        var isError = false;
+        if (health.fast_with_sleep.status == 'OG2_MISALIGNED' && (index == 0 || index == 1)) {
+            isError = true;
+        }
         return <View key={index}
             className="timeline_item"
             // hoverClass='cell_hover' hoverStayTime={50}
@@ -202,14 +222,13 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                         display: 'flex',
                         alignItems: 'center',
                         justifyContent: 'center',
-                        backgroundColor: getIconColor(index, finish)
+                        backgroundColor: isError ? MainColorType.error : getIconColor(index, finish)
                     }}>
                         {
-                            finish ? <Image style={{ width: rpxToPx(20), height: rpxToPx(20) }} src={require('@assets/_health/checked.png')} /> :
-                                item.timeline.reminder ? <IconNotification color="#fff" width={rpxToPx(20)} /> : <IconNotificationOff color="#fff" width={rpxToPx(20)} />
+                            processIcon(item, finish, isError)
                         }
                     </View>
-                    <Text className="timeline_time">{time}</Text>
+                    <Text className="timeline_time" style={{ color: isError ? MainColorType.error : MainColorType.g01 }}>{time}</Text>
                 </View>
 
 
@@ -219,7 +238,6 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                 {
                     hasDescription && <Text className="timeline_desc">{item.moment.description}</Text>
                 }
-                {/* space */}
                 <View style={{
                     height: hasDescription ? rpxToPx(28) : rpxToPx(54), flexShrink: 0,
 
@@ -229,16 +247,13 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
             <View style={{ flex: 1 }} />
 
             {
-                item.moment && item.moment.media && item.moment.media.length > 0 && <Image
+                !isError && item.moment && item.moment.media && item.moment.media.length > 0 && <Image
                     src={item.moment.media[0].url}
                     mode="aspectFill"
                     className="console_item_img" />
             }
-            {/* {
-                itemValue(item)
-            } */}
             {
-                showBtn && <NewButton
+                !isError && showBtn && <NewButton
                     color={getThemeColor(item.mode)}
                     type={NewButtonType.alpha}
                     title={'Log'}
@@ -250,13 +265,40 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                     }} />
             }
             {
-                item.action == 'POST_MOMENT' && item.timeline.real && <IconCellArrow color='#B2B2B2' width={rpxToPx(34)} />
+                isError && <View style={{
+                    borderColor: MainColorType.error,
+                    borderWidth: rpxToPx(2),
+                    borderRadius: rpxToPx(76 / 4),
+                    borderStyle: 'solid'
+                }}>
+                    <NewButton
+                        type={NewButtonType.gray}
+                        title='Correct'
+                        fontSize={rpxToPx(34)}
+                        width={rpxToPx(128)}
+                        height={rpxToPx(72)}
+                        onClick={() => {
+                            jumpPage(`/_health/pages/log_time?is_fast_with_sleep=1&index=${1}&single=0&initCheck=1`)
+                        }}
+                    />
+                </View>
+            }
+            {
+                !isError && item.action == 'POST_MOMENT' && item.timeline.real && <IconCellArrow color='#B2B2B2' width={rpxToPx(34)} />
             }
             <View className="seperate_line" style={{ left: count - 1 == index ? -rpxToPx(52) : rpxToPx(52) }} />
         </View>
     }
 
     return <View style={{ backgroundColor: '#fff' }}>
+        {
+            health.fast_with_sleep.status == 'OG2_MISALIGNED' && <View className="error_bg" >
+                <View className="error_icon_bg">
+                    <Image src={require('@assets/_health/tip_error.png')} style={{ width: rpxToPx(26), height: rpxToPx(26) }} />
+                </View>
+                <Text className="h24" style={{ lineHeight: rpxToPx(36) + 'px' }}>Logged times are not in their proper order</Text>
+            </View>
+        }
         {
             props.step != 2 && props.step != 3 && timelineItem({
                 title: 'Start Fast',
@@ -264,7 +306,7 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                 is_start: true,
                 action: props.data.fast.timeline[0].action,
                 moment: props.data.fast.timeline[0].moment,
-                timeline:props.data.fast.timeline[0]
+                timeline: props.data.fast.timeline[0]
             }, 0, 4)
         }
         {
@@ -274,7 +316,7 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                 is_start: true,
                 action: props.data.fast.timeline[0].action,
                 moment: props.data.sleep.timeline[0].moment,
-                timeline:props.data.sleep.timeline[0]
+                timeline: props.data.sleep.timeline[0]
             }, 1, 4)
         }
         {
@@ -283,7 +325,7 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                 mode: 'SLEEP',
                 is_start: false,
                 moment: props.data.sleep.timeline[1].moment,
-                timeline:props.data.sleep.timeline[1]
+                timeline: props.data.sleep.timeline[1]
             }, 2, 4)
         }
         {
@@ -292,7 +334,7 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                 mode: 'FAST',
                 is_start: false,
                 moment: props.data.fast.timeline[1].moment,
-                timeline:props.data.fast.timeline[1]
+                timeline: props.data.fast.timeline[1]
             }, 3, 4)
         }
         {

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

@@ -3,8 +3,10 @@ import './fast_sleep_detail_card.scss'
 import { MainColorType } from '@/context/themes/color'
 import { TimeFormatter } from '@/utils/time_format'
 import { rpxToPx } from '@/utils/tools'
+import { useSelector } from 'react-redux'
 
 export default function FastSleepDetailCard(props: { data: any }) {
+    const health = useSelector((state: any) => state.health);
 
     function total() {
         const { fast } = props.data
@@ -20,6 +22,9 @@ export default function FastSleepDetailCard(props: { data: any }) {
     }
 
     function step1() {
+        if (health.fast_with_sleep.status == 'OG2_MISALIGNED'){
+            return '-'
+        }
         const { fast, sleep, status } = props.data
         if (status == 'WFS') {
             return ('-')

+ 24 - 0
src/_health/pages/fast_sleep.scss

@@ -0,0 +1,24 @@
+.error_bg{
+    background-color: #FF00001A;
+    display: flex;
+    flex-direction: row;
+    min-height: 72px;
+    padding-top: 18px;
+    padding-bottom: 18px;
+    padding-left: 48px;
+    padding-right: 40px;
+    box-sizing: border-box;
+}
+
+
+.error_icon_bg{
+    width: 26px;
+    height: 26px;
+    border-radius: 13px;
+    background-color: red;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    margin-right: 12px;
+    margin-top: 4px;
+}

+ 42 - 33
src/_health/pages/fast_sleep.tsx

@@ -35,6 +35,7 @@ export default function FastSleep() {
         switch (health.fast_with_sleep.status) {
             case 'WFS':
             case 'OG2_NO1':
+            case 'OG2_MISALIGNED':
                 setCurrent(0)
                 break;
             case 'OG1':
@@ -70,41 +71,49 @@ export default function FastSleep() {
     if (!loaded) return <View />
 
     return <View className="page_container">
-        <NewHeader type={NewHeaderType.left_subtitle}
+        <NewHeader type={health.fast_with_sleep.status != 'OG2_MISALIGNED'?NewHeaderType.left_subtitle:NewHeaderType.left}
             title="Fast with Sleep"
-            subtitle="Tune Into Your Circadian Rhythm "
+            subtitle={health.fast_with_sleep.status != 'OG2_MISALIGNED'?'Tune Into Your Circadian Rhythm ':''}
         />
-        <Swiper indicatorColor='#999'
-            indicatorActiveColor='#333'
-            style={{ height: rpxToPx(344), marginBottom: 20, flexShrink: 0 }}
-            onChange={e => setCurrent(e.detail.current)}
-            current={current}
-            indicatorDots>
-            <SwiperItem>
-                <Card>
-                    <FastSleepCard step={0} data={data} />
-
-                </Card>
-            </SwiperItem>
-            <SwiperItem>
-                <Card>
-                    <FastSleepCard step={1} data={data} />
-                </Card>
-            </SwiperItem>
-            <SwiperItem>
-                <Card>
-                    <FastSleepCard step={2} data={data} />
-                </Card>
-            </SwiperItem>
-            <SwiperItem>
-                <Card>
-                    <FastSleepCard step={3} data={data} />
-                </Card>
-            </SwiperItem>
-        </Swiper>
-
-        <FastSleepDetailCard data={data} />
-        <FastSleepConsole step={current} data={data} />
+        {
+            health.fast_with_sleep.status != 'OG2_MISALIGNED' && <Swiper indicatorColor='#999'
+                indicatorActiveColor='#333'
+                style={{ height: rpxToPx(344), marginBottom: 20, flexShrink: 0 }}
+                onChange={e => setCurrent(e.detail.current)}
+                current={current}
+                indicatorDots>
+                <SwiperItem>
+                    <Card>
+                        <FastSleepCard step={0} data={data} />
+
+                    </Card>
+                </SwiperItem>
+                <SwiperItem>
+                    <Card>
+                        <FastSleepCard step={1} data={data} />
+                    </Card>
+                </SwiperItem>
+                <SwiperItem>
+                    <Card>
+                        <FastSleepCard step={2} data={data} />
+                    </Card>
+                </SwiperItem>
+                <SwiperItem>
+                    <Card>
+                        <FastSleepCard step={3} data={data} />
+                    </Card>
+                </SwiperItem>
+            </Swiper>
+        }
+        {
+            health.fast_with_sleep.status != 'OG2_MISALIGNED' && <FastSleepDetailCard data={data} />
+        }
+
+
+
+        <FastSleepConsole step={current} data={data} del={()=>{
+            getDatas()
+        }}/>
         <MainHistory type='FAST,SLEEP' />
         {/* <NewButton type={NewButtonType.link} title="hello world" onClick={() => {
 

+ 121 - 52
src/_health/pages/log_time.tsx

@@ -1,5 +1,6 @@
 import { View, Text, Image } from "@tarojs/components";
 import './log_time.scss'
+import './fast_sleep.scss'
 import { useSelector } from "react-redux";
 import { useEffect, useState } from "react";
 import NewButton, { NewButtonType } from "../base/new_button";
@@ -37,7 +38,7 @@ export default function LogTime() {
     else {
         router = useRouter()
     }
-    const enterTime = new Date().getTime()
+    const [enterTime,setEnterTime] = useState(new Date().getTime())
 
     const isSingle = router.params.single == '1'
     const isFast = router.params.window == 'FAST'
@@ -51,7 +52,11 @@ export default function LogTime() {
 
     const [expandIndex, setExpandIndex] = useState(tapIndex)
     const [array, setArray] = useState<any>([])
+    const [errors, setErrors] = useState<any>([])
+    const [conflicts, setConflicts] = useState<any>([])
     const [loaded, setLoaded] = useState(false)
+    const [autoCheck, setAutoCheck] = useState(false)
+    const [initCheck,setInitCheck] = useState(router.params.initCheck=='1')
 
     useEffect(() => {
         if (isSingle) {
@@ -71,6 +76,16 @@ export default function LogTime() {
 
     }, [])
 
+    useEffect(() => {
+        if (autoCheck) {
+            tapCommit(true)
+        }
+        if (initCheck && array.length>0){
+            tapCommit(true)
+            setInitCheck(false)
+        }
+    }, [array])
+
     function loadData() {
         fastWithSleep().then(res => {
             setData(res)
@@ -213,7 +228,7 @@ export default function LogTime() {
         return timestamp
     }
 
-    function tapCommit() {
+    function tapCommit(onlyCheck) {
         var list: any = []
         if (isSingle) {
             var obj = array[0]
@@ -310,36 +325,41 @@ export default function LogTime() {
                     cancel: () => {
                     },
                     confirm: () => {
-                        commit(list)
+                        commit(list, onlyCheck)
                     }
                 })
                 return;
             }
         }
-        commit(list)
+        commit(list, onlyCheck)
 
     }
 
-    function commit(list) {
+    function commit(list, onlyCheck) {
         clockTimes({
             check_items: list,
-            op_page: isFastWithSleep ? 'FAST_WITH_SLEEP' : null
+            op_page: isFastWithSleep ? 'FAST_WITH_SLEEP' : null,
+            only_check: onlyCheck
         }).then(res => {
-            if ((res as any).result){
-                global.refreshWindow()
-                if (global.refreshFastSleep)
-                    global.refreshFastSleep()
-                Taro.redirectTo({
-                    url: './post_result?data=' + JSON.stringify(res)
-                })
+            if ((res as any).result) {
+                setErrors([])
+                setConflicts([])
+                if (!onlyCheck) {
+                    global.refreshWindow()
+                    if (global.refreshFastSleep)
+                        global.refreshFastSleep()
+                    Taro.redirectTo({
+                        url: './post_result?data=' + JSON.stringify(res)
+                    })
+                }
+
             }
             else {
-                showAlert({
-                    title:'error',
-                    content:(res as any).error_messages[0]
-                })
+                setErrors((res as any).error_messages)
+                setConflicts((res as any).conflict_schedule_ids)
+                setAutoCheck(true)
             }
-            
+
             // Taro.navigateBack({
             //     delta: 1
             // })
@@ -383,8 +403,10 @@ export default function LogTime() {
         var time = array[index].time
 
         const today = dayjs();
+        var schedule_id = ''
         if (iFast) {
             schedule_time = iStart ? fast.period.start_time : fast.period.end_time
+            schedule_id = iStart ? fast.timeline[0].schedule_id : fast.timeline[1].schedule_id
             if (!iStart && fast.status == 'OG') {
                 schedule_time = dayjs(fast.target.end_timestamp).format('HH:mm')
             }
@@ -409,6 +431,7 @@ export default function LogTime() {
         }
         else {
             schedule_time = iStart ? sleep.period.start_time : sleep.period.end_time
+            schedule_id = iStart ? sleep.timeline[0].schedule_id : sleep.timeline[1].schedule_id
             if (!iStart && sleep.status == 'OG') {
                 schedule_time = dayjs(sleep.target.end_timestamp).format('HH:mm')
             }
@@ -429,41 +452,67 @@ export default function LogTime() {
             }
         }
 
+        var showError = false;
+        if ( conflicts.includes(schedule_id)) {
+            showError = true
+            disable = false
+        }
+
 
 
         return <View style={{ position: 'relative' }}>
             <View className="card_header">
+                {
+                    showError && <View className="error_icon_bg">
+                            <Image src={require('@assets/_health/tip_error.png')} style={{ width: rpxToPx(26), height: rpxToPx(26) }} />
+                        </View>
+
+                }
                 {
                     isSingle ? <View style={{ flex: 1 }} /> :
                         <View className="h34" style={{ flex: 1 }}>{title}</View>
                 }
 
-                <NewButton
-                    type={NewButtonType.gray}
-                    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
-                        setArray(list)
-                    }}
-                />
+                <View style={{
+                    borderColor: showError ? 'red' : 'transparent',
+                    borderWidth: rpxToPx(2),
+                    borderRadius: rpxToPx(88 / 4),
+                    borderStyle: 'solid'
+                }}>
+                    <NewButton
+                        type={NewButtonType.gray}
+                        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
+                            setArray(list)
+                        }}
+                    />
+                </View>
                 <View style={{ width: rpxToPx(12) }} />
-                <NewButton
-                    type={expandIndex == index ? NewButtonType.alpha : NewButtonType.gray}
-                    color={iFast ? MainColorType.fast : MainColorType.sleep}
-                    title={time}
-                    fontSize={rpxToPx(34)}
-                    width={rpxToPx(196)}
-                    height={rpxToPx(84)}
-                    disable={disable}
-                    onClick={() => {
-                        setExpandIndex(index)
-                    }}
-                />
+                <View style={{
+                    borderColor: showError ? 'red' : 'transparent',
+                    borderWidth: rpxToPx(2),
+                    borderRadius: rpxToPx(88 / 4),
+                    borderStyle: 'solid'
+                }}>
+                    <NewButton
+                        type={expandIndex == index ? NewButtonType.alpha : NewButtonType.gray}
+                        color={iFast ? MainColorType.fast : MainColorType.sleep}
+                        title={time}
+                        fontSize={rpxToPx(34)}
+                        width={rpxToPx(136)}
+                        height={rpxToPx(84)}
+                        disable={disable}
+                        onClick={() => {
+                            setExpandIndex(index)
+                        }}
+                    />
+                </View>
                 {
                     isSingle && <View style={{ flex: 1 }} />
                 }
@@ -519,7 +568,7 @@ export default function LogTime() {
             case 1:
                 return <View style={{ position: 'relative' }}>
                     {
-                        logItem(0, true, true, true)
+                        logItem(0, true, true, true, !(status == 'WFS' || status == 'OG2_NO1'))
                     }
                     {
                         logItem(1, false, true, false)
@@ -560,13 +609,33 @@ export default function LogTime() {
 
     return <View className="page_container">
         <Card>
-            {
-                isSingle ? <View style={{ position: 'relative' }}>
-                    {
-                        logItem(0, isFast, isStart, false)
-                    }
-                </View> : multiContent()
-            }
+            <View style={{ display: 'flex', flexDirection: 'column' }}>
+                {
+                    errors.map((item, index) => {
+                        return <View className="error_bg" key={index}>
+                            <View className="error_icon_bg">
+                                <Image src={require('@assets/_health/tip_error.png')} style={{ width: rpxToPx(26), height: rpxToPx(26) }} />
+                            </View>
+                            <Text className="h24" style={{ lineHeight: rpxToPx(36) + 'px' }}>{item}</Text>
+                        </View>
+                    })
+                }
+                {
+                    autoCheck && errors.length == 0 && <View className="error_bg" style={{ backgroundColor: MainColorType.success + '1A' }}>
+                        <View className="error_icon_bg" style={{ backgroundColor: MainColorType.success }}>
+                            <Image src={require('@assets/_health/tip_check.png')} style={{ width: rpxToPx(26), height: rpxToPx(26) }} />
+                        </View>
+                        <Text className="h24" style={{ lineHeight: rpxToPx(36) + 'px' }}>成功提示</Text>
+                    </View>
+                }
+                {
+                    isSingle ? <View style={{ position: 'relative' }}>
+                        {
+                            logItem(0, isFast, isStart, false)
+                        }
+                    </View> : multiContent()
+                }
+            </View>
 
         </Card>
         <View style={{ height: rpxToPx(36) }} />
@@ -622,7 +691,7 @@ export default function LogTime() {
                 width={rpxToPx(670)}
                 height={rpxToPx(96)}
                 bold={true}
-                onClick={tapCommit} />
+                onClick={() => tapCommit(false)} />
         </View>
 
     </View>

BIN
src/assets/_health/tip_check.png


BIN
src/assets/_health/tip_error.png


+ 23 - 2
src/features/health/HistoryItem.tsx

@@ -153,6 +153,27 @@ export default function HistoryItem(props: {
         })
     }
 
+    function dayTag(index) {
+        if (index == 0) {
+            return ''
+        }
+        else {
+            var begin = props.data.events[0].time.timestamp
+            var end = props.data.events[index].time.timestamp
+
+            const date1 = dayjs(begin);
+            const date2 = dayjs(end);
+
+            // 获取日期部分(去掉时间)
+            const startDate = date1.startOf('day');
+            const endDate = date2.startOf('day');
+            const days = endDate.diff(startDate, 'day')
+            if (days > 0)
+                return '+' + days;
+        }
+        return ''
+    }
+
     return <View className="history_item2">
         <View className="history_date">{historyDate()}</View>
         <View className="history_content">
@@ -161,7 +182,7 @@ export default function HistoryItem(props: {
                 {
                     props.data.events.map((item, index) => {
                         return <Text key={index}>
-                            <Text className="history_item_title">{item.time && dayjs(item.time.timestamp).format('HH:mm')}<Text style={{ fontSize: 9, lineHeight: '20px', fontWeight: 'bold', verticalAlign: 'text-top' }}></Text> {getTitle(item)} </Text>
+                            <Text className="history_item_title">{item.time && dayjs(item.time.timestamp).format('HH:mm')}<Text style={{ fontSize: 9, lineHeight: '20px', fontWeight: 'bold', verticalAlign: 'text-top' }}>{dayTag(index)}</Text> {getTitle(item)} </Text>
                             {
                                 item.moments && item.moments.map((moment, i) => {
                                     return <Text className="history_item_desc" key={i * 1000}>{moment.description}</Text>
@@ -237,7 +258,7 @@ export default function HistoryItem(props: {
                     </View>
                 </View>
             }
-            <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center',height:rpxToPx(60) }}>
+            <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', height: rpxToPx(60) }}>
                 <View style={{ flex: 1 }} />
                 <NewButton type={NewButtonType.more}
                     onClick={tapDel}

+ 13 - 0
src/features/health/MainConsole.tsx

@@ -926,6 +926,9 @@ export default function MainConsole(props: { type: WindowType }) {
             case 'OG2':
                 str = 'Fast while Sleeping'
                 break;
+            case 'OG2_MISALIGNED':
+                str = 'Misaligned/错位'
+                break;
             case 'OG3':
                 str = 'Fast after Wake Up'
                 break
@@ -1041,6 +1044,16 @@ export default function MainConsole(props: { type: WindowType }) {
                     {
                         fastWithSleepStatus()
                     }
+                    {
+                        health.fast_with_sleep.status=='OG2_MISALIGNED' && <View style={{
+                            backgroundColor:MainColorType.error,
+                            width:rpxToPx(12),
+                            height:rpxToPx(12),
+                            borderRadius:rpxToPx(6),
+                            marginLeft:rpxToPx(12),
+                            marginRight:rpxToPx(12)
+                        }}/>
+                    }
                     <IconCellArrow color='#B2B2B2' width={rpxToPx(34)} />
                     {
                         health.mode == 'FAST' && <View className="border_footer_line" style={{ left: rpxToPx(100) }} />

+ 4 - 4
src/services/health.tsx

@@ -193,13 +193,13 @@ export const updateEventDuration = (id, duration) => {
 }
 
 export const clockTimes = (params) => {
-    return new Promise((resolve,reject) => {
+    return new Promise((resolve, reject) => {
         request({
             url: API_HEALTH_CLOCK, method: 'POST', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
-        }).catch(e=>{
+        }).catch(e => {
             reject(e)
         })
     })
@@ -350,10 +350,10 @@ export const updateFast = (params) => {
     })
 }
 
-export const delRecord = (id) => {
+export const delRecord = (id, params={}) => {
     return new Promise((resolve) => {
         request({
-            url: API_HEALTH_WINDOWS + '/' + id, method: 'DELETE'
+            url: API_HEALTH_WINDOWS + '/' + id, method: 'DELETE'//, data: { ...params }
         }).then(res => {
             resolve(res)
         })