Leon há 2 anos atrás
pai
commit
2233412024

+ 0 - 1
src/components/input/Slider.tsx

@@ -29,7 +29,6 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
     };
 
     const handleTouchMove = (event) => {
-        console.log('aaaa', isSliding)
         if (isSliding) {
             const { touches } = event;
             const touchX = touches[0].clientX;

+ 13 - 0
src/components/navigation/TabBar.scss

@@ -23,16 +23,29 @@
 .tabbar-item{
     color: rgba($color: #ffffff, $alpha: 0.4);
     font-size: 36px;
+    line-height: 36px;
     // padding-top: 25px;
     display: flex;
     flex: 1;
     align-items: center;
     justify-content: center;
     font-weight: bold;
+    position: relative;
 }
 
 .tabbar-item-sel{
     color: #ffffff;
     font-size: 40px;
+    line-height: 40px;
     font-weight: bold;
+    position: relative;
+}
+
+.food-tab-badge{
+    position: absolute;
+    width: 20px;
+    height: 20px;
+    border-radius: 10px;
+    right:-10px;
+    top:-10px;
 }

+ 13 - 4
src/components/navigation/TabBar.tsx

@@ -1,9 +1,12 @@
-import { View,Text } from '@tarojs/components'
+import { View, Text } from '@tarojs/components'
 import './Tabbar.scss'
 import Taro from '@tarojs/taro';
 import { useState } from 'react';
+import { useSelector } from 'react-redux';
+import { ColorType } from '@/context/themes/color';
 
-export default function Component(props:{index:number}) {
+export default function Component(props: { index: number }) {
+    const common = useSelector((state: any) => state.common);
     const [selIndex] = useState(props.index)
     function switchTab(index: number) {
         switch (index) {
@@ -42,12 +45,18 @@ export default function Component(props:{index:number}) {
             <Text>生物钟</Text>
         </View>
         <View className={selIndex == 4 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(4)}>
-            <Text>饮食</Text>
+            <View style={{ position: 'relative' }}>
+                <Text>饮食</Text>
+                {
+                    common.showFoodTabBadge && <View className='food-tab-badge' style={{ backgroundColor: ColorType.food }} />
+                }
+            </View>
+
         </View>
         <View className={selIndex == 1 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(1)}>
             <Text>指标</Text>
         </View>
-        
+
         <View className={selIndex == 2 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(2)}>
             <Text>运动</Text>
         </View>

+ 5 - 0
src/features/food/FoodConsole.scss

@@ -124,4 +124,9 @@
     background-color: #fff;
     opacity: 0.2;
     z-index: -1;
+}
+
+.myswitch{
+    width: 100px !important;
+    height: 50px !important;
 }

+ 3 - 2
src/features/food/FoodConsole.tsx

@@ -262,11 +262,12 @@ export default function Component(props: { addItem: Function, firstItem: any })
         <View className='food_console_box'>
             <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
                 <Text className='food_console_title'>感知模式</Text>
-                <Switch disabled={lastUnFinished} checked={modeOn} color={ColorType.food} style={{ marginRight: rpxToPx(40), opacity: lastUnFinished ? 0.4 : 1 }} onChange={modeChange} />
+                <Switch className='myswitch' disabled={lastUnFinished} checked={modeOn} color={ColorType.food} style={{ marginRight: rpxToPx(40), opacity: lastUnFinished ? 0.4 : 1 }} onChange={modeChange} />
             </View>
             {
                 modeOn && <View className='food_console_desc'>
-                    <View className='food_console_desc_point' style={{ backgroundColor: ColorType.food,marginTop:rpxToPx(46+18) }} />
+                    <View className='food_console_desc_point' 
+                    style={{ backgroundColor: ColorType.food,marginTop:props.firstItem && props.firstItem.status=='WAIT_FOR_POSTMEAL'?rpxToPx(46+18):rpxToPx(18) }} />
                     {/* <View className='food_console_desc_point' style={{ backgroundColor: ColorType.food }} /> */}
                     <Text>{t('feature.food.sence_desc')}</Text>
                 </View>

+ 1 - 0
src/features/food/FoodTimelineItem.scss

@@ -65,6 +65,7 @@
 .thumb {
     width: 304px;
     height: 304px;
+    border-radius: 36px;
 }
 
 .food_desc {

+ 7 - 5
src/features/food/FoodTimelineItem.tsx

@@ -233,11 +233,13 @@ export default function Component(props: {
             }
         }
         editFoodJournal(params, detail.id).then(res => {
+            
             if (isPreMeal) {
                 (res as any).showDate = props.data.showDate
                 setDetail(res)
                 setCount(count + 1)
-                props.refresh()
+                // props.refresh()
+                props.forceRefresh()
             }
             else {
                 props.forceRefresh()
@@ -386,14 +388,14 @@ export default function Component(props: {
 
     return <View style={{ position: 'relative' }}>
         {
-            detail.mindful_mode == 'AWARE' && detail.status != 'ABANDONED' && detail.feel.pre_meal && !detail.feel.post_meal &&
+            detail.mindful_mode == 'AWARE' && detail.status == 'WAIT_FOR_POSTMEAL' &&
             <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginBottom: rpxToPx(60), position: 'relative' }}>
                 <Slider onChanged={(value) => { updateFeel(value, false) }} value={detail.feel.pre_meal} isPreMeal={false} />
                 <Image src={require('@assets/images/more-vertical.png')} className="food_timeline_more" onClick={more} />
             </View>
         }
         {
-            detail.mindful_mode == 'AWARE' && detail.feel.post_meal &&
+            detail.mindful_mode == 'AWARE' && detail.status=='COMPLETED' &&
             <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
                 <View style={{ width: rpxToPx(375) }} />
                 <View className="food_item_point" style={{ backgroundColor: ColorType.food }} />
@@ -440,13 +442,13 @@ export default function Component(props: {
 
         </View>
         {
-            detail.mindful_mode == 'AWARE' && !detail.feel.pre_meal &&
+            detail.mindful_mode == 'AWARE' && detail.status=='WAIT_FOR_PREMEAL' &&
             <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginBottom: rpxToPx(60) }}>
                 <Slider onChanged={(value) => { updateFeel(value, true) }} isPreMeal={true} />
             </View>
         }
         {
-            detail.mindful_mode == 'AWARE' && detail.feel.pre_meal &&
+            detail.mindful_mode == 'AWARE' && detail.status=='WAIT_FOR_POSTMEAL' &&
             <View style={{
                 display: 'flex', flexDirection: 'row', alignItems: 'center',
                 marginBottom: rpxToPx(60), marginTop: -rpxToPx(60)

+ 16 - 1
src/features/trackTimeDuration/components/Console.tsx

@@ -18,6 +18,7 @@ import { updateScenario } from "@/store/time";
 import { useTranslation } from "react-i18next";
 import { ColorType } from "@/context/themes/color";
 import { jumpPage } from "../hooks/Common";
+import { setFoodTabBadge } from "@/store/common";
 
 let useNavigation;
 if (process.env.TARO_ENV == 'rn') {
@@ -222,6 +223,16 @@ export default function Component(props: { isNextStep?: boolean }) {
         </View>
     }
 
+    function showFoodGuide(){
+        dispatch(setFoodTabBadge(true))
+        Taro.showModal({
+            title:'断食已结束',
+            content:'推荐使用『饮食日记』感知模式,记录你的餐前饥饿感',
+            showCancel:false,
+            confirmText:'我知道了'
+        })
+    }
+
     function pickerConfirm(t: number) {
         var date = new Date(t)
         var setDate = new Date(global.set_time);
@@ -231,7 +242,9 @@ export default function Component(props: { isNextStep?: boolean }) {
         t = date.getTime();
 
         if (props.isNextStep) {
-            endFast(t)
+            endFast(t).then(res => {
+                showFoodGuide()
+            })
             return;
         }
 
@@ -249,12 +262,14 @@ export default function Component(props: { isNextStep?: boolean }) {
                     }
                     dispatch(updateScenario((res as any).current_record));
                     global.postBtnUpdateStatus('idle');
+                    dispatch(setFoodTabBadge(false))
                 });
             }
             else {
                 endFast(t).then(res => {
                     dispatch(updateScenario((res as any).current_record));
                     global.postBtnUpdateStatus('idle');
+                    showFoodGuide()
                 })
             }
         }

+ 0 - 559
src/features/trackTimeDuration/components/Console_backup.tsx

@@ -1,559 +0,0 @@
-
-import { View, Text, PickerView } from "@tarojs/components";
-import { useEffect, useRef, useState } from "react";
-import { TimeFormatter } from "@/utils/time_format";
-import { useDispatch, useSelector } from "react-redux";
-import Taro from "@tarojs/taro";
-import LimitPickers from '@/components/input/LimitPickers';
-import { endFast, endSleep, startFast, startSleep } from "../actions/TrackTimeActions";
-import { durationDatas, durationIndex, getColor, getDurationTitle, getTimePickerTitle, getTitle, textAlpha, textNextStepAlpha } from "../hooks/Console";
-import PickerViews from "@/components/input/PickerViews";
-import Modal from "@/components/layout/Modal";
-import Stepper from "@/components/input/Stepper";
-import { EndFastBtn, EndSleepBtn, StartFastBtn, StartSleepBtn } from "@/features/common/SpecBtns";
-import Box from "@/components/layout/Box";
-import './Console.scss'
-import { ConsoleType, changeConsoleStatus } from "@/store/console";
-import { updateScenario } from "@/store/time";
-import { useTranslation } from "react-i18next";
-import { ColorType } from "@/context/themes/color";
-import { jumpPage } from "../hooks/Common";
-
-let useNavigation;
-if (process.env.TARO_ENV=='rn'){
-    useNavigation = require("@react-navigation/native").useNavigation
-}
-
-export default function Component(props: { isNextStep?: boolean }) {
-    const scenario = useSelector((state: any) => state.scenario);
-    const time = useSelector((state: any) => state.time);
-    const user = useSelector((state: any) => state.user);
-    const common = useSelector((state: any) => state.common);
-    const [isFast, setIsFast] = useState(true);
-    const [fastDuration, setFastDuration] = useState<number>(0);
-    const [sleepDuration, setSleepDuration] = useState<number>(0);
-
-    const [fastPickerValue, setFastPickerValue] = useState([0, 0])
-    const [sleepPickerValue, setSleepPickerValue] = useState([0, 0])
-    const limitPickerRef = useRef(null)
-    const durationPickerRef = useRef(null)
-    const { t } = useTranslation()
-    const dispatch = useDispatch();
-
-    let navigation;
-    if (useNavigation){
-        navigation = useNavigation()
-    }
-
-    useEffect(() => {
-        getStateDetail();
-    }, [time.fast, time.sleep, time.status, time.scenario]);
-
-    function getStateDetail() {
-        if (time.fast) {
-            var fastCount = time.fast.target_end_time - time.fast.target_start_time
-            setFastDuration(fastCount)
-            setFastPickerValue(durationIndex(time.fast.target_start_time, time.fast.target_end_time, common))
-        }
-
-        if (time.sleep) {
-            var sleepCount = time.sleep.target_end_time - time.sleep.target_start_time
-            setSleepDuration(sleepCount)
-            setSleepPickerValue(durationIndex(time.sleep.target_start_time, time.sleep.target_end_time, common))
-        }
-
-        if (time.scenario == 'FAST') {
-            setIsFast(true)
-        }
-        else if (time.scenario == 'SLEEP') {
-            setIsFast(false)
-        }
-        else {
-            if (time.status == 'WAIT_FOR_START' || time.status == 'ONGOING3') {
-                setIsFast(true)
-            }
-            else {
-                setIsFast(false)
-            }
-        }
-    }
-
-
-    function showPicker() {
-        if (global.testInfotimer) {
-            return
-        }
-        global.set_time = new Date().getTime()
-        updateNodeInfo()
-        global.testInfotimer = setInterval(() => {
-            updateNodeInfo()
-
-        }, 1000)
-
-    }
-
-    function updateNodeInfo() {
-        var node = (<Modal testInfo={testLayout()} children={layoutContent()} dismiss={() => {
-            global.showClockModal(false, null);
-            hidePicker()
-        }} confirm={() => {
-            hidePicker()
-            var picker = limitPickerRef.current;
-            pickerConfirm((picker as any).getConfirmData());
-            global.showClockModal(false, null);
-        }} />);
-        global.showClockModal(true, node);
-    }
-
-    function hidePicker() {
-        global.showClockModal(false, null);
-        if (global.testInfotimer) {
-            clearInterval(global.testInfotimer)
-            global.testInfotimer = null
-        }
-        else {
-            console.log('global test info timer')
-        }
-    }
-
-    function testLayout() {
-        if (!user.test_user) {
-            return <View />
-        }
-        var isStart = false;
-        if (time.status == 'WAIT_FOR_START' || time.status == 'ONGOING1') {
-            isStart = true
-        }
-        var isFast = false;
-        switch (time.status) {
-            case 'WAIT_FOR_START':
-            case 'ONGOING':
-                {
-                    isFast = (scenario.name == 'FAST' || scenario.name == 'FAST_SLEEP')
-                }
-                break;
-            case 'ONGOING1':
-            case 'ONGOING2':
-                {
-                    isFast = false;
-                }
-                break
-            case 'ONGOING3':
-                {
-                    isFast = true;
-                }
-                break;
-
-
-        }
-
-        if (props.isNextStep) {
-            isFast = true
-            isStart = false
-        }
-
-        return <View style={{ color: '#fff', paddingTop: 30, paddingLeft: 30, display: 'flex', flexDirection: 'column' }}>
-            <Text>check scenario:{isFast ? 'fast' : 'sleep'}</Text>
-            <Text>check type:{isStart ? 'start' : 'end'}</Text>
-            <Text style={{ marginTop: 30 }}>picker restriction</Text>
-            <Text style={{ marginLeft: 50 }}>min:{TimeFormatter.formatTimestamp(global.limit)}</Text>
-            <Text style={{ marginLeft: 50 }}>pick:{TimeFormatter.formatTimestamp(global.picker_time)}</Text>
-            <Text style={{ marginLeft: 50 }}>max{TimeFormatter.formatTimestamp(global.set_time)}</Text>
-
-            <Text style={{ marginTop: 30 }}>now:{TimeFormatter.formatTimestamp(new Date().getTime())}</Text>
-            <Text>elapsed:{TimeFormatter.calculateTimeDifference(global.picker_time, new Date().getTime())}</Text>
-
-            <Text style={{ marginTop: 30 }}>real start:{isStart ? '-' : TimeFormatter.formatTimestamp(isFast ? time.fast.real_start_time : time.sleep.real_start_time)}</Text>
-            <Text>real duration:{isStart ? '-' : TimeFormatter.calculateTimeDifference(isFast ? time.fast.real_start_time : time.sleep.real_start_time, new Date().getTime())}</Text>
-        </View>
-    }
-
-
-    function layoutContent() {
-        var limit = global.set_time - 7 * 3600 * 1000 * 24;
-        global.limit = limit
-
-        if (time.last_real_check_time) {
-            limit = time.last_real_check_time
-            global.limit = limit
-            //当set_time秒数<=latest_record_time秒数时,最小限制时间戳需+1分钟
-            if (new Date(global.set_time).getSeconds() <= new Date(time.last_real_check_time).getSeconds()) {
-                limit = limit + 60 * 1000
-            }
-        }
-
-        var title = getTimePickerTitle(time, t)
-        var color = getColor(time)
-        if (props.isNextStep) {
-            title = t('feature.track_time_duration.console.fast_end')
-            color = global.fastColor?global.fastColor:ColorType.fast
-        }
-
-
-        return <LimitPickers ref={limitPickerRef} limit={limit} limitDay={8}
-            themeColor={color}
-            title={title}
-            onCancel={hidePicker} onChange={(e) => {
-                pickerConfirm(e)
-                hidePicker()
-            }} />
-    }
-
-    function pickerConfirm(t: number) {
-        var date = new Date(t)
-        var setDate = new Date(global.set_time);
-        date.setMilliseconds(setDate.getMilliseconds());
-        date.setSeconds(setDate.getSeconds());
-
-        t = date.getTime();
-
-        if (props.isNextStep) {
-            endFast(t)
-            return;
-        }
-
-        global.postBtnUpdateStatus('normal');
-
-        if (isFast) {
-            if (time.status == 'WAIT_FOR_START') {
-                startFast(t, fastDuration).then(res => {
-
-                    if ((res as any).current_record.scenario == 'FAST_SLEEP' &&
-                        (res as any).current_record.status == 'ONGOING1') {
-                        global.consoleType = 'going'
-                        global.showSingleFastEnd()
-                        dispatch(changeConsoleStatus({ status: ConsoleType.going }));
-                    }
-                    dispatch(updateScenario((res as any).current_record));
-                    global.postBtnUpdateStatus('idle');
-                });
-            }
-            else {
-                endFast(t).then(res => {
-                    dispatch(updateScenario((res as any).current_record));
-                    global.postBtnUpdateStatus('idle');
-                })
-            }
-        }
-        else {
-            if (time.status == 'WAIT_FOR_START' || time.status == 'ONGOING1') {
-                startSleep(t, sleepDuration).then(res => {
-                    dispatch(updateScenario((res as any).current_record));
-                    global.postBtnUpdateStatus('idle');
-                });
-            }
-            else {
-                endSleep(t).then(res => {
-                    dispatch(updateScenario((res as any).current_record));
-                    global.postBtnUpdateStatus('idle');
-                })
-            }
-        }
-    }
-
-    function targetView() {
-        if (props.isNextStep && (time.status == 'ONGOING1' || time.status == 'ONGOING2')) {
-            var opacity = textNextStepAlpha(time)
-            if (opacity == 1) {
-                return <View className="target_view" style={{ backgroundColor: '#FA51511A' }}>
-                    <Text className="target_text" style={{ color: '#FA5151' }}>超出目标结束</Text>
-                </View>
-            }
-            return <View className="target_view" style={{ backgroundColor: global.fastColor?global.fastColor:ColorType.fast + '1A', opacity: opacity }}>
-                <Text className="target_text" style={{ color: global.fastColor?global.fastColor:ColorType.fast }}>距离目标结束</Text>
-            </View>
-        }
-
-        if (time.status == 'ONGOING' || time.status == 'ONGOING2' || time.status == 'ONGOING3') {
-            var opacity = textAlpha(time)
-            if (opacity == 1) {
-                return <View className="target_view" style={{ backgroundColor: '#FA51511A' }}>
-                    <Text className="target_text" style={{ color: '#FA5151' }}>超出目标结束</Text>
-                </View>
-            }
-            return <View className="target_view" style={{ backgroundColor: isFast ? global.fastColor?global.fastColor:ColorType.fast + '1A' : global.sleepColor?global.sleepColor:ColorType.sleep + '1A', opacity: opacity }}>
-                <Text className="target_text" style={{ color: isFast ? global.fastColor?global.fastColor:ColorType.fast : global.sleepColor?global.sleepColor:ColorType.sleep }}>距离目标结束</Text>
-            </View>
-        }
-        return <View />
-    }
-
-    function mixedBtns() {
-        return <View className="btn_bg">
-            {
-                (time.status == 'WAIT_FOR_START' || time.status == 'DONE') &&
-                <StartFastBtn onClick={showPicker} />
-            }
-            {
-                (time.status == 'ONGOING' || time.status == 'ONGOING3') &&
-                <EndFastBtn onClick={showPicker} lowLight={time.fast.target_end_time > new Date().getTime()} />
-            }
-            {
-                time.status == 'ONGOING1' && <StartSleepBtn onClick={showPicker} />
-            }
-            {
-                time.status == 'ONGOING2' && <EndSleepBtn onClick={showPicker} lowLight={time.sleep.target_end_time > new Date().getTime()} />
-
-            }
-        </View>
-    }
-
-    function nextStepBtns() {
-        return <View className="btn_bg">
-            {
-                (time.status == 'WAIT_FOR_START') &&
-                <StartSleepBtn onClick={showPicker} />
-            }
-            {
-                time.status == 'ONGOING1' && <EndFastBtn onClick={showPicker} lowLight={time.fast.target_end_time > new Date().getTime()} />
-            }
-            {
-                time.status == 'ONGOING2' && <EndFastBtn onClick={showPicker} lowLight={time.fast.target_end_time > new Date().getTime()} />
-
-            }
-        </View>
-    }
-
-
-    function fastBtns() {
-        return <View className="btn_bg">
-            {
-                time.status == 'ONGOING' ? <EndFastBtn onClick={showPicker} lowLight={textAlpha(time) != 1} /> : <StartFastBtn onClick={showPicker} />
-            }
-        </View>
-    }
-
-    function sleepBtns() {
-        return <View className="btn_bg">
-            {
-                time.status == 'ONGOING' ? <EndSleepBtn onClick={showPicker} lowLight={textAlpha(time) != 1} /> : <StartSleepBtn onClick={showPicker} />
-            }
-        </View>
-    }
-
-    function durationChange(e) {
-        var count = (e[0] + common.duration.min) * 60 + e[1] * common.duration.step
-        isFast ? setFastDuration(count * 60000) : setSleepDuration(count * 60000);
-        isFast ? setFastPickerValue(e) : setSleepPickerValue(e)
-        global.showClockModal2(false, null)
-    }
-
-    function login() {
-        jumpPage('/pages/account/ChooseAuth','ChooseAuth',navigation)
-    }
-
-    function durationFormate() {
-        var t = isFast ? fastDuration / 60000 : sleepDuration / 60000
-        if (props.isNextStep) t = sleepDuration / 60000
-        var hour = Math.floor(t / 60)
-        var minute = Math.floor(t % 60)
-        return `${hour > 0 ? hour + '小时' : ''}${minute > 0 ? minute + '分钟' : ''}`
-    }
-
-    function showDurationPicker(e) {
-        if (process.env.TARO_ENV == 'weapp') {
-            e.stopPropagation()
-        }
-        var node = <Modal children={durationPickerContent()} dismiss={() => global.showClockModal2(false, null)} confirm={() => {
-            var picker = durationPickerRef.current;
-            durationChange((picker as any).getConfirmData());
-            global.showClockModal2(false, null);
-        }} />
-        global.showClockModal2(true, node);
-    }
-
-
-
-
-    function durationPickerContent() {
-        var color = getColor(time)
-        var title = getDurationTitle(time, t)
-        return <View style={{ color: '#fff', backgroundColor: 'transparent' }}>
-            <PickerViews ref={durationPickerRef}
-                onChange={durationChange}
-                items={durationDatas(common)}
-                value={isFast ? fastPickerValue : sleepPickerValue}
-                themeColor={color}
-                title={title}
-                showBtns={true} onCancel={() => { global.showClockModal2(false, null); }} />
-        </View>
-    }
-
-    function minus() {
-        if (isFast) {
-            var count = fastDuration - common.duration.step * 60 * 1000
-            count = count<3600000?3600000:count
-
-            setFastDuration(count)
-            var hour = count / 60000 / 60
-            var minute = count / 60000 % 60
-
-            setFastPickerValue(durationIndex('00:00', `${hour > 10 ? hour : '0' + hour}:${minute > 10 ? minute : '0' + minute}`, common))
-        }
-        else {
-            var count = sleepDuration - common.duration.step * 60 * 1000
-            count = count<3600000?3600000:count
-
-            setSleepDuration(count)
-            var hour = count / 60000 / 60
-            var minute = count / 60000 % 60
-
-            setSleepPickerValue(durationIndex('00:00', `${hour > 10 ? hour : '0' + hour}:${minute > 10 ? minute : '0' + minute}`, common))
-        }
-    }
-
-    function plus() {
-        if (isFast) {
-            var count = fastDuration + common.duration.step * 60 * 1000
-            count = count>23*3600000?23*3600000:count
-
-            setFastDuration(count)
-            var hour = count / 60000 / 60
-            var minute = count / 60000 % 60
-
-            setFastPickerValue(durationIndex('00:00', `${hour > 10 ? hour : '0' + hour}:${minute > 10 ? minute : '0' + minute}`, common))
-        }
-        else {
-            var count = sleepDuration + common.duration.step * 60 * 1000
-
-            count = count>23*3600000?23*3600000:count
-
-            setSleepDuration(count)
-            var hour = count / 60000 / 60
-            var minute = count / 60000 % 60
-
-            setSleepPickerValue(durationIndex('00:00', `${hour > 10 ? hour : '0' + hour}:${minute > 10 ? minute : '0' + minute}`, common))
-        }
-    }
-
-    function disableMinus() {
-        if (isFast) {
-            if (fastDuration <= 60 * 60 * 1000) {
-                return true;
-            }
-        }
-        else {
-            if (sleepDuration <= 60 * 60 * 1000) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    function disablePlus() {
-        if (isFast) {
-            if (fastDuration >= 23 * 60 * 60 * 1000) {
-                return true;
-            }
-        }
-        else {
-            if (sleepDuration >= 23 * 60 * 60 * 1000) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    var textColor = getColor(time)
-    if (time.status != 'ONGOING1' && time.status != 'WAIT_FOR_START') {
-        if (textAlpha(time) == 1) {
-            textColor = '#FA5151';
-        }
-    }
-
-    if (!user.isLogin) {
-        return <View style={{ display: 'flex', flexDirection: 'column', width: '100%', alignItems: 'center' }}>
-            <Text>16:00</Text>
-            <Text style={{ color: global.fastColor?global.fastColor:ColorType.fast }} onClick={login}>Start Fast</Text>
-        </View>
-    }
-
-    if (props.isNextStep) {
-        return <Box >
-            <View style={{
-                display: 'flex', flexDirection: 'column', alignItems: 'center', flexShrink: 0,
-                opacity: time.status == 'WAIT_FOR_START' ? 0.4 : 1,
-                pointerEvents: time.status == 'WAIT_FOR_START' ? 'none' : 'all'
-            }}>
-                {
-                    (time.status == 'WAIT_FOR_START') && <Stepper child={
-                        <Text className="stepper_text" style={{ color: global.sleepColor?global.sleepColor:ColorType.sleep, opacity: textAlpha(time) }} onClick={showDurationPicker}>{durationFormate()}</Text>
-                    } minus={minus} plus={plus}
-                        themeColor={global.sleepColor?global.sleepColor:ColorType.sleep} disableMinus={disableMinus()} disablePlus={disablePlus()} />
-                }
-                {
-                    (time.status == 'ONGOING1' || time.status == 'ONGOING2') &&
-                    <View className="console_time_bg">
-                        <View className="console_time_item">
-                            <Text className="console_time_value" style={{ color: global.fastColor?global.fastColor:ColorType.fast, opacity: textNextStepAlpha(time) }}>{
-                                TimeFormatter.calculateTimeDifference(time.fast.target_start_time,
-                                    time.fast.target_end_time, true)}</Text>
-                            <Text className="console_time_desc">{t('feature.track_time_duration.console.total_duration')}</Text>
-                        </View>
-                        <View className="console_time_item">
-                            <Text className="console_time_value" style={{ color: textNextStepAlpha(time) == 1 ? '#FA5151' : global.fastColor?global.fastColor:ColorType.fast, opacity: textNextStepAlpha(time) }}>{TimeFormatter.countdown(time.fast.target_end_time)}</Text>
-                            <Text className="console_time_desc">{textNextStepAlpha(time) == 1 ? t('feature.track_time_duration.console.timeout') : t('feature.track_time_duration.console.countdown_not_due')}</Text>
-                        </View>
-                    </View>
-                }
-
-                <View>
-                    {
-                        nextStepBtns()
-                    }
-                </View>
-            </View>
-        </Box>
-    }
-
-    function ongoing() {
-        if (time.status == 'ONGOING' || time.status == 'ONGOING2' || time.status == 'ONGOING3') {
-            var isFastData = time.scenario == 'FAST' || time.status == 'ONGOING3'
-            var duration = TimeFormatter.calculateTimeDifference(isFastData ? time.fast.target_start_time : time.sleep.target_start_time,
-                isFast ? time.fast.target_end_time : time.sleep.target_end_time, true);
-            return <View className="console_time_bg">
-                <View className="console_time_item">
-                    <Text className="console_time_value" style={{ color: isFastData ? global.fastColor?global.fastColor:ColorType.fast : global.sleepColor?global.sleepColor:ColorType.sleep, opacity: textAlpha(time) }}>{duration}</Text>
-                    <Text className="console_time_desc">{t('feature.track_time_duration.console.total_duration')}</Text>
-                </View>
-                <View className="console_time_item">
-                    <Text className="console_time_value" style={{ color: textColor, opacity: textAlpha(time) }}>{isFastData ?
-                        TimeFormatter.countdown(time.fast.target_end_time) :
-                        TimeFormatter.countdown(time.sleep.target_end_time)}</Text>
-                    <Text className="console_time_desc">{textAlpha(time) == 1 ? t('feature.track_time_duration.console.timeout') : t('feature.track_time_duration.console.countdown_not_due')}</Text>
-                </View>
-            </View>
-        }
-        return <View />
-    }
-    return (
-        <Box >
-            <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flexShrink: 0 }}>
-                {
-                    ongoing()
-                }
-                {
-                    (time.status == 'ONGOING1' || time.status == 'WAIT_FOR_START') && <Stepper child={
-                        <Text className="stepper_text" style={{ color: textColor, opacity: textAlpha(time) }} onClick={showDurationPicker}>{durationFormate()}</Text>
-                    } minus={minus} plus={plus}
-                        themeColor={isFast ? global.fastColor?global.fastColor:ColorType.fast : global.sleepColor?global.sleepColor:ColorType.sleep} disableMinus={disableMinus()} disablePlus={disablePlus()} />
-                }
-                {/* {
-                    targetView()
-                } */}
-
-                <View>
-                    {
-                        time.scenario === 'FAST_SLEEP' && mixedBtns()
-                    }
-                    {
-                        time.scenario === 'FAST' && fastBtns()
-                    }
-                    {
-                        time.scenario === 'SLEEP' && sleepBtns()
-                    }
-                </View>
-            </View>
-        </Box>
-    )
-}

+ 1 - 1
src/pages/clock/Clock.weapp.tsx

@@ -61,7 +61,7 @@ export default function IndexPage() {
   const [checkData, setCheckData] = useState(null)
   const user = useSelector((state: any) => state.user);
   const time = useSelector((state: any) => state.time);
-  const common = useSelector((state: any) => state.common);
+  
   const consoleData = useSelector((state: any) => state.console);
   const [counter, setCounter] = useState(0)
   const [timerId, setTimerId] = useState(null)

+ 7 - 0
src/pages/food/Food.tsx

@@ -4,9 +4,16 @@ import './Food.scss'
 import FoodJournal from "@/features/food/FoodJournal";
 import { useDidShow, useReady, useShareAppMessage } from "@tarojs/taro";
 import { useTranslation } from "react-i18next";
+import { useDispatch } from "react-redux";
+import { setFoodTabBadge } from "@/store/common";
 
 export default function Page() {
     const {t} = useTranslation()
+    const dispatch = useDispatch();
+    
+    useDidShow(()=>{
+        dispatch(setFoodTabBadge(false))
+    })
     
 
     if (process.env.TARO_ENV == 'weapp') {

+ 6 - 1
src/store/common.tsx

@@ -11,6 +11,7 @@ interface CommonState {
         step: number;
     } | null;
     showTabbar: boolean | true;
+    showFoodTabBadge: boolean | false;
     pageIndex: number | 0;
 }
 
@@ -21,6 +22,7 @@ const initialState: CommonState = {
     configs: null,
     duration: null,
     showTabbar: true,
+    showFoodTabBadge: false,
     pageIndex: 0
 }
 
@@ -58,9 +60,12 @@ const commonSlice = createSlice({
         },
         changeTabbar(state, action) {
             state.pageIndex = action.payload;
+        },
+        setFoodTabBadge(state, action) {
+            state.showFoodTabBadge = action.payload;
         }
     }
 });
 
 export default commonSlice.reducer;
-export const { setResources, setMealTags, setFoodScales, setConfigs, setTabbarStatus, changeTabbar } = commonSlice.actions;
+export const { setResources, setMealTags, setFoodScales, setConfigs, setTabbarStatus, changeTabbar, setFoodTabBadge } = commonSlice.actions;