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

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

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

+ 14 - 0
src/_health/components/fast_sleep_card.scss

@@ -0,0 +1,14 @@
+.circle_content{
+    margin-left: 66px;
+    width: 224px;
+    height: 224px;
+    margin-right: 38px;
+    flex-shrink: 0;
+    background-color: palegoldenrod;
+}
+
+.right_content{
+    display: flex;
+    flex-direction: column;
+
+}

+ 127 - 0
src/_health/components/fast_sleep_card.tsx

@@ -0,0 +1,127 @@
+import { View, Text } from '@tarojs/components'
+import './fast_sleep_card.scss'
+import { rpxToPx } from '@/utils/tools'
+import { MainColorType } from '@/context/themes/color';
+
+export default function FastSleepCard(props: { step: number, data: any }) {
+
+    function statusBar() {
+        var title = ''
+        var hide = false;
+        const { status } = props.data
+        switch (props.step) {
+            case 0:
+                {
+                    if (status == 'WFS') {
+                        title = 'Ready to start'
+                    }
+                    else {
+                        title = 'In progress'
+                    }
+                }
+                break;
+            case 1:
+                {
+                    if (status == 'WFS') {
+                        title = 'Stage 1'
+                    }
+                    else if (status == 'OG1') {
+                        title = 'Stage 1 in progress'
+                    }
+                    else if (status == 'OG2_NO1') {
+                        title = 'Stage 1'
+                    }
+                    else {
+                        title = 'Stage 1 completed'
+                    }
+                }
+                break;
+            case 2:
+                {
+                    if (status == 'OG2') {
+                        title = 'Stage 2 in progress'
+                    }
+                    else if (status == 'OG3' || status == 'OG2_NO1') {
+                        title = 'Stage 2 completed'
+                    }
+                    else {
+                        title = 'Stage 2'
+                    }
+                }
+                break;
+            case 3:
+                {
+                    if (status == 'OG3') {
+                        title = 'Stage 3 in progress'
+                    }
+                    else {
+                        title = 'Stage 3'
+                    }
+
+                }
+                break;
+        }
+        return <View style={{
+            position: 'absolute',
+            display: 'flex',
+            alignItems: 'center',
+            flexDirection: 'row',
+            left: rpxToPx(20),
+            top: rpxToPx(20),
+            opacity: hide ? 0 : 1
+        }}>
+            <View style={{
+                width: rpxToPx(12),
+                height: rpxToPx(12),
+                borderRadius: rpxToPx(6),
+                marginLeft: rpxToPx(10),
+                marginRight: rpxToPx(10),
+                backgroundColor: props.step == 2 ? MainColorType.sleep : MainColorType.fast
+            }} />
+            <View className='h20' style={{ color: MainColorType.g01 }}>{title}</View>
+        </View>
+    }
+
+    function statusDetail(){
+        switch (props.step) {
+            case 0:
+                return <View className='right_content'>
+                    <View className='h34' style={{color:MainColorType.g01}}>Fast</View>
+                    <View className='h50 bold' style={{color:MainColorType.fast}}>Fast</View>
+                    <View className='h34' style={{color:MainColorType.g01}}>Sleep</View>
+                    <View className='h50 bold' style={{color:MainColorType.sleep}}>Fast</View>
+                </View>
+            case 1:
+                return <View className='right_content'>
+                    <View className='h34' style={{color:MainColorType.g01}}>Fast before Bedtime</View>
+                    <View className='h50 bold' style={{color:MainColorType.fast}}>Fast</View>
+                </View>
+            case 2:
+                return <View className='right_content'>
+                    <View className='h34' style={{color:MainColorType.g01}}>Fast while Sleeping</View>
+                    <View className='h50 bold' style={{color:MainColorType.sleep}}>Fast</View>
+                </View>
+            case 3:
+                return <View className='right_content'>
+                    <View className='h34' style={{color:MainColorType.g01}}>Fast after Wake Up</View>
+                    <View className='h50 bold' style={{color:MainColorType.fast}}>Fast</View>
+                </View>
+        }
+        return <View className='right_content'></View>
+    }
+
+    return <View style={{
+        position: 'relative', display: 'flex', flexDirection: 'row',
+        height: rpxToPx(366),
+        paddingTop: rpxToPx(66),
+        boxSizing:'border-box'
+    }}>
+        {
+            statusBar()
+        }
+        <View className='circle_content'/>
+        {
+            statusDetail()
+        }
+    </View>
+}

+ 145 - 13
src/_health/components/fast_sleep_console.tsx

@@ -4,10 +4,116 @@ import { rpxToPx } from "@/utils/tools";
 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";
+
+export default function FastSleepConsole(props: { step: number, data: any }) {
+
+    function tapLogBtn(index: number) {
+        const { fast, sleep, status } = props.data
+        var single = 0;
+        var is_start = 0;
+        var window = 'FAST'
+
+        switch (index) {
+            case 0:
+                {
+                    single = 1;
+                    is_start = 1;
+                }
+                break;
+            case 1:
+                {
+                    if (status == 'OG1') {
+                        single = 1;
+                        is_start = 1;
+                        window = 'SLEEP'
+                    }
+                    else {
+                        single = 0;
+                    }
+                }
+                break;
+            case 2:
+                {
+                    if (status == 'OG2') {
+                        single = 1;
+                        is_start = 0;
+                        window = 'SLEEP'
+                    }
+                    else {
+                        single = 0;
+                    }
+                }
+                break;
+            case 3:
+                {
+                    if (status == 'OG3') {
+                        single = 1;
+                        is_start = 0;
+                        window = 'FAST'
+                    }
+                    else {
+                        single = 0;
+                    }
+                }
+                break;
+        }
+
+        jumpPage(`/_health/pages/log_time?index=${index}&single=${single}&is_start=${is_start}&window=${window}&data=${JSON.stringify(props.data)}`)
+        /*
+            const isSingle = router.params.single == '1'
+    const isFast = router.params.window == 'FAST'
+    const isStart = router.params.is_start == '1'
+    */
+    }
 
-export default function FastSleepConsole() {
     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
+
+        switch (index) {
+            case 0:
+                {
+                    if (status == 'OG2_NO1' || status == 'WFS') {
+                        showBtn = true
+                    }
+                    else {
+                        showBtn = false;
+                    }
+                    time = dayjs(fast.target.start_timestamp).format('HH:mm')
+                }
+                break;
+            case 1:
+                {
+                    if (status == 'WFS' || status == 'OG1') {
+                        showBtn = true
+                    }
+                    else {
+                        showBtn = false
+                    }
+                    time = dayjs(sleep.target.start_timestamp).format('HH:mm')
+                }
+                break;
+            case 2:
+                {
+                    if (status == 'OG3') {
+                        showBtn = false
+                    }
+                    else {
+                        showBtn = true
+                    }
+                    time = dayjs(sleep.target.end_timestamp).format('HH:mm')
+                }
+                break;
+            case 3:
+                {
+                    showBtn = true
+                    time = dayjs(fast.target.end_timestamp).format('HH:mm')
+                }
+                break;
+        }
         return <View key={index}
             className="timeline_item"
             // hoverClass='cell_hover' hoverStayTime={50}
@@ -26,7 +132,7 @@ export default function FastSleepConsole() {
                         marginRight: rpxToPx(8),
                         backgroundColor: 'gray'
                     }} />
-                    <Text className="timeline_time">time</Text>
+                    <Text className="timeline_time">{time}</Text>
                 </View>
 
 
@@ -54,16 +160,19 @@ export default function FastSleepConsole() {
             {/* {
                 itemValue(item)
             } */}
-            <NewButton
-                color={getThemeColor('FAST')}
-                type={NewButtonType.alpha}
-                title={'Log'}
-                width={rpxToPx(128)}
-                height={rpxToPx(72)}
-                bold={true}
-                onClick={() => {
-                    jumpPage('/_health/pages/log_time')
-                }} />
+            {
+                showBtn && <NewButton
+                    color={getThemeColor(item.mode)}
+                    type={NewButtonType.alpha}
+                    title={'Log'}
+                    width={rpxToPx(128)}
+                    height={rpxToPx(72)}
+                    bold={true}
+                    onClick={() => {
+                        tapLogBtn(index)
+                        // 
+                    }} />
+            }
             <View className="seperate_line" style={{ left: count - 1 == index ? -rpxToPx(52) : rpxToPx(52) }} />
         </View>
     }
@@ -71,8 +180,31 @@ export default function FastSleepConsole() {
     return <View style={{ backgroundColor: '#fff' }}>
         {
             timelineItem({
-                title: 'Start Fast'
+                title: 'Start Fast',
+                mode: 'FAST',
+                is_start: true
             }, 0, 4)
         }
+        {
+            timelineItem({
+                title: 'Go to bed',
+                mode: 'SLEEP',
+                is_start: true
+            }, 1, 4)
+        }
+        {
+            timelineItem({
+                title: 'Wake up',
+                mode: 'SLEEP',
+                is_start: false
+            }, 2, 4)
+        }
+        {
+            timelineItem({
+                title: 'End Fast',
+                mode: 'FAST',
+                is_start: false
+            }, 3, 4)
+        }
     </View>
 }

+ 27 - 15
src/_health/pages/fast_sleep.tsx

@@ -12,21 +12,39 @@ import { MainColorType } from "@/context/themes/color";
 import NewHeader, { NewHeaderType } from "../components/new_header";
 import Card from "../components/card";
 import FastSleepConsole from "../components/fast_sleep_console";
+import { fastWithSleep } from "@/services/health";
+import FastSleepCard from "../components/fast_sleep_card";
 
 export default function FastSleep() {
     const health = useSelector((state: any) => state.health);
     const [time, setTime] = useState(dayjs().format('HH:mm'))
     const [count, setCount] = useState(0)
 
+    const [loaded, setLoaded] = useState(false)
+    const [data, setData] = useState<any>(null)
+
     useEffect(() => {
         let timer = setInterval(() => {
             setCount(count => count + 1)
         }, 1000)
 
+        getDatas()
+
         return () => {
             clearInterval(timer)
         }
     }, [])
+
+
+    function getDatas() {
+        fastWithSleep().then(res => {
+            setLoaded(true)
+            setData(res)
+        })
+    }
+
+    if (!loaded) return <View />
+
     return <View className="page_container">
         <NewHeader type={NewHeaderType.left_subtitle}
             title="Fast with Sleep"
@@ -34,38 +52,32 @@ export default function FastSleep() {
         />
         <Swiper indicatorColor='#999'
             indicatorActiveColor='#333'
+            style={{ height: rpxToPx(344), marginBottom: 20 }}
             indicatorDots>
             <SwiperItem>
                 <Card>
-                    <View style={{ height: 100 }}>
-                        <Text>hello world</Text>
-                    </View>
+                    <FastSleepCard step={0} data={data} />
+
                 </Card>
             </SwiperItem>
             <SwiperItem>
                 <Card>
-                    <View style={{ height: 100 }}>
-                        <Text>hello world</Text>
-                    </View>
+                    <FastSleepCard step={1} data={data} />
                 </Card>
             </SwiperItem>
             <SwiperItem>
                 <Card>
-                    <View style={{ height: 100 }}>
-                        <Text>hello world</Text>
-                    </View>
+                    <FastSleepCard step={2} data={data} />
                 </Card>
             </SwiperItem>
             <SwiperItem>
                 <Card>
-                    <View style={{ height: 100 }}>
-                        <Text>hello world</Text>
-                    </View>
+                    <FastSleepCard step={3} data={data} />
                 </Card>
             </SwiperItem>
         </Swiper>
-        <FastSleepConsole />
-        <NewButton type={NewButtonType.link} title="hello world" onClick={() => {
+        <FastSleepConsole step={0} data={data} />
+        {/* <NewButton type={NewButtonType.link} title="hello world" onClick={() => {
 
         }} />
         <NewButton type={NewButtonType.label} title="hello world" onClick={() => {
@@ -73,6 +85,6 @@ export default function FastSleep() {
         }} />
         <NewButton type={NewButtonType.label} title="hello world" labelBorder onClick={() => {
 
-        }} />
+        }} /> */}
     </View>
 }

+ 157 - 35
src/_health/pages/log_time.tsx

@@ -10,6 +10,8 @@ import { IconCalendar } from "@/components/basic/Icons";
 import dayjs from "dayjs";
 import { useRouter } from "@tarojs/taro";
 import Card from "../components/card";
+import { MainColorType } from "@/context/themes/color";
+import Taro from "@tarojs/taro";
 
 let useRoute;
 let useNavigation;
@@ -36,58 +38,178 @@ export default function LogTime() {
     const isSingle = router.params.single == '1'
     const isFast = router.params.window == 'FAST'
     const isStart = router.params.is_start == '1'
+    const data = JSON.parse(router.params.data)
     const health = useSelector((state: any) => state.health);
     const [time, setTime] = useState(dayjs().format('HH:mm'))
     const [isToday, setIsToday] = useState(true)
+    const [showGoal, setShowGoal] = useState(false)
+    const tapIndex = router.params.index ?? 0
+
+    const [expandIndex, setExpandIndex] = useState(0)
 
     useEffect(() => {
+        if (isSingle) {
+            if (isFast) {
+                Taro.setNavigationBarTitle({
+                    title: isStart ? '开始断食' : '结束断食'
+                });
+            }
+            else {
+                Taro.setNavigationBarTitle({
+                    title: isStart ? '就寝' : '起床'
+                });
+            }
+        }
 
     }, [])
-    return <View className="page_container">
-        <Card>
-            <View style={{ position: 'relative' }}>
-                <View className="card_header">
-                    <View style={{ flex: 1 }} />
-                    <NewButton
-                        type={NewButtonType.gray}
-                        title={isToday ? "Today" : "Yesterday"}
-                        fontSize={rpxToPx(34)}
-                        width={rpxToPx(196)}
-                        height={rpxToPx(84)}
-                        onClick={() => {
-                            setIsToday(!isToday)
-                        }}
-                    />
-                    <View style={{ width: rpxToPx(12) }} />
-                    <NewButton
-                        type={NewButtonType.alpha}
-                        color={getThemeColor('FAST')}
-                        title={time}
-                        fontSize={rpxToPx(34)}
-                        width={rpxToPx(196)}
-                        height={rpxToPx(84)}
-                        onClick={() => {
 
-                        }}
-                    />
-                    <View style={{ flex: 1 }} />
-                    <View className='border_footer_line' />
-                </View>
+    function footerBtnColor() {
+        if (isSingle) {
+            return isFast ? MainColorType.fast : MainColorType.sleep
+        }
+        return MainColorType.fast
+    }
 
-                <NewTimePicker time={time} onChange={(e) => {
+    function logItem(index: number, iFast: boolean, iStart: boolean, showLine: boolean) {
+        const {fast,sleep} = data
+        var schedule_time = ''
+        if (iFast){
+            schedule_time = iStart?fast.period.start_time:fast.period.end_time
+        }
+        else {
+            schedule_time = iStart?sleep.period.start_time:sleep.period.end_time
+        }
+        return <View style={{ position: 'relative' }}>
+            <View className="card_header">
+                <View style={{ flex: 1 }} />
+                <NewButton
+                    type={NewButtonType.gray}
+                    title={isToday ? "Today" : "Yesterday"}
+                    fontSize={rpxToPx(34)}
+                    width={rpxToPx(196)}
+                    height={rpxToPx(84)}
+                    onClick={() => {
+                        setIsToday(!isToday)
+                    }}
+                />
+                <View style={{ width: rpxToPx(12) }} />
+                <NewButton
+                    type={NewButtonType.alpha}
+                    color={iFast?MainColorType.fast:MainColorType.sleep}
+                    title={time}
+                    fontSize={rpxToPx(34)}
+                    width={rpxToPx(196)}
+                    height={rpxToPx(84)}
+                    onClick={() => {
+                        setExpandIndex(index)
+                    }}
+                />
+                <View style={{ flex: 1 }} />
+                <View className='border_footer_line' />
+            </View>
+            {
+                expandIndex == index && <NewTimePicker time={time} onChange={(e) => {
                     setTime(e)
-                }} color={getThemeColor(health.mode)} />
+                }} color={iFast?MainColorType.fast:MainColorType.sleep} />
+            }
 
-                <View className='card_footer'>
+            {
+                expandIndex == index && <View className='card_footer'>
                     <IconCalendar width={rpxToPx(24)} color='#5C7099' />
-                    <Text style={{ color: '#5C7099', marginLeft: rpxToPx(12), fontSize: rpxToPx(26) }}>Scheduled for xxx today</Text>
+                    <Text style={{ color: '#5C7099', marginLeft: rpxToPx(12), fontSize: rpxToPx(26) }}>Scheduled for {schedule_time} today</Text>
                 </View>
-            </View>
+            }
+            {
+                showLine && <View className="border_footer_line" />
+            }
+
+        </View>
+    }
+
+    function multiContent() {
+        const { status } = data
+        switch (parseInt(tapIndex+'')) {
+            case 1:
+                return <View style={{ position: 'relative' }}>
+                    {
+                        logItem(0, true, true, true)
+                    }
+                    {
+                        logItem(1, false, true, false)
+                    }
+                </View>
+            case 2:
+                return <View style={{ position: 'relative' }}>
+                    {
+                        (status == 'WFS' || status == 'OG2_NO1') && logItem(0, true, true, true)
+                    }
+                    {
+                        (status == 'WFS' || status == 'OG1') && logItem(1, false, true, true)
+                    }
+                    {
+                        logItem(2, false, false, false)
+                    }
+                </View>
+            case 3:
+                return <View style={{ position: 'relative' }}>
+                    {
+                        (status == 'WFS' || status == 'OG2_NO1') && logItem(0, true, true, true)
+                    }
+                    {
+                        (status == 'WFS' || status == 'OG1') && logItem(1, false, true, true)
+                    }
+                    {
+                        (status == 'WFS' || status == 'OG1' || status == 'OG2'|| status == 'OG2_NO1') && logItem(2, false, false, true)
+                    }
+                    {
+                        logItem(3, true, false, false)
+                    }
+                </View>
+        }
+        return <View style={{ position: 'relative' }}></View>
+    }
+    return <View className="page_container">
+        <Card>
+            {
+                isSingle ? <View style={{ position: 'relative' }}>
+                    {
+                        logItem(0, isFast, isStart, false)
+                    }
+                </View> : multiContent()
+            }
+
         </Card>
+        <View style={{ height: rpxToPx(36) }} />
+        {
+            isSingle && isStart && !showGoal && <View style={{ height: rpxToPx(72), marginTop: rpxToPx(18) }}>
+                <NewButton
+                    type={NewButtonType.link}
+                    title="Show More"
+                    onClick={() => {
+                        setShowGoal(true)
+                    }}
+                />
+            </View>
+        }
+        {
+            isSingle && isStart && showGoal && <Card>
+                <View style={{ position: 'relative' }}>
+                    <View className="card_header" style={{ justifyContent: 'space-between' }}>
+                        <View className="h34">{isFast ? 'Fast Goal' : 'Sleep Goal'}</View>
+                        <NewButton
+                            type={NewButtonType.gray}
+                            height={rpxToPx(84)}
+                            title="xxx"
+                            onClick={() => { }}
+                        />
+                    </View>
+                </View>
+            </Card>
+        }
         <View style={{ flex: 1 }} />
         <View style={{ marginBottom: rpxToPx(128), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
             <NewButton
-                color={getThemeColor('FAST')}
+                color={footerBtnColor()}
                 type={NewButtonType.fill}
                 title={'Log'}
                 width={rpxToPx(670)}

+ 77 - 41
src/_health/pages/schedules.tsx

@@ -44,21 +44,31 @@ export default function Schedules() {
     const [selItem, setSelItem] = useState<any>(null)
     const [selIndex, setSelIndex] = useState(-1)
     const [showModal, setShowModal] = useState(false)
+    const [highlight, setHighlight] = useState(true)
+    const [tempArray, setTempArray] = useState<any>([])
+    const [btnEnable, setBtnEnable] = useState(true)
     const selMode = router.params.mode;
 
     useEffect(() => {
         if (selMode == '' && router.params.schedules) {
             setList(JSON.parse(router.params.schedules))
+            if (router.params.errors){
+                setErrors(JSON.parse(router.params.errors))
+            }
         }
         else {
             schedules()
+            if (selMode != '') {
+                global.refreshSchedules2 = () => {
+                    schedules()
+                }
+            }
+
         }
 
     }, [])
 
-    global.refreshSchedules = () => {
-        schedules()
-    }
+
 
     global.tempRefresh = () => {
         schedules()
@@ -88,6 +98,10 @@ export default function Schedules() {
         }
         getSchedules({ window: windows }).then(res => {
             setList((res as any).data)
+            setErrors([])
+            setTimeout(() => {
+                setHighlight(false)
+            }, 2000)
         }).catch(e => {
 
         })
@@ -140,6 +154,7 @@ export default function Schedules() {
     }
 
     function checkData(array) {
+        setTempArray(array)
         createSchedule({
             schedules: array,
             // only_check: true
@@ -154,47 +169,47 @@ export default function Schedules() {
                 if (global.refreshSchedules) {
                     global.refreshSchedules()
                 }
-                // if (global.refreshSchedules2) {
-                //     global.refreshSchedules2()
-                // }
+                if (global.refreshSchedules2) {
+                    global.refreshSchedules2()
+                }
             }
             else {
                 setShowAutoSave(false)
                 setList((res as any).schedules)
                 setErrors((res as any).error_messages ? (res as any).error_messages : [])
-                // var array = (res as any).conflict_windows;
-                // var showMore = false;
-                // if (array.length > 2) {
-                //     showMore = true;
-                // }
-                // else if (array.length == 1) {
-                //     showMore = false;
-                // }
-                // else {
-                //     // 判断是否同时存在 FAST 和 EAT
-                //     const containsFastAndEat = array.includes('FAST') && array.includes('EAT');
-
-                //     // 判断是否同时存在 SLEEP 和 ACTIVE
-                //     const containsSleepAndActive = array.includes('SLEEP') && array.includes('ACTIVE');
-
-                //     // 最终结果
-                //     const result = containsFastAndEat || containsSleepAndActive;
-                //     showMore = !result;
-                // }
-                // if (selMode != '' && showMore) {
-                //     showAlert({
-                //         title: '弹窗标题',
-                //         content: '冲突描述',
-                //         showCancel: false,
-                //         confirm: () => {
-                //             jumpPage(`./schedules?mode=&schedules=${JSON.stringify((res as any).schedules)}&errors=${JSON.stringify((res as any).error_messages)}`)
-                //         }
-                //     })
-                // }
-                // else {
-                //     setList((res as any).schedules)
-                //     setErrors((res as any).error_messages ? (res as any).error_messages : [])
-                // }
+                var array = (res as any).conflict_windows;
+                var showMore = false;
+                if (array.length > 2) {
+                    showMore = true;
+                }
+                else if (array.length == 1) {
+                    showMore = false;
+                }
+                else {
+                    // 判断是否同时存在 FAST 和 EAT
+                    const containsFastAndEat = array.includes('FAST') && array.includes('EAT');
+
+                    // 判断是否同时存在 SLEEP 和 ACTIVE
+                    const containsSleepAndActive = array.includes('SLEEP') && array.includes('ACTIVE');
+
+                    // 最终结果
+                    const result = containsFastAndEat || containsSleepAndActive;
+                    showMore = !result;
+                }
+                if (selMode != '' && showMore) {
+                    showAlert({
+                        title: '弹窗标题',
+                        content: '冲突描述',
+                        showCancel: false,
+                        confirm: () => {
+                            // jumpPage(`./schedules?mode=&schedules=${JSON.stringify((res as any).schedules)}&errors=${JSON.stringify((res as any).error_messages)}`)
+                        }
+                    })
+                }
+                else {
+                    // setList((res as any).schedules)
+                    // setErrors((res as any).error_messages ? (res as any).error_messages : [])
+                }
             }
         })
     }
@@ -257,6 +272,27 @@ export default function Schedules() {
         }
     }
 
+    function showAll() {
+        if (!btnEnable){
+            return
+        }
+        if (errors.length == 0) {
+            jumpPage('/_health/pages/schedules?mode=')
+        }
+        else {
+            setBtnEnable(false)
+            createSchedule({
+                schedules: tempArray,
+                return_all:true
+                // only_check: true
+            }).then(res => {
+                setBtnEnable(true)
+                jumpPage('/_health/pages/schedules?mode=&schedules='+JSON.stringify((res as any).schedules)+'&errors='+JSON.stringify((res as any).error_messages))
+            })
+        }
+
+    }
+
 
     return <View>
         <View style={{ display: 'flex', flexDirection: 'column' }}>
@@ -275,7 +311,7 @@ export default function Schedules() {
                         return <View className='schedule_item' key={i} style={{
                             width: rpxToPx(750),
                             boxSizing: 'border-box',
-                            backgroundColor: obj.window == selMode ? getThemeColor(selMode) + '08' : '#fff'
+                            backgroundColor: (obj.window == selMode && highlight) ? getThemeColor(selMode) + '08' : '#fff'
 
                         }}>
                             <View className='item_left2'>
@@ -321,7 +357,7 @@ export default function Schedules() {
 
             {
                 selMode != '' && <Text onClick={() => {
-                    jumpPage('/_health/pages/schedules?mode=')
+                    showAll()
                 }}>查看全部</Text>
             }
 

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

@@ -622,6 +622,10 @@ export default function MainConsole(props: { type: WindowType }) {
                         desc="Subtitle"
                         btnTitle="Action"
                         onClick={() => {
+                            if (!user.isLogin) {
+                                jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+                                return
+                            }
                             jumpPage('/_health/pages/active_plan?schedule=' + JSON.stringify(list.length > 0 ? list[0] : '{}'))
                         }}
                     />
@@ -767,6 +771,7 @@ export default function MainConsole(props: { type: WindowType }) {
         }
         return 'time_point'
     }
+    
     return <View className="main-console-bg">
         <Image className="main_arrow" src={require('@assets/images/center_arrow.png')} />
         <View className="main_summary">

+ 1 - 1
src/features/health/MainFastEatCard.tsx

@@ -96,7 +96,7 @@ export default function MainFastEatCard(props: {
         setFastData(fast)
 
         update(fast)
-    }, [user.isLogin])
+    }, [])
 
     useEffect(() => {
         if (fastData) {

+ 0 - 1
src/features/health/MainHistory.tsx

@@ -36,7 +36,6 @@ export default function MainHistory(props: { type: string }) {
             lastMode = health.mode
             loadData(1)
         }
-        // console.log(health.mode)
 
     }, [health.mode])
 

+ 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_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_ME_ALBUMS, API_ME_ALBUMS_STAT, API_ME_JOURNALS } from "./http/api";
 import { request } from "./http/request";
 
 export const getLabelsEvent = (params) => {
@@ -312,3 +312,14 @@ export const getEvents = (id)=>{
         })
     })
 }
+
+export const fastWithSleep = ()=>{
+    return new Promise((resolve) => {
+        request({
+            url: API_HEALTH_FAST_SLEEP, method: 'GET', data: {  }
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        })
+    })
+}

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

@@ -95,6 +95,7 @@ export const API_ORDER_CHECK = `${baseUrl}/api/payment/member/orders/`
 
 //health
 export const API_SET_SCHEDULE = `${baseUrl}/api/fast/schedules`
+export const API_HEALTH_FAST_SLEEP = `${baseUrl}/api/health/fast-with-sleep`
 export const API_HEALTH_TARGET = `${baseUrl}/api/health/events`
 export const API_HEALTH_MOMENT = `${baseUrl}/api/health/moments`
 export const API_HEALTH_SCHEDULES = `${baseUrl}/api/health/schedules`