Leon 1 년 전
부모
커밋
4091e8a97a

+ 2 - 2
src/_health/base/new_button.tsx

@@ -61,7 +61,7 @@ export default function NewButton(props: {
     type: NewButtonType,
     color?: string,
     title?: string,
-    component?: any,
+    children?: any,
     disable?: boolean,
     loading?: boolean,
     onClick?: any,
@@ -220,5 +220,5 @@ export default function NewButton(props: {
             }
             setIsTouched(false)
         }}
-    >{props.component}{props.title}</View>
+    >{props.children}{props.title}</View>
 }

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

@@ -62,7 +62,7 @@ export default function FastSleepConsole(props: { step: number, data: any }) {
                 break;
         }
 
-        jumpPage(`/_health/pages/log_time?index=${index}&single=${single}&is_start=${is_start}&window=${window}&data=${JSON.stringify(props.data)}`)
+        jumpPage(`/_health/pages/log_time?is_fast_with_sleep=1&index=${index}&single=${single}&is_start=${is_start}&window=${window}&data=${JSON.stringify(props.data)}`)
         /*
             const isSingle = router.params.single == '1'
     const isFast = router.params.window == 'FAST'

+ 4 - 1
src/_health/pages/add_moment.tsx

@@ -172,7 +172,10 @@ export default function AddMoment() {
         }
         createMoment(params).then(res => {
             if (process.env.TARO_ENV == 'weapp') {
-                Taro.navigateBack();
+                // Taro.navigateBack();
+                Taro.redirectTo({
+                    url:'/_health/pages/post_result?data=' + JSON.stringify(res)
+                })
             }
 
             if (health.mode == 'EAT') {

+ 98 - 13
src/_health/pages/log_time.tsx

@@ -41,6 +41,8 @@ export default function LogTime() {
     const isSingle = router.params.single == '1'
     const isFast = router.params.window == 'FAST'
     const isStart = router.params.is_start == '1'
+    const isFastWithSleep = router.params.is_fast_with_sleep == '1'
+    const type = router.params.type
     const [data, setData] = useState<any>(null)
     const health = useSelector((state: any) => state.health);
     const [showGoal, setShowGoal] = useState(false)
@@ -101,6 +103,18 @@ export default function LogTime() {
         }
         else {
             for (var i = 0; i <= tapIndex; i++) {
+                // if (type == 'home'){
+                //     if (tapIndex == 2){
+                //         if (i == 0 || i==3){
+                //             continue;
+                //         }
+                //     }
+                //     else if (tapIndex ==3){
+                //         if (i==1||i==2){
+                //             continue;
+                //         }
+                //     }
+                // }
                 var timeline: any;
                 if (i == 0 || i == 3) {
                     timeline = i == 0 ? fast.timeline[0] : fast.timeline[1]
@@ -215,16 +229,28 @@ export default function LogTime() {
             list.push(params)
         }
         else {
-            const { status } = data
-            for (var i = 0; i <= tapIndex; i++) {
-                if ((status == 'OG1' || status == 'OG2' || status == 'OG3') && i == 0) {
-                }
-                else if ((status == 'OG2' || status == 'OG3' || status == 'OG2_NO1') && i == 1) {
-                }
-                else if (status == 'OG3' && i == 2) {
+            if (type == 'home') {
+                if (parseInt(tapIndex + '') == 2) {
+                    var obj = array[1]
+                    var timestamp = getTimestamp(obj)
+                    list.push({
+                        schedule_id: obj.schedule_id,
+                        extra: obj.extra,
+                        date: dayjs(timestamp).format('YYYYMMDD'),
+                        timestamp: timestamp,
+                    })
+
+                    var obj2 = array[2]
+                    var timestamp2 = getTimestamp(obj2)
+                    list.push({
+                        schedule_id: obj2.schedule_id,
+                        extra: obj2.extra,
+                        date: dayjs(timestamp2).format('YYYYMMDD'),
+                        timestamp: timestamp2,
+                    })
                 }
-                else {
-                    var obj = array[i]
+                if (parseInt(tapIndex + '') == 3) {
+                    var obj = array[0]
                     var timestamp = getTimestamp(obj)
                     list.push({
                         schedule_id: obj.schedule_id,
@@ -232,6 +258,38 @@ export default function LogTime() {
                         date: dayjs(timestamp).format('YYYYMMDD'),
                         timestamp: timestamp,
                     })
+
+                    var obj2 = array[3]
+                    var timestamp2 = getTimestamp(obj2)
+                    list.push({
+                        schedule_id: obj2.schedule_id,
+                        extra: obj2.extra,
+                        date: dayjs(timestamp2).format('YYYYMMDD'),
+                        timestamp: timestamp2,
+                    })
+                }
+            }
+            else {
+
+
+                const { status } = data
+                for (var i = 0; i <= tapIndex; i++) {
+                    if ((status == 'OG1' || status == 'OG2' || status == 'OG3') && i == 0) {
+                    }
+                    else if ((status == 'OG2' || status == 'OG3' || status == 'OG2_NO1') && i == 1) {
+                    }
+                    else if (status == 'OG3' && i == 2) {
+                    }
+                    else {
+                        var obj = array[i]
+                        var timestamp = getTimestamp(obj)
+                        list.push({
+                            schedule_id: obj.schedule_id,
+                            extra: obj.extra,
+                            date: dayjs(timestamp).format('YYYYMMDD'),
+                            timestamp: timestamp,
+                        })
+                    }
                 }
             }
         }
@@ -241,7 +299,7 @@ export default function LogTime() {
         if (fast.real) {
             var t = fast.real.start_timestamp
             var schedule_id = fast.timeline[1].schedule_id
-            if (list[list.length-1].schedule_id==schedule_id && list[list.length-1].timestamp-t>24*3600*1000){
+            if (list[list.length - 1].schedule_id == schedule_id && list[list.length - 1].timestamp - t > 24 * 3600 * 1000) {
                 showAlert({
                     title: 'Saving as Long Fast',
                     content: 'Fasting that lasts more than 24 hours will be saved as Long Fast. ',
@@ -263,14 +321,18 @@ export default function LogTime() {
 
     function commit(list) {
         clockTimes({
-            check_items: list
+            check_items: list,
+            op_page: isFastWithSleep ? 'FAST_WITH_SLEEP' : null
         }).then(res => {
             global.refreshWindow()
             if (global.refreshFastSleep)
                 global.refreshFastSleep()
-            Taro.navigateBack({
-                delta: 1
+            Taro.redirectTo({
+                url: './post_result?data='+JSON.stringify(res)
             })
+            // Taro.navigateBack({
+            //     delta: 1
+            // })
         })
     }
 
@@ -419,6 +481,29 @@ export default function LogTime() {
     }
 
     function multiContent() {
+        if (type == 'home') {
+            switch (parseInt(tapIndex + '')) {
+                case 2:
+                    return <View style={{ position: 'relative' }}>
+                        {
+                            logItem(1, false, true, false)
+                        }
+                        {
+                            logItem(2, false, false, false)
+                        }
+                    </View>
+                case 3:
+                    return <View style={{ position: 'relative' }}>
+                        {
+                            logItem(0, true, true, false)
+                        }
+                        {
+                            logItem(3, true, false, false)
+                        }
+                    </View>
+            }
+
+        }
         const { status } = data
         switch (parseInt(tapIndex + '')) {
             case 1:

+ 2 - 0
src/_health/pages/long_fast.tsx

@@ -17,6 +17,7 @@ import dayjs from "dayjs";
 import showActionSheet from "@/components/basic/ActionSheet";
 import NewModal from "../base/new_modal";
 import NewDurationPicker, { DurationPickerType } from "../base/new_durationpicker";
+import Taro from "@tarojs/taro";
 
 let useActionSheet;
 if (process.env.TARO_ENV == 'rn') {
@@ -153,6 +154,7 @@ export default function LongFast() {
         }).then(res => {
             global.refreshWindow()
             global.refreshHistory()
+            jumpPage('/_health/pages/post_result?data=' + JSON.stringify(res))
         }).catch(e => {
         })
     }

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

@@ -12,6 +12,7 @@ import NewTimePicker from "../base/new_timepicker";
 import { useSelector } from "react-redux";
 import { clockTimes } from "@/services/health";
 import Taro from "@tarojs/taro";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 
 export default function LongFastSetting() {
     const [showGoal, setShowGoal] = useState(true)
@@ -37,9 +38,9 @@ export default function LongFastSetting() {
 
     function commit() {
 
-        let now = new Date(dayjs().format('YYYY-MM-DDT')+time+':00').getTime()
-        if (!isToday){
-            now = now - 24*3600*1000
+        let now = new Date(dayjs().format('YYYY-MM-DDT') + time + ':00').getTime()
+        if (!isToday) {
+            now = now - 24 * 3600 * 1000
         }
 
         clockTimes({
@@ -48,7 +49,7 @@ export default function LongFastSetting() {
                 date: dayjs(now).format('YYYYMMDD'),
                 timestamp: now,
                 extra: {
-                    long_fast_goal:duration*60,
+                    long_fast_goal: duration * 60,
                     set_time: global.set_time ? global.set_time : new Date().getTime(),
                     confirm_time: new Date().getTime()
                 }
@@ -56,7 +57,12 @@ export default function LongFastSetting() {
         }).then(res => {
             global.refreshWindow()
             global.refreshHistory()
-            Taro.navigateBack()
+
+            Taro.redirectTo({
+                url: '/_health/pages/post_result?data=' + JSON.stringify(res)
+            })
+            // jumpPage('/_health/pages/post_result?data='+JSON.stringify(res))
+            // Taro.navigateBack()
         }).catch(e => {
         })
     }

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

@@ -172,10 +172,12 @@ export default function Move() {
                 timestamp: new Date().getTime(),
                 schedule_id: schedule_id
             }).then(res => {
-                Taro.showToast({
-                    title: '上报成功',
-                    icon: 'none'
-                })
+                // Taro.showToast({
+                //     title: '上报成功',
+                //     icon: 'none'
+                // })
+                console.log(res)
+                jumpPage('./post_result?data='+JSON.stringify((res as any).post_result))
                 getMovesCurrent()
                 getMovesHistory()
             })

+ 12 - 0
src/_health/pages/post_result.config.ts

@@ -0,0 +1,12 @@
+export default definePageConfig({
+    // "lazyCodeLoading": "requiredComponents",
+    // "componentFramework": "glass-easel",
+    // "renderer": "skyline",
+    // "rendererOptions": {
+    //     "skyline": {
+    //         "disableABTest": true,
+    //         "defaultDisplayBlock": true
+    //     }
+    // },
+    "navigationStyle":"custom",
+})

+ 76 - 0
src/_health/pages/post_result.scss

@@ -0,0 +1,76 @@
+.post_result_container{
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    padding-top: 246px;
+    height: 100vh;
+    box-sizing: border-box;
+}
+
+.post_result_header{
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+}
+
+.result_icon_bg{
+    width: 108px;
+    height: 108px;
+    position: relative;
+    border-radius: 54px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.result_icon_small{
+    position: absolute;
+    right: 0;
+    bottom: 0;
+    width: 40px;
+    height: 40px;
+    border-radius: 20px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.result_next{
+    margin-top: 48px;
+    display: flex;
+    flex-direction: column;
+
+}
+
+.result_top_line{
+    background-color: #9E9E9E;
+    height: 2px;
+    transform: scaleY(0.5);
+    width: 400px;
+    margin-bottom: 48px;
+}
+
+.next_target{
+    display: flex;
+    height: 72px;
+}
+
+.result_footer{
+    height: 348px;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    padding-top: 40px;
+    box-sizing: border-box;
+}
+
+.setting_item{
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    box-sizing: border-box;
+    padding-left: 64px;
+    padding-right: 40px;
+    padding-top: 40px;
+    padding-bottom: 57px;
+}

+ 187 - 3
src/_health/pages/post_result.tsx

@@ -1,5 +1,189 @@
-import { View } from "@tarojs/components";
+import { View, Image, Text, Switch } from "@tarojs/components";
+import Taro, { useRouter } from "@tarojs/taro";
+import './post_result.scss'
+import { getThemeColor } from "@/features/health/hooks/health_hooks";
+import { rpxToPx } from "@/utils/tools";
+import NewButton, { NewButtonType } from "../base/new_button";
+import { IconCheck, IconNotificationOff } from "@/components/basic/Icons";
+import { MainColorType } from "@/context/themes/color";
+import { useState } from "react";
+import dayjs from "dayjs";
+import { useDispatch } from "react-redux";
+import { setMode } from "@/store/health";
+import NewModal from "../base/new_modal";
+import Card from "../components/card";
 
-export default function PostResult(){
-    return <View></View>
+let useRoute;
+let useNavigation;
+if (process.env.TARO_ENV == 'rn') {
+    useRoute = require("@react-navigation/native").useRoute
+    useNavigation = require("@react-navigation/native").useNavigation
+}
+export default function PostResult() {
+    let router
+    let navigation;
+    if (useNavigation) {
+        navigation = useNavigation()
+    }
+
+    if (process.env.TARO_ENV == 'rn') {
+        router = useRoute()
+    }
+    else {
+        router = useRouter()
+    }
+
+    const [data, setData] = useState(JSON.parse(router.params.data))
+    const [showSetting, setShowSetting] = useState(false)
+    const dispatch = useDispatch()
+    console.log(JSON.parse(router.params.data))
+
+    function getMainColor() {
+        return getThemeColor(data.window)
+    }
+
+    function nextTitle() {
+        const today = dayjs();
+
+        var timestamp = data.next.timestamp
+        const dt = dayjs(timestamp);
+        const yesterday = today.subtract(1, 'day');
+        const tomorrow = today.subtract(-1, 'day');
+        var date = ''
+        var time = dt.format('HH:mm')
+        if (dt.isSame(today, 'day')) {
+            date = '今天';
+        } else if (dt.isSame(yesterday, 'day')) {
+            date = '昨天';
+        } else if (dt.isSame(tomorrow, 'day')) {
+            date = '明天';
+        } else {
+            date = dt.format('MM-DD');
+        }
+        return date + ' ' + time + ' ' + data.next.title
+    }
+
+    function showSwitchBtn() {
+        if (data.extra && data.extra.fast_type == 'LF') return false;
+        return data.schedule_completed
+    }
+
+    function swithBtnText() {
+        switch (data.window) {
+            case 'FAST':
+                return 'Switch to Eat'
+            case 'EAT':
+                return 'Switch to Fast'
+            case 'ACTIVE':
+                return 'Switch to Sleep'
+            case 'SLEEP':
+                return 'Swtich to Active'
+        }
+        return ''
+    }
+
+    function tapSwitch() {
+        switch (data.window) {
+            case 'FAST':
+                dispatch(setMode('EAT'))
+                break
+            case 'EAT':
+                dispatch(setMode('FAST'))
+                break
+            case 'ACTIVE':
+                dispatch(setMode('SLEEP'))
+                break
+            case 'SLEEP':
+                dispatch(setMode('ACTIVE'))
+                break
+        }
+        Taro.navigateBack()
+    }
+
+    function headerIcon() {
+        if (data.images) {
+            return <View className="result_icon_bg">
+                <Image className="result_icon_bg" mode="aspectFill" src={data.images[0]} />
+                <View className="result_icon_small" style={{ backgroundColor: getMainColor() }}>
+                    <IconCheck color="#fff" width={rpxToPx(18)} height={rpxToPx(18)} />
+                </View>
+            </View>
+        }
+
+        if (data.scenario == 'MOVE') {
+            return <Image className="result_icon_bg" mode="aspectFill" src={require('@assets/_health/sit.png')} />
+        }
+        return <View className="result_icon_bg" style={{ backgroundColor: getMainColor() }}>
+            <IconCheck color="#fff" width={rpxToPx(40)} height={rpxToPx(40)} />
+        </View>
+    }
+
+    return <View className="post_result_container">
+        {
+            headerIcon()
+        }
+
+        <View className="h50 bold" style={{ color: getMainColor(), marginTop: rpxToPx(30) }}>{data.title}</View>
+        <View className="h30" style={{ marginTop: rpxToPx(12) }}>{data.description}</View>
+        {
+            data.next && <View className="result_next">
+                <View className="result_top_line" />
+                <View className="next_target">
+                    <NewButton
+                        type={NewButtonType.link}
+                        title={nextTitle()}
+                        onClick={() => {
+                            setShowSetting(true)
+                        }}
+                    >
+                        <IconNotificationOff color={MainColorType.link} width={rpxToPx(26)} />
+                    </NewButton>
+                </View>
+            </View>
+        }
+
+        <View style={{ flex: 1 }} />
+        <View className="result_footer">
+            <NewButton
+                type={NewButtonType.gray}
+                width={rpxToPx(400)}
+                height={rpxToPx(96)}
+                title="Done"
+                onClick={() => {
+                    Taro.navigateBack()
+                }}
+            />
+            {
+                showSwitchBtn() && <View style={{ marginTop: rpxToPx(36), width: rpxToPx(400), height: rpxToPx(72), display: 'flex' }}>
+                    <NewButton
+                        type={NewButtonType.link}
+                        title={swithBtnText()}
+                        onClick={tapSwitch}
+                    />
+                </View>
+            }
+
+
+        </View>
+        {
+            showSetting && <NewModal
+                themeColor={getMainColor()}
+                title='开启提醒'
+                dismiss={()=>setShowSetting(false)}
+                confirm={()=>setShowSetting(false)}
+            >
+                <View style={{marginBottom:rpxToPx(72)}}>
+                <Card>
+                    <View className="setting_item">
+                        <View style={{flex:1}}>
+                            <View className="h24" style={{color:MainColorType.g01}}>{dayjs(data.next.timestamp).format('HH:mm')}</View>
+                            <View className="h34">{data.next.title}</View>
+                        </View>
+                        <Switch color={getMainColor()}/>
+                    </View>
+                </Card>
+                </View>
+            </NewModal>
+        }
+    </View>
 }

BIN
src/assets/_health/walk2.png


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 5 - 1
src/components/basic/Icons.tsx


+ 19 - 11
src/features/health/MainConsole.tsx

@@ -100,22 +100,29 @@ export default function MainConsole(props: { type: WindowType }) {
         switch (item.action) {
             case 'START':
                 {
-                    defaultTimestamp = new Date().getTime()
-                    min = defaultTimestamp - 1 * 24 * 3600 * 1000
-                    max = defaultTimestamp
+                    // defaultTimestamp = new Date().getTime()
+                    // min = defaultTimestamp - 1 * 24 * 3600 * 1000
+                    // max = defaultTimestamp
 
-                    setOperateType('startFast')
-                    setShowTimePicker(true)
+                    // setOperateType('startFast')
+                    // setShowTimePicker(true)
+
+                    jumpPage(`/_health/pages/log_time?index=${health.mode=='FAST'?0:1}&single=1&is_start=1&window=${health.mode}`)
                 }
                 return;
             case 'END':
                 {
-                    defaultTimestamp = new Date().getTime()
-                    // defaultTimestamp = e ? new Date().getTime() : logEventTimestamp
-                    min = defaultTimestamp - 1 * 24 * 3600 * 1000
-                    max = defaultTimestamp
-                    setOperateType('endFast')
-                    setShowTimePicker(true)
+                    // defaultTimestamp = new Date().getTime()
+                    // // defaultTimestamp = e ? new Date().getTime() : logEventTimestamp
+                    // min = defaultTimestamp - 1 * 24 * 3600 * 1000
+                    // max = defaultTimestamp
+                    // setOperateType('endFast')
+                    // setShowTimePicker(true)
+                    console.log(item)
+
+                    var sceniaro = getScenario(health.windows,health.mode)
+
+                    jumpPage(`/_health/pages/log_time?type=home&index=${health.mode=='FAST'?3:2}&single=${sceniaro.status == 'OG'?1:0}&is_start=0&window=${health.mode}`)
                 }
                 return;
             case 'MARK_DONE':
@@ -505,6 +512,7 @@ export default function MainConsole(props: { type: WindowType }) {
             setShowTimePicker(false)
             global.refreshWindow()
             global.refreshHistory()
+            jumpPage('/_health/pages/post_result?data='+JSON.stringify(res))
         }).catch(e => {
             setBtnDisable(false)
         })

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.