Leon 1 سال پیش
والد
کامیت
0aabbba9a4

+ 4 - 3
src/_health/components/console_cell.tsx

@@ -13,7 +13,8 @@ export default function ConsoleCell(props: {
     onClick?: any,
     showLine: boolean,
     fullLine: boolean,
-    key?: any
+    key?: any,
+    moveCell?:boolean
 }) {
     return <Cell disable={props.disable} onClick={props.onClick} key={props.key}>
         <View className="timeline_item"
@@ -26,11 +27,11 @@ export default function ConsoleCell(props: {
                     props.status
                 }
                 {
-                    props.title ? <View className='h34' style={{ lineHeight: rpxToPx(46) + 'px',marginLeft:rpxToPx(56) }}>{props.title}</View> : props.titleComponent
+                    props.title ? <View className='h34' style={{ lineHeight: rpxToPx(46) + 'px',marginLeft:props.moveCell?rpxToPx(32):rpxToPx(56) }}>{props.title}</View> : props.titleComponent
                 }
 
                 {
-                    props.description && <Text className='h24 timeline_desc g02' style={{marginLeft:rpxToPx(56)}}>{props.description}{props.subDesc}</Text>
+                    props.description && <Text className='h24 timeline_desc g02' style={{marginLeft:props.moveCell?rpxToPx(32):rpxToPx(56)}}>{props.description}{props.subDesc}</Text>
                 }
                 <View style={{
                     height: props.description ? rpxToPx(28) : rpxToPx(54), flexShrink: 0,

+ 40 - 6
src/_health/components/fast_sleep_card.tsx

@@ -71,7 +71,24 @@ export default function FastSleepCard(props: { step: number, data: any }) {
 
 
     function target1BigRing() {
-        const { fast, sleep } = props.data
+        const { fast, sleep, status } = props.data
+        if (status == 'OG2_NO1') {
+            var fastStarttoSleepDuration = 0
+            var time1 = sleep.period.start_time
+            var time2 = fast.period.start_time
+
+            var t1 = parseInt(time1.split(':')[0]) * 60 + parseInt(time1.split(':')[1])
+            var t2 = parseInt(time2.split(':')[0]) * 60 + parseInt(time2.split(':')[1])
+            fastStarttoSleepDuration = t1 - t2 > 0 ? (t1 - t2) * 60 * 1000 : (t1 - t2) * 60 * 1000 + 24 * 3600 * 1000
+
+            return {
+                color: MainColorType.fastLight,
+                startArc: getStartArc(fast.target.start_timestamp),
+                durationArc: getDurationArc(fast.target.start_timestamp, fast.target.start_timestamp + fastStarttoSleepDuration)
+            }
+            // var now = new Date().getTime()
+            // return TimeFormatter.calculateTimeDifference(now, now + fastStarttoSleepDuration)
+        }
         return {
             color: MainColorType.fastLight,
             startArc: getStartArc(fast.target.start_timestamp),
@@ -97,6 +114,23 @@ export default function FastSleepCard(props: { step: number, data: any }) {
 
     function target3BigRing() {
         const { fast, sleep, status } = props.data
+        if (status == 'OG2_NO1') {
+            var time1 = fast.period.end_time
+            var time2 = sleep.period.end_time
+            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
+
+            return {
+                color: MainColorType.fastLight,
+                startArc: getStartArc(fast.target.end_timestamp - duration),
+                durationArc: getDurationArc(fast.target.end_timestamp - duration, fast.target.end_timestamp)
+            }
+
+        }
+
         return {
             color: MainColorType.fastLight,
             startArc: getStartArc(status == 'OG3' ? sleep.real.end_timestamp : sleep.target.end_timestamp),
@@ -316,7 +350,7 @@ export default function FastSleepCard(props: { step: number, data: any }) {
                 {
                     title = t('health.stage1')
                     var type = StatusType.normal
-                    var color:any = MainColorType.fast
+                    var color: any = MainColorType.fast
                     var img: any = null
                     if (status == 'WFS') {
                         type = StatusType.img
@@ -373,11 +407,11 @@ export default function FastSleepCard(props: { step: number, data: any }) {
                     // }
                     var type = StatusType.normal
                     var img: any = null
-                    var color:any = MainColorType.sleep
-                    if (status == 'WFS'||status == 'OG1') {
+                    var color: any = MainColorType.sleep
+                    if (status == 'WFS' || status == 'OG1') {
                         type = StatusType.img
                         img = <IconCircle width={rpxToPx(26)} color={MainColorType.sleep} />
-                        color='transparent'
+                        color = 'transparent'
                     }
                     else if (status == 'OG2') {
                         type = StatusType.ing
@@ -439,7 +473,7 @@ export default function FastSleepCard(props: { step: number, data: any }) {
                         opacity: hide ? 0 : 1
                     }}>
                         <StatusIndicator type={type}
-                            color={status == 'OG3'?MainColorType.fast:'transparent'}
+                            color={status == 'OG3' ? MainColorType.fast : 'transparent'}
                             text={title}
                             fontColor={MainColorType.g01}
                             fontSize={rpxToPx(20)}

+ 11 - 5
src/_health/pages/add_moment.tsx

@@ -100,12 +100,9 @@ export default function AddMoment() {
             if (moment.media.length > 0) {
                 setImgUrl(moment.media[0].url)
             }
-            debugger
         }
-    }, [])
-
-    useLoad(() => {
-        if (!router.params.edit)
+        else {
+            debugger
             Taro.enableAlertBeforeUnload({
                 message: 'hhh',
                 success(res) {
@@ -118,6 +115,11 @@ export default function AddMoment() {
 
                 },
             })
+        }
+    }, [])
+
+    useLoad(() => {
+
     })
 
     useUnload(() => {
@@ -289,6 +291,10 @@ export default function AddMoment() {
             params.duration = durationT * 60 * 1000
         }
 
+        Taro.disableAlertBeforeUnload({
+
+        })
+
 
         params.extra = {
             set_time: global.set_time ? global.set_time : new Date().getTime(),

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

@@ -33,7 +33,7 @@ if (process.env.TARO_ENV == 'rn') {
     useNavigation = require("@react-navigation/native").useNavigation
 }
 export default function GuideActive() {
-    const systemInfo: any = Taro.getSystemInfoSync();
+    const systemInfo: any = Taro.getWindowInfo();
     const navigationBarHeight = systemInfo.statusBarHeight + 44;
     const user = useSelector((state: any) => state.user);
     const health = useSelector((state: any) => state.health);

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

@@ -33,7 +33,7 @@ if (process.env.TARO_ENV == 'rn') {
 }
 
 export default function GuideEat() {
-    const systemInfo: any = Taro.getSystemInfoSync();
+    const systemInfo: any = Taro.getWindowInfo();
     const navigationBarHeight = systemInfo.statusBarHeight + 44;
     const user = useSelector((state: any) => state.user);
     const health = useSelector((state: any) => state.health);

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

@@ -21,7 +21,7 @@ import CellFooterText from "../base/cell_footer_text";
 import Taro from "@tarojs/taro";
 
 export default function GuideFast() {
-    const systemInfo: any = Taro.getSystemInfoSync();
+    const systemInfo: any = Taro.getWindowInfo();
     const navigationBarHeight = systemInfo.statusBarHeight + 44;
     const user = useSelector((state: any) => state.user);
 

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

@@ -21,7 +21,7 @@ import CellFooterText from "../base/cell_footer_text";
 import Taro from "@tarojs/taro";
 
 export default function GuideFull() {
-    const systemInfo: any = Taro.getSystemInfoSync();
+    const systemInfo: any = Taro.getWindowInfo();
     const navigationBarHeight = systemInfo.statusBarHeight + 44;
     const user = useSelector((state: any) => state.user);
 

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

@@ -23,7 +23,7 @@ import { StatusType } from "../base/status_indicator";
 import Taro from "@tarojs/taro";
 
 export default function GuideSleep() {
-    const systemInfo: any = Taro.getSystemInfoSync();
+    const systemInfo: any = Taro.getWindowInfo();
     const navigationBarHeight = systemInfo.statusBarHeight + 44;
     const user = useSelector((state: any) => state.user);
     const health = useSelector((state: any) => state.health);

+ 144 - 46
src/_health/pages/log_time.tsx

@@ -52,8 +52,9 @@ export default function LogTime() {
     const type = router.params.type
     const [data, setData] = useState<any>(null)
     const health = useSelector((state: any) => state.health);
-    const [showGoal, setShowGoal] = useState(false)
+    const [showGoal, setShowGoal] = useState(router.params.longfast)
     const tapIndex = router.params.index ?? 0
+    const [longDuration, setLongDuration] = useState(24)
 
     const [expandIndex, setExpandIndex] = useState(router.params.initIndex ? router.params.initIndex : tapIndex)
     const [chooseDate, setChooseDate] = useState(false)
@@ -121,6 +122,17 @@ export default function LogTime() {
 
     }
 
+    function getLongDuration() {
+        var day = Math.floor(longDuration / 24)
+        var hour = longDuration % 24
+        var str = ''
+        if (day > 0)
+            str = day + '天'
+        if (hour > 0)
+            str += hour + '小时'
+        return str
+    }
+
     function initDatas(res = data) {
         const { fast, sleep } = res
 
@@ -139,6 +151,11 @@ export default function LogTime() {
                     title: isStart ? sleep.timeline[0].title : sleep.timeline[1].title
                 });
             }
+            if (router.params.longfast) {
+                Taro.setNavigationBarTitle({
+                    title: t('health.long_fast')
+                })
+            }
             list.push({
                 event_id: timeline.event_id,
                 schedule_id: timeline.schedule_id,
@@ -298,6 +315,19 @@ export default function LogTime() {
                 params.duration = isFast ? data.fast.target.duration : data.sleep.target.duration
             }
             list.push(params)
+
+            if (router.params.longfast && isStart) {
+                list = [{
+                    schedule_id: health.long_fast.timeline[0].schedule_id,
+                    date: dayjs(timestamp).format('YYYYMMDD'),
+                    timestamp: timestamp,
+                    extra: {
+                        long_fast_goal: longDuration * 60,
+                        set_time: global.set_time ? global.set_time : new Date().getTime(),
+                        confirm_time: new Date().getTime()
+                    }
+                }]
+            }
         }
         else {
             if (type == 'home') {
@@ -409,6 +439,10 @@ export default function LogTime() {
                         global.refreshHistory()
                     if (global.refreshFastSleep)
                         global.refreshFastSleep()
+
+                    if (global.refreshLongFast) {
+                        global.refreshLongFast()
+                    }
                     Taro.redirectTo({
                         url: './post_result?data=' + JSON.stringify(res)
                     })
@@ -433,6 +467,21 @@ export default function LogTime() {
                     })
                     return
                 }
+                if ((res as any).warn_code == 'SAVE_AS_IF') {
+                    showAlert({
+                        title: 'Saving as Intermittent Fasting',
+                        content: 'Fasting that lasts fewer than 24 hours will be saved as Intermittent Fasting.',
+                        showCancel: true,
+                        cancelText: '取消',
+                        confirmText: '保存',
+                        cancel: () => {
+                        },
+                        confirm: () => {
+                            tapCommit(false, false, (res as any).warn_code)
+                        }
+                    })
+                    return
+                }
                 setErrors((res as any).error_messages)
                 setConflicts((res as any).conflict_schedule_ids)
                 setShowSuccess(true)
@@ -504,7 +553,13 @@ export default function LogTime() {
         var obj = array[0]
         var timestamp = getTimestamp(obj)
         var duration = isFast ? data.fast.target.duration : data.sleep.target.duration
+        if (router.params.longfast){
+            duration = longDuration*1000*3600
+        }
         var time2 = timestamp + duration
+        if (router.params.longfast){
+            return 'Expect to end fast at ' + dayjs(time2).format('MM-DD HH:mm')
+        }
         var strTime = TimeFormatter.dayjsFormat(time2, false)
         if (isFast) {
             return 'Expect to end fast at ' + strTime
@@ -691,6 +746,93 @@ export default function LogTime() {
         return <View style={{ position: 'relative' }}></View>
     }
 
+    function goalCard() {
+        if (isSingle && isStart && showGoal) {
+            if (router.params.longfast) {
+                return <Card>
+                    <View style={{ position: 'relative' }}>
+                        <View className="card_header" style={{ justifyContent: 'space-between' }}>
+                            <View className="h34" style={{ marginLeft: rpxToPx(12) }}>LongFast Goal</View>
+                            <NewButton
+                                type={expandIndex == -1 ? NewButtonType.alpha : NewButtonType.gray}
+                                color={isFast ? MainColorType.fast : MainColorType.sleep}
+                                height={rpxToPx(84)}
+                                title={getLongDuration()}
+                                fontNormal
+                                onClick={() => { setExpandIndex(-1) }}
+                            />
+                            {/* </View> */}
+                        </View>
+                        {
+                            expandIndex == -1 && <View style={{
+                                display: 'flex',
+                                flexDirection: 'column',
+                                alignItems: 'center'
+                            }}>
+                                <NewDurationPicker color={MainColorType.fast}
+                                    type={DurationPickerType.long}
+                                    value={longDuration}
+                                    onChange={(e) => {
+                                        setLongDuration(e)
+                                    }}
+                                />
+                            </View>
+                        }
+
+                    </View>
+                </Card>
+            }
+            else {
+                return <Card>
+                    <View style={{ position: 'relative' }}>
+                        <View className="card_header" style={{ justifyContent: 'space-between' }}>
+                            <View className="h34" style={{ marginLeft: rpxToPx(12) }}>{isFast ? 'Fast Goal' : 'Sleep Goal'}</View>
+                            {/* <View style={{
+                            borderColor: expandIndex == -1 ? isFast ? MainColorType.fast : MainColorType.sleep : 'transparent',
+                            borderWidth: rpxToPx(2),
+                            borderRadius: rpxToPx(88 / 4),
+                            borderStyle: 'solid'
+                        }}> */}
+                            <NewButton
+                                type={expandIndex == -1 ? NewButtonType.alpha : NewButtonType.gray}
+                                color={isFast ? MainColorType.fast : MainColorType.sleep}
+                                height={rpxToPx(84)}
+                                title={durationTime()}
+                                fontNormal
+                                onClick={() => { setExpandIndex(-1) }}
+                            />
+                            {/* </View> */}
+                        </View>
+                        {
+                            expandIndex == -1 && <View style={{
+                                display: 'flex',
+                                flexDirection: 'column',
+                                alignItems: 'center'
+                            }}>
+                                <NewDurationPicker
+                                    type={DurationPickerType.normal}
+                                    value={isFast ? data.fast.target.duration : data.sleep.target.duration}
+                                    onChange={e => {
+                                        var temp = JSON.parse(JSON.stringify(data))
+                                        if (isFast) {
+                                            temp.fast.target.duration = e
+                                        }
+                                        else {
+                                            temp.sleep.target.duration = e
+                                        }
+                                        setData(temp)
+                                    }}
+                                    color={isFast ? MainColorType.fast : MainColorType.sleep} />
+                            </View>
+                        }
+
+                    </View>
+                </Card>
+            }
+        }
+        return <View />
+    }
+
     if (!loaded) return <View />
 
     return <View className="page_container">
@@ -738,51 +880,7 @@ export default function LogTime() {
             </View>
         }
         {
-            isSingle && isStart && showGoal && <Card>
-                <View style={{ position: 'relative' }}>
-                    <View className="card_header" style={{ justifyContent: 'space-between' }}>
-                        <View className="h34" style={{ marginLeft: rpxToPx(12) }}>{isFast ? 'Fast Goal' : 'Sleep Goal'}</View>
-                        {/* <View style={{
-                            borderColor: expandIndex == -1 ? isFast ? MainColorType.fast : MainColorType.sleep : 'transparent',
-                            borderWidth: rpxToPx(2),
-                            borderRadius: rpxToPx(88 / 4),
-                            borderStyle: 'solid'
-                        }}> */}
-                        <NewButton
-                            type={expandIndex == -1 ? NewButtonType.alpha : NewButtonType.gray}
-                            color={isFast ? MainColorType.fast : MainColorType.sleep}
-                            height={rpxToPx(84)}
-                            title={durationTime()}
-                            fontNormal
-                            onClick={() => { setExpandIndex(-1) }}
-                        />
-                        {/* </View> */}
-                    </View>
-                    {
-                        expandIndex == -1 && <View style={{
-                            display: 'flex',
-                            flexDirection: 'column',
-                            alignItems: 'center'
-                        }}>
-                            <NewDurationPicker
-                                type={DurationPickerType.normal}
-                                value={isFast ? data.fast.target.duration : data.sleep.target.duration}
-                                onChange={e => {
-                                    var temp = JSON.parse(JSON.stringify(data))
-                                    if (isFast) {
-                                        temp.fast.target.duration = e
-                                    }
-                                    else {
-                                        temp.sleep.target.duration = e
-                                    }
-                                    setData(temp)
-                                }}
-                                color={isFast ? MainColorType.fast : MainColorType.sleep} />
-                        </View>
-                    }
-
-                </View>
-            </Card>
+            goalCard()
         }
         {
             isSingle && isStart && showGoal && <View className="h24 g02" style={{

+ 21 - 8
src/_health/pages/long_fast.tsx

@@ -24,6 +24,7 @@ import NewTimePicker from "../base/new_timepicker";
 import StickyDateList from "../components/sticky_date_list";
 
 let useActionSheet;
+let pauseTime = false;
 if (process.env.TARO_ENV == 'rn') {
     useActionSheet = require('@expo/react-native-action-sheet').useActionSheet
 }
@@ -35,6 +36,7 @@ export default function LongFast() {
     const [editDuration, setEditDuration] = useState(false)
     const [showPicker, setShowPicker] = useState(false)
     const [duration, setDuration] = useState(0)
+    
     const [time, setTime] = useState(dayjs().format('HH:mm'))
     const { t } = useTranslation()
     const [isPulling, setIsPulling] = useState(false)
@@ -49,7 +51,8 @@ export default function LongFast() {
 
     useEffect(() => {
         var timer = setInterval(() => {
-            setCount(count => count + 1)
+            if (!pauseTime)
+                setCount(count => count + 1)
         }, 1000)
 
         setDuration(health.long_fast.extra.long_fast_goal / 60)
@@ -59,6 +62,10 @@ export default function LongFast() {
         }
     }, [])
 
+    useEffect(()=>{
+        pauseTime = editDuration
+    },[editDuration])
+
     function tapStart() {
         const fast = getScenario(health.windows, 'FAST')
         if (fast.status == 'OG') {
@@ -77,7 +84,8 @@ export default function LongFast() {
             })
         }
         else {
-            jumpPage('./long_fast_setting')
+            jumpPage('./log_time?single=1&is_start=1&index=0&longfast=1&window=FAST')
+            // jumpPage('./long_fast_setting')
         }
     }
 
@@ -90,7 +98,8 @@ export default function LongFast() {
 
     function tapEnd() {
         // save()
-        setShowPicker(true)
+        // setShowPicker(true)
+        jumpPage('./log_time?single=1&is_start=0&index=3&longfast=1&window=FAST')
     }
 
     function tapMore() {
@@ -198,11 +207,11 @@ export default function LongFast() {
         // return str
     }
 
-    function getDurationStr(){
-        var days = Math.floor(duration/24)
-        var hours = duration%24
+    function getDurationStr() {
+        var days = Math.floor(duration / 24)
+        var hours = duration % 24
         var str = `${days} 天`
-        if (hours>0){
+        if (hours > 0) {
             str = `${str} ${hours} 小时`
         }
         return str
@@ -229,6 +238,10 @@ export default function LongFast() {
         return <View />
     }
 
+    global.refreshLongFast = ()=>{
+        (historyRef.current as any).refresh()
+    }
+
     return <StickyDateList
         isPulling={isPulling}
         showDate={showDate}
@@ -249,7 +262,7 @@ export default function LongFast() {
         }}
     ><View className="page_container">
             <NewHeader type={NewHeaderType.left_subtitle}
-                title="Long Fast "
+                title={t('health.long_fast')}
                 subtitle="Prolonged Fasting beyond 24 hours"
             />
             <Card>

+ 45 - 6
src/_health/pages/move.tsx

@@ -248,6 +248,7 @@ export default function Move() {
         })
 
         thirdPartRequest(RequestType.RequestTypeWXRunData).then(res => {
+            console.log(res)
             uploadActiveMoves({
                 wechat_run: {
                     encryptedData: (res as any).encryptedData,
@@ -777,12 +778,50 @@ export default function Move() {
         jumpPage('./move_detail?id=' + item.id)
     }
 
-    function historyDate(){
-        return '22'
+    function historyDate(item, index) {
+        if (index == 0) {
+            if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
+                return '今天'
+            }
+            if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
+                return '昨天'
+            }
+            return dayjs(item.timestamp).format('DD')
+        }
+        if (dayjs(item.timestamp).format('MM-DD') ==
+            dayjs(list[index - 1].timestamp).format('MM-DD')) {
+            return ''
+        }
+        if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
+            return '今天'
+        }
+        if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
+            return '昨天'
+        }
+        return dayjs(item.timestamp).format('DD')
     }
 
-    function historyMonth(){
-        return 'May'
+    function historyMonth(item, index) {
+        if (index == 0) {
+            if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
+                return ''
+            }
+            if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
+                return ''
+            }
+            return dayjs(item.timestamp).format('MMM')
+        }
+        if (dayjs(item.timestamp).format('MM-DD') ==
+            dayjs(list[index - 1].timestamp).format('MM-DD')) {
+            return ''
+        }
+        if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
+            return ''
+        }
+        if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
+            return ''
+        }
+        return dayjs(item.timestamp).format('MMM')
     }
 
     if (!loaded || !loadAuth) return <View />
@@ -821,8 +860,8 @@ export default function Move() {
                             return <View key={index} id={`history-${index}`} className="history_item" onClick={() => goDetail(item)}>
                                 {/* <Text className="history_item_date">{(item.date + '').substring(6, 8)}</Text> */}
                                 <View className="cell_date" >
-                                    <View className="h42 bold" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate()}</View>
-                                    <View className="h24 bold" style={{ marginLeft: rpxToPx(6), marginTop: rpxToPx(11), lineHeight: rpxToPx(49) + 'px' }}>{historyMonth()}</View>
+                                    <View className="h42 bold" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate(item,index)}</View>
+                                    <View className="h24 bold" style={{ marginLeft: rpxToPx(6), marginTop: rpxToPx(11), lineHeight: rpxToPx(49) + 'px' }}>{historyMonth(item,index)}</View>
                                 </View>
                                 <View className="history_item_detail_bg">
                                     <IconWalk width={rpxToPx(32)} color={MainColorType.active} />

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

@@ -150,6 +150,7 @@ export default function MoveSchedule() {
                 open = (open + '').padStart(2, '0')
                 if (item.status != 'WFS') return <View key={index} />
                 return <ConsoleCell key={index}
+                    moveCell
                     status={<StatusIndicator type={StatusType.normal}
                         color={MainColorType.active}
                         text={'WAKING HOUR ' + (index + 1)} />}

+ 3 - 1
src/_health/pages/move_setting_time.tsx

@@ -39,6 +39,7 @@ export default function MoveSettingTime() {
         {
             detail.schedules.map((item, index) => {
                 return <ConsoleCell key={index}
+                    moveCell
                     status={<StatusIndicator
                         type={StatusType.normal}
                         text={'WALKING HOUR ' + (index + 1)}
@@ -53,11 +54,12 @@ export default function MoveSettingTime() {
                     fullLine={false}
                     description={`${item.time}-${item.end_time}`}
                     title={selIndex != index ? `Hit ${item.goal} Steps` : null}
-                    titleComponent={selIndex == index ? <Input className='item_name h34' style={{ flex: 1,  height: rpxToPx(46) }}
+                    titleComponent={selIndex == index ? <Input className='item_name h34' style={{ flex: 1, height: rpxToPx(46),marginLeft:rpxToPx(32) }}
                         value={item.goal}
                         autoFocus={true}
                         focus={true}
                         type="number"
+                        cursor={item.goal.length}
                         onBlur={() => {
                             setSelIndex(-1)
                             createSchedule({

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

@@ -252,7 +252,7 @@ export default function SchedulesEdit() {
         return <View />
     }
     return <View className='schedule_list_bg'>
-        <ScrollView enableFlex style={{ height: Taro.getSystemInfoSync().screenHeight - 220 }} scrollY>
+        <ScrollView enableFlex style={{ height: Taro.getWindowInfo().screenHeight - 220 }} scrollY>
             <NewHeader title="日程设置" type={NewHeaderType.left} />
             <View style={{ display: 'flex', flexDirection: 'column' }}>
                 {

+ 119 - 19
src/_health/pages/timeline_detail.tsx

@@ -8,7 +8,7 @@ import dayjs from "dayjs";
 import { getThemeColor } from "@/features/health/hooks/health_hooks";
 import { baseUrl } from "@/services/http/api";
 import { checkAuthorized } from "@/utils/check_authorized";
-import { createMoment, delEvents, getEvents } from "@/services/health";
+import { createMoment, delEvents, delRecord, getEvents, getRecordDetail } from "@/services/health";
 import NewButton, { NewButtonType } from "../base/new_button";
 import { IconClose } from "@/components/basic/Icons";
 import { rpxToPx } from "@/utils/tools";
@@ -37,6 +37,7 @@ export default function TimelineDetail() {
     const health = useSelector((state: any) => state.health);
     const user = useSelector((state: any) => state.user);
     const [list, setList] = useState<any>([])
+    const [history, setHistory] = useState<any>([])
     const [detail, setDetail] = useState<any>(null)
     const [desc, setDesc] = useState('')
     const [imgUrl, setImgUrl] = useState('')
@@ -64,7 +65,7 @@ export default function TimelineDetail() {
         router = useRouter()
     }
 
-    const { schedule_id, event_id } = router.params
+    const { schedule_id, event_id, window_id } = router.params
 
     useEffect(() => {
         Taro.setNavigationBarColor({
@@ -95,12 +96,27 @@ export default function TimelineDetail() {
     }
 
     function getDatas() {
-        getEvents(event_id).then(res => {
-            setLoaded(true)
-            setDetail(res)
-            setList((res as any).moments)
-            setPublish((res as any).publish)
-        })
+        if (router.params.type == 'recent') {
+            var params = {
+                op_page: 'FAST_WITH_SLEEP'
+            }
+            getRecordDetail(window_id, router.params.isFastsleep?params:null).then(res => {
+                setLoaded(true)
+                setDetail(res)
+                setHistory((res as any).events)
+                // setList((res as any).moments)
+                // setPublish((res as any).publish)
+            })
+        }
+        else {
+            getEvents(event_id).then(res => {
+                setLoaded(true)
+                setDetail(res)
+                setList((res as any).moments)
+                setPublish((res as any).publish)
+            })
+        }
+
     }
 
     function addImage(isCamera: boolean) {
@@ -227,13 +243,14 @@ export default function TimelineDetail() {
     }
 
     function mediaCount() {
-        let count = 0;
-        list && list.map(moment => {
-            moment.media.map((obj) => {
-                count++
-            })
-        })
-        return count;
+        // let count = 0;
+        // list && list.map(moment => {
+        //     moment.media.map((obj) => {
+        //         count++
+        //     })
+        // })
+        // return count;
+        return imgList().length;
     }
 
     function imgList() {
@@ -243,6 +260,14 @@ export default function TimelineDetail() {
                 array.push(obj.url)
             })
         })
+
+        history && history.map(item => {
+            item.moments && item.moments.map(moment => {
+                moment.media && moment.media.map((obj) => {
+                    array.push(obj.url)
+                })
+            })
+        })
         return array;
     }
 
@@ -268,7 +293,34 @@ export default function TimelineDetail() {
         })
     }
 
+    function delHistory(){
+        showAlert({
+            title: '删除',
+            content: '确认删除此记录吗?',
+            showCancel: true,
+            confirm: () => {
+                delRecord(window_id).then(res => {
+                    global.refreshWindow()
+                    global.refreshHistory()
+                })
+            }
+        })
+    }
+
     function tapMore() {
+        if (window_id) {
+            showActionSheet({
+                showActionSheetWithOptions: showActionSheetWithOptions,
+                title: t('health.more_actions'),
+                itemList: ['删除'],
+                success: (res) => {
+                    if (res == 0) {
+                        delHistory()
+                    }
+                }
+            })
+            return
+        }
         var list: any = []
         if (health.mode != 'ACTIVE' && health.mode != 'EAT') {
             list = ['删除']
@@ -292,6 +344,26 @@ export default function TimelineDetail() {
 
     }
 
+    function dayTag(obj) {
+        var begin = history[0].time.timestamp
+        // if (history[0].moments) {
+        //     begin = history[0].moments[0].time.timestamp
+        // }
+
+        var end = obj.time.timestamp
+
+        const date1 = dayjs(begin);
+        const date2 = dayjs(end);
+
+        // 获取日期部分(去掉时间)
+        const startDate = date1.startOf('day');
+        const endDate = date2.startOf('day');
+        const days = endDate.diff(startDate, 'day')
+        if (days > 0)
+            return '+' + days;
+        return ''
+    }
+
     if (!loaded) return <View />
 
     return <View style={{ display: 'flex', flex: 1, flexDirection: 'column' }}>
@@ -303,7 +375,7 @@ export default function TimelineDetail() {
             <View className="detail_header_content">
                 <Text className="detail_nickname">{user.nickname}</Text>
                 {
-                    (detail.scenario != 'MEAL' && detail.scenario != 'ACTIVITY') &&
+                    !window_id && (detail.scenario != 'MEAL' && detail.scenario != 'ACTIVITY') &&
                     <TimeTitleDesc
                         timeObj={detail.time}
                         time={dayjs(detail.time.timestamp).format('HH:mm')}
@@ -311,7 +383,7 @@ export default function TimelineDetail() {
                     />
                 }
                 {
-                    detail.scenario == 'ACTIVITY' && !list &&
+                    !window_id && detail.scenario == 'ACTIVITY' && !list &&
                     <TimeTitleDesc
                         timeObj={detail.time}
                         time={dayjs(detail.time.timestamp).format('HH:mm')}
@@ -330,6 +402,34 @@ export default function TimelineDetail() {
                         </View>
                     })
                 }
+                {
+                    history && history.map((item, index) => {
+                        return <View key={index} style={{ flexDirection: 'column', display: 'flex' }}>
+                            {
+                                item.moments && item.moments.map((moment, j) => {
+                                    return <View key={j * 10} style={{ flexDirection: 'column', display: 'flex' }}>
+                                        <TimeTitleDesc
+                                            timeObj={moment.time}
+                                            time={dayjs(item.time.timestamp).format('HH:mm')}
+                                            title={moment.title ? moment.title : item.title}
+                                            dayTag={dayTag(item)}
+                                            desc={moment.description}
+                                        />
+                                    </View>
+                                })
+                            }
+                            {
+                                !item.moments && <TimeTitleDesc
+                                    timeObj={item.time}
+                                    time={dayjs(item.time.timestamp).format('HH:mm')}
+                                    title={item.title}
+                                    dayTag={dayTag(item)}
+                                    desc=''
+                                />
+                            }
+                        </View>
+                    })
+                }
                 {/* {
                     <View className="media" style={{ marginRight: mediaCount() == 4 ? 80 : 0, marginTop: rpxToPx(24) }}>
                         {
@@ -348,7 +448,7 @@ export default function TimelineDetail() {
                 </View>
                 {
                     publish && <View style={{ display: 'flex', flexDirection: 'row', height: rpxToPx(60), alignItems: 'center', justifyContent: 'space-between' }}>
-                        <Text className="h24 g02">发布于{dayjs(publish.timestamp).format('MM-DD HH:mm')}</Text>
+                        <Text className="h24 g02">{publish.edited ? '编辑于' : '发布于'}{dayjs(publish.timestamp).format('MM-DD HH:mm')}</Text>
                         <NewButton
                             type={NewButtonType.more}
                             onClick={tapMore}
@@ -359,7 +459,7 @@ export default function TimelineDetail() {
         </View>
         <ListFooter />
         {
-            health.mode != 'ACTIVE' && health.mode != 'EAT' && <View className="add_note"><NewButton type={NewButtonType.link} title="写个笔记" onClick={() => {
+            !window_id && health.mode != 'ACTIVE' && health.mode != 'EAT' && <View className="add_note"><NewButton type={NewButtonType.link} title="写个笔记" onClick={() => {
                 timestamp = new Date().getTime()
                 setShowPop(true)
 

+ 1 - 1
src/components/view/Rings.weapp.tsx

@@ -9,7 +9,7 @@ export default function Rings(props: { strokeWidth: number; radius: number; colo
     const color = props.color || 'orange'
     const canvasRef = useRef(null);
     const canvasId = props.canvasId ? 'canvas_' + props.canvasId : 'progress-canvas';
-    const dpr = Taro.getSystemInfoSync().pixelRatio; // 获取设备的像素比
+    const dpr = Taro.getWindowInfo().pixelRatio; // 获取设备的像素比
     const radius = r; // 圆形进度条的半径
     const lineWidth = strokeWidth; // 圆形进度条的线宽
 

+ 6 - 1
src/features/health/HistoryItem.tsx

@@ -17,6 +17,7 @@ import NewButton, { NewButtonType } from "@/_health/base/new_button";
 import TimeTitleDesc from "@/_health/components/time_title_desc";
 import CoverList from "@/_health/components/cover_list";
 import { TimeFormatter } from "@/utils/time_format";
+import { jumpPage } from "../trackTimeDuration/hooks/Common";
 
 export default function HistoryItem(props: {
     data: any,
@@ -234,7 +235,11 @@ export default function HistoryItem(props: {
         return ''
     }
 
-    return <View className="history_item2">
+    function goDetail(){
+        jumpPage(`/_health/pages/timeline_detail?window_id=${props.data.window_id}&fast_type=${props.fast_type}&type=recent&isFastsleep=${props.mode=='FAST,SLEEP'}`)
+    }
+
+    return <View className="history_item2" onClick={goDetail}>
         <View className="cell_date" >
             <View className="h42 bold" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate()}</View>
             <View className="h24 bold" style={{ marginLeft: rpxToPx(6), marginTop: rpxToPx(11), lineHeight: rpxToPx(49) + 'px' }}>{historyMonth()}</View>

+ 1 - 1
src/features/trackTimeDuration/components/Rings.weapp.tsx

@@ -80,7 +80,7 @@ export default function Rings(props: {
     // const color = props.color || 'orange'
     const canvasRef = useRef(null);
     const canvasId = props.canvasId ? 'canvas_' + props.canvasId : 'progress-canvas';
-    const dpr = Taro.getSystemInfoSync().pixelRatio; // 获取设备的像素比
+    const dpr = Taro.getWindowInfo().pixelRatio; // 获取设备的像素比
     const radius = r; // 圆形进度条的半径
     const lineWidth = strokeWidth; // 圆形进度条的线宽
     const time = useSelector((state: any) => state.time);

+ 18 - 18
src/pages/account/Journal.tsx

@@ -184,7 +184,7 @@ export default function Journal() {
         var showDate = false;
         var dateStr2: any = ''
         if (index == 0) {
-            var currentDate = global.language == 'en' ? dayjs(journals[index].publish_timestamp).format('YYYY') : dayjs(journals[index].publish_timestamp).format('YYYY年')
+            var currentDate = global.language == 'en' ? dayjs(journals[index].publish.timestamp).format('YYYY') : dayjs(journals[index].publish.timestamp).format('YYYY年')
             var now = global.language == 'en' ? dayjs().format('YYYY') : dayjs().format('YYYY年')
 
             if (currentDate != now) {
@@ -195,7 +195,7 @@ export default function Journal() {
 
         }
         else {
-            var currentDate = global.language == 'en' ? dayjs(journals[index].publish_timestamp).format('YYYY') : dayjs(journals[index].publish_timestamp).format('YYYY年')
+            var currentDate = global.language == 'en' ? dayjs(journals[index].publish.timestamp).format('YYYY') : dayjs(journals[index].publish.timestamp).format('YYYY年')
             var now = global.language == 'en' ? dayjs().format('YYYY') : dayjs().format('YYYY年')
             if (currentDate != now) {
                 showDate = true
@@ -210,48 +210,48 @@ export default function Journal() {
 
     function historyDate(item, index) {
         if (index == 0) {
-            if (global.language == 'zh' && TimeFormatter.isToday(item.publish_timestamp)) {
+            if (global.language == 'zh' && TimeFormatter.isToday(item.publish.timestamp)) {
                 return '今天'
             }
-            if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish_timestamp)) {
+            if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish.timestamp)) {
                 return '昨天'
             }
-            return dayjs(item.publish_timestamp).format('DD')
+            return dayjs(item.publish.timestamp).format('DD')
         }
-        if (dayjs(item.publish_timestamp).format('MM-DD') ==
-            dayjs(journals[index - 1].publish_timestamp).format('MM-DD')) {
+        if (dayjs(item.publish.timestamp).format('MM-DD') ==
+            dayjs(journals[index - 1].publish.timestamp).format('MM-DD')) {
             return ''
         }
-        if (global.language == 'zh' && TimeFormatter.isToday(item.publish_timestamp)) {
+        if (global.language == 'zh' && TimeFormatter.isToday(item.publish.timestamp)) {
             return '今天'
         }
-        if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish_timestamp)) {
+        if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish.timestamp)) {
             return '昨天'
         }
-        return dayjs(item.publish_timestamp).format('DD')
+        return dayjs(item.publish.timestamp).format('DD')
     }
 
     function historyMonth(item, index) {
         if (index == 0) {
-            if (global.language == 'zh' && TimeFormatter.isToday(item.publish_timestamp)) {
+            if (global.language == 'zh' && TimeFormatter.isToday(item.publish.timestamp)) {
                 return ''
             }
-            if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish_timestamp)) {
+            if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish.timestamp)) {
                 return ''
             }
-            return dayjs(item.publish_timestamp).format('MMM')
+            return dayjs(item.publish.timestamp).format('MMM')
         }
-        if (dayjs(item.publish_timestamp).format('MM-DD') ==
-            dayjs(journals[index - 1].publish_timestamp).format('MM-DD')) {
+        if (dayjs(item.publish.timestamp).format('MM-DD') ==
+            dayjs(journals[index - 1].publish.timestamp).format('MM-DD')) {
             return ''
         }
-        if (global.language == 'zh' && TimeFormatter.isToday(item.publish_timestamp)) {
+        if (global.language == 'zh' && TimeFormatter.isToday(item.publish.timestamp)) {
             return ''
         }
-        if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish_timestamp)) {
+        if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish.timestamp)) {
             return ''
         }
-        return dayjs(item.publish_timestamp).format('MMM')
+        return dayjs(item.publish.timestamp).format('MMM')
     }
 
     return <StickyDateList onRefresherRefresh={() => {

+ 4 - 2
src/pages/account/PhotoWall.tsx

@@ -4,6 +4,7 @@ import Taro, { useRouter } from "@tarojs/taro";
 import { useEffect, useState } from "react";
 import NewTimePicker from "@/_health/base/new_timepicker";
 import { getAlbums } from "@/services/health";
+import ListFooter from "@/_health/components/list_footer";
 
 let useRoute;
 let useNavigation;
@@ -16,7 +17,7 @@ if (process.env.TARO_ENV == 'rn') {
 const scale = '?x-oss-process=image/resize,w_150,limit_0'
 
 export default function PhotoWall() {
-    const screenWidth = Taro.getSystemInfoSync().screenWidth
+    const screenWidth = Taro.getWindowInfo().screenWidth
     const space = 2
     const itemWidth = (screenWidth - space * 2) / 3.0
     const [list, setList] = useState<any>([])
@@ -42,7 +43,7 @@ export default function PhotoWall() {
     function getAlbumsData(str) {
         getAlbums({
             page: 1,
-            limit: 50,
+            limit: 100,
             window: str
         }).then(res => {
             var array: any = [];
@@ -66,5 +67,6 @@ export default function PhotoWall() {
             <View style={{ width: itemWidth, height: itemWidth }} />
             <View style={{ width: itemWidth, height: itemWidth }} />
         </View>
+        <ListFooter noMore={true} />
     </View>
 }

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

@@ -29,7 +29,7 @@ export default function Clock() {
     const user = useSelector((state: any) => state.user);
     const [showCalendar, setShowCalendar] = useState(false)
 
-    const systemInfo: any = Taro.getSystemInfoSync();
+    const systemInfo: any = Taro.getWindowInfo();
     const navigationBarHeight = systemInfo.statusBarHeight + 44;
 
     let navigation;
@@ -48,6 +48,7 @@ export default function Clock() {
     }
 
     useEffect(() => {
+        var aa = Taro.getSystemSetting()
         if (navigation) {
             navigation.setOptions({
                 headerTitle: '',

+ 6 - 6
src/pages/clock/Suggest.tsx

@@ -121,9 +121,9 @@ export default function Suggest() {
             if (process.env.TARO_ENV == 'rn') {
                 setTimeout(() => {
                     
-                        var screenHeight = Taro.getSystemInfoSync().screenHeight
-                        var safeBottom = Taro.getSystemInfoSync().safeArea?.bottom
-                        setScrollHeight(Taro.getSystemInfoSync().windowHeight - 50 - rpxToPx(88) - rpxToPx(420) - (screenHeight - safeBottom) - rpxToPx(46));
+                        var screenHeight = Taro.getWindowInfo().screenHeight
+                        var safeBottom = Taro.getWindowInfo().safeArea?.bottom
+                        setScrollHeight(Taro.getWindowInfo().windowHeight - 50 - rpxToPx(88) - rpxToPx(420) - (screenHeight - safeBottom) - rpxToPx(46));
                 }, 100)
                 setTimeout(() => {
                     (scrollViewRef.current as any).scrollTo({ x: 0, y: currentIndex * (rpxToPx(92 + 28) + 72) - 30, animated: true })
@@ -132,9 +132,9 @@ export default function Suggest() {
             else {
                 setTimeout(() => {
                     Taro.createSelectorQuery().select('#myScrollView').boundingClientRect((rect) => {
-                        var screenHeight = Taro.getSystemInfoSync().screenHeight
-                        var safeBottom = Taro.getSystemInfoSync().safeArea?.bottom
-                        setScrollHeight(Taro.getSystemInfoSync().windowHeight - (rect as any).top - rpxToPx(88) - 50 - (screenHeight - safeBottom) - rpxToPx(46));
+                        var screenHeight = Taro.getWindowInfo().screenHeight
+                        var safeBottom = Taro.getWindowInfo().safeArea?.bottom
+                        setScrollHeight(Taro.getWindowInfo().windowHeight - (rect as any).top - rpxToPx(88) - 50 - (screenHeight - safeBottom) - rpxToPx(46));
                     }).exec()
                 }, 100)
             }

+ 11 - 0
src/services/health.tsx

@@ -339,6 +339,17 @@ export const getEvents = (id) => {
     })
 }
 
+export const getRecordDetail = (id,params) =>{
+    return new Promise((resolve) => {
+        request({
+            url: API_HEALTH_RECORD + '/' + id, method: 'GET', data: {...params}
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        })
+    })
+}
+
 export const delEvents = (id) => {
     return new Promise((resolve) => {
         request({

+ 1 - 4
src/services/http/request.ts

@@ -60,9 +60,6 @@ export async function request<T>(param: RequestParam): Promise<T> {
 
 
     function performRequest(resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) {
-        // if (process.env.TARO_ENV == 'rn' && Taro.getSystemInfoSync().platform != 'ios') {
-        //     return;
-        // }
         const { url, method, data } = param;
         console.log(url)
         var requestTask: any = null;
@@ -84,7 +81,7 @@ export async function request<T>(param: RequestParam): Promise<T> {
 
 
 
-        header['X-Platform'] = Taro.getSystemInfoSync().platform == 'ios' ? 'IOS' : 'ANDROID'; //IOS ANDROID
+        header['X-Platform'] = Taro.getDeviceInfo().platform == 'ios' ? 'IOS' : 'ANDROID'; //IOS ANDROID
         header['X-Lang'] = process.env.TARO_ENV == 'rn' ? global.language : 'zh' //zh en
         if (process.env.TARO_ENV == 'weapp'){
             header['X-Lang'] = global.language??'zh'

+ 2 - 0
src/services/thirdPartRequest.tsx

@@ -22,9 +22,11 @@ export const thirdPartRequest = (type: RequestType) => {
                     clearTimeout(timer);
                     Taro.getWeRunData({
                         success: (res) => {
+                            console.log('success',res)
                             resolve(res);
                         },
                         fail: (err) => {
+                            console.log('err',err)
                             reject(err);
                         },
                         complete: () => {

+ 1 - 1
src/utils/tools.ts

@@ -42,7 +42,7 @@ export function rgbaToRgb(rgba) {
 }
 
 export function rpxToPx(n: number) {
-    var rate = Taro.getSystemInfoSync().windowWidth / 750;
+    var rate = Taro.getWindowInfo().windowWidth / 750;
     return n * rate;
 }