leon 1 рік тому
батько
коміт
d5cedf8be5

+ 0 - 1
src/_eat/components/add_label.tsx

@@ -44,7 +44,6 @@ export default function AddLabel(props: { labels: any }) {
             label:value,
             time:e
         }).then(res=>{
-            global.refreshFastEat()
             if (process.env.TARO_ENV=='weapp'){
                 Taro.navigateBack()
             }

+ 2 - 2
src/_eat/pages/meal_list.tsx

@@ -18,7 +18,7 @@ export default function MealList() {
     }, [])
 
     function schedules() {
-        getSchedules({ category: 'EAT' }).then(res => {
+        getSchedules({ window: 'EAT' }).then(res => {
             if ((res as any).schedules && (res as any).schedules.length > 0) {
                 setList((res as any).schedules[0].items)
             }
@@ -26,7 +26,7 @@ export default function MealList() {
 
         })
 
-        getLabels({ category: 'EAT' }).then(res => {
+        getLabels({ window: 'EAT' }).then(res => {
             setLabels((res as any).labels)
         })
     }

+ 4 - 0
src/features/health/History.scss

@@ -6,9 +6,13 @@
     padding-left: 40px;
     padding-right: 40px;
     box-sizing: border-box;
+    
 }
 
 .no_more{
+    display: flex;
+    align-items: center;
+    justify-content: center;
     width: 750px;
     text-align: center;
     margin-top: 20px;

+ 46 - 0
src/features/health/HistoryItem.tsx

@@ -0,0 +1,46 @@
+import formatMilliseconds from "@/utils/format_time";
+import { View, Text, Image } from "@tarojs/components";
+import Taro from "@tarojs/taro";
+import dayjs from "dayjs";
+
+export default function HistoryItem(props: { data: any, index: number }) {
+
+    function preview(obj) {
+        Taro.previewImage({
+            current: obj.url,
+            urls: [obj.url]
+        })
+    }
+
+    return <View style={{display:'flex',flexDirection:'column'}}>
+        <Text style={{color:'blue'}}>Date:{dayjs(props.data.window_range.start_timestamp).format('YYYY-MM-DD')}</Text>
+        {
+            <Text style={{color:'blue'}}>开始时间:{dayjs(props.data.window_range.start_timestamp).format('MM-DD HH:mm')}</Text>
+        }
+        {
+            props.data.window_range.end_timestamp && <Text style={{color:'blue'}}>结束时间:{dayjs(props.data.window_range.end_timestamp).format('MM-DD HH:mm')}</Text>
+        }
+        {
+            props.data.window_range.end_timestamp && <Text style={{color:'blue'}}>时长:{formatMilliseconds(props.data.window_range.end_timestamp-props.data.window_range.start_timestamp)}</Text>
+        }
+        {
+            props.data.events.map((item, i) => {
+                return <View key={i} >
+                    
+                    <View style={{ flexDirection: 'column', display: 'flex' }}>
+                        <Text>Time:{dayjs(item.real.start_timestamp).format('HH:mm')}</Text>
+                        <Text>{item.moment.title}</Text>
+                        <Text>{item.moment.description}</Text>
+                        <View>
+                            {
+                                item.moment.media.map((obj, j) => {
+                                    return <Image onClick={() => preview(obj)} src={obj.url} key={j * 10} style={{ width: 100, height: 100 }} />
+                                })
+                            }
+                        </View>
+                    </View>
+                </View>
+            })
+        }
+    </View>
+}

+ 114 - 6
src/features/health/MainConsole.tsx

@@ -8,7 +8,9 @@ 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 } from "@/services/health";
+import { clockTimes, updateSchedule } from "@/services/health";
+import TimePicker from "../common/TimePicker";
+import showActionSheet from "@/components/basic/ActionSheet";
 
 let useNavigation;
 let min = 0
@@ -22,6 +24,7 @@ if (process.env.TARO_ENV == 'rn') {
 export default function MainConsole(props: { type: WindowType }) {
     const health = useSelector((state: any) => state.health);
     const user = useSelector((state: any) => state.user);
+    const [showPicker, setShowPicker] = useState(false)
     const [showTimePicker, setShowTimePicker] = useState(false)
     const [operateType, setOperateType] = useState('')
     const [btnDisable, setBtnDisable] = useState(false)
@@ -38,6 +41,18 @@ export default function MainConsole(props: { type: WindowType }) {
 
     }, [props.type])
 
+    function edit(item) {
+        if (item.scenario != 'FAST' && item.scenario != 'SLEEP') {
+            return
+        }
+        if (!user.isLogin) {
+            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+            return
+        }
+        setSelItem(item)
+        setShowPicker(true)
+    }
+
 
     function record(item) {
         if (!user.isLogin) {
@@ -73,19 +88,76 @@ export default function MainConsole(props: { type: WindowType }) {
         jumpPage('/pages/clock/AddMoment?moment=' + JSON.stringify(item))
     }
 
+    function operateTitle(item) {
+        switch (item.action) {
+            case 'START':
+            case 'END':
+                return '打卡'
+        }
+        return '记录'
+    }
+
     function timelineItem(item: any, index: number) {
         return <View key={index} className="timeline_item" >
             <View className="timeline_left">
                 <Text className="timeline_title">{item.title}</Text>
-                <Text className="timeline_time">{dayjs(item.target.timestamp).format('HH:mm')}</Text>
+                <Text className="timeline_time" onClick={() => edit(item)}>{dayjs(item.target.timestamp).format('HH:mm')}</Text>
             </View>
             {
-                item.action && item.action != 'NA' && <View className="timeline_operate" onClick={() => record(item)}>记录</View>
+                item.action && item.action != 'NA' && <View className="timeline_operate" onClick={() => record(item)}>{operateTitle(item)}</View>
             }
 
         </View>
     }
 
+    function timeContent() {
+        return <Modal
+            testInfo={null}
+            dismiss={() => {
+                setShowPicker(false)
+            }}
+            confirm={() => { }}>
+            {
+                pickerContent()
+            }
+        </Modal>
+    }
+
+    function pickerContent() {
+        const timestamp = selItem.target.timestamp
+        const strTime = dayjs(timestamp).format('HH:mm')
+
+        var title, color;
+        switch (selItem.scenario) {
+            case 'FAST':
+                title = operateType == 'endFast' ? '结束断食' : '开始断食'
+                color = MainColorType.fast
+                break;
+            case 'SLEEP':
+                title = operateType == 'endFast' ? '结束睡眠' : '开始睡眠'
+                color = MainColorType.sleep
+        }
+
+        return <TimePicker time={strTime}
+            color={color}
+            title={title}
+            confirm={(e) => {
+                confirmPickerTime(e)
+            }}
+            cancel={() => {
+                setShowPicker(false)
+            }} />
+    }
+
+    function confirmPickerTime(strTime) {
+        updateSchedule({
+            time: strTime
+        }, selItem.schedule_id).then(res => {
+            global.refreshWindow()
+            setShowPicker(false)
+        })
+    }
+
     function modalContent() {
         global.set_time = new Date().getTime()
         return <Modal
@@ -101,14 +173,23 @@ export default function MainConsole(props: { type: WindowType }) {
     }
 
     function timePickerContent() {
-        var title = operateType == 'endFast' ? '结束断食' : '开始断食'
-        var color = MainColorType.fast
+        var title, color;
+        switch (selItem.scenario) {
+            case 'FAST':
+                title = operateType == 'endFast' ? '结束断食' : '开始断食'
+                color = MainColorType.fast
+                break;
+            case 'SLEEP':
+                title = operateType == 'endFast' ? '结束睡眠' : '开始睡眠'
+                color = MainColorType.sleep
+        }
+
         var endTimestamp = 0
         if (operateType == 'endFast') {
             endTimestamp = new Date().getTime()//fastData.target.end_time
         }
 
-        var duration = 24*3600*1000//fastData.target.duration
+        var duration = 24 * 3600 * 1000//fastData.target.duration
 
         return <View className="modal_content">
             <ConsolePicker ref={limitPickerRef}
@@ -155,6 +236,26 @@ export default function MainConsole(props: { type: WindowType }) {
         })
     }
 
+    function more() {
+        showActionSheet({
+            showActionSheetWithOptions: showActionSheetWithOptions,
+            title: 'Oprate Title',
+            itemList: [
+                'Add Snack',
+                '自定义餐次列表',
+            ],
+            success: (res) => {
+                switch (res) {
+                    case 0:
+                        break;
+                    case 1:
+                        jumpPage('/_eat/pages/meal_list')
+                        break;
+                }
+            }
+        });
+    }
+
     function detail() {
         const { day, night } = health.windows.night_day
         const { fast, eat } = health.windows.fast_eat
@@ -209,14 +310,21 @@ export default function MainConsole(props: { type: WindowType }) {
                     }
                 </View>
         }
+
         return <View />
     }
     return <View>
         {
             detail()
         }
+        {
+            (health.mode == 'EAT' || health.mode == 'ACTIVE') && <Text style={{display:'flex',alignItems:'center',justifyContent:'center'}} onClick={more}>更多</Text>
+        }
         {
             showTimePicker && modalContent()
         }
+        {
+            showPicker && timeContent()
+        }
     </View>
 }

+ 6 - 6
src/features/health/MainDayNightCard.tsx

@@ -16,7 +16,7 @@ import { durationArc, isCurrentTimeInRange, startArc } from "./util";
 import { setMode } from "@/store/health";
 import { IconSwitch1, IconSwitch2 } from "@/components/basic/Icons";
 
-export default function MainDayNightCard(props: { count: number, typeChanged: Function }) {
+export default function MainDayNightCard(props: { count: number, typeChanged: Function,id:number }) {
     const [isDay, setIsDay] = useState(true)
     const [isDayMode, setIsDayMode] = useState(true)
     const user = useSelector((state: any) => state.user);
@@ -55,8 +55,8 @@ export default function MainDayNightCard(props: { count: number, typeChanged: Fu
 
     const common: RingCommon = {
         useCase: 'ChooseScenario',
-        radius: 115,
-        lineWidth: 26,
+        radius: 50,
+        lineWidth: 15,
         isFast: true,
         status: 'WAIT_FOR_START'
     }
@@ -128,7 +128,7 @@ export default function MainDayNightCard(props: { count: number, typeChanged: Fu
             durationArc: getRealArc()
         }
 
-        return <Rings common={common} bgRing={bgRing} targetRing={targetRing} realRing={realRing} currentDot={currentDot} canvasId={'smal1w1l'} />
+        return <Rings common={common} bgRing={bgRing} targetRing={targetRing} realRing={realRing} currentDot={currentDot} canvasId={'smal1w1l'+props.id} />
     }
 
     function formatTime(format: string, timestamp?: number) {
@@ -198,7 +198,7 @@ export default function MainDayNightCard(props: { count: number, typeChanged: Fu
         </View>
     }
 
-    return <View style={{ width: rpxToPx(750), display: 'flex', flexShrink: 0, flexDirection: 'column', alignItems: 'center', position: 'relative' }}>
+    return <View style={{ width: rpxToPx(750/3), display: 'flex', flexShrink: 0, flexDirection: 'column', alignItems: 'center', position: 'relative' }}>
         {/* <Calendar year={2024} month={8}/> */}
         <View style={{ position: 'relative' }}>
             {
@@ -214,7 +214,7 @@ export default function MainDayNightCard(props: { count: number, typeChanged: Fu
 
         {switchBtn()}
         {/* <Text onClick={switchMode}>Switch</Text> */}
-        <View className="sticky"></View>
+        {/* <View className="sticky"></View> */}
         {/* <View style={{ height: 200 }} /> */}
     </View>
 }

+ 33 - 48
src/features/health/MainFastEatCard.tsx

@@ -39,7 +39,7 @@ if (process.env.TARO_ENV == 'rn') {
     checkNotification = require('@/utils/native_permission_check').checkNotification;
     useActionSheet = require('@expo/react-native-action-sheet').useActionSheet
 }
-export default function MainFastEatCard(props: { count: any, typeChanged: Function }) {
+export default function MainFastEatCard(props: { count: any, typeChanged: Function,id:number }) {
     const [isFastMode, setIsFastMode] = useState(true)
 
     const [showModal, setShowModal] = useState(false)
@@ -49,8 +49,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
     const [btnDisable, setBtnDisable] = useState(false)
     const [logEvent, setLogEvent] = useState('LOG_ONCE');
 
-    const [startScheduleTime, setStartScheduleTime] = useState('00:00')
-    const [endScheduleTime, setEndScheduleTime] = useState('00:00')
     const [eatData, setEatData] = useState<any>(null)
     const [fastData, setFastData] = useState<any>(null)
     const [startTime, setStartTime] = useState<any>(null)
@@ -81,8 +79,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
 
         setEatData(eat)
         setFastData(fast)
-        setStartScheduleTime(fast.period.start_time)
-        setEndScheduleTime(fast.period.end_time)
 
         update(fast)
     }, [user.isLogin])
@@ -97,25 +93,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
         if (health.selTab == 1) {
             dispatch(setMode(isFastMode ? 'FAST' : 'EAT'))
         }
-    }, [health.selTab,isFastMode])
-
-
-    global.refreshFastEat = () => {
-        refresh()
-    }
-
-
-
-    function refresh() {
-        fastWindow().then(res => {
-            const { eat_win, fast_win } = res
-            const fast = fast_win.fast
-            setEatData(eat_win)
-            setFastData(fast_win)
-            setStartScheduleTime(fast_win.fast.period.start_time)
-            setEndScheduleTime(fast_win.fast.period.end_time)
-        })
-    }
+    }, [health.selTab, isFastMode])
 
     function update(fast) {
         var now = new Date().getTime()
@@ -134,8 +112,8 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
 
     const common: RingCommon = {
         useCase: 'ChooseScenario',
-        radius: 115,
-        lineWidth: 26,
+        radius: 50,
+        lineWidth: 15,
         isFast: true,
         status: 'WAIT_FOR_START'
     }
@@ -145,8 +123,10 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
     }
 
     function scheduleRing() {
-        var starts: any = startScheduleTime.split(':')
-        var ends: any = endScheduleTime.split(':')
+        const { fast, eat } = health.windows.fast_eat
+
+        var starts: any = fast.period.start_time.split(':')
+        var ends: any = fast.period.end_time.split(':')
         const startSeconds: any = parseInt(starts[0] + '') * 60 + parseInt(starts[1] + '')
         const endSeconds: any = parseInt(ends[0] + '') * 60 + parseInt(ends[1] + '')
         const color = isFastMode ? '#9AE2FE' : '#FE810C66'
@@ -168,8 +148,10 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
         if (status != 'process') {
             return null
         }
-        var starts: any = startScheduleTime.split(':')
-        var ends: any = endScheduleTime.split(':')
+        const { fast, eat } = health.windows.fast_eat
+
+        var starts: any = fast.period.start_time.split(':')
+        var ends: any = fast.period.end_time.split(':')
         const startSeconds: any = parseInt(starts[0] + '') * 60 + parseInt(starts[1] + '')
         const endSeconds: any = parseInt(ends[0] + '') * 60 + parseInt(ends[1] + '')
         const color = isFastMode ? '#9AE2FE' : '#FE810C66'
@@ -199,9 +181,16 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
 
 
     function realRing() {
+        const { fast, eat } = health.windows.fast_eat
         if (isFastMode) {
             if (status != 'upcoming') {
-                var starts: any = startTime ? startTime.split(':') : startScheduleTime.split(':')
+
+
+
+                // var starts: any = fast.period.start_time.split(':')
+                // var ends: any = fast.period.end_time.split(':')
+
+                var starts: any = startTime ? startTime.split(':') : fast.period.start_time.split(':')
                 const startSeconds = parseInt(starts[0] + '') * 3600 + parseInt(starts[1] + '') * 60
 
                 const color = MainColorType.fast
@@ -231,8 +220,8 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
             }
         }
         else {
-            if (isCurrentTimeInRange(endScheduleTime, startScheduleTime)) {
-                var starts: any = endScheduleTime.split(':')
+            if (isCurrentTimeInRange(fast.period.end_time, fast.period.start_time)) {
+                var starts: any = fast.period.end_time.split(':')
                 const startSeconds = parseInt(starts[0] + '') * 60 + parseInt(starts[1] + '')
 
                 const color = MainColorType.eat
@@ -313,7 +302,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
             whiteIcon: true
         }
 
-        return <Rings common={common} bgRing={bgRing} scheduleRing={scheduleRing()} targetRing={targetRing()} realRing={realRing()} currentDot={currentDot} canvasId={'smal11l'} />
+        return <Rings common={common} bgRing={bgRing} scheduleRing={scheduleRing()} targetRing={targetRing()} realRing={realRing()} currentDot={currentDot} canvasId={'smal11l'+props.id} />
     }
 
     function formatTime(format: string, timestamp?: number) {
@@ -490,7 +479,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
                 code: isStart ? 'FAST_START' : 'FAST_END',
                 time: strTime
             }).then(res => {
-                refresh()
                 setShowPicker(false)
             })
         }
@@ -511,7 +499,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
                     target_duration: getIntervalSeconds(startTime, endTime) * 1000
                 }
             }, fastData.id).then(res => {
-                refresh()
                 setShowPicker(false)
             })
         }
@@ -551,7 +538,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
         if (operateType == 'startFast') {
             startFast(t1, fastData.target_duration, event ? event : logEvent).then(res => {
                 setBtnDisable(false)
-                refresh()
                 setShowTimePicker(false)
             }).catch(e => {
                 setBtnDisable(false)
@@ -560,7 +546,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
         else {
             endFast(t1, event ? event : logEvent).then(res => {
                 setBtnDisable(false)
-                refresh()
                 setShowTimePicker(false)
             }).catch(e => {
                 setBtnDisable(false)
@@ -607,12 +592,12 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
 
     function switchIcon() {
         if (isFastMode) {
-            if (status!='upcoming') {
+            if (status != 'upcoming') {
                 return <IconSwitch1 color="#000" width={15} />
             }
             return <IconSwitch2 color="#fff" width={15} />
         }
-        if (status!='upcoming') {
+        if (status != 'upcoming') {
             return <IconSwitch2 color="#fff" width={15} />
         }
         return <IconSwitch1 color="#000" width={15} />
@@ -621,7 +606,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
     function switchBtn() {
         var bgColor = ''
         if (isFastMode) {
-            if (status!='upcoming') {
+            if (status != 'upcoming') {
                 bgColor = '#fff'
             }
             else {
@@ -630,7 +615,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
 
         }
         else {
-            if (status!='upcoming') {
+            if (status != 'upcoming') {
                 bgColor = MainColorType.fast
             }
             else {
@@ -647,9 +632,9 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
     if (!fastData)
         return <View />
 
-    return <View style={{ alignItems: 'center', display: 'flex', flexDirection: 'column', width: rpxToPx(750), flexShrink: 0 }}>
+    return <View style={{ alignItems: 'center', display: 'flex', flexDirection: 'column', width: rpxToPx(750/3), flexShrink: 0 }}>
 
-        <View style={{ width: rpxToPx(750), }} />
+        <View style={{ width: rpxToPx(750/3), }} />
         <View style={{ position: 'relative', }}>
             {
                 ring()
@@ -662,7 +647,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
                 <Text className="date1">{global.language == 'en' ? formatTime('dddd, MMM D') : formatTime('MMMD日 dddd')}</Text>
             </View>
         </View>
-        <View>{isFastMode ? formatMilliseconds(fastData.target.duration) : formatMilliseconds(eatData.target.end_timestamp - eatData.target.start_timestamp)}</View>
+        <View>{isFastMode ? formatMilliseconds(health.windows.fast_eat.fast.target.duration) : formatMilliseconds(health.windows.fast_eat.eat.target.duration)}</View>
         {/* {
             isFastMode && <View>
                 <View className="log_row">
@@ -727,10 +712,10 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
         {
             switchBtn()
         }
-        {
+        {/* {
             !isFastMode && <Text onClick={more}>更多</Text>
-        }
-        <MainHistory type={isFastMode ? 'FAST' : 'EAT'} />
+        } */}
+        {/* <MainHistory type={isFastMode ? 'FAST' : 'EAT'} /> */}
         {
             showModal && <Modal dismiss={() => setShowModal(false)}>
                 <View style={{ width: 100, height: 100, backgroundColor: 'red' }}>{props.count}</View>

+ 15 - 9
src/features/health/MainHistory.tsx

@@ -8,6 +8,8 @@ import { records } from "@/services/health";
 import './History.scss'
 import Calendar from "./calendar";
 import { useSelector } from "react-redux";
+import HistoryItem from "./HistoryItem";
+import { rpxToPx } from "@/utils/tools";
 
 let lastMode = ''
 export default function MainHistory(props: { type: string }) {
@@ -19,16 +21,18 @@ export default function MainHistory(props: { type: string }) {
     const health = useSelector((state: any) => state.health);
 
 
-
+    global.refreshHistory = () => {
+        refresh()
+    }
 
 
     useEffect(() => {
-        if (lastMode !=health.mode){
+        if (lastMode != health.mode) {
             lastMode = health.mode
             loadData(1)
         }
         // console.log(health.mode)
-        
+
     }, [health.mode])
 
     function refresh() {
@@ -44,6 +48,7 @@ export default function MainHistory(props: { type: string }) {
     }
 
     function loadData(index: number) {
+        // return
         records({
             window: health.mode,
             limit: 10,
@@ -64,19 +69,20 @@ export default function MainHistory(props: { type: string }) {
     if (!loaded)
         return <View />
 
-    return <>
+    return <View style={{ width: rpxToPx(750) }}>
         {/* <Calendar year={2024} month={8}/> */}
-        <View style={{
+        {/* <View style={{
             // position: 'sticky',
             top: 0,
             height: 50,
             backgroundColor: 'blue',
             zIndex: 100
-        }} />
+        }} /> */}
         {
             list.map((item, index) => {
                 return <View key={index}>
-                    {
+                    <HistoryItem data={item} index={index} />
+                    {/* {
                         props.type == 'EAT' && <HistoryEatItem data={item} index={index} />
                     }
                     {
@@ -87,12 +93,12 @@ export default function MainHistory(props: { type: string }) {
                     }
                     {
                         props.type == 'SLEEP' && <HistorySleepItem data={item} index={index} />
-                    }
+                    } */}
                 </View>
             })
         }
         {
             (total == list.length) && <Text className="no_more">没有更多了</Text>
         }
-    </>
+    </View>
 }

+ 5 - 5
src/features/health/MainSleepActiveCard.tsx

@@ -13,7 +13,7 @@ import { durationArc, isCurrentTimeInRange, startArc } from "./util";
 import { setMode } from "@/store/health";
 import { IconSwitch1, IconSwitch2 } from "@/components/basic/Icons";
 
-export default function MainSleepActiveCard(props: { count: any, typeChanged: Function }) {
+export default function MainSleepActiveCard(props: { count: any, typeChanged: Function,id:number }) {
     const [isSleepMode, setIsSleepMode] = useState(true)
 
     const startScheduleTime = '19:00'
@@ -56,8 +56,8 @@ export default function MainSleepActiveCard(props: { count: any, typeChanged: Fu
 
     const common: RingCommon = {
         useCase: 'ChooseScenario',
-        radius: 115,
-        lineWidth: 26,
+        radius: 50,
+        lineWidth: 15,
         isFast: true,
         status: 'WAIT_FOR_START'
     }
@@ -178,7 +178,7 @@ export default function MainSleepActiveCard(props: { count: any, typeChanged: Fu
             whiteIcon: true
         }
 
-        return <Rings common={common} bgRing={bgRing} targetRing={targetRing()} realRing={realRing()} currentDot={currentDot} canvasId={'smal11lee'} />
+        return <Rings common={common} bgRing={bgRing} targetRing={targetRing()} realRing={realRing()} currentDot={currentDot} canvasId={'smal11lee'+props.id} />
     }
 
     function switchIcon() {
@@ -222,7 +222,7 @@ export default function MainSleepActiveCard(props: { count: any, typeChanged: Fu
         </View>
     }
 
-    return <View style={{ width: rpxToPx(750), display: 'flex', flexShrink: 0, flexDirection: 'column', alignItems: 'center' }}>
+    return <View style={{ width: rpxToPx(750/3), display: 'flex', flexShrink: 0, flexDirection: 'column', alignItems: 'center' }}>
         <View style={{ position: 'relative', }}>
             {
                 ring()

+ 29 - 4
src/features/health/MainSwiper.tsx

@@ -66,16 +66,41 @@ export default function MainSwiper(props: { count: number, pageChanged: Function
             <View style={{ width: rpxToPx(40) }} />
             <View className="tab_item" style={{ backgroundColor: current != 2 ? '#B2B2B2' : isSleep() ? MainColorType.sleep : MainColorType.active }} onClick={() => tapScroll(2)}></View>
         </View>
-        <Swiper style={{ height: 400 }} onChange={pageChanged} current={current}>
+        <Swiper style={{ height: 200, width: rpxToPx(750) }} circular
+            previousMargin={rpxToPx(250)}
+            nextMargin={rpxToPx(250)}
+            onChange={pageChanged}
+            current={current}>
             <SwiperItem>
-                <MainDayNightCard count={props.count} typeChanged={typeChanged} />
+                <MainDayNightCard count={props.count} typeChanged={typeChanged} id={1}/>
             </SwiperItem>
             <SwiperItem>
-                <MainFastEatCard count={props.count} typeChanged={typeChanged} />
+                <MainFastEatCard count={props.count} typeChanged={typeChanged} id={2}/>
             </SwiperItem>
             <SwiperItem>
-                <MainSleepActiveCard count={props.count} typeChanged={typeChanged} />
+                <MainSleepActiveCard count={props.count} typeChanged={typeChanged} id={3}/>
+            </SwiperItem>
+            <SwiperItem>
+                <MainDayNightCard count={props.count} typeChanged={typeChanged} id={7}/>
+            </SwiperItem>
+            <SwiperItem>
+                <MainFastEatCard count={props.count} typeChanged={typeChanged} id={8}/>
+            </SwiperItem>
+            <SwiperItem>
+                <MainSleepActiveCard count={props.count} typeChanged={typeChanged} id={9}/>
             </SwiperItem>
         </Swiper>
+
+        <View style={{flexDirection:'row',display:'flex'}}>
+            <View style={{backgroundColor:current==0?'#f0f0f0':'#fff'}} onClick={()=>setCurrent(0)}>
+                <MainDayNightCard count={props.count} typeChanged={typeChanged} id={4}/>
+            </View>
+            <View style={{backgroundColor:current==1?'#f0f0f0':'#fff'}} onClick={()=>setCurrent(1)}>
+                <MainFastEatCard count={props.count} typeChanged={typeChanged} id={5}/>
+            </View>
+            <View style={{backgroundColor:current==2?'#f0f0f0':'#fff'}} onClick={()=>setCurrent(2)}>
+                <MainSleepActiveCard count={props.count} typeChanged={typeChanged} id={6}/>
+            </View>
+        </View>
     </View>
 }

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

@@ -54,7 +54,7 @@ export default function Calendar(props: { year: number, month: number }) {
 
         streaks({
             window:health.mode,
-            month:202408
+            month:202409
         }).then(res=>{
             const array = (res as any).streaks
             for (var i=0;i<list.length;i++){

+ 16 - 4
src/pages/clock/AddMoment.tsx

@@ -112,7 +112,14 @@ export default function AddMoment() {
     }
 
     function save() {
-        createMoment({
+        if (desc.length ==0 && imgUrl.length==0){
+            Taro.showToast({
+                icon:'none',
+                title:'请输入描述或添加图片'
+            })
+            return
+        }
+        var params:any = {
             schedule_id: moment.schedule_id,
             title:moment.title,
             description: desc,
@@ -121,17 +128,22 @@ export default function AddMoment() {
                 timestamp:moment.target.timestamp
             },
             // real_end_time: meal.target_end_time,
-            media: [{
+        }
+
+        if (imgUrl.length>0){
+            params.media = [{
                 url:imgUrl,
                 type: imgUrl.indexOf('mp4') != -1 ? 'video' : 'image',
                 source: 'album'
-            }],
-        }).then(res => {
+            }]
+        }
+        createMoment(params).then(res => {
             if (process.env.TARO_ENV == 'weapp') {
                 Taro.navigateBack();
             }
 
             global.refreshWindow()
+            global.refreshHistory()
         })
     }
 

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

@@ -1,6 +1,6 @@
 import { View, ScrollView, Swiper, SwiperItem } from "@tarojs/components";
 import './Clock.scss'
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
 import MainDayNightCard from "@/features/health/MainDayNightCard";
 import MainFastEatCard from "@/features/health/MainFastEatCard";
 import MainSleepActiveCard from "@/features/health/MainSleepActiveCard";
@@ -25,13 +25,18 @@ export default function ClockNew() {
     const health = useSelector((state: any) => state.health);
     const [type, setType] = useState(WindowType.day)
     const [showCalendar, setShowCalendar] = useState(false)
-    const dispatch = useDispatch()
+    const healthRef = useRef(health)
+    const dispatch = useDispatch();
+    global.dispatch = dispatch;
 
+    useEffect(()=>{
+        healthRef.current = health;
+    },[health])
 
     useEffect(() => {
         setInterval(() => {
             setCount(index => index + 1)
-            health.refreshs.map((item) => {
+            healthRef.current.refreshs.map((item) => {
                 const strTime = dayjs(item).format('YYYY-MM-DDTHH:mm:ss')
                 const now = dayjs().format('YYYY-MM-DDTHH:mm:ss')
                 if (strTime == now) {

+ 2 - 2
src/services/health.tsx

@@ -40,10 +40,10 @@ export const createSchedule = (params) => {
     })
 }
 
-export const updateSchedule = () => {
+export const updateSchedule = (params,id) => {
     return new Promise((resolve, reject) => {
         request({
-            url: API_HEALTH_SCHEDULES, method: 'PUT', data: {}
+            url: `${API_HEALTH_SCHEDULES}/${id}`, method: 'PUT', data: {...params}
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));