leon 1 年之前
父节点
当前提交
b5b7730d5c

+ 8 - 8
src/_health/components/fast_sleep_popup.tsx

@@ -57,7 +57,7 @@ export default function FastSleepPopup(props: { close: any, data: any,top?:numbe
             return <View className="time_count h30 bold" style={{ backgroundColor: MainColorType.error }}>00:00:00</View>
         }
         if (status == 'WFS') {
-            return <View className="g02 h24 bold">{TimeFormatter.calculateTimeDifference(fast.target.start_timestamp, sleep.target.start_timestamp)}</View>
+            return <View className="g02 h24 bold">{TimeFormatter.calculateTimeDifference(fast.target.start_timestamp, sleep.target.start_timestamp,false,true)}</View>
         }
         else if (status == 'OG1') {
             return <View className="time_count h30 bold" style={{ backgroundColor: MainColorType.fast }}>{TimeFormatter.countdown(fast.real.start_timestamp)}</View>
@@ -65,13 +65,13 @@ export default function FastSleepPopup(props: { close: any, data: any,top?:numbe
         else if (status == 'OG2_NO1') {
             return ('')
         }
-        return <View className="line_height_48 h30 bold" style={{ color: MainColorType.fast }}>{TimeFormatter.calculateTimeDifference(fast.real.start_timestamp, sleep.real.start_timestamp)}</View>
+        return <View className="line_height_48 h30 bold" style={{ color: MainColorType.fast }}>{TimeFormatter.calculateTimeDifference(fast.real.start_timestamp, sleep.real.start_timestamp,false,true)}</View>
     }
 
     function step2() {
         const { fast, sleep, status } = props.data
         if (status == 'WFS') {
-            return <View className="g02 h24 bold">{TimeFormatter.calculateTimeDifference(sleep.target.start_timestamp, sleep.target.end_timestamp)}</View>
+            return <View className="g02 h24 bold">{TimeFormatter.calculateTimeDifference(sleep.target.start_timestamp, sleep.target.end_timestamp,false,true)}</View>
         }
         if (status == 'OG1') {
             return <View className="time_count h30 bold" style={{ backgroundColor: MainColorType.g03 }}>00:00:00</View>
@@ -81,15 +81,15 @@ export default function FastSleepPopup(props: { close: any, data: any,top?:numbe
             return <View className="time_count h30 bold" style={{ backgroundColor: MainColorType.sleep }}>{TimeFormatter.countdown(sleep.real.start_timestamp)}</View>
         }
         else if (status == 'OG3') {
-            return <View className="h30 bold" style={{ color: MainColorType.sleep }}>{TimeFormatter.calculateTimeDifference(sleep.real.start_timestamp, sleep.real.end_timestamp)}</View>
+            return <View className="h30 bold" style={{ color: MainColorType.sleep }}>{TimeFormatter.calculateTimeDifference(sleep.real.start_timestamp, sleep.real.end_timestamp,false,true)}</View>
         }
-        return <View className="h30 bold" style={{ color: MainColorType.sleep }}>{TimeFormatter.calculateTimeDifference(sleep.target.start_timestamp, sleep.target.end_timestamp)}</View>
+        return <View className="h30 bold" style={{ color: MainColorType.sleep }}>{TimeFormatter.calculateTimeDifference(sleep.target.start_timestamp, sleep.target.end_timestamp,false,true)}</View>
     }
 
     function step3() {
         const { fast, sleep, status } = props.data
         if (status == 'WFS') {
-            return <View className="g02 h24 bold">{TimeFormatter.calculateTimeDifference(sleep.target.end_timestamp, fast.target.end_timestamp)}</View>
+            return <View className="g02 h24 bold">{TimeFormatter.calculateTimeDifference(sleep.target.end_timestamp, fast.target.end_timestamp,false,true)}</View>
         }
         if (status == 'OG1' || status == 'OG2_NO1' || status == 'OG2') {
             return <View className="time_count h30 bold" style={{ backgroundColor: MainColorType.g03 }}>00:00:00</View>
@@ -97,7 +97,7 @@ export default function FastSleepPopup(props: { close: any, data: any,top?:numbe
         if (status == 'OG3') {
             return <View className="time_count h30 bold" style={{ backgroundColor: MainColorType.fast }}>{TimeFormatter.countdown(sleep.real.end_timestamp)}</View>
         }
-        return TimeFormatter.calculateTimeDifference(sleep.target.end_timestamp, fast.target.end_timestamp)
+        return TimeFormatter.calculateTimeDifference(sleep.target.end_timestamp, fast.target.end_timestamp,false,true)
     }
 
     function diffentTime(time2, time1) {
@@ -108,7 +108,7 @@ export default function FastSleepPopup(props: { close: any, data: any,top?:numbe
         duration = t1 - t2 >= 0 ? (t1 - t2) * 60 * 1000 : (t1 - t2) * 60 * 1000 + 24 * 3600 * 1000
 
         var now = new Date().getTime()
-        return TimeFormatter.calculateTimeDifference(now, now + duration)
+        return TimeFormatter.calculateTimeDifference(now, now + duration,false,true)
     }
 
     function beforeStatus() {

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

@@ -33,9 +33,8 @@ if (process.env.TARO_ENV == 'rn') {
     useNavigation = require("@react-navigation/native").useNavigation
 }
 
-const enterTimestamp = new Date().getTime()
-
 export default function AddMoment() {
+    const [enterTimestmap] = useState(new Date().getTime())
     const [desc, setDesc] = useState('')
     const { t } = useTranslation()
     const [imgUrl, setImgUrl] = useState('')
@@ -193,7 +192,8 @@ export default function AddMoment() {
         // }
         // debugger
 
-        var date = new Date(selDate + ' ' + time + ':'+dayjs(enterTimestamp).format('ss'))
+        var date = new Date(selDate + ' ' + time + ':'+dayjs(enterTimestmap).format('ss'))
+        date.setMilliseconds(new Date(enterTimestmap).getMilliseconds())
 
         var params: any = {
             schedule_id: schedule_id,

+ 3 - 0
src/_health/pages/fast_sleep.tsx

@@ -18,6 +18,7 @@ import MainHistory from "@/features/health/MainHistory";
 import StickyDateList from "../components/sticky_date_list";
 import FastSleepPopup from "../components/fast_sleep_popup";
 import { useTranslation } from "react-i18next";
+import Taro from "@tarojs/taro";
 
 let scrollTop = 0
 export default function FastSleep() {
@@ -71,9 +72,11 @@ export default function FastSleep() {
 
 
     function getDatas() {
+        Taro.showLoading()
         fastWithSleep().then(res => {
             setLoaded(true)
             setData(res)
+            Taro.hideLoading()
         })
     }
 

+ 54 - 16
src/_health/pages/log_time.tsx

@@ -25,12 +25,13 @@ import { t } from "i18next";
 let useRoute;
 let useNavigation;
 let scenario = '';
+let AppState;
 if (process.env.TARO_ENV == 'rn') {
     useRoute = require("@react-navigation/native").useRoute
     useNavigation = require("@react-navigation/native").useNavigation
+    AppState = require("react-native").AppState
 }
 
-const enter_timestamp = new Date().getTime()
 export default function LogTime() {
     let router
     let navigation;
@@ -45,6 +46,7 @@ export default function LogTime() {
         router = useRouter()
     }
     const [enterTime, setEnterTime] = useState(new Date().getTime())
+    const [enter_timestamp] = useState(new Date().getTime())
 
     const isSingle = router.params.single == '1'
     const isFast = router.params.window == 'FAST'
@@ -73,7 +75,7 @@ export default function LogTime() {
 
 
 
-    
+
 
 
     useEffect(() => {
@@ -95,7 +97,6 @@ export default function LogTime() {
 
         //前端待处理,日期更新
         setTimeout(() => {
-            console.log('zzzzzzzzzzzzzzzzzzzz')
             setCount(count => count + 1)
             setArray(array => {
                 array.map((item) => {
@@ -105,8 +106,25 @@ export default function LogTime() {
             })
         }, left)
 
+        if (process.env.TARO_ENV == 'rn') {
+            AppState.addEventListener('change', handleAppStateChange);
+        }
+        Taro.onAppShow(() => {
+            setCount(count => count + 1)
+        })
+
     }, [])
 
+    const handleAppStateChange = (nextAppState) => {
+        if (nextAppState != 'active') {
+            return
+        }
+        if (nextAppState == 'active') {
+            setCount(count => count + 1)
+        }
+
+    };
+
     useEffect(() => {
         if (autoCheck) {
             if (ignoreCheck) {
@@ -148,28 +166,47 @@ export default function LogTime() {
         var list: any = []
         if (isSingle) {
             var timeline: any;
+            var time = dayjs().format('HH:mm')
+            var date = dayjs().format('YYYY-MM-DD')
+
             if (isFast) {
                 timeline = isStart ? fast.timeline[0] : fast.timeline[1]
                 Taro.setNavigationBarTitle({
                     title: isStart ? fast.timeline[0].title : fast.timeline[1].title
                 });
+
+                //特殊处理单场景下,结束,超过24小时,picker设置为target_end_time
+                if (!isStart && new Date().getTime() - fast.timeline[0].target.timestamp>=24*3600*1000) {
+                    time = dayjs(fast.timeline[1].target.timestamp).format('HH:mm')
+                    date = dayjs(fast.timeline[1].target.timestamp).format('YYYY-MM-DD')
+                }
             }
             else {
                 timeline = isStart ? sleep.timeline[0] : sleep.timeline[1]
                 Taro.setNavigationBarTitle({
                     title: isStart ? sleep.timeline[0].title : sleep.timeline[1].title
                 });
+
+                //特殊处理单场景下,结束,超过24小时,picker设置为target_end_time
+                if (!isStart && new Date().getTime() - sleep.timeline[0].target.timestamp>=24*3600*1000) {
+                    time = dayjs(sleep.timeline[1].target.timestamp).format('HH:mm')
+                    date = dayjs(sleep.timeline[1].target.timestamp).format('YYYY-MM-DD')
+                }
             }
             if (router.params.longfast) {
                 Taro.setNavigationBarTitle({
                     title: t('health.long_fast')
                 })
             }
+
+
+
+
             list.push({
                 event_id: timeline.event_id,
                 schedule_id: timeline.schedule_id,
-                time: dayjs().format('HH:mm'),
-                date: dayjs().format('YYYY-MM-DD'),
+                time: time,
+                date: date,
                 extra: {
                     set_time: enterTime,
                     confirm_time: enterTime
@@ -305,6 +342,7 @@ export default function LogTime() {
         // var minute = parseInt(time.split(':')[1])
         // var date = obj.date
         var now = new Date(obj.date + 'T' + time + ':' + dayjs(enter_timestamp).format('ss'))
+        now.setMilliseconds(new Date(enter_timestamp).getMilliseconds())
         // now.setHours(hour)
         // now.setMinutes(minute)
         // now.setSeconds(0)
@@ -313,7 +351,7 @@ export default function LogTime() {
         return timestamp
     }
 
-    function tapDone(){
+    function tapDone() {
         var findError = false
         for (var i = 0; i < array.length; i++) {
             var obj = array[i]
@@ -341,7 +379,7 @@ export default function LogTime() {
     }
 
     function tapCommit(onlyCheck, firstCheck = false, save_confirm = null) {
-        
+
         for (var i = 0; i < array.length; i++) {
             var obj = array[i]
             if (obj.time == '' || obj.date == '') {
@@ -352,9 +390,9 @@ export default function LogTime() {
                 return;
             }
 
-            
+
         }
-        
+
 
 
 
@@ -466,16 +504,16 @@ export default function LogTime() {
 
     }
 
-    function getLogMethod(list){
+    function getLogMethod(list) {
         // if (isSingle) return 'LOG_ONCE'
-        if (list.length==1) return 'LOG_ONCE'
+        if (list.length == 1) return 'LOG_ONCE'
         const { status } = data
         if (status == 'OG2_MISALIGNED') return 'LOG_MULTIPLE'
         if (status == 'OG2_NO1') return 'LOG_MULTIPLE'
-        if (status == 'WFS' && list.length>1) return 'LOG_MULTIPLE'
-        if (status == 'OG1' && list.length>2) return 'LOG_MULTIPLE'
-        if (status == 'OG2' && list.length>3) return 'LOG_MULTIPLE'
-        
+        if (status == 'WFS' && list.length > 1) return 'LOG_MULTIPLE'
+        if (status == 'OG1' && list.length > 2) return 'LOG_MULTIPLE'
+        if (status == 'OG2' && list.length > 3) return 'LOG_MULTIPLE'
+
         return 'LOG_ONCE'
     }
 
@@ -606,7 +644,7 @@ export default function LogTime() {
         if (minutes > 0) {
             str += minutes + TimeFormatter.getMinutesUnit(minutes)
         }
-        if (hour == 0 && minutes == 0){
+        if (hour == 0 && minutes == 0) {
             str = 0 + TimeFormatter.getMinutesUnit(0)
         }
         return str

+ 1 - 1
src/_health/pages/long_fast_setting.tsx

@@ -16,7 +16,6 @@ import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import ChooseDateTime from "../components/choose_date_time";
 import StatusIndicator, { StatusType } from "../base/status_indicator";
 
-const enterTimestamp = new Date().getTime()
 export default function LongFastSetting() {
     const [showGoal, setShowGoal] = useState(true)
     const [isToday, setIsToday] = useState(true)
@@ -24,6 +23,7 @@ export default function LongFastSetting() {
     const [time, setTime] = useState(dayjs().format('HH:mm'))
     const [date, setDate] = useState(dayjs().format('YYYY-MM-DD'))
     const health = useSelector((state: any) => state.health);
+    const [enterTimestamp] = useState(new Date().getTime())
 
     useEffect(() => {
         global.set_time = new Date().getTime()

+ 5 - 4
src/_health/pages/timeline_detail.tsx

@@ -40,9 +40,9 @@ if (process.env.TARO_ENV == 'rn') {
     useNavigation = require("@react-navigation/native").useNavigation
 }
 
-const enterTimestmap = new Date().getTime()
 export default function TimelineDetail() {
     let showActionSheetWithOptions;
+    const [enterTimestmap] = useState(new Date().getTime())
     const health = useSelector((state: any) => state.health);
     const user = useSelector((state: any) => state.user);
     const [list, setList] = useState<any>([])
@@ -262,6 +262,7 @@ export default function TimelineDetail() {
             return
         }
         var dt = new Date(selDate + ' ' + time + ':'+dayjs(enterTimestmap).format('ss'))
+        dt.setMilliseconds(new Date(enterTimestmap).getMilliseconds())
         var params: any = {
             schedule_id: schedule_id,
             description: desc,
@@ -485,9 +486,9 @@ export default function TimelineDetail() {
                 // total1={total1()}
                 // total2={total2()}
                 // total3={total3()}
-                step1={stepContent(TimeFormatter.calculateTimeDifference(fast.window_range.start_timestamp, sleep.window_range.start_timestamp), 0)}
-                step2={stepContent(TimeFormatter.calculateTimeDifference(sleep.window_range.start_timestamp, sleep.window_range.end_timestamp), 1)}
-                step3={stepContent(TimeFormatter.calculateTimeDifference(sleep.window_range.end_timestamp, fast.window_range.end_timestamp), 2)}
+                step1={stepContent(TimeFormatter.calculateTimeDifference(fast.window_range.start_timestamp, sleep.window_range.start_timestamp,false,true), 0)}
+                step2={stepContent(TimeFormatter.calculateTimeDifference(sleep.window_range.start_timestamp, sleep.window_range.end_timestamp,false,true), 1)}
+                step3={stepContent(TimeFormatter.calculateTimeDifference(sleep.window_range.end_timestamp, fast.window_range.end_timestamp,false,true), 2)}
             />
         }
         return null

+ 1 - 0
src/app.scss

@@ -691,5 +691,6 @@ page {
     padding-left: 40px;
     padding-right: 52px;
     width: 750px;
+    box-sizing: border-box;
     // background-color: palegoldenrod;
 }

+ 2 - 2
src/components/input/Inputs.scss

@@ -6,7 +6,7 @@
     display: flex;
     flex-direction: row;
     align-items: center;
-    background-color: $ringColor;
+    background-color: #fff;
     border-radius: 36px;
     padding-left: 40px;
     margin-left: 46px;
@@ -15,7 +15,7 @@
 
 .input{
     height: 96px;
-    color: #fff;
+    color: #000;
     caret-color: $fastColor;
     flex: 1;
     // border: solid 4px #000;

+ 2 - 2
src/components/input/Inputs.tsx

@@ -59,8 +59,8 @@ export default function Component({
                     onChangeText={(e)=>{
                         onChange(e)
                     }}
-                    placeholderTextColor="#ffffff99"
-                    placeholderStyle='color:#ffffffCC'
+                    placeholderTextColor="#00000099"
+                    placeholderStyle='color:#000000CC'
                     focus={autoFocus}
                     confirmType="done"
                     selectionColor={global.fastColor ? global.fastColor : ColorType.fast}

+ 1 - 2
src/components/layout/TableCell.scss

@@ -6,7 +6,7 @@
     align-items: center;
     margin-left: 46px;
     margin-right: 46px;
-    background-color: $boxColor;
+    background-color: #fff;
     border-radius: 36px;
     padding-left: 40px;
     padding-right: 40px;
@@ -25,7 +25,6 @@
     font-size: 32px;
     display: flex;
     flex: 1;
-    color: #fff;
 }
 
 .table_cell_arrow {

+ 5 - 2
src/components/layout/TableCell.tsx

@@ -1,5 +1,8 @@
 import { View, Text, Image } from "@tarojs/components";
 import './TableCell.scss'
+import { MainColorType } from "@/context/themes/color";
+import { IconArrow } from "../basic/Icons";
+import { rpxToPx } from "@/utils/tools";
 
 export default function Component(props: {
     children?: React.ReactNode,
@@ -17,13 +20,13 @@ export default function Component(props: {
 
     return <View onClick={onClick} className={props.showMarginBottom ? "table_cell table_cell_margin_bottom" : "table_cell"}>
         <View style={{ flex: 1,display:'flex',flexDirection:'row',alignItems:'center' }}>
-            <Text className='table_cell_title'>{props.title}</Text>
+            <Text className='table_cell_title' style={{color:MainColorType.g01}}>{props.title}</Text>
         </View>
         {
             props.children
         }
         {
-            props.showArrow && <Image src={require('@assets/images/arrow3.png')} className="table_cell_arrow" />
+            props.showArrow && <IconArrow width={rpxToPx(34)} color={MainColorType.g02}/>//<Image src={require('@assets/images/arrow3.png')} className="table_cell_arrow" />
         }
     </View>
 }

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

@@ -656,13 +656,17 @@ export default function MainConsole(props: { type: WindowType }) {
                                     showCancel: true,
                                     cancelText: '稍后',
                                     confirmText: '立即设置',
+                                    cancel:()=>{
+                                        global.showIndexAddActive(labels)
+                                    },
                                     confirm: () => {
                                         tapGuide()
                                     }
                                 })
                                 return
                             }
-                            setShowModal(true)
+                            global.showIndexAddActive(labels)
+                            // setShowModal(true)
                             // jumpPage('/_health/pages/active_plan?schedule=' + JSON.stringify(list.length > 0 ? list[0] : '{}'))
                         }}
                     />

+ 6 - 4
src/features/health/MainFastEatCard.tsx

@@ -71,10 +71,12 @@ export default function MainFastEatCard(props: {
     //     fast.target.start_time <= t1 && fast.target.end_time >= t1) ||
     //     isCurrentTimeInRange(fast.period.start_time, fast.period.end_time)
 
-    const isTempFast = eat.status != 'OG' && (isCurrentTimeInRange(fast.period.start_time, fast.period.end_time) ||
-        fast.target.start_time <= t1 && fast.target.end_time >= t1 ||
-        fast.status == 'WAIT_FOR_END'
-    )
+    // const isTempFast = eat.status != 'OG' && (isCurrentTimeInRange(fast.period.start_time, fast.period.end_time) ||
+    //     fast.target.start_time <= t1 && fast.target.end_time >= t1 ||
+    //     fast.status == 'WAIT_FOR_END'
+    // )
+
+    const isTempFast = fast.status == 'OG' || (isCurrentTimeInRange(fast.period.start_time, fast.period.end_time) && eat.status == 'WFS')
     const [isFastMode, setIsFastMode] = useState(isTempFast)
     const { t } = useTranslation()
 

+ 2 - 1
src/pages/account/EditPage.config.ts

@@ -3,5 +3,6 @@ export default definePageConfig({
         // 'ec-canvas': '../../lib/ec-canvas/ec-canvas',
         // 'demo':'../../components/demo'
     },
-    "navigationBarTitleText": "编辑名字"
+    "navigationBarTitleText": "编辑名字",
+    "navigationBarBackgroundColor":"#f5f5f5"
 })

+ 17 - 5
src/pages/account/EditPage.tsx

@@ -1,9 +1,11 @@
+import NewButton, { NewButtonType } from "@/_health/base/new_button";
 import Inputs from "@/components/input/Inputs";
 import Footer from "@/components/layout/Footer";
-import { ColorType } from "@/context/themes/color";
+import { ColorType, MainColorType } from "@/context/themes/color";
 import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
 import { update } from "@/services/user";
 import { updateSuccess } from "@/store/user";
+import { rpxToPx } from "@/utils/tools";
 import { Input, View, Text } from "@tarojs/components";
 import Taro, { useRouter } from "@tarojs/taro";
 import { useEffect, useState } from "react";
@@ -101,14 +103,24 @@ export default function Page() {
                 <Inputs autoFocus placeholder={t('feature.common.toast.input_nickname')} value={value} onChange={handleChange} onConfirm={save}
                 />
         }
-        
+
 
         <View className="cell_footer">{t('page.user_profile.nickname_footer')}</View>
         <View style={{ flex: 1 }} />
-        <Footer>
+        {/* <Footer>
             <ChooseScenarioBtn disable={btnDisable} title={t('page.user_profile.save')} onClick={save} background={ColorType.fast} />
         </Footer>
-        <View style={{ height: 40 }} />
-        {/* <Text onClick={save} style={{ color: '#fff' }}>保存</Text> */}
+        <View style={{ height: 40 }} /> */}
+        <View className="main_footer">
+            <NewButton
+                color={MainColorType.blue}
+                type={NewButtonType.fill}
+                title={t('feature.common.picker_confirm_btn')}
+                width={rpxToPx(646)}
+                height={rpxToPx(96)}
+                disable={btnDisable}
+                bold={true}
+                onClick={save} />
+        </View>
     </View>
 }

+ 2 - 2
src/pages/account/Profile.tsx

@@ -388,7 +388,7 @@ export default function Page() {
                 showLine
                 icon={<Image src={require('@assets/_health/setting_more.png')} className="profile_cell_icon" />}
             />
-            <View className="a1">测试ABCDabcd1234 weight 100</View>
+            {/* <View className="a1">测试ABCDabcd1234 weight 100</View>
             <View className="a2">测试ABCDabcd1234 weight 200</View>
             <View className="a3">测试ABCDabcd1234 weight 300</View>
             <View className="a3" style={{fontWeight:'normal'}}>测试ABCDabcd1234 weight normal</View>
@@ -401,7 +401,7 @@ export default function Page() {
 
             <View className="a3 b1">测试ABCDabcd1234 weight 300</View>
             <View className="a3 b2">测试ABCDabcd1234 weight 300</View>
-            <View className="a3 b3">测试ABCDabcd1234 weight 300</View>
+            <View className="a3 b3">测试ABCDabcd1234 weight 300</View> */}
             <View style={{ height: 140, flexShrink: 0 }}></View>
         </View>
     }

+ 1 - 1
src/pages/account/ProfileSetting.tsx

@@ -170,7 +170,7 @@ export default function Page() {
 
         <View onClick={editNickname}>
             <TableCell onClick={editNickname} title={t('page.user_profile.nickname')} showArrow={true} showMarginBottom={true}>
-                <Text style={{ opacity: 0.8, color: '#fff' }}>{router.params.newuser == '1' ? (user.nickname == name ? '取个名字' : user.nickname) : user.nickname}</Text>
+                <Text style={{ opacity: 0.8, color: MainColorType.g01 }}>{router.params.newuser == '1' ? (user.nickname == name ? '取个名字' : user.nickname) : user.nickname}</Text>
             </TableCell>
         </View>
         <View style={{ flex: 1 }} />

+ 39 - 4
src/pages/clock/Clock.tsx

@@ -13,6 +13,8 @@ import Streak from "@/features/health/Streak";
 import Calendar from "@/features/health/calendar";
 import HeaderCircadian from "@/features/health/HeaderCircadian";
 import { rpxToPx } from "@/utils/tools";
+import AddLabel from "@/_health/components/add_label";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 
 let useNavigation;
 
@@ -29,10 +31,12 @@ export default function Clock() {
     const health = useSelector((state: any) => state.health);
     const user = useSelector((state: any) => state.user);
     const [showCalendar, setShowCalendar] = useState(false)
-    const [showStreak,setShowStreak] = useState(true)
+    const [showStreak, setShowStreak] = useState(true)
 
     const systemInfo: any = Taro.getWindowInfo();
     const navigationBarHeight = systemInfo.statusBarHeight + 44;
+    const [showModal, setShowModal] = useState(false)
+    const [labels,setLabels] = useState<any>([])
 
     let navigation;
     if (useNavigation) {
@@ -49,6 +53,11 @@ export default function Clock() {
         })
     }
 
+    global.showIndexAddActive = (array)=>{
+        setLabels(array)
+        setShowModal(true)
+    }
+
     useEffect(() => {
         var aa = Taro.getSystemSetting()
         if (navigation) {
@@ -217,10 +226,10 @@ export default function Clock() {
         return null
     }
 
-    function onScroll(e){
+    function onScroll(e) {
         scrollTop = e.detail.scrollTop
 
-        setShowStreak(scrollTop<240)
+        setShowStreak(scrollTop < 240)
     }
 
     if (!loaded)
@@ -240,7 +249,7 @@ export default function Clock() {
             }} >{health.title}</View>
 
             {
-                showStreak&&steakIcon()
+                showStreak && steakIcon()
             }
             {
                 locationIcon()
@@ -276,6 +285,32 @@ export default function Clock() {
                 </Streak>
             }
         </ClockNew>
+        {
+            showModal && <AddLabel labels={labels}
+                window='ACTIVE'
+                disMiss={() => setShowModal(false)}
+                op_page='SCHEDULE_ACTIVE_SLEEP'
+                // onlyCheck={true}
+                // schedules={[]}
+                confirm={(res) => {
+                    setShowModal(false)
+                    if ((res as any).result) {
+                        global.refreshWindow()
+                        // dispatch(setSchedules((res as any).schedules))
+                        // dispatch(setFooter((res as any).footer))
+                        // setList((res as any).schedules)
+                        // setErrors([])
+                    }
+                    else {
+                        jumpPage('/_health/pages/schedules?mode=' + health.mode + '&error=' + JSON.stringify(res))
+                        // setList((res as any).schedules)
+                        // dispatch(setFooter((res as any).footer))
+                        // setErrors((res as any).error_messages ? (res as any).error_messages : [])
+                    }
+
+                }}
+                color={MainColorType.active} />
+        }
 
 
     </View>

+ 36 - 4
src/pages/clock/ClockNew.tsx

@@ -21,6 +21,7 @@ import NoData from "@/_health/components/no_data";
 import Taro, { useDidShow } from "@tarojs/taro";
 import { IconClose } from "@/components/basic/Icons";
 import showAlert from "@/components/basic/Alert";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 
 let AppState;
 if (process.env.TARO_ENV == 'rn') {
@@ -60,8 +61,11 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
     useDidShow(() => {
         if (process.env.TARO_ENV == 'weapp') {
             checkTimeZone()
-            
         }
+
+        setTimeout(() => {
+            checkVersionUpdate();
+        }, 1000)
     })
 
     function refreshData() {
@@ -104,7 +108,7 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
         if (process.env.TARO_ENV == 'rn') {
             AppState.addEventListener('change', handleAppStateChange);
         }
-        Taro.onAppShow(()=>{
+        Taro.onAppShow(() => {
             refreshData()
         })
         setInterval(() => {
@@ -124,6 +128,10 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
             })
         }, 1000)
 
+        setTimeout(() => {
+            checkVersionUpdate();
+        }, 1500)
+
 
     }, [])
 
@@ -204,7 +212,7 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
 
     function archived() {
         getLatestJournal(true, {
-            window:'EAT',
+            window: 'EAT',
         }).then(res => {
             if (!(res as any).user_confirmed && (res as any).id) {
                 global.eatTipId = (res as any).id
@@ -212,7 +220,7 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
             }
         })
         getLatestJournal(true, {
-            window:'ACTIVE'
+            window: 'ACTIVE'
         }).then(res => {
             if (!(res as any).user_confirmed && (res as any).id) {
                 global.activeTipId = (res as any).id
@@ -266,6 +274,30 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
 
     }
 
+    async function checkVersionUpdate() {
+        if (!user.isLogin) {
+            return
+        }
+
+
+        const showAlert1 = await getStorage('148alert') || false;
+        Taro.setStorage({ key: '148alert', data: true })
+        console.log('test abc')
+        if (!showAlert1 && !health.finish_setup){
+            jumpPage('/_health/pages/guide_begin')
+        }
+
+    }
+
+    async function getStorage(key: string) {
+        try {
+            const res = await Taro.getStorage({ key });
+            return res.data;
+        } catch {
+            return '';
+        }
+    }
+
     function tapScroll(index) {
         setScrollLeft(rpxToPx(750) * index)
     }

+ 10 - 1
src/utils/time_format.ts

@@ -391,7 +391,16 @@ export class TimeFormatter {
   }
 
   //计算时间间隔
-  static calculateTimeDifference(startTimestamp: number, endTimestamp: number, showDays?: boolean): string {
+  static calculateTimeDifference(startTimestamp: number, endTimestamp: number, showDays?: boolean,ignoreSeconds?:boolean): string {
+    if (ignoreSeconds){
+      var date1 = new Date(startTimestamp)
+      var date2 = new Date(endTimestamp)
+      date1.setSeconds(0,0)
+      date2.setSeconds(0,0)
+      startTimestamp = date1.getTime()
+      endTimestamp = date2.getTime()
+    }
+    
     const diff = Math.abs(endTimestamp - startTimestamp);
     // 计算小时、分钟和秒数
     let hours = Math.floor(diff / (1000 * 60 * 60));