leon 1 år sedan
förälder
incheckning
d23d55f23e

+ 6 - 0
src/_health/pages/schedules_list.scss

@@ -62,4 +62,10 @@
 .toolbar_btn{
     color: #FF751A;
     font-size: 30px;
+}
+
+.notification_icon{
+    width: 34px;
+    height: 34px;
+    margin-right: 12px;
 }

+ 9 - 4
src/_health/pages/schedules_list.tsx

@@ -1,4 +1,4 @@
-import { View, Text } from '@tarojs/components'
+import { View, Text, Image } from '@tarojs/components'
 import './schedules_list.scss'
 import './edit.scss'
 import { useEffect, useState } from 'react'
@@ -24,12 +24,12 @@ export default function SchedulesList() {
         schedules()
     }, [])
 
-    global.refreshSchedules = ()=>{
+    global.refreshSchedules = () => {
         schedules()
     }
 
     function schedules() {
-        getSchedules({ window: health.mode, is_all_day: false }).then(res => {
+        getSchedules({ window: health.mode }).then(res => {
             console.log('sss', res)
             if ((res as any).data && (res as any).data.length > 0) {
                 setList((res as any).data)
@@ -131,6 +131,11 @@ export default function SchedulesList() {
 
                         <Text className='item_name'>{item.title}</Text>
                     </View>
+                    <View style={{ flex: 1 }} />
+                    {
+                        !item.reminder && <Image src={require('@assets/images/notification_off.png')} className='notification_icon' />
+                    }
+
                     <Text className='item_time'>{item.time}</Text>
                     <View className='item_line' />
                 </View>
@@ -143,7 +148,7 @@ export default function SchedulesList() {
             (health.mode == 'EAT' || health.mode == 'ACTIVE') && <View className='toolbar'>
                 <View className='toolbar_btn' style={{ color: getThemeColor(health.mode) }} onClick={add}>添加</View>
                 <View style={{ flex: 1 }} />
-                <View className='toolbar_btn' style={{ color: getThemeColor(health.mode) }} onClick={() => setShowDel(!showDel)}>移除</View>
+                {/* <View className='toolbar_btn' style={{ color: getThemeColor(health.mode) }} onClick={() => setShowDel(!showDel)}>移除</View> */}
             </View>
         }
 

+ 3 - 3
src/_health/pages/schedules_reminder.tsx

@@ -35,7 +35,7 @@ export default function SchedulesReminder() {
                 time:item.time,
                 event:item.event,
                 title:item.title,
-                reminder_enabled:item.reminder_enabled
+                reminder:item.reminder
             })
         })
 
@@ -60,8 +60,8 @@ export default function SchedulesReminder() {
                     <Text className="cell_index">{index + 1}</Text>
                     <Text>{item.title}</Text>
                     <View style={{flex:1}}/>
-                    <Switch checked={item.reminder_enabled} onChange={(e)=>{
-                        item.reminder_enabled = e.detail.value
+                    <Switch checked={item.reminder} onChange={(e)=>{
+                        item.reminder = e.detail.value
                         setList([...list])
                     }}/>
                     {

+ 4 - 0
src/app.scss

@@ -389,4 +389,8 @@ page {
     left: 0;
     right: 0;
     bottom: 0;
+}
+
+.canvas{
+    // transform: translate(-50%,-50%);
 }

BIN
src/assets/images/notification_off.png


+ 8 - 0
src/features/health/MainCard.scss

@@ -162,4 +162,12 @@
 .aaaa{
     // transform-origin: center;
     // transform: scale(0.4);
+}
+
+.swiper-item{
+    transform: scale(0.85);
+    transition: all ease .4s;
+    &.active {
+        transform: scale(1);
+    }
 }

+ 9 - 1
src/features/health/MainConsole.scss

@@ -12,7 +12,7 @@
 .timeline_left{
     display: flex;
     flex-direction: column;
-    flex:1;
+    width: 300px;
 }
 
 .timeline_title{
@@ -43,6 +43,7 @@
     display: flex;
     align-items: center;
     justify-content: center;
+    flex-shrink: 0;
 }
 
 .main-console-bg{
@@ -122,3 +123,10 @@
     border-radius: 36px;
 }
 
+.notification_icon{
+    width: 34px;
+    height: 34px;
+    margin-right: 12px;
+    flex-shrink: 0;
+}
+

+ 18 - 14
src/features/health/MainConsole.tsx

@@ -31,7 +31,7 @@ export default function MainConsole(props: { type: WindowType }) {
     const user = useSelector((state: any) => state.user);
     const [showPicker, setShowPicker] = useState(false)
     const [showTimePicker, setShowTimePicker] = useState(false)
-    const [durationPicker,setDurationPicker] = useState(false)
+    const [durationPicker, setDurationPicker] = useState(false)
     const [operateType, setOperateType] = useState('')
     const [btnDisable, setBtnDisable] = useState(false)
     const [selItem, setSelItem] = useState<any>(null)
@@ -147,6 +147,10 @@ export default function MainConsole(props: { type: WindowType }) {
                 }
 
             </View>
+            <View style={{flex:1}}/>
+            {
+                !item.reminder && <Image src={require('@assets/images/notification_off.png')} className='notification_icon' />
+            }
             {
                 item.moment && item.moment.media && item.moment.media.length > 0 && <Image
                     src={item.moment.media[0].url}
@@ -187,7 +191,7 @@ export default function MainConsole(props: { type: WindowType }) {
                 color = MainColorType.fast
                 break;
             case 'SLEEP':
-                title = selItem.event == 'SLEEP_WAKE_UP' ?  '结束睡眠':'开始睡眠'
+                title = selItem.event == 'SLEEP_WAKE_UP' ? '结束睡眠' : '开始睡眠'
                 color = MainColorType.sleep
         }
 
@@ -270,7 +274,7 @@ export default function MainConsole(props: { type: WindowType }) {
                 color = MainColorType.fast
                 break;
             case 'SLEEP':
-                title = selItem.event == 'SLEEP_WAKE_UP' ? '结束睡眠':'开始睡眠'
+                title = selItem.event == 'SLEEP_WAKE_UP' ? '结束睡眠' : '开始睡眠'
                 color = MainColorType.sleep
                 break
         }
@@ -431,7 +435,7 @@ export default function MainConsole(props: { type: WindowType }) {
                             const obj = getScenario(health.windows, health.mode)
                             if (obj.window_id) {
                                 //del record
-                                
+
                                 console.log('zzzzzzzzz')
                             }
                             else {
@@ -555,10 +559,10 @@ export default function MainConsole(props: { type: WindowType }) {
         return ''
     }
 
-    function updateDuration(duration){
+    function updateDuration(duration) {
         setDurationPicker(false)
-        const scenario = getScenario(health.windows,health.mode)
-        updateEventDuration(scenario.timeline[0].event_id,duration).then(res=>{
+        const scenario = getScenario(health.windows, health.mode)
+        updateEventDuration(scenario.timeline[0].event_id, duration).then(res => {
             global.refreshWindow()
         })
     }
@@ -593,13 +597,13 @@ export default function MainConsole(props: { type: WindowType }) {
             showPicker && timeContent()
         }
         {
-            durationPicker && <DurationPicker 
-            done={(time)=>{
-                updateDuration(time)
-            }}
-            dismiss={()=>{
-                setDurationPicker(false)
-            }} time={getScenario(health.windows,health.mode).target.duration}/>
+            durationPicker && <DurationPicker
+                done={(time) => {
+                    updateDuration(time)
+                }}
+                dismiss={() => {
+                    setDurationPicker(false)
+                }} time={getScenario(health.windows, health.mode).target.duration} />
         }
     </View>
 }

+ 20 - 85
src/features/health/MainDayNightCard.tsx

@@ -17,7 +17,13 @@ import { setMode } from "@/store/health";
 import { IconSwitch1, IconSwitch2 } from "@/components/basic/Icons";
 import { getScenario, getWindowStatus } from "./hooks/health_hooks";
 
-export default function MainDayNightCard(props: { count: number, typeChanged: Function, id: number, onClick: Function }) {
+export default function MainDayNightCard(props: {
+    count: number,
+    typeChanged: Function,
+    id: number,
+    onClick: Function,
+    scale: number
+}) {
     const [isDay, setIsDay] = useState(true)
     const [isDayMode, setIsDayMode] = useState(true)
     const user = useSelector((state: any) => state.user);
@@ -98,10 +104,10 @@ export default function MainDayNightCard(props: { count: number, typeChanged: Fu
     }
 
     function getRealArc() {
-        const status = getWindowStatus(health.windows,isDayMode?'DAY':'NIGHT')
-        if (status == WindowStatusType.upcoming){
-            const scenario = getScenario(health.windows,isDayMode?'DAY':'NIGHT')
-            return durationArc(new Date().getTime(),scenario.target.start_timestamp)
+        const status = getWindowStatus(health.windows, isDayMode ? 'DAY' : 'NIGHT')
+        if (status == WindowStatusType.upcoming) {
+            const scenario = getScenario(health.windows, isDayMode ? 'DAY' : 'NIGHT')
+            return durationArc(new Date().getTime(), scenario.target.start_timestamp)
         }
         const { day, night } = health.windows.night_day
         if (isDayMode) {
@@ -128,18 +134,10 @@ export default function MainDayNightCard(props: { count: number, typeChanged: Fu
             offset = hour * 60 + minute - new Date().getHours() * 60 - new Date().getMinutes()
         }
 
-        // const currentDot: CurrentDot = {
-        //     color: isDayMode ? MainColorType.day : MainColorType.night,
-        //     lineWidth: 10,
-        //     borderColor: '#fff',
-        //     offset: offset,
-        //     whiteIcon: true
-        // }
-
         var targetColor: string = isDayMode ? MainColorType.dayLight : MainColorType.nightLight
         var realColor: string = isDayMode ? MainColorType.day : MainColorType.night
-        const status = getWindowStatus(health.windows,isDayMode?'DAY':'NIGHT')
-        if (status == WindowStatusType.upcoming){
+        const status = getWindowStatus(health.windows, isDayMode ? 'DAY' : 'NIGHT')
+        if (status == WindowStatusType.upcoming) {
             realColor = '#CCCCCC'
         }
 
@@ -155,84 +153,21 @@ export default function MainDayNightCard(props: { count: number, typeChanged: Fu
             durationArc: getRealArc()
         }
 
-        return <Rings common={common} bgRing={bgRing} targetRing={targetRing} realRing={realRing} canvasId={'smal1w1l' + props.id} />
-    }
-
-    function formatTime(format: string, timestamp?: number) {
-        // var moment = require('moment-timezone');
-        // if (current) {
-        //     if (timestamp) {
-        //         return moment(timestamp).tz(current.time.timezone.id).format(format)
-        //     }
-        //     return moment().tz(current.time.timezone.id).format(format)
-        // }
-
-        return dayjs().format(format)
-    }
-
-    function switchMode() {
-        const mode = !isDayMode
-        setIsDayMode(mode)
-        props.typeChanged(mode ? WindowType.day : WindowType.night)
-    }
-
-    function switchIcon() {
-        if (isDayMode) {
-            if (isDay) {
-                return <IconSwitch1 color="#000" width={15} />
-            }
-            return <IconSwitch2 color="#fff" width={15} />
-        }
-        if (isDay) {
-            return <IconSwitch2 color="#fff" width={15} />
-        }
-        return <IconSwitch1 color="#000" width={15} />
-    }
-
-    function switchBtn() {
-        var bgColor = ''
-        if (isDayMode) {
-            if (isDay) {
-                bgColor = '#fff'
-            }
-            else {
-                bgColor = '#000'
-            }
-
-        }
-        else {
-            if (isDay) {
-                bgColor = MainColorType.day
-            }
-            else {
-                bgColor = '#fff'
-            }
-        }
-        return <View className="switch_btn" style={{ backgroundColor: bgColor }} onClick={switchMode}>
-            {
-                switchIcon()
-            }
-        </View>
+        return <Rings
+            common={common}
+            bgRing={bgRing}
+            targetRing={targetRing}
+            realRing={realRing}
+            canvasId={'smal1w1l' + props.id}
+            scale={props.scale??1.0} />
     }
 
     return <View onClick={() => props.onClick()} style={{ width: rpxToPx(750 / 3), display: 'flex', flexShrink: 0, flexDirection: 'column', alignItems: 'center', position: 'relative' }}>
-        {/* <Calendar year={2024} month={8}/> */}
         <View style={{ position: 'relative' }}>
             {
                 ring()
             }
             <View className={health.selTab == 0 ? 'window_name window_name_sel' : 'window_name'}>{isDayMode ? 'Day' : 'Night'}</View>
-            {/* <View className="ring_center">
-                <View>{isDayMode ? 'Daylight' : 'Night'}</View>
-                <View>{timeStatus()}</View>
-                <Text className="time1" style={{ color: '#000' }}>{formatTime('HH:mm:ss')}</Text>
-                <Text className="date1">{global.language == 'en' ? formatTime('dddd, MMM D') : formatTime('MMMD日 dddd')}</Text>
-            </View> */}
         </View>
-
-        {/* {switchBtn()} */}
-        {/* <Text onClick={switchMode}>Switch</Text> */}
-        {/* <View className="sticky"></View> */}
-        {/* <View style={{ height: 200 }} /> */}
     </View>
 }

+ 16 - 317
src/features/health/MainFastEatCard.tsx

@@ -25,7 +25,6 @@ import { IconSwitch1, IconSwitch2 } from "@/components/basic/Icons";
 import { getScenario, getWindowStatus } from "./hooks/health_hooks";
 let useNavigation;
 
-let Linking, PushNotification;
 let checkNotification;
 let min = 0
 let max = 0
@@ -34,13 +33,16 @@ let useActionSheet;
 
 if (process.env.TARO_ENV == 'rn') {
     useNavigation = require("@react-navigation/native").useNavigation
-    Linking = require('react-native').Linking;
-    // JPush = require('jpush-react-native').default;
-    PushNotification = require('react-native-push-notification')
     checkNotification = require('@/utils/native_permission_check').checkNotification;
     useActionSheet = require('@expo/react-native-action-sheet').useActionSheet
 }
-export default function MainFastEatCard(props: { count: any, typeChanged: Function, id: number, onClick: Function }) {
+export default function MainFastEatCard(props: {
+    count: any,
+    typeChanged: Function,
+    id: number,
+    onClick: Function,
+    scale: number
+}) {
     const [isFastMode, setIsFastMode] = useState(true)
 
     const [showModal, setShowModal] = useState(false)
@@ -52,8 +54,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
 
     const [eatData, setEatData] = useState<any>(null)
     const [fastData, setFastData] = useState<any>(null)
-    const [startTime, setStartTime] = useState<any>(null)
-    const [endTime, setEndTime] = useState<any>(null)
     const [status, setStatus] = useState<any>('upcoming')
     const [showPicker, setShowPicker] = useState(false)
     const [isStart, setIsStart] = useState(true)
@@ -62,11 +62,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
     const health = useSelector((state: any) => state.health);
     const dispatch = useDispatch()
 
-    let navigation, showActionSheetWithOptions;
-    if (useNavigation) {
-        navigation = useNavigation()
-        showActionSheetWithOptions = useActionSheet()
-    }
 
     useEffect(() => {
         if (health.mode == 'FAST') {
@@ -178,7 +173,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
             durationArc = ((fastData.target.end_time - fastData.target.start_time) / 1000) / (1440 * 60) * 2 * Math.PI
         }
 
-        
+
 
         return {
             color,
@@ -220,160 +215,16 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
         }
     }
 
-
-
-    function getTimeToDestination(timeStr, isPasted) {
-        // 获取当前时间
-        const now = new Date();
-        const currentHours = now.getHours();
-        const currentMinutes = now.getMinutes();
-        const currentSeconds = now.getSeconds();
-
-        // 解析目标时间
-        const [targetHours, targetMinutes] = timeStr.split(':').map(Number);
-
-        // 计算时间差
-        let hours = targetHours - currentHours;
-        let minutes = targetMinutes - currentMinutes;
-        let seconds = 60 - currentSeconds;
-
-        if (minutes < 0) {
-            minutes += 60;
-            hours--;
-        }
-
-        if (hours < 0) {
-            hours += 24;
-        }
-
-        if (seconds === 60) {
-            seconds = 0;
-            minutes++;
-        }
-
-        // 如果是过去的时间,则返回剩余时间
-        if (isPasted) {
-            hours = 24 - hours;
-            minutes = 60 - minutes;
-            seconds = 60 - seconds;
-        }
-
-        // 格式化输出
-        return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
-    }
-
     function ring() {
-        var offset = 0
-
-        var hour = new Date().getHours()
-        var minute = new Date().getMinutes()
-
-        if (hour != new Date().getHours() || minute != new Date().getMinutes()) {
-            offset = hour * 60 + minute - new Date().getHours() * 60 - new Date().getMinutes()
-        }
-
-        // const currentDot: CurrentDot = {
-        //     color: isFastMode ? MainColorType.fast : MainColorType.eat,
-        //     lineWidth: 10,
-        //     borderColor: '#fff',
-        //     offset: offset,
-        //     whiteIcon: true
-        // }
-
-        return <Rings common={common} bgRing={bgRing} scheduleRing={scheduleRing()} targetRing={targetRing()} realRing={realRing()} canvasId={'smal11l' + props.id} />
-    }
-
-    function formatTime(format: string, timestamp?: number) {
-        // var moment = require('moment-timezone');
-        // if (current) {
-        //     if (timestamp) {
-        //         return moment(timestamp).tz(current.time.timezone.id).format(format)
-        //     }
-        //     return moment().tz(current.time.timezone.id).format(format)
-        // }
-
-        return dayjs().format(format)
-    }
-
-    function switchMode() {
-        const mode = !isFastMode
-        setIsFastMode(mode)
-        props.typeChanged(mode ? WindowType.fast : WindowType.eat)
-    }
-
-    function getFastStatus() {
-        switch (status) {
-            case 'process':
-                return 'Process'
-            case 'new':
-                return 'New Open'
-            case 'upcoming':
-                return 'Upcoming'
-        }
-        return ''
-    }
-
-    function getFastTime() {
-        var milliSeconds = 0;
-
-        switch (status) {
-            case 'process':
-                milliSeconds = new Date().getTime() - fastData.real_start_time
-                break;
-            case 'new':
-                return getTimeToDestination(fastData.period.start_time, true)
-            case 'upcoming':
-                return getTimeToDestination(fastData.period.start_time, false)
-
-        }
-        var seconds = Math.floor(milliSeconds / 1000)
-        const hours = Math.floor(seconds / 3600);
-        const minutes = Math.floor((seconds % 3600) / 60);
-        const remainingSeconds = seconds % 60;
-        return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
-    }
-
-    function getEatTime() {
-
-        return getTimeToDestination(eatData.period.start_time, isCurrentTimeInRange(eatData.period.start_time, eatData.period.end_time))
-    }
-
-    function tapFastStart() {
-        setIsStart(true)
-        setShowPicker(true)
-    }
-
-    function tapFastEnd() {
-        setIsStart(false)
-        setShowPicker(true)
-    }
-
-    function tapStartLog() {
-        if (status == 'upcoming') {
-            return;
-        }
-        if (!user.isLogin) {
-            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
-            return
-        }
-        defaultTimestamp = new Date().getTime()
-        min = defaultTimestamp - 1 * 24 * 3600 * 1000
-        max = defaultTimestamp
-
-        setOperateType('startFast')
-        setShowTimePicker(true)
-    }
 
-    function tapEndLog() {
-        if (status != 'process') {
-            return
-        }
-        defaultTimestamp = new Date().getTime()
-        // defaultTimestamp = e ? new Date().getTime() : logEventTimestamp
-        min = defaultTimestamp - 1 * 24 * 3600 * 1000
-        max = defaultTimestamp
-        setOperateType('endFast')
-        setShowTimePicker(true)
+        return <Rings common={common}
+            bgRing={bgRing}
+            scheduleRing={scheduleRing()}
+            targetRing={targetRing()}
+            realRing={realRing()}
+            canvasId={'smal11l' + props.id}
+            scale={props.scale ?? 1.0}
+        />
     }
 
     function modalContent() {
@@ -531,82 +382,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
         }
     }
 
-    function goAddEat(meal, index) {
-        if (!enableMeal(meal)) {
-            return;
-        }
-        jumpPage('/pages/clock/AddEat?meal=' + JSON.stringify(eatData.meals[index]))
-    }
-
-    function enableMeal(meal) {
-        if (meal.real_start_time > 0) {
-            return true
-        }
-        if (meal.target.start_time > new Date().getTime()) {
-            return true
-        }
-        return true
-    }
-
-    function more() {
-        showActionSheet({
-            showActionSheetWithOptions: showActionSheetWithOptions,
-            title: 'Oprate Title',
-            itemList: [
-                'Add Snack',
-                '自定义餐次列表',
-            ],
-            success: (res) => {
-                switch (res) {
-                    case 0:
-                        break;
-                    case 1:
-                        jumpPage('/_health/pages/schedules_list')
-                        break;
-                }
-            }
-        });
-    }
-
-    function switchIcon() {
-        if (isFastMode) {
-            if (status != 'upcoming') {
-                return <IconSwitch1 color="#000" width={15} />
-            }
-            return <IconSwitch2 color="#fff" width={15} />
-        }
-        if (status != 'upcoming') {
-            return <IconSwitch2 color="#fff" width={15} />
-        }
-        return <IconSwitch1 color="#000" width={15} />
-    }
-
-    function switchBtn() {
-        var bgColor = ''
-        if (isFastMode) {
-            if (status != 'upcoming') {
-                bgColor = '#fff'
-            }
-            else {
-                bgColor = MainColorType.eat
-            }
-
-        }
-        else {
-            if (status != 'upcoming') {
-                bgColor = MainColorType.fast
-            }
-            else {
-                bgColor = '#fff'
-            }
-        }
-        return <View className="switch_btn" style={{ backgroundColor: bgColor }} onClick={switchMode}>
-            {
-                switchIcon()
-            }
-        </View>
-    }
-
     if (!fastData)
         return <View />
 
@@ -618,83 +393,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
                 ring()
             }
             <View className={health.selTab == 1 ? 'window_name window_name_sel' : 'window_name'}>{isFastMode ? 'Fast' : 'Eat'}</View>
-            {/* <View className="ring_center">
-                {
-                    isFastMode && <Text>{getFastStatus()}</Text>
-                }
-                <Text className="time1">{isFastMode ? getFastTime() : getEatTime()}</Text>
-                <Text className="date1">{global.language == 'en' ? formatTime('dddd, MMM D') : formatTime('MMMD日 dddd')}</Text>
-            </View> */}
         </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">
-                    {
-                        status == 'process' ? <View className="schedule_name">Fast starts</View> : <View className="schedule" onClick={tapFastStart}>
-                            <Text className="schedule_name">
-                                Fast starts:
-                            </Text>
-                            <Text className="schedule">
-                                {startScheduleTime}
-                            </Text>
-                        </View>
-                    }
-
-                    {
-                        status == 'process' ? <View className="schedule">{dayjs(fastData.target.start_time).format('HH:mm')}</View> :
-                            <View onClick={tapStartLog} className={status == 'new' ? "fast_log_btn" : "fast_log_btn fast_log_btn_disable"}>Log{status == 'new' && <View className="badge" />}</View>
-                    }
-
-
-                </View>
-                <View className="log_row">
-                    <View className="schedule" onClick={tapFastEnd}>
-                        <Text className="schedule_name">
-                            Fast ends:
-                        </Text>
-                        <Text className="schedule">
-                            {status == 'process' ? dayjs(fastData.target.end_time).format('HH:mm') : endScheduleTime}
-                        </Text>
-                    </View>
-                    <View onClick={tapEndLog} className={status == 'process' ? "fast_log_btn" : "fast_log_btn fast_log_btn_disable"}>Log</View>
-                </View>
-            </View>
-        }
-        {
-            !isFastMode && <View>
-                {
-                    eatData.meals.map((item, index) => {
-                        return <View className="log_row" style={{ justifyContent: 'flex-start' }} key={index}>
-                            {
-                                item.real_start_time && item.media && item.media.length > 0 && item.media[0].url && <Image src={item.media[0].url} style={{ width: 50, height: 50, marginRight: 10 }} />
-                            }
-                            <View className="schedule">
-                                <Text className="schedule_name">{item.name}</Text>
-                                <Text className="schedule">
-                                    {item.real_start_time ? dayjs(item.real_start_time).format('HH:mm') + ' - ' + dayjs(item.real_end_time).format('HH:mm') : item.period.start_time}
-                                </Text>
-                            </View>
-                            <View style={{ flex: 1 }} />
-                            {
-                                item.real_start_time ? <View className="fast_log_btn fast_log_btn_disable">已记录</View> : <View onClick={() => goAddEat(item, index)} className={enableMeal(item) ? "fast_log_btn fast_log_eat_btn" : "fast_log_btn fast_log_btn_disable"}>Add</View>
-                            }
-
-                        </View>
-                    })
-                }
-            </View>
-        } */}
-
-
-
-        {/* {
-            switchBtn()
-        } */}
-        {/* {
-            !isFastMode && <Text onClick={more}>更多</Text>
-        } */}
-        {/* <MainHistory type={isFastMode ? 'FAST' : 'EAT'} /> */}
         {
             showModal && <Modal dismiss={() => setShowModal(false)}>
                 <View style={{ width: 100, height: 100, backgroundColor: 'red' }}>{props.count}</View>

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

@@ -104,7 +104,7 @@ export default function MainHistory(props: { type: string }) {
             })
         }
         {
-            (health.mode !='DAY' && health.mode !='NIGHT')&&(total == list.length) && <Text className="no_more">没有更多了</Text>
+            (list.length>0)&&(total == list.length) && <Text className="no_more">没有更多了</Text>
         }
     </View>
 }

+ 18 - 88
src/features/health/MainSleepActiveCard.tsx

@@ -3,36 +3,35 @@ import './MainCard.scss'
 import { useEffect, useState } from "react";
 import { rpxToPx } from "@/utils/tools";
 import Rings, { RingCommon, BgRing, TargetRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
-import dayjs from "dayjs";
-import moment from 'moment-timezone'
 import { MainColorType } from "@/context/themes/color";
 import { useDispatch, useSelector } from "react-redux";
-import { sleepWindow } from "@/services/trackTimeDuration";
 import { WindowStatusType, WindowType } from "@/utils/types";
 import { durationArc, isCurrentTimeInRange, startArc } from "./util";
 import { setMode } from "@/store/health";
-import { IconSwitch1, IconSwitch2 } from "@/components/basic/Icons";
 import { getScenario, getWindowStatus } from "./hooks/health_hooks";
 
-export default function MainSleepActiveCard(props: { count: any, typeChanged: Function, id: number, onClick: Function }) {
+export default function MainSleepActiveCard(props: {
+    count: any,
+    typeChanged: Function,
+    id: number,
+    onClick: Function,
+    scale: number
+}) {
     const [isSleepMode, setIsSleepMode] = useState(true)
 
-    const startScheduleTime = '19:00'
-    const endScheduleTime = '06:00'
-
     const user = useSelector((state: any) => state.user);
     const health = useSelector((state: any) => state.health);
     const dispatch = useDispatch()
 
 
-    useEffect(()=>{
-        if (health.mode == 'SLEEP'){
+    useEffect(() => {
+        if (health.mode == 'SLEEP') {
             setIsSleepMode(true)
         }
-        else if (health.mode == 'ACTIVE'){
+        else if (health.mode == 'ACTIVE') {
             setIsSleepMode(false)
         }
-    },[health.mode])
+    }, [health.mode])
 
     useEffect(() => {
         const { sleep } = health.windows.sleep_active
@@ -54,17 +53,6 @@ export default function MainSleepActiveCard(props: { count: any, typeChanged: Fu
         }
     }, [health.selTab, isSleepMode])
 
-    function formatTime(format: string, timestamp?: number) {
-
-        return dayjs().format(format)
-    }
-
-    function switchMode() {
-        var mode = !isSleepMode;
-        setIsSleepMode(mode)
-        props.typeChanged(mode ? WindowType.sleep : WindowType.active)
-    }
-
     const common: RingCommon = {
         useCase: 'ChooseScenario',
         radius: 37,
@@ -138,65 +126,15 @@ export default function MainSleepActiveCard(props: { count: any, typeChanged: Fu
     }
 
     function ring() {
-        var offset = 0
 
-        var hour = new Date().getHours()
-        var minute = new Date().getMinutes()
-
-        if (hour != new Date().getHours() || minute != new Date().getMinutes()) {
-            offset = hour * 60 + minute - new Date().getHours() * 60 - new Date().getMinutes()
-        }
 
-        // const currentDot: CurrentDot = {
-        //     color: isSleepMode ? MainColorType.sleep : MainColorType.active,
-        //     lineWidth: 10,
-        //     borderColor: '#fff',
-        //     offset: offset,
-        //     whiteIcon: true
-        // }
-
-        return <Rings common={common} bgRing={bgRing} targetRing={targetRing()} realRing={realRing()} canvasId={'smal11lee' + props.id} />
-    }
-
-    function switchIcon() {
-        const { sleep } = health.windows.sleep_active
-        if (isSleepMode) {
-            if (isCurrentTimeInRange(sleep.period.start_time, sleep.period.end_time)) {
-                return <IconSwitch1 color="#000" width={15} />
-            }
-            return <IconSwitch2 color="#fff" width={15} />
-        }
-        if (isCurrentTimeInRange(sleep.period.start_time, sleep.period.end_time)) {
-            return <IconSwitch2 color="#fff" width={15} />
-        }
-        return <IconSwitch1 color="#000" width={15} />
-    }
-
-    function switchBtn() {
-        var bgColor = ''
-        const { sleep } = health.windows.sleep_active
-        if (isSleepMode) {
-            if (isCurrentTimeInRange(sleep.period.start_time, sleep.period.end_time)) {
-                bgColor = '#fff'
-            }
-            else {
-                bgColor = MainColorType.active
-            }
-
-        }
-        else {
-            if (isCurrentTimeInRange(sleep.period.start_time, sleep.period.end_time)) {
-                bgColor = MainColorType.sleep
-            }
-            else {
-                bgColor = '#fff'
-            }
-        }
-        return <View className="switch_btn" style={{ backgroundColor: bgColor }} onClick={switchMode}>
-            {
-                switchIcon()
-            }
-        </View>
+        return <Rings
+            common={common}
+            bgRing={bgRing}
+            targetRing={targetRing()}
+            realRing={realRing()}
+            canvasId={'smal11lee' + props.id}
+            scale={props.scale ?? 1.0} />
     }
 
     return <View style={{ width: rpxToPx(750 / 3), display: 'flex', flexShrink: 0, flexDirection: 'column', alignItems: 'center' }} onClick={() => props.onClick()}>
@@ -207,14 +145,6 @@ export default function MainSleepActiveCard(props: { count: any, typeChanged: Fu
                 }
             </View>
             <View className={health.selTab == 2 ? 'window_name window_name_sel' : 'window_name'}>{isSleepMode ? 'Sleep' : 'Activity'}</View>
-            {/* <View className="ring_center">
-                <Text className="time1">{formatTime('HH:mm:ss')}</Text>
-                <Text className="date1">{global.language == 'en' ? formatTime('dddd, MMM D') : formatTime('MMMD日 dddd')}</Text>
-            </View> */}
         </View>
-
-        {/* {
-            switchBtn()
-        } */}
     </View>
 }

+ 119 - 14
src/features/health/MainSwiper.tsx

@@ -11,19 +11,21 @@ import { MainColorType } from "@/context/themes/color";
 import { rpxToPx } from "@/utils/tools";
 import dayjs from "dayjs";
 
+
+let scrollPage = 0;
 export default function MainSwiper(props: { count: number, pageChanged: Function, typeChanged: Function }) {
     const [current, setCurrent] = useState(0)
     const [type, setType] = useState(WindowType.day)
     const health = useSelector((state: any) => state.health);
-    const dispatch = useDispatch()
 
-    function tapScroll(index) {
-        setCurrent(index)
-    }
+    const [scale0, setScale0] = useState(1.0)
+    const [scale1, setScale1] = useState(0.8)
+    const [scale2, setScale2] = useState(0.8)
+    const dispatch = useDispatch()
 
     function pageChanged(e) {
         const page = e.detail.current
-
+        console.log(page)
         setCurrent(page)
         props.pageChanged(page)
 
@@ -47,6 +49,110 @@ export default function MainSwiper(props: { count: number, pageChanged: Function
         props.typeChanged(e)
     }
 
+    function onTransition(e) {
+        let x = e.detail.dx
+
+        let scale0 = 0
+        let scale1 = 0
+        let scale2 = 0
+
+        const pageWidth = 143
+
+        if (x >= -pageWidth && x <= pageWidth) {
+            switch (scrollPage) {
+                case 0:
+                case 3:
+                    {
+                        scale0 = 1 - Math.abs(x) / pageWidth * 0.2
+                        scale1 = x > 0 ? 1 - (pageWidth - x) / pageWidth * 0.2 : 0.8
+                        scale2 = x < 0 ? 1 - (pageWidth + x) / pageWidth * 0.2 : 0.8
+                    }
+                    break;
+                case 1:
+                case 4:
+                    {
+                        scale0 = x < 0 ? 1 - (pageWidth + x) / pageWidth * 0.2 : 0.8
+                        scale1 = 1 - Math.abs(x) / pageWidth * 0.2
+                        scale2 = x > 0 ? 1 - (pageWidth - x) / pageWidth * 0.2 : 0.8
+                    }
+                    break;
+                case 2:
+                case 5:
+                    {
+                        scale0 = x > 0 ? 1 - (pageWidth - x) / pageWidth * 0.2 : 0.8
+                        scale1 = x < 0 ? 1 - (pageWidth + x) / pageWidth * 0.2 : 0.8
+                        scale2 = 1 - Math.abs(x) / pageWidth * 0.2
+                    }
+                    break;
+            }
+        }
+        else if (x >= -pageWidth*2 && x <= pageWidth*2) {
+            switch (scrollPage) {
+                case 0:
+                case 3:
+                    {
+                        scale1 = 1 - (Math.abs(x)-pageWidth) / pageWidth * 0.2
+                        scale2 = x > 0 ? 1 - (pageWidth - x+pageWidth) / pageWidth * 0.2 : 0.8
+                        scale0 = x < 0 ? 1 - (pageWidth + x+pageWidth) / pageWidth * 0.2 : 0.8
+                    }
+                    break;
+                case 1:
+                case 4:
+                    {
+                        scale1 = x < 0 ? 1 - (pageWidth + x+pageWidth) / pageWidth * 0.2 : 0.8
+                        scale2 = 1 - (Math.abs(x)-pageWidth) / pageWidth * 0.2
+                        scale0 = x > 0 ? 1 - (pageWidth - x+pageWidth) / pageWidth * 0.2 : 0.8
+                    }
+                    break;
+                case 2:
+                case 5:
+                    {
+                        scale1 = x > 0 ? 1 - (pageWidth - x+pageWidth) / pageWidth * 0.2 : 0.8
+                        scale2 = x < 0 ? 1 - (pageWidth + x+pageWidth) / pageWidth * 0.2 : 0.8
+                        scale0 = 1 - (Math.abs(x)-pageWidth) / pageWidth * 0.2
+                    }
+                    break;
+            }
+        }
+        else if (x >= -pageWidth*3 && x <= pageWidth*3) {
+            switch (scrollPage) {
+                case 0:
+                case 3:
+                    {
+                        scale2 = 1 - (Math.abs(x)-pageWidth*2) / pageWidth * 0.2
+                        scale0 = x > 0 ? 1 - (pageWidth - x+pageWidth*2) / pageWidth * 0.2 : 0.8
+                        scale1 = x < 0 ? 1 - (pageWidth + x+pageWidth*2) / pageWidth * 0.2 : 0.8
+                    }
+                    break;
+                case 1:
+                case 4:
+                    {
+                        scale2 = x < 0 ? 1 - (pageWidth + x+pageWidth*2) / pageWidth * 0.2 : 0.8
+                        scale0 = 1 - (Math.abs(x)-pageWidth*2) / pageWidth * 0.2
+                        scale1 = x > 0 ? 1 - (pageWidth - x+pageWidth*2) / pageWidth * 0.2 : 0.8
+                    }
+                    break;
+                case 2:
+                case 5:
+                    {
+                        scale2 = x > 0 ? 1 - (pageWidth - x+pageWidth*2) / pageWidth * 0.2 : 0.8
+                        scale0 = x < 0 ? 1 - (pageWidth + x+pageWidth*2) / pageWidth * 0.2 : 0.8
+                        scale1 = 1 - (Math.abs(x)-pageWidth*2) / pageWidth * 0.2
+                    }
+                    break;
+            }
+        }
+
+        setScale0(scale0)
+        setScale1(scale1)
+        setScale2(scale2)
+
+    }
+
+    function onTransitionend(){
+        scrollPage = current
+    }
+
     return <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center' }}>
         <Text className="today">Today</Text>
         <Text className="main_date">{global.language == 'en' ? dayjs().format('dddd, MMM D') : dayjs().format('MMMD日, dddd')}</Text>
@@ -58,41 +164,40 @@ export default function MainSwiper(props: { count: number, pageChanged: Function
             <View className="tab_item" style={{ backgroundColor: current != 2 ? '#B2B2B2' : isSleep() ? MainColorType.sleep : MainColorType.active }} onClick={() => tapScroll(2)}></View>
         </View> */}
         <Swiper
-
+            onTransition={onTransition}
+            onAnimationFinish={onTransitionend}
             style={{ height: 140, width: rpxToPx(750) }} circular
             previousMargin={rpxToPx(250)}
             nextMargin={rpxToPx(250)}
             onChange={pageChanged}
             current={current}>
             <SwiperItem>
-                <View className="aaaa">
-                <MainDayNightCard count={props.count} typeChanged={typeChanged} id={1} onClick={() => {
+                <MainDayNightCard scale={current==0?1:0.8} count={props.count} typeChanged={typeChanged} id={1} onClick={() => {
                     setCurrent(0)
                 }} />
-                </View>
             </SwiperItem>
             <SwiperItem>
-                <MainFastEatCard count={props.count} typeChanged={typeChanged} id={2} onClick={() => {
+                <MainFastEatCard scale={current==1?1:0.8} count={props.count} typeChanged={typeChanged} id={2} onClick={() => {
                     setCurrent(1)
                 }} />
             </SwiperItem>
             <SwiperItem>
-                <MainSleepActiveCard count={props.count} typeChanged={typeChanged} id={3} onClick={() => {
+                <MainSleepActiveCard scale={current==2?1:0.8} count={props.count} typeChanged={typeChanged} id={3} onClick={() => {
                     setCurrent(2)
                 }} />
             </SwiperItem>
             <SwiperItem>
-                <MainDayNightCard count={props.count} typeChanged={typeChanged} id={7} onClick={() => {
+                <MainDayNightCard scale={current==3?1:0.8} count={props.count} typeChanged={typeChanged} id={7} onClick={() => {
                     setCurrent(3)
                 }} />
             </SwiperItem>
             <SwiperItem>
-                <MainFastEatCard count={props.count} typeChanged={typeChanged} id={8} onClick={() => {
+                <MainFastEatCard scale={current==4?1:0.8} count={props.count} typeChanged={typeChanged} id={8} onClick={() => {
                     setCurrent(4)
                 }} />
             </SwiperItem>
             <SwiperItem>
-                <MainSleepActiveCard count={props.count} typeChanged={typeChanged} id={9} onClick={() => {
+                <MainSleepActiveCard scale={current==5?1:0.8} count={props.count} typeChanged={typeChanged} id={9} onClick={() => {
                     setCurrent(5)
                 }} />
             </SwiperItem>

+ 117 - 230
src/features/trackTimeDuration/components/Rings.weapp.tsx

@@ -4,6 +4,7 @@ import Taro from "@tarojs/taro";
 import { useDidShow, useReady } from "@tarojs/taro";
 import { useEffect, useRef, useState } from "react";
 import { useSelector } from "react-redux";
+import '../../../app.scss'
 
 export type RingCommon = {
     useCase: string;
@@ -17,9 +18,9 @@ export type CurrentDot = {
     color: string;
     lineWidth: number;
     borderColor: string;
-    timestamp?:number;
-    offset?:number;
-    whiteIcon?:boolean;
+    timestamp?: number;
+    offset?: number;
+    whiteIcon?: boolean;
 }
 
 export type RealRing = {
@@ -28,7 +29,7 @@ export type RealRing = {
     durationArc: number;
     radius?: number;
     lineWidth?: number;
-    hideBg?:boolean;
+    hideBg?: boolean;
 }
 
 export type TargetRing = {
@@ -50,22 +51,24 @@ export type BgRing = {
 }
 
 let arrowImg;
+let startTime;
 
 export default function Rings(props: {
-    common: RingCommon; 
+    common: RingCommon;
     currentDot?: CurrentDot;
-    realRing?: RealRing; 
-    targetRing?: TargetRing; 
-    scheduleRing?:ScheduleRing;
-    breathAnimation?:boolean;
-    bgRing: BgRing; 
+    realRing?: RealRing;
+    targetRing?: TargetRing;
+    scheduleRing?: ScheduleRing;
+    breathAnimation?: boolean;
+    bgRing: BgRing;
     canvasId?: string;
-    ctx?:any;
-    setCtx?:any;
-    canvas?:any;
-    setCanvas?:any;
-    dotList?:Array<CurrentDot>;
-    stageList?:Array<RealRing>;
+    ctx?: any;
+    setCtx?: any;
+    canvas?: any;
+    setCanvas?: any;
+    dotList?: Array<CurrentDot>;
+    stageList?: Array<RealRing>;
+    scale?: number;
 }) {
     const r = props.common.radius
     const strokeWidth = props.common.lineWidth;
@@ -78,71 +81,61 @@ export default function Rings(props: {
     const time = useSelector((state: any) => state.time);
     const user = useSelector((state: any) => state.user);
 
-    useEffect(()=>{
+    const [scale, setScale] = useState(props.scale ?? 1.0)
+
+    const animationDuration = 150; // 动画时长(毫秒
+    const animateScale = (newScale) => {
+        // const startTime = performance.now();
+        const animate = () => {
+            const elapsed = new Date().getTime() - startTime.getTime();
+            const progress = Math.min(elapsed / animationDuration, 1);
+            const currentScale = scale + (newScale - scale) * progress;
+
+            setScale(currentScale);
+
+            if (progress < 1) {
+                requestAnimationFrame(animate);
+            } else {
+                setScale(newScale);
+            }
+        };
+        requestAnimationFrame(animate);
+    };
+
+    useEffect(() => {
         // drawCircle()
-    },[])
+        if (props.scale && props.scale != scale) {
+            // setScale(props.scale ?? 1.0)
+            startTime = new Date()
+            animateScale(props.scale)
+        }
+    }, [props.scale])
 
     useReady(() => {
         drawCircle()
     })
     useEffect(() => {
-        
-        if (props.ctx){
+
+        if (props.ctx) {
             drawContent(props.ctx)
         }
         else {
 
             drawCircle()
         }
-        
-    }, [time.status,time.scenario,user.isLogin,props.targetRing, props.currentDot,props.realRing,props.currentDot?.color,props.canvasId]);
-    
-
-    useEffect(()=>{
-        // if (props.breathAnimation){
-        //     animation()
-        // }
-        // else {
-        //     global.breathAlpha = 1
-        //     animation()
-        // }
-    },[props.breathAnimation])
-
-    function animation(){
-        const duration = 1000; // 动画执行时间(毫秒)
-        let animationId: number | null = null;
-        let startTime: number | null = null;
-        const animate = (timestamp: number) => {
-            if (!startTime) {
-              startTime = timestamp;
-            }
-      
-            const elapsed = timestamp - startTime;
-            const progress = elapsed / duration; // 动画进度(0 到 1)
-            global.breathAlpha = progress
-
-            if (elapsed < duration) {
-                animationId = requestAnimationFrame(animate);
-              } else {
-                // 动画完成后重新开始
-                startTime = null;
-                animationId = requestAnimationFrame(animate);
-              }
-        }
-        animationId = requestAnimationFrame(animate);
-    }
 
-    
+    }, [time.status, time.scenario, user.isLogin, props.targetRing, props.currentDot, props.realRing, props.currentDot?.color, props.canvasId]);
+
 
     var retryCount = 0;
     function drawCircle() {
-        
+
         const query = Taro.createSelectorQuery();
-        query.select(`.${canvasId}`).fields({ node: true, size: true });
+        query.select(`#${canvasId}`).fields({ node: true, size: true });
         query.exec((res) => {
             if (res[0] == null) {
                 retryCount++;
-                if (retryCount>5){
+                if (retryCount > 5) {
                     return;
                 }
                 drawCircle()
@@ -155,7 +148,7 @@ export default function Rings(props: {
             const ctx = _canvas.getContext('2d');
             global.canvas2 = _canvas
 
-            if (props.setCtx){
+            if (props.setCtx) {
                 props.setCtx(ctx)
                 props.setCanvas(_canvas)
                 drawContent(ctx)
@@ -170,25 +163,24 @@ export default function Rings(props: {
         });
     }
 
-    function calculateCoordinates(x, y, r, angle) {
-        const radians = angle * Math.PI / 180; // 将角度转换为弧度
-        const xPrime = x + r * Math.cos(radians);
-        const yPrime = y + r * Math.sin(radians);
-        return { x: xPrime, y: yPrime };
-      }
-      
-
-    function drawContent(ctx){
-        if (props.canvas){
+    function drawContent(ctx) {
+        if (props.canvas) {
             props.canvas.width = ((radius * 2 + lineWidth)) * dpr;
             props.canvas.height = ((radius * 2 + lineWidth)) * dpr;
         }
-        
+
         const center = radius + lineWidth / 2; // 圆心坐标
         ctx.clearRect(0, 0, radius * 2, radius * 2); // 清除画布
 
+
         // 设置画布尺寸
-        ctx.scale(dpr, dpr);
+        ctx.scale(dpr, dpr)
+
+        ctx.translate(center, center)
+        ctx.scale(scale, scale);
+        ctx.translate(-center, -center);
+
+
 
         // 绘制背景圆
         ctx.beginPath();
@@ -199,11 +191,11 @@ export default function Rings(props: {
         ctx.stroke();
 
         // 绘制schedule进度环
-        if (props.scheduleRing){
+        if (props.scheduleRing) {
             ctx.beginPath();
             ctx.arc(center, center, radius, props.scheduleRing!.startArc,
                 props.scheduleRing!.startArc + props.scheduleRing!.durationArc);
-            ctx.lineWidth = lineWidth+4;
+            ctx.lineWidth = lineWidth + 4;
             ctx.strokeStyle = MainColorType.bg;
             ctx.lineCap = 'round'; // 设置为圆角
             ctx.stroke();
@@ -221,17 +213,17 @@ export default function Rings(props: {
         // 绘制target进度环
         if (props.targetRing) {
             ctx.beginPath();
-            ctx.arc(center, center, props.targetRing!.radius?props.targetRing!.radius:radius, props.targetRing!.startArc,
+            ctx.arc(center, center, props.targetRing!.radius ? props.targetRing!.radius : radius, props.targetRing!.startArc,
                 props.targetRing!.startArc + props.targetRing!.durationArc);
-            ctx.lineWidth = props.targetRing!.lineWidth?props.targetRing!.lineWidth+4:lineWidth+4;
+            ctx.lineWidth = props.targetRing!.lineWidth ? props.targetRing!.lineWidth + 4 : lineWidth + 4;
             ctx.strokeStyle = MainColorType.bg;
             ctx.lineCap = 'round'; // 设置为圆角
             ctx.stroke();
-            
+
             ctx.beginPath();
-            ctx.arc(center, center, props.targetRing!.radius?props.targetRing!.radius:radius, props.targetRing!.startArc,
+            ctx.arc(center, center, props.targetRing!.radius ? props.targetRing!.radius : radius, props.targetRing!.startArc,
                 props.targetRing!.startArc + props.targetRing!.durationArc);
-            ctx.lineWidth = props.targetRing!.lineWidth?props.targetRing!.lineWidth:lineWidth;
+            ctx.lineWidth = props.targetRing!.lineWidth ? props.targetRing!.lineWidth : lineWidth;
             ctx.strokeStyle = props.targetRing!.color;
             ctx.lineCap = 'round'; // 设置为圆角
             ctx.stroke();
@@ -239,49 +231,49 @@ export default function Rings(props: {
 
         //绘制real进度环
         if (props.realRing) {
-            if (props.realRing.durationArc <0.01) props.realRing.durationArc=0.01;
-            if (!props.realRing.hideBg){
+            if (props.realRing.durationArc < 0.01) props.realRing.durationArc = 0.01;
+            if (!props.realRing.hideBg) {
                 ctx.beginPath();
-                ctx.arc(center, center, props.realRing!.radius?props.realRing!.radius:radius, props.realRing!.startArc,
+                ctx.arc(center, center, props.realRing!.radius ? props.realRing!.radius : radius, props.realRing!.startArc,
                     props.realRing!.startArc + props.realRing!.durationArc);
-                ctx.lineWidth = props.realRing!.lineWidth?props.realRing!.lineWidth+4:lineWidth+4;
+                ctx.lineWidth = props.realRing!.lineWidth ? props.realRing!.lineWidth + 4 : lineWidth + 4;
                 ctx.strokeStyle = MainColorType.bg;
                 ctx.lineCap = 'round'; // 设置为圆角
                 ctx.stroke();
             }
-            
+
 
             ctx.beginPath();
-            ctx.arc(center, center, props.realRing!.radius?props.realRing!.radius:radius, props.realRing!.startArc,
+            ctx.arc(center, center, props.realRing!.radius ? props.realRing!.radius : radius, props.realRing!.startArc,
                 props.realRing!.startArc + props.realRing!.durationArc);
-            ctx.lineWidth = props.realRing!.lineWidth?props.realRing!.lineWidth:lineWidth;
+            ctx.lineWidth = props.realRing!.lineWidth ? props.realRing!.lineWidth : lineWidth;
             ctx.strokeStyle = props.realRing!.color;
             ctx.lineCap = 'round'; // 设置为圆角
             ctx.stroke();
         }
 
-        if (props.stageList){
-            props.stageList.map(item=>{
-                if (item.durationArc <0.01) item.durationArc=0.01;
-            ctx.beginPath();
-            ctx.arc(center, center, radius, item.startArc,
-                item.startArc + item.durationArc);
-            ctx.lineWidth = lineWidth;
-            ctx.strokeStyle = item.color;
-            ctx.lineCap = 'round'; // 设置为圆角
-            ctx.stroke();
+        if (props.stageList) {
+            props.stageList.map(item => {
+                if (item.durationArc < 0.01) item.durationArc = 0.01;
+                ctx.beginPath();
+                ctx.arc(center, center, radius, item.startArc,
+                    item.startArc + item.durationArc);
+                ctx.lineWidth = lineWidth;
+                ctx.strokeStyle = item.color;
+                ctx.lineCap = 'round'; // 设置为圆角
+                ctx.stroke();
             })
         }
         //绘制current_dot点
         if (props.currentDot) {
             var time = new Date();
             var seconds = time.getHours() * 3600 + time.getMinutes() * 60 + time.getSeconds();
-            seconds += props.currentDot.offset!*60
-            if (seconds>24*3600){
-                seconds -= 24*3600
-            } 
-            else if (seconds<0){
-                seconds += 24*3600
+            seconds += props.currentDot.offset! * 60
+            if (seconds > 24 * 3600) {
+                seconds -= 24 * 3600
+            }
+            else if (seconds < 0) {
+                seconds += 24 * 3600
             }
             var arc = seconds / 86400 * 2 * Math.PI - Math.PI / 2.0;
             const radians = arc;//angle * Math.PI / 180; // 将角度转换为弧度
@@ -290,25 +282,25 @@ export default function Rings(props: {
 
             ctx.beginPath();
             var dotLineWidth = 2
-            if (lineWidth==28){
+            if (lineWidth == 28) {
                 dotLineWidth = 4
-                
+
             }
-            ctx.arc(xPrime, yPrime, lineWidth/2.0+dotLineWidth/2, 0, 2 * Math.PI);
+            ctx.arc(xPrime, yPrime, lineWidth / 2.0 + dotLineWidth / 2, 0, 2 * Math.PI);
             ctx.lineWidth = dotLineWidth;
             ctx.strokeStyle = props.currentDot.borderColor//'#1C1C1C';
             ctx.lineCap = 'round'; // 设置为圆角
             ctx.stroke();
 
-            if (props.currentDot.color!='#ffffffff'){
+            if (props.currentDot.color != '#ffffffff') {
                 ctx.beginPath();
                 ctx.arc(xPrime, yPrime, lineWidth / 2, 0, 2 * Math.PI, false);
                 ctx.fillStyle = props.currentDot.color;
                 ctx.fill();
             }
 
-            
-    
+
+
             if (arrowImg) {
                 //绘制终点图标
                 ctx.save()
@@ -316,13 +308,13 @@ export default function Rings(props: {
                 ctx.translate(xPrime, yPrime)
                 ctx.rotate(arc)
                 ctx.translate(-xPrime, -yPrime)
-                ctx.drawImage(arrowImg, xPrime - lineWidth/2, yPrime - lineWidth/2, lineWidth, lineWidth)
+                ctx.drawImage(arrowImg, xPrime - lineWidth / 2, yPrime - lineWidth / 2, lineWidth, lineWidth)
                 ctx.restore()
                 ctx.closePath()
             }
             else {
                 let tempImage = global.canvas2.createImage()
-                tempImage.src = require(props.currentDot.whiteIcon?'@/assets/images/dot_arrow_white.png':'@/assets/images/dot_arrow.png')//'./watch_line.png'//'..//assets/images/watch_line.png'
+                tempImage.src = require(props.currentDot.whiteIcon ? '@/assets/images/dot_arrow_white.png' : '@/assets/images/dot_arrow.png')//'./watch_line.png'//'..//assets/images/watch_line.png'
                 tempImage.onload = () => {
                     arrowImg = tempImage
                     ctx.save()
@@ -330,16 +322,16 @@ export default function Rings(props: {
                     ctx.translate(xPrime, yPrime)
                     ctx.rotate(arc)
                     ctx.translate(-xPrime, -yPrime)
-                    ctx.drawImage(arrowImg, xPrime - lineWidth/2, yPrime - lineWidth/2, lineWidth, lineWidth)
+                    ctx.drawImage(arrowImg, xPrime - lineWidth / 2, yPrime - lineWidth / 2, lineWidth, lineWidth)
                     ctx.restore()
                     ctx.closePath()
                 }
             }
-    
-            
 
-            
-        
+
+
+
+
             // ctx.beginPath();
             // ctx.arc(center, center, radius, arc,
             //     arc + 0.001);
@@ -347,7 +339,7 @@ export default function Rings(props: {
             // ctx.strokeStyle = props.currentDot!.borderColor;
             // ctx.lineCap = 'round'; // 设置为圆角
             // ctx.stroke();
-            
+
             // ctx.save()
             // ctx.beginPath();
             // ctx.arc(center, center, radius, arc,
@@ -360,19 +352,19 @@ export default function Rings(props: {
         }
 
 
-        if (props.dotList){
-            props.dotList.map(item=>{
-                var time = item.timestamp?new Date(item.timestamp):new Date();
+        if (props.dotList) {
+            props.dotList.map(item => {
+                var time = item.timestamp ? new Date(item.timestamp) : new Date();
                 var seconds = time.getHours() * 3600 + time.getMinutes() * 60 + time.getSeconds();
                 var arc = seconds / 86400 * 2 * Math.PI - Math.PI / 2.0;
                 ctx.beginPath();
                 ctx.arc(center, center, radius, arc,
                     arc + 0.001);
-                ctx.lineWidth = lineWidth+6;
+                ctx.lineWidth = lineWidth + 6;
                 ctx.strokeStyle = item.borderColor;
                 ctx.lineCap = 'round'; // 设置为圆角
                 ctx.stroke();
-                
+
                 ctx.save()
                 ctx.beginPath();
                 ctx.arc(center, center, radius, arc,
@@ -387,111 +379,6 @@ export default function Rings(props: {
         }
     }
 
-    return <Canvas canvasId={canvasId}  id={canvasId} className={canvasId} type="2d" style={{ width: (radius * 2 + lineWidth), height: (radius * 2 + lineWidth), zIndex: 0 }} ref={canvasRef} />
-
-}
+    return <Canvas canvasId={canvasId} id={canvasId} className="canvas" type="2d" style={{ width: (radius * 2 + lineWidth), height: (radius * 2 + lineWidth), zIndex: 0 }} ref={canvasRef} />
 
-// export default function Rings(props: {
-//     common: RingCommon; currentDot?: CurrentDot;
-//     realRing?: RealRing; targetRing?: TargetRing; bgRing: BgRing; canvasId?: string;test?:boolean
-// }) {
-//     const r = props.common.radius
-//     const strokeWidth = props.common.lineWidth;
-//     // const color = props.color || 'orange'
-//     const canvasRef = useRef(null);
-//     const canvasId = props.canvasId ? 'canvas_' + props.canvasId : 'progress-canvas';
-//     const dpr = Taro.getSystemInfoSync().pixelRatio; // 获取设备的像素比
-//     const radius = r; // 圆形进度条的半径
-//     const lineWidth = strokeWidth; // 圆形进度条的线宽
-
-//     useDidShow(() => {
-//         // drawCircle()
-//     })
-
-//     useReady(() => {
-//         drawCircle()
-
-//     })
-
-//     function drawCircle() {
-//         const query = Taro.createSelectorQuery();
-//         query.select(`.${canvasId}`).fields({ node: true, size: true });
-//         query.exec((res) => {
-//             if (res[0] == null) return;
-//             const _canvas = res[0].node;
-//             _canvas.width = res[0].width * dpr;
-//             _canvas.height = res[0].height * dpr;
-//             const ctx = _canvas.getContext('2d');
-//             // const ctx = Taro.createCanvasContext(canvasId);
-
-
-//             const center = radius + lineWidth / 2; // 圆心坐标
-//             ctx.clearRect(0, 0, radius * 2, radius * 2); // 清除画布
-
-//             // 设置画布尺寸
-//             ctx.scale(dpr, dpr);
-
-//             // 绘制背景圆
-//             ctx.beginPath();
-//             ctx.arc(center, center, radius, 0, 2 * Math.PI);
-//             ctx.lineWidth = lineWidth;
-//             ctx.strokeStyle = props.bgRing.color;
-//             ctx.lineCap = 'round'; // 设置为圆角
-//             ctx.stroke();
-
-//             // 绘制target进度环
-//             if (props.common.useCase == 'ChooseScenario' || (props.common.useCase == 'Clock' && props.targetRing)) {
-//                 ctx.beginPath();
-//                 ctx.arc(center, center, radius, props.targetRing!.startArc,
-//                     props.targetRing!.startArc + props.targetRing!.durationArc);
-//                 ctx.lineWidth = lineWidth;
-//                 ctx.strokeStyle = props.targetRing!.color;
-//                 ctx.lineCap = 'round'; // 设置为圆角
-//                 ctx.stroke();
-//             }
-
-//             //绘制real进度环
-//             if (props.common.status != 'WAIT_FOR_START' && props.realRing) {
-                
-//                 ctx.beginPath();
-//                 ctx.arc(center, center, radius, props.realRing!.startArc,
-//                     props.realRing!.startArc + props.realRing!.durationArc);
-//                 ctx.lineWidth = lineWidth;
-//                 ctx.strokeStyle = props.realRing!.color;
-//                 ctx.lineCap = 'round'; // 设置为圆角
-//                 ctx.stroke();
-//             }
-
-//             //绘制current_dot点
-//             if (props.common.useCase == 'Clock') {
-//                 var time = new Date();
-//                 var seconds = time.getHours() * 3600 + time.getMinutes() * 60 + time.getSeconds();
-//                 var arc = seconds / 86400 * 2 * Math.PI - Math.PI / 2.0;
-//                 ctx.beginPath();
-//                 ctx.arc(center, center, radius, arc,
-//                     arc + 0.001);
-//                 ctx.lineWidth = lineWidth;
-//                 ctx.strokeStyle = props.currentDot!.borderColor;
-//                 ctx.lineCap = 'round'; // 设置为圆角
-//                 ctx.stroke();
-
-//                 ctx.beginPath();
-//                 ctx.arc(center, center, radius, arc,
-//                     arc + 0.001);
-//                 ctx.lineWidth = lineWidth - 2;
-//                 ctx.strokeStyle = props.currentDot!.color;
-//                 ctx.lineCap = 'round'; // 设置为圆角
-//                 ctx.stroke();
-//             }
-
-
-//             // ctx.draw();
-//         });
-//     }
-
-//     useEffect(() => {
-//         drawCircle()
-//     }, [props.targetRing, props.currentDot]);
-//     return <Canvas canvasId={canvasId} id={canvasId} className={canvasId} type="2d" style={{ width: (radius * 2 + lineWidth), height: (radius * 2 + lineWidth), zIndex: 0 }} ref={canvasRef} />
-
-// }
+}