leon 1 년 전
부모
커밋
57491ed367

+ 48 - 24
src/_health/base/new_date_picker.tsx

@@ -10,7 +10,14 @@ export enum NewDatePickerType {
     normal = 'normal',
     date = 'date'
 }
-export default function NewDatePicker(props: { value?: any, onChange?: any, color?: string, type?: NewDatePickerType,isToday?:boolean }) {
+export default function NewDatePicker(props: {
+    value?: any,
+    onChange?: any,
+    color?: string,
+    type?: NewDatePickerType,
+    isToday?: boolean,
+    minTimestamp?: number
+}) {
     const [items, setItems] = useState<any>([[0]])
     const [values, setValues] = useState<any>([0])
     const [loaded, setLoaded] = useState(false)
@@ -30,39 +37,54 @@ export default function NewDatePicker(props: { value?: any, onChange?: any, colo
     }, [])
 
     function itemDatas() {
-        return [['Yesterday','Today']]
+        return [['Yesterday', 'Today']]
     }
 
     function itemValues() {
-        return [props.isToday?1:0]
+        return [props.isToday ? 1 : 0]
     }
 
     function longDatas() {
-        var min = 1
-        var max = 99
-
-        var days: string[] = []
-
-        for (let i = min; i <= max; i++) {
-            days.push(i + '天')
-        }
-
-        var hours: string[] = []
-        for (var i = 0; i < 24; i++) {
-            hours.push(i + TimeFormatter.getHoursUnit(i))
+        let result: any = []
+        const currentDate = new Date()
+        const startDate = new Date(props.minTimestamp!)
+        let date = startDate
+
+        const today = dayjs();
+        const yesterday = today.subtract(1, 'day');
+        while (date <= currentDate) {
+            var dt = dayjs(date.getTime())
+            var string = global.langauge == 'en' ? dt.format('MMM D') : dt.format('MMMD日')
+            if (dt.isSame(today, 'day')&&dt.isSame(today, 'month')&&dt.isSame(today, 'year')) {
+                string = (global.langauge == 'en' ? 'Today, ' : '今天 ') + string
+            }
+            else if (dt.isSame(yesterday, 'day')&&dt.isSame(yesterday, 'month')&&dt.isSame(yesterday, 'year')) {
+                string = (global.langauge == 'en' ? 'Yesterday, ' : '昨天 ') + string
+            }
+            result.push(string)
+            date.setDate(date.getDate() + 1)
         }
-        return [days, hours]
+        return [result]
     }
 
     function longValues() {
-        if (props.value){
-            var day = Math.floor(props.value/24)
-            var hour = props.value%24
-            return [day-1,hour]
-            
+        if (props.value) {
+            var obj = dayjs(props.value)
+            const startDate = new Date(props.minTimestamp!)
+            let date = startDate
+            for (var i = 0; i < longDatas()[0].length; i++) {
+                
+                var dt = dayjs(date.getTime())
+                if (dt.isSame(obj,'day') && dt.isSame(obj,'month') && dt.isSame(obj,'year')){
+                    return [i]
+                }
+                date.setDate(date.getDate()+1)
+            }
+
+
 
         }
-        return [0, 0]
+        return [0]
     }
 
     function onPickerChange(e) {
@@ -74,8 +96,10 @@ export default function NewDatePicker(props: { value?: any, onChange?: any, colo
                     props.onChange(list[0])
                     break
                 case NewDatePickerType.date:
-                    props.onChange(list[0]*24+list[1]+24)
-                    break
+                    {
+                        var timestamp = props.minTimestamp!+list[0]*24*3600*1000
+                        props.onChange(dayjs(timestamp).format('YYYY-MM-DD'))
+                    }
                     break
             }
 

+ 0 - 0
src/_health/components/fast_sleep_detail_card.scss → src/_health/components/choose_date_time.scss


+ 170 - 0
src/_health/components/choose_date_time.tsx

@@ -0,0 +1,170 @@
+import { View, Image } from "@tarojs/components"
+import './choose_date_time.scss'
+import { rpxToPx } from "@/utils/tools"
+import NewButton, { NewButtonType } from "../base/new_button"
+import { useState } from "react"
+import NewDatePicker, { NewDatePickerType } from "../base/new_date_picker"
+import NewTimePicker from "../base/new_timepicker"
+import { IconCalendar } from "@/components/basic/Icons"
+import dayjs from "dayjs"
+
+export default function ChooseDateTime(props: {
+    title?: any,
+    disable?: boolean,
+    showError?: boolean,
+    showLine?: boolean,
+    minTimestamp?:number,
+    footerTitle?: string,
+    tapFooter?: any,
+    color: string,
+    date: string,
+    time: string,
+    expand: boolean,
+    choose?: any,
+    timeChange: any,
+    dateChange: any
+}) {
+    const [chooseDate, setChooseDate] = useState(false)
+
+    function dateTitle(){
+        var today = dayjs()
+        const yesterday = today.subtract(1, 'day');
+        var date = dayjs(props.date)
+        
+        if (today.format('YYYY-MM-DD') == date.format('YYYY-MM-DD')){
+            return global.languange=='en'?'Today':'今天'
+        }
+        if (yesterday.format('YYYY-MM-DD') == date.format('YYYY-MM-DD')){
+            return global.languange=='en'?'Yesterday':'昨天'
+        }
+        else {
+            return global.languange=='en'?date.format('MMM D'):date.format('MMMD日')
+        }
+    }
+
+    return <View style={{ position: 'relative' }}>
+        <View className="card_header">
+            {
+                props.showError && <View className="error_icon_bg">
+                    <Image src={require('@assets/_health/tip_error.png')} style={{ width: rpxToPx(26), height: rpxToPx(26) }} />
+                </View>
+
+            }
+            {
+                props.title ? <View className="h34" style={{ flex: 1 }}>{props.title}</View> :
+                    <View style={{ flex: 1 }} />
+            }
+
+            <View style={{
+                borderColor: props.showError ? 'red' : 'transparent',
+                borderWidth: rpxToPx(2),
+                borderRadius: rpxToPx(88 / 4),
+                borderStyle: 'solid'
+            }}>
+                <NewButton
+                    type={(props.expand && chooseDate) ? NewButtonType.alpha : NewButtonType.gray}
+                    color={props.color}
+                    title={dateTitle()}
+                    fontSize={rpxToPx(34)}
+                    width={rpxToPx(196)}
+                    height={rpxToPx(84)}
+                    disable={props.disable}
+                    onClick={() => {
+                        setChooseDate(true)
+                        if (props.choose) {
+                            props.choose()
+                        }
+                        // setExpandIndex(index)
+                        // var list = JSON.parse(JSON.stringify(array))
+                        // list[index].today = !list[index].today
+                        // list[index].extra.confirm_time = new Date().getTime()
+                        // setArray(list)
+                    }}
+                />
+            </View>
+            <View style={{ width: rpxToPx(12) }} />
+            <View style={{
+                borderColor: props.showError ? 'red' : 'transparent',
+                borderWidth: rpxToPx(2),
+                borderRadius: rpxToPx(88 / 4),
+                borderStyle: 'solid'
+            }}>
+                <NewButton
+                    type={(props.expand && !chooseDate) ? NewButtonType.alpha : NewButtonType.gray}
+                    color={props.color}
+                    title={props.time}
+                    fontSize={rpxToPx(34)}
+                    width={rpxToPx(136)}
+                    height={rpxToPx(84)}
+                    disable={props.disable}
+                    onClick={() => {
+                        setChooseDate(false)
+                        if (props.choose) {
+                            props.choose()
+                        }
+                    }}
+                />
+            </View>
+            {
+                !props.title && <View style={{ flex: 1 }} />
+            }
+            <View className='border_footer_line' style={{ left: rpxToPx(66) }} />
+        </View>
+        {
+            props.expand && chooseDate && <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: rpxToPx(698) }}>
+                {/* <NewDatePicker
+                        type={NewDatePickerType.normal}
+                        isToday={array[index].today}
+                        onChange={(e) => {
+                            var list = JSON.parse(JSON.stringify(array))
+                            list[index].today = e==1
+                            list[index].extra.confirm_time = new Date().getTime()
+                            setArray(list)
+                        }}
+                        color={iFast ? MainColorType.fast : MainColorType.sleep} /> */}
+                <NewDatePicker
+                    type={NewDatePickerType.date}
+                    minTimestamp={props.minTimestamp?props.minTimestamp:new Date().getTime()-24*3600*1000}
+                    value={props.date}
+                    onChange={(e) => {
+                        // var list = JSON.parse(JSON.stringify(array))
+                        // list[index].today = e == 1
+                        // list[index].extra.confirm_time = new Date().getTime()
+                        // setArray(list)
+                        props.dateChange(e)
+                    }}
+                    color={props.color} />
+            </View>
+        }
+        {
+            props.expand && chooseDate && <View className='card_footer' />
+        }
+        {
+            props.expand && !chooseDate && <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: rpxToPx(698) }}>
+                <NewTimePicker time={props.time} onChange={(e) => {
+                    // var list = JSON.parse(JSON.stringify(array))
+                    // list[index].time = e
+                    // list[index].extra.confirm_time = new Date().getTime()
+                    // setArray(list)
+                    props.timeChange(e)
+                }} color={props.color} />
+            </View>
+        }
+
+        {
+            props.expand && !chooseDate && <View className='card_footer'>
+                <NewButton type={NewButtonType.link}
+                    title={props.footerTitle}
+                    onClick={props.tapFooter}
+                >
+                    <View style={{ marginRight: rpxToPx(12), display: 'flex' }}>
+                        <IconCalendar width={rpxToPx(24)} color='#5C7099' />
+                    </View>
+                </NewButton>
+            </View>
+        }
+        {
+            props.showLine && <View className="border_footer_line" style={{ left: rpxToPx(66) }} />
+        }
+    </View>
+}

+ 0 - 117
src/_health/components/fast_sleep_detail_card.tsx

@@ -1,117 +0,0 @@
-import { View, Text } from '@tarojs/components'
-import './fast_sleep_detail_card.scss'
-import { MainColorType } from '@/context/themes/color'
-import { TimeFormatter } from '@/utils/time_format'
-import { rpxToPx } from '@/utils/tools'
-import { useSelector } from 'react-redux'
-
-export default function FastSleepDetailCard(props: { data: any }) {
-    const health = useSelector((state: any) => state.health);
-
-    function total() {
-        const { fast } = props.data
-        return diffentTime(fast.period.start_time, fast.period.end_time)
-    }
-
-    function process() {
-        const { fast, status } = props.data
-        if (status == 'OG2_NO1' || status == 'WFS') {
-            return '-'
-        }
-        return TimeFormatter.countdown(fast.real.start_timestamp)
-    }
-
-    function step1() {
-        if (health.fast_with_sleep.status == 'OG2_MISALIGNED'){
-            return '-'
-        }
-        const { fast, sleep, status } = props.data
-        if (status == 'WFS') {
-            return ('-')
-        }
-        else if (status == 'OG1') {
-            return TimeFormatter.countdown(fast.real.start_timestamp)
-        }
-        else if (status == 'OG2_NO1') {
-            return ('-')
-        }
-        return TimeFormatter.calculateTimeDifference(fast.real.start_timestamp, sleep.real.start_timestamp)
-    }
-
-    function step2() {
-        const { fast, sleep, status } = props.data
-        if (status == 'WFS' || status == 'OG1') {
-            return '-'
-        }
-
-        if (status == 'OG2_NO1' || status == 'OG2') {
-            return TimeFormatter.countdown(sleep.real.start_timestamp)
-        }
-        else if (status == 'OG3') {
-            return TimeFormatter.calculateTimeDifference(sleep.real.start_timestamp, sleep.real.end_timestamp)
-        }
-        return TimeFormatter.calculateTimeDifference(sleep.target.start_timestamp, sleep.target.end_timestamp)
-    }
-
-    function step3() {
-        const { fast, sleep, status } = props.data
-        if (status == 'WFS' || status == 'OG1' || status == 'OG2_NO1' || status == 'OG2') {
-            return '-'
-        }
-        if (status == 'OG3') {
-            return TimeFormatter.countdown(sleep.real.end_timestamp)
-        }
-        return TimeFormatter.calculateTimeDifference(sleep.target.end_timestamp, fast.target.end_timestamp)
-    }
-
-    function diffentTime(time2, time1) {
-        var duration = 0
-
-        var t1 = parseInt(time1.split(':')[0]) * 60 + parseInt(time1.split(':')[1])
-        var t2 = parseInt(time2.split(':')[0]) * 60 + parseInt(time2.split(':')[1])
-        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)
-    }
-
-    function total1() {
-        const { fast, sleep } = props.data
-        return diffentTime(fast.period.start_time, sleep.period.start_time)
-    }
-
-    function total2() {
-        const { sleep } = props.data
-        return diffentTime(sleep.period.start_time, sleep.period.end_time)
-    }
-
-    function total3() {
-        const { fast, sleep } = props.data
-        return diffentTime(sleep.period.end_time, fast.period.end_time)
-    }
-
-    return <View style={{ background: '#fff', marginBottom: 20 }}>
-        <Text>详情</Text>
-
-
-        <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
-            <View className='h22' style={{ color: MainColorType.g02 }}>断食</View>
-            <View>{process()}/{total()}</View>
-
-            <View style={{ display: 'flex', marginTop: 10, width: rpxToPx(750), flexDirection: 'row', alignItems: 'center', justifyContent: 'space-around' }}>
-                <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
-                    <View className='h22' style={{ color: MainColorType.g02 }}>睡前断食</View>
-                    <View style={{ color: props.data.status == 'OG1' ? MainColorType.fast : '#000' }}>{step1()}/{total1()}</View>
-                </View>
-                <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
-                    <View className='h22' style={{ color: MainColorType.g02 }}>睡眠期间断食</View>
-                    <View style={{ color: props.data.status == 'OG2'||props.data.status == 'OG2_NO1' ? MainColorType.sleep : '#000' }}>{step2()}/{total2()}</View>
-                </View>
-                <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
-                    <View className='h22' style={{ color: MainColorType.g02 }}>起床后断食</View>
-                    <View style={{ color: props.data.status == 'OG3' ? MainColorType.fast : '#000' }}>{step3()}/{total3()}</View>
-                </View>
-            </View>
-        </View>
-    </View>
-}

+ 1 - 1
src/_health/components/sticky_date_list.tsx

@@ -16,7 +16,7 @@ export default function StickyDateList(props: {
             left: 0,
             top: 0,
             right: 0,
-            height: rpxToPx(84),
+            height: props.showDate ?rpxToPx(84):0,
             backgroundColor: '#f5f5f5',
             paddingLeft: rpxToPx(40),
             display: 'flex',

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

@@ -14,7 +14,6 @@ import Card from "../components/card";
 import FastSleepConsole from "../components/fast_sleep_console";
 import { fastWithSleep } from "@/services/health";
 import FastSleepCard from "../components/fast_sleep_card";
-import FastSleepDetailCard from "../components/fast_sleep_detail_card";
 import MainHistory from "@/features/health/MainHistory";
 import StickyDateList from "../components/sticky_date_list";
 import FastSleepPopup from "../components/fast_sleep_popup";

+ 82 - 160
src/_health/pages/log_time.tsx

@@ -17,6 +17,7 @@ import { clockTimes, fastWithSleep } from "@/services/health";
 import NewDurationPicker, { DurationPickerType } from "../base/new_durationpicker";
 import showAlert from "@/components/basic/Alert";
 import NewDatePicker, { NewDatePickerType } from "../base/new_date_picker";
+import ChooseDateTime from "../components/choose_date_time";
 
 let useRoute;
 let useNavigation;
@@ -89,6 +90,8 @@ export default function LogTime() {
         var t2 = now.getTime()
         t2 += 24 * 3600 * 1000
         var left = t2 - t + 500
+
+        //前端待处理,日期更新
         setTimeout(() => {
             setArray(array => {
                 array.map((item) => {
@@ -139,7 +142,7 @@ export default function LogTime() {
                 event_id: timeline.event_id,
                 schedule_id: timeline.schedule_id,
                 time: dayjs().format('HH:mm'),
-                today: true,
+                date:dayjs().format('YYYY-MM-DD'),
                 extra: {
                     set_time: enterTime,
                     confirm_time: enterTime
@@ -172,7 +175,7 @@ export default function LogTime() {
                     event_id: timeline.event_id,
                     schedule_id: timeline.schedule_id,
                     time: dayjs().format('HH:mm'),
-                    today: true,
+                    date:dayjs().format('YYYY-MM-DD'),
                     extra: {
                         set_time: enterTime,
                         confirm_time: enterTime
@@ -211,17 +214,14 @@ export default function LogTime() {
             }
 
             if (!isConflict) {
-                var fastStartToday = new Date().getDate() == new Date(fastStartTime).getDate()
-                list[0].today = fastStartToday
+                list[0].date = dayjs(fastStartTime).format('YYYY-MM-DD')
                 list[0].time = dayjs(fastStartTime).format('HH:mm')
 
-                var sleepStartToday = new Date().getDate() == new Date(sleepStartTime).getDate()
-                list[1].today = sleepStartToday
+                list[1].date = dayjs(sleepStartTime).format('YYYY-MM-DD')
                 list[1].time = dayjs(sleepStartTime).format('HH:mm')
 
                 if (list.length > 2) {
-                    var sleepEndToday = new Date().getDate() == new Date(sleepEndTime).getDate()
-                    list[2].today = sleepEndToday
+                    list[2].date = dayjs(sleepEndTime).format('YYYY-MM-DD')
                     list[2].time = dayjs(sleepEndTime).format('HH:mm')
 
                 }
@@ -229,22 +229,19 @@ export default function LogTime() {
             }
 
             if (fast.real && fast.real.start_timestamp) {
-                var fastStartToday = new Date().getDate() == new Date(fast.real.start_timestamp).getDate()
-                list[0].today = fastStartToday
+                list[0].date = dayjs(fast.real.start_timestamp).format('YYYY-MM-DD')
                 list[0].disable = true
                 list[0].time = dayjs(fast.real.start_timestamp).format('HH:mm')
             }
 
             if (sleep.real && sleep.real.start_timestamp) {
-                var sleepStartToday = new Date().getDate() == new Date(sleep.real.start_timestamp).getDate()
-                list[1].today = sleepStartToday
+                list[1].date = dayjs(sleep.real.start_timestamp).format('YYYY-MM-DD')
                 list[1].disable = true
                 list[1].time = dayjs(sleep.real.start_timestamp).format('HH:mm')
             }
 
             if (list.length > 2 && sleep.real && sleep.real.end_timestamp) {
-                var sleepEndToday = new Date().getDate() == new Date(sleep.real.end_timestamp).getDate()
-                list[2].today = sleepEndToday
+                list[2].date = dayjs(sleep.real.end_timestamp).format('YYYY-MM-DD')
                 list[2].disable = true
                 list[2].time = dayjs(sleep.real.end_timestamp).format('HH:mm')
             }
@@ -263,18 +260,15 @@ export default function LogTime() {
 
     function getTimestamp(obj) {
         var time = obj.time
-        var hour = parseInt(time.split(':')[0])
-        var minute = parseInt(time.split(':')[1])
-        var today = obj.today
-        var now = new Date()
-        now.setHours(hour)
-        now.setMinutes(minute)
-        now.setSeconds(0)
-        now.setMilliseconds(0)
+        // var hour = parseInt(time.split(':')[0])
+        // var minute = parseInt(time.split(':')[1])
+        // var date = obj.date
+        var now = new Date(obj.date+'T'+time+':'+dayjs().format('ss'))
+        // now.setHours(hour)
+        // now.setMinutes(minute)
+        // now.setSeconds(0)
+        // now.setMilliseconds(0)
         var timestamp = now.getTime()
-        if (!today) {
-            timestamp -= 24 * 3600 * 1000
-        }
         return timestamp
     }
 
@@ -453,12 +447,12 @@ export default function LogTime() {
     function changeToScheduleTime(schedule_time, index) {
         var nowTime = parseInt(dayjs().format('HHmm'))
         var scheduleTime = parseInt(schedule_time.replace(':', ''))
-        var isToday = true
+        var date = dayjs().format('YYYY-MM-DD')
         if (scheduleTime > nowTime) {
-            isToday = false
+            date = dayjs(new Date().getTime()-24*3600*1000).format('YYYY-MM-DD')
         }
         var list = JSON.parse(JSON.stringify(array))
-        list[index].today = isToday
+        list[index].date = date
         list[index].time = schedule_time
         list[index].extra.confirm_time = new Date().getTime()
         setArray(list)
@@ -501,8 +495,15 @@ export default function LogTime() {
         var schedule_time = ''
         var title = ''
 
-        var date = array[index].today ? "Today" : "Yesterday"
+        var date = array[index].date//array[index].today ? "Today" : "Yesterday"
         var time = array[index].time
+        var min = new Date().getTime()
+        if (iFast) {
+            min = fast.picker_min_timestamp
+        }
+        else {
+            min = sleep.picker_min_timestamp
+        }
 
         const today = dayjs();
         var schedule_id = ''
@@ -518,17 +519,18 @@ export default function LogTime() {
 
             if (array[index].disable) {
                 var timestamp = iStart ? fast.real.start_timestamp : fast.real.end_timestamp
-                const dt = dayjs(timestamp);
-                const yesterday = today.subtract(1, 'day');
-                time = dayjs(timestamp).format('HH:mm')
-
-                if (dt.isSame(today, 'day')) {
-                    date = 'Today';
-                } else if (dt.isSame(yesterday, 'day')) {
-                    date = 'Yesterday';
-                } else {
-                    date = dt.format('MM-DD');
-                }
+                date = dayjs(timestamp).format('YYYY-MM-DD')
+                // const dt = dayjs(timestamp);
+                // const yesterday = today.subtract(1, 'day');
+                // time = dayjs(timestamp).format('HH:mm')
+
+                // if (dt.isSame(today, 'day')) {
+                //     date = global.language == 'en' ? 'Today' : '今天';
+                // } else if (dt.isSame(yesterday, 'day')) {
+                //     date = global.language == 'en' ? 'Yesterday' : '昨天';
+                // } else {
+                //     date = global.language == 'en' ? dt.format('MMM D') : dt.format('MMMD日');
+                // }
             }
         }
         else {
@@ -540,132 +542,52 @@ export default function LogTime() {
             title = iStart ? 'Bedtime' : 'Wake up'
             if (array[index].disable) {
                 var timestamp = iStart ? sleep.real.start_timestamp : sleep.real.end_timestamp
-                const dt = dayjs(timestamp);
-                const yesterday = today.subtract(1, 'day');
-                time = dayjs(timestamp).format('HH:mm')
-
-                if (dt.isSame(today, 'day')) {
-                    date = 'Today';
-                } else if (dt.isSame(yesterday, 'day')) {
-                    date = 'Yesterday';
-                } else {
-                    date = dt.format('MM-DD');
-                }
+                date = dayjs(timestamp).format('YYYY-MM-DD')
+                // const dt = dayjs(timestamp);
+                // const yesterday = today.subtract(1, 'day');
+                // time = dayjs(timestamp).format('HH:mm')
+
+                // if (dt.isSame(today, 'day')) {
+                //     date = global.language == 'en' ? 'Today' : '今天';
+                // } else if (dt.isSame(yesterday, 'day')) {
+                //     date = global.language == 'en' ? 'Yesterday' : '昨天';
+                // } else {
+                //     date = global.language == 'en' ? dt.format('MMM D') : dt.format('MMMD日');
+                // }
             }
         }
-
         var showError = false;
         if (conflicts.includes(schedule_id)) {
             showError = true
         }
-
-
-
-        return <View style={{ position: 'relative' }}>
-            <View className="card_header">
-                {
-                    showError && !isSingle && <View className="error_icon_bg">
-                        <Image src={require('@assets/_health/tip_error.png')} style={{ width: rpxToPx(26), height: rpxToPx(26) }} />
-                    </View>
-
-                }
-                {
-                    isSingle ? <View style={{ flex: 1 }} /> :
-                        <View className="h34" style={{ flex: 1 }}>{title}</View>
-                }
-
-                <View style={{
-                    borderColor: showError ? 'red' : 'transparent',
-                    borderWidth: rpxToPx(2),
-                    borderRadius: rpxToPx(88 / 4),
-                    borderStyle: 'solid'
-                }}>
-                    <NewButton
-                        type={(expandIndex == index && chooseDate) ? NewButtonType.alpha :NewButtonType.gray}
-                        color={iFast ? MainColorType.fast : MainColorType.sleep}
-                        title={date}
-                        fontSize={rpxToPx(34)}
-                        width={rpxToPx(196)}
-                        height={rpxToPx(84)}
-                        disable={array[index].disable}
-                        onClick={() => {
-                            setChooseDate(true)
-                            setExpandIndex(index)
-                            // var list = JSON.parse(JSON.stringify(array))
-                            // list[index].today = !list[index].today
-                            // list[index].extra.confirm_time = new Date().getTime()
-                            // setArray(list)
-                        }}
-                    />
-                </View>
-                <View style={{ width: rpxToPx(12) }} />
-                <View style={{
-                    borderColor: showError ? 'red' : 'transparent',
-                    borderWidth: rpxToPx(2),
-                    borderRadius: rpxToPx(88 / 4),
-                    borderStyle: 'solid'
-                }}>
-                    <NewButton
-                        type={(expandIndex == index && !chooseDate) ? NewButtonType.alpha : NewButtonType.gray}
-                        color={iFast ? MainColorType.fast : MainColorType.sleep}
-                        title={time}
-                        fontSize={rpxToPx(34)}
-                        width={rpxToPx(136)}
-                        height={rpxToPx(84)}
-                        disable={array[index].disable}
-                        onClick={() => {
-                            setChooseDate(false)
-                            setExpandIndex(index)
-                        }}
-                    />
-                </View>
-                {
-                    isSingle && <View style={{ flex: 1 }} />
-                }
-                <View className='border_footer_line' style={{ left: rpxToPx(66) }} />
-            </View>
-            {
-                expandIndex == index && chooseDate && <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: rpxToPx(698) }}>
-                    <NewDatePicker
-                        type={NewDatePickerType.normal}
-                        isToday={array[index].today}
-                        onChange={(e) => {
-                            // console.log(e)
-                            var list = JSON.parse(JSON.stringify(array))
-                            list[index].today = e==1
-                            list[index].extra.confirm_time = new Date().getTime()
-                            setArray(list)
-                        }}
-                        color={iFast ? MainColorType.fast : MainColorType.sleep} />
-                </View>
-            }
-            {
-                expandIndex == index && !chooseDate && <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: rpxToPx(698) }}>
-                    <NewTimePicker time={array[index].time} onChange={(e) => {
-                        var list = JSON.parse(JSON.stringify(array))
-                        list[index].time = e
-                        list[index].extra.confirm_time = new Date().getTime()
-                        setArray(list)
-                    }} color={iFast ? MainColorType.fast : MainColorType.sleep} />
-                </View>
-            }
-            {
-                expandIndex == index && !chooseDate && <View className='card_footer'>
-                    <NewButton type={NewButtonType.link}
-                        title={changeTimeText(schedule_time, time)}
-                        onClick={() => tapChangeTime(schedule_time, time, index)}
-                    >
-                        <View style={{ marginRight: rpxToPx(12), display: 'flex' }}>
-                            <IconCalendar width={rpxToPx(24)} color='#5C7099' />
-                        </View>
-                    </NewButton>
-                </View>
-            }
-            {
-                showLine && <View className="border_footer_line" style={{ left: rpxToPx(66) }} />
-            }
-
-        </View>
+        return <ChooseDateTime
+            title={isSingle ? null : title}
+            disable={array[index].disable}
+            showError={showError}
+            showLine={showLine}
+            footerTitle={changeTimeText(schedule_time, time)}
+            tapFooter={() => tapChangeTime(schedule_time, time, index)}
+            color={iFast ? MainColorType.fast : MainColorType.sleep}
+            minTimestamp={min}
+            date={date}
+            time={time}
+            expand={expandIndex == index}
+            choose={() => {
+                setExpandIndex(index)
+            }}
+            dateChange={(e) => {
+                var list = JSON.parse(JSON.stringify(array))
+                list[index].date = e
+                list[index].extra.confirm_time = new Date().getTime()
+                setArray(list)
+            }}
+            timeChange={(e) => {
+                var list = JSON.parse(JSON.stringify(array))
+                list[index].time = e
+                list[index].extra.confirm_time = new Date().getTime()
+                setArray(list)
+            }}
+        />
     }
 
     function multiContent() {

+ 29 - 3
src/_health/pages/schedules.tsx

@@ -232,9 +232,9 @@ export default function Schedules() {
         })
     }
 
-    function add() {
+    function add(isEat) {
         var isMax = false
-        if (selMode == 'FAST' || selMode == 'EAT') {
+        if (isEat) {
             setIsEat(true)
             const countFastWindows = list.filter(item => item.window === 'EAT').length;
             if (countFastWindows >= 4) {
@@ -411,7 +411,7 @@ export default function Schedules() {
             <View style={{ height: 20, flexShrink: 0 }} />
             {
                 selMode != '' && selMode != 'DAY' && selMode != 'NIGHT' && <Card><View className='item_add'
-                    onClick={() => add()}>
+                    onClick={() => add((selMode == 'FAST' || selMode == 'EAT'))}>
                     <StatusIndicator type={StatusType.img}
                         fontColor={getAddColor()}
                         fontSize={rpxToPx(34)}
@@ -423,6 +423,32 @@ export default function Schedules() {
                     <View style={{ flex: 1 }} />
                 </View></Card>
             }
+            {
+                selMode == '' && <Card>
+                    <View className='item_add'
+                        style={{ position: 'relative' }}
+                        onClick={() => add(true)}>
+                        <StatusIndicator type={StatusType.img}
+                            fontColor={MainColorType.eat}
+                            fontSize={rpxToPx(34)}
+                            text={t('health.add_meal')} color={MainColorType.eat}>
+                            <IconAdd color="#fff" width={rpxToPx(26)} />
+                        </StatusIndicator>
+                        <View style={{ flex: 1 }} />
+                        <View className='border_footer_line' style={{ left: rpxToPx(66) }} />
+                    </View>
+                    <View className='item_add'
+                        onClick={() => add(false)}>
+                        <StatusIndicator type={StatusType.img}
+                            fontColor={MainColorType.active}
+                            fontSize={rpxToPx(34)}
+                            text={t('health.add_active')} color={MainColorType.active}>
+                            <IconAdd color="#fff" width={rpxToPx(26)} />
+                        </StatusIndicator>
+                        <View style={{ flex: 1 }} />
+                    </View>
+                </Card>
+            }
 
             {
                 health.finish_setup && <View style={{

+ 22 - 0
src/app.scss

@@ -408,6 +408,18 @@ page {
     background-color: #E5E5E5;
 }
 
+.guide_tip {
+    height: 80px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    background-color: #0080FF1A;
+    color: #0080FF;
+    width: 750px;
+    position: relative;
+    z-index: 10;
+}
+
 .page_container {
     display: flex;
     flex-direction: column;
@@ -551,4 +563,14 @@ page {
 
 .g05 {
     color: #f5f5f5
+}
+
+.line1 {
+    white-space: nowrap;
+    /* 不换行 */
+    overflow: hidden;
+    /* 隐藏超出部分 */
+    text-overflow: ellipsis;
+    /* 显示省略号 */
+    width: 100%;
 }

+ 2 - 0
src/context/locales/en.js

@@ -870,6 +870,8 @@ export default {
         guide_current_scenario: 'Live Now: {{scenario}} Schedule',
 
         console_guide_tip:'Remember to finish setting up my schedule here 👆',
+        add_mini_guide_tip:'Add to My Mini Programs for easy access 👆',
+
 
         add_meal: 'Add Meal',
         add_active: 'Add Activity',

+ 1 - 0
src/context/locales/zh.js

@@ -870,6 +870,7 @@ export default {
         guide_current_scenario: '当前正处于{{scenario}}日程内',
 
         console_guide_tip:'完成我的日程设置,开启规律的健康生活 👆',
+        add_mini_guide_tip:'添加到我的小程序,下次使用更方便 👆',
 
         add_meal: '添加餐次',
         add_active: '添加活动',

+ 3 - 3
src/features/health/HistoryItem.tsx

@@ -50,8 +50,8 @@ export default function HistoryItem(props: {
 
     function getTitle(item) {
         if (item.title) return item.title
-        if (item.moment) {
-            return item.moment.title
+        if (item.moments) {
+            return item.moments[0].title
         }
         // if (health.mode == 'FAST') {
         //     return '开始断食'
@@ -188,7 +188,7 @@ export default function HistoryItem(props: {
                     props.data.events.map((item, index) => {
                         return <Text key={index}>
                             <Text className="history_item_title">{item.time && dayjs(item.time.timestamp).format('HH:mm')}
-                                <Text style={{ fontSize: 9, lineHeight: '20px', fontWeight: 'bold', verticalAlign: 'text-top' }}>{dayTag(index)}</Text>
+                                <Text style={{ fontSize: 9, lineHeight: '20px', fontWeight: 'bold', verticalAlign: 'text-top' }}>{dayTag(index)} </Text>
                                 {getTitle(item)} </Text>
                             {
                                 item.moments && item.moments.map((moment, i) => {

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

@@ -229,16 +229,7 @@
   flex: 1;
 }
 
-.guide_tip{
-  height: 80px;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  background-color: #0080FF1A;
-  color: #0080FF;
-  width: 750px;
-  position: relative;
-}
+
 
 /*
 rn呼吸灯效果

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

@@ -259,6 +259,9 @@ export default function MainConsole(props: { type: WindowType }) {
         if (timeline.real) {
             return MainColorType.g03
         }
+        if (timeline.target.timestamp<new Date().getTime()){
+            return MainColorType.error
+        }
         return color
     }
 

+ 1 - 1
src/pages/account/Journal.scss

@@ -23,7 +23,7 @@
     display: flex;
     flex-direction: row;
     padding-top: 40px;
-    padding-bottom: 44px;
+    padding-bottom: 28px;
     position: relative;
     background-color: #fff;
 }

+ 46 - 26
src/pages/account/Journal.tsx

@@ -44,12 +44,54 @@ export default function Journal() {
         if (item.title) {
             return item.title;
         }
-        if (item.moment) {
-            return item.moment.title
+        if (item.moments) {
+            return item.moments[0].title
         }
         return ''
     }
 
+    function journalItem(window, index) {
+        var array: any = [];
+        window.events.map(event => {
+            event.moments && event.moments.map(moment => {
+                if (moment.media && moment.media.length > 0) {
+                    moment.media.map(media => {
+                        array.push(media.url)
+                    })
+                }
+            })
+        })
+        return <View style={{ flex: 1, display: 'flex', flexDirection: 'row', marginBottom: rpxToPx(16),overflow:'hidden' }} key={index}>
+            {
+                array.length > 0 && <JournalCover imgs={array} />
+            }
+            <View style={{
+                display: 'flex',
+                flexDirection: 'column',
+                flex: 1,
+                overflow:'hidden',
+                backgroundColor: array.length == 0 ? '#f5f5f5' : 'transparent',
+                padding: array.length == 0 ? rpxToPx(20) : 0,
+                marginRight: rpxToPx(40)
+            }}>
+                {
+
+                    window.events.map((item2, index2) => {
+                        return <Text className="line1" style={{width:array.length>0?rpxToPx(370):rpxToPx(532)}} key={index2 * 1000}>
+                            <Text className="history_item_title" style={{ color: '#000' }}>{dayjs(item2.time.timestamp).format('HH:mm')} {getTitle(item2)} </Text>
+                            {
+                                item2.moments && item2.moments.length>0 && item2.moments[0].description && <Text className="history_item_desc">{item2.moments[0].description}</Text>
+                            }
+                        </Text>
+                    })
+                }
+
+
+
+            </View>
+        </View>
+    }
+
 
     return <View style={{ display: 'flex', flexDirection: 'column' }}>
         <NewHeader type={NewHeaderType.left} title="Journal" />
@@ -59,34 +101,12 @@ export default function Journal() {
                     jumpPage('/pages/account/JournalDetail?detail=' + JSON.stringify(item))
                 }}>
                     <Text className="album_date">{(item.date + '').substring(6, 9)}</Text>
-                    {
-                        item.imgs.length > 0 && <JournalCover imgs={item.imgs} />
-                    }
-
-                    <View style={{
-                        display: 'flex',
-                        flexDirection: 'column',
-                        flex: 1,
-                        backgroundColor: item.imgs.length == 0 ? '#f5f5f5' : 'transparent',
-                        padding: item.imgs.length == 0 ? rpxToPx(20) : 0,
-                        marginRight: rpxToPx(40)
-                    }}>
+                    <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
                         {
                             item.windows.map((window, i) => {
-                                return <View key={i * 400} style={{ display: 'flex', flexDirection: 'column' }}>{
-                                    window.events.map((item2, index2) => {
-                                        return <Text key={index2 * 1000}>
-                                            <Text className="history_item_title" style={{color:'#000'}}>{dayjs(item2.time.timestamp).format('HH:mm')} {getTitle(item2)} </Text>
-                                            {
-                                                item2.moment && item2.moment.description && <Text className="history_item_desc">{item2.moment.description}</Text>
-                                            }
-                                        </Text>
-                                    })
-                                }</View>
-
+                                return journalItem(window, i)
                             })
                         }
-
                     </View>
                     <View className="border_footer_line" />
                 </View>

+ 42 - 1
src/pages/clock/ClockNew.tsx

@@ -5,7 +5,7 @@ import MainDayNightCard from "@/features/health/MainDayNightCard";
 import MainFastEatCard from "@/features/health/MainFastEatCard";
 import MainSleepActiveCard from "@/features/health/MainSleepActiveCard";
 import TabBar from "@/components/navigation/TabBar";
-import { rpxToPx } from "@/utils/tools";
+import { compareVersion, rpxToPx } from "@/utils/tools";
 import MainSwiper from "@/features/health/MainSwiper";
 import MainConsole from "@/features/health/MainConsole";
 import MainHistory from "@/features/health/MainHistory";
@@ -24,6 +24,8 @@ import StatusIndicator, { StatusType } from "@/_health/base/status_indicator";
 import { useTranslation } from "react-i18next";
 import StickyDateList from "@/_health/components/sticky_date_list";
 import NoData from "@/_health/components/no_data";
+import Taro from "@tarojs/taro";
+import { IconClose } from "@/components/basic/Icons";
 
 export default function ClockNew() {
     const [count, setCount] = useState(0)
@@ -35,6 +37,8 @@ export default function ClockNew() {
     const [type, setType] = useState(WindowType.day)
     const [showCalendar, setShowCalendar] = useState(false)
     const [showSection, setShowSection] = useState(false)
+    const [needShowAddTip, setNeedShowAddTip] = useState(false)
+    const [reminderAdd,setReminderAdd] = useState(true)
     const [showDate, setShowDate] = useState(false)
     const [date, setDate] = useState('')
     const [isPulling, setIsPulling] = useState(false)
@@ -84,9 +88,11 @@ export default function ClockNew() {
     global.refreshWindow = () => {
         getWindows();
         archived();
+        
     }
 
     function getWindows() {
+        checkAddToMini()
         windows().then(res => {
             setLoaded(true)
             setShowRetry(false)
@@ -157,6 +163,24 @@ export default function ClockNew() {
         }
     }
 
+    function checkAddToMini() {
+        if (process.env.TARO_ENV == 'weapp' && user.isLogin && reminderAdd) {
+            const version = Taro.getAppBaseInfo().SDKVersion
+            if (compareVersion(version, '2.30.3') >= 0) {
+                wx.checkIsAddedToMyMiniProgram({
+                    success: (res) => {
+                        if (!res.added) {
+                            setNeedShowAddTip(true)
+                        }
+                    },
+                    fail: (e) => {
+                    }
+                });
+            }
+        }
+
+    }
+
     function tapScroll(index) {
         setScrollLeft(rpxToPx(750) * index)
     }
@@ -216,6 +240,23 @@ export default function ClockNew() {
             }}
         >
             <View style={{ display: 'flex', flexDirection: 'column' }}>
+                {
+                    needShowAddTip && reminderAdd && <View className="guide_tip h26">{t('health.add_mini_guide_tip')}
+                        <NewButton type={NewButtonType.img} btnStyle={{
+                            position: 'absolute',
+                            right: 0,
+                            top: 0,
+                            bottom: 0,
+                            width: rpxToPx(92)
+                        }} onClick={() => {
+                            setReminderAdd(false)
+                            console.log('ssssss')
+                        }}>
+                            <IconClose color={MainColorType.g01} width={rpxToPx(32)} height={rpxToPx(32)} />
+                        </NewButton>
+        
+                    </View>
+                }
                 <MainSwiper count={count} pageChanged={pageChanged} typeChanged={typeChanged} />
                 <MainConsole type={type} />