|
|
@@ -1,43 +1,109 @@
|
|
|
-import { View, Text } from "@tarojs/components";
|
|
|
+import { View, Text, Icon } from "@tarojs/components";
|
|
|
import './Stage.scss'
|
|
|
import { TimeFormatter } from "@/utils/time_format";
|
|
|
import { ColorType } from "@/context/themes/color";
|
|
|
|
|
|
export default function Component(props: { data: any }) {
|
|
|
function getTime(t1: number, t2: number) {
|
|
|
- return TimeFormatter.calculateTimeDifference(t1, t2)
|
|
|
+ return TimeFormatter.formateTimeDifference(t1, t2)
|
|
|
+ }
|
|
|
+
|
|
|
+ function getDuration(t1: number, t2: number) {
|
|
|
+ return TimeFormatter.calculateTimeDifference(t1, t2, true)
|
|
|
}
|
|
|
|
|
|
function getStepATime(obj) {
|
|
|
if (obj.status == 'COMPLETED' && obj.sleep.status == 'NOT_STARTED') {
|
|
|
- return '未知'
|
|
|
+ return '未完成'
|
|
|
}
|
|
|
+
|
|
|
return obj.status == 'ONGOING1' ?
|
|
|
getTime(obj.fast.real_start_time, (new Date()).getTime()) :
|
|
|
- obj.sleep.real_start_time ? getTime(obj.sleep.real_start_time, obj.fast.real_start_time ? obj.fast.real_start_time : obj.fast.target_start_time) :
|
|
|
- getTime(obj.sleep.target_start_time, obj.fast.real_start_time ? obj.fast.real_start_time : obj.fast.target_start_time)
|
|
|
+ obj.sleep.real_start_time ? getDuration(obj.sleep.real_start_time, obj.fast.real_start_time ? obj.fast.real_start_time : obj.fast.target_start_time) :
|
|
|
+ getDuration(obj.sleep.target_start_time, obj.fast.real_start_time ? obj.fast.real_start_time : obj.fast.target_start_time)
|
|
|
}
|
|
|
|
|
|
function getStepBTime(obj) {
|
|
|
- if (obj.status == 'ONGOING1') return 'Next up'
|
|
|
+ if (obj.status == 'ONGOING1') return '待开始'
|
|
|
if (obj.status == 'ONGOING2') return getTime(obj.sleep.real_start_time, (new Date()).getTime())
|
|
|
- if (obj.status == 'WAIT_FOR_START') return getTime(obj.sleep.target_end_time, obj.sleep.target_start_time)
|
|
|
- if (obj.sleep.status == 'NOT_COMPLETED' || obj.sleep.status == 'NOT_STARTED') return '未知'
|
|
|
- return getTime(obj.sleep.real_end_time, obj.sleep.real_start_time)
|
|
|
+ if (obj.status == 'WAIT_FOR_START') return getDuration(obj.sleep.target_end_time, obj.sleep.target_start_time)
|
|
|
+ if (obj.sleep.status == 'NOT_STARTED') return '未开始'
|
|
|
+ if (obj.sleep.status == 'NOT_COMPLETED') return '未完成'
|
|
|
+ return getDuration(obj.sleep.real_end_time, obj.sleep.real_start_time)
|
|
|
|
|
|
}
|
|
|
|
|
|
function getStepCTime(obj) {
|
|
|
- if (obj.status == 'ONGOING1') return 'Final stage'
|
|
|
- if (obj.status == 'ONGOING2') return 'Next up'
|
|
|
+ if (obj.status == 'ONGOING1') return '待开始'
|
|
|
+ if (obj.status == 'ONGOING2') return '待开始'
|
|
|
if (obj.status == 'ONGOING3') return getTime(obj.sleep.real_end_time, (new Date()).getTime())
|
|
|
- if (obj.status == 'WAIT_FOR_START') return getTime(obj.fast.target_end_time, obj.sleep.target_end_time)
|
|
|
- if (obj.sleep.status == 'NOT_COMPLETED' || obj.sleep.status == 'NOT_STARTED') return '未知'
|
|
|
- return getTime(obj.fast.real_end_time, obj.sleep.real_end_time)
|
|
|
+ if (obj.status == 'WAIT_FOR_START') return getDuration(obj.fast.target_end_time, obj.sleep.target_end_time)
|
|
|
+ if (obj.sleep.status == 'NOT_COMPLETED' || obj.sleep.status == 'NOT_STARTED') return '未开始'
|
|
|
+ return getDuration(obj.fast.real_end_time, obj.sleep.real_end_time)
|
|
|
}
|
|
|
|
|
|
return <View className="stage">
|
|
|
- <View className="stage_item">
|
|
|
+
|
|
|
+ <View className='timelineItem'>
|
|
|
+ <View className='timelineContentView'>
|
|
|
+ {
|
|
|
+ <Icon type='circle' size='16' color='#ffffff00' />//<CheckBox type={CheckBoxType.empty} opacity={0.4} />
|
|
|
+ }
|
|
|
+ <View className='timelineContentDetail'>
|
|
|
+ <View className="timeline-time" >{' '}</View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ <View className="timeline-detail" style={{ color: ColorType.fast,opacity:1 }}>睡前断食
|
|
|
+ <View className="timeline-date" style={{ color: ColorType.fast,opacity:1 }}>{getStepATime(props.data)}</View>
|
|
|
+
|
|
|
+ </View>
|
|
|
+ <View className={true ? 'timeline_line1 line1_bottom_space' : 'timeline_line1 line1_bottom_zero'} />
|
|
|
+ {true &&
|
|
|
+ <View className='timeline-line'
|
|
|
+ style={{ background: '#ffffff66' }}
|
|
|
+ />}
|
|
|
+
|
|
|
+ </View>
|
|
|
+ <View className='timelineItem'>
|
|
|
+ <View className='timelineContentView'>
|
|
|
+ {
|
|
|
+ <Icon type='circle' size='16' color='#ffffff00' />//<CheckBox type={CheckBoxType.empty} opacity={0.4} />
|
|
|
+ }
|
|
|
+ <View className='timelineContentDetail'>
|
|
|
+ <View className="timeline-time" >{' '}</View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ <View className="timeline-detail" style={{ color: ColorType.sleep,opacity:1 }}>睡眠中断食
|
|
|
+ <View className="timeline-date" style={{ color: ColorType.sleep ,opacity:1}}>{getStepBTime(props.data)}</View>
|
|
|
+
|
|
|
+ </View>
|
|
|
+ <View className={true ? 'timeline_line1 line1_bottom_space' : 'timeline_line1 line1_bottom_zero'} />
|
|
|
+ {true &&
|
|
|
+ <View className='timeline-line'
|
|
|
+ style={{ background: '#ffffff66' }}
|
|
|
+ />}
|
|
|
+
|
|
|
+ </View>
|
|
|
+ <View className='timelineItem'>
|
|
|
+ <View className='timelineContentView'>
|
|
|
+ {
|
|
|
+ <Icon type='circle' size='16' color='#ffffff00' />//<CheckBox type={CheckBoxType.empty} opacity={0.4} />
|
|
|
+ }
|
|
|
+ <View className='timelineContentDetail'>
|
|
|
+ <View className="timeline-time" >{' '}</View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ <View className="timeline-detail" style={{ color: ColorType.fast ,opacity:1}}>起床后断食
|
|
|
+ <View className="timeline-date" style={{ color: ColorType.fast ,opacity:1}}>{getStepCTime(props.data)}</View>
|
|
|
+
|
|
|
+ </View>
|
|
|
+ <View className={'timeline_line1 line1_bottom_zero'} />
|
|
|
+ {true &&
|
|
|
+ <View className='timeline-line'
|
|
|
+ style={{ background: '#ffffff66' }}
|
|
|
+ />}
|
|
|
+ </View>
|
|
|
+ {/* <View className="stage_item">
|
|
|
<Text className='stage_step'>A</Text>
|
|
|
<View className="stage_line" style={{ opacity: props.data.status == 'ONGOING1' ? 1 : 0.4 }} />
|
|
|
<View className="stage_right">
|
|
|
@@ -51,8 +117,8 @@ export default function Component(props: { data: any }) {
|
|
|
}}>{getStepATime(props.data)}</Text>
|
|
|
</View>
|
|
|
|
|
|
- </View>
|
|
|
- <View className="stage_item">
|
|
|
+ </View> */}
|
|
|
+ {/* <View className="stage_item">
|
|
|
<Text className='stage_step'>B</Text>
|
|
|
<View className="stage_line" style={{ opacity: props.data.status == 'ONGOING2' ? 1 : 0.4 }} />
|
|
|
<View className="stage_right">
|
|
|
@@ -81,7 +147,7 @@ export default function Component(props: { data: any }) {
|
|
|
}}>{getStepCTime(props.data)}</Text>
|
|
|
</View>
|
|
|
|
|
|
- </View>
|
|
|
+ </View> */}
|
|
|
|
|
|
</View>
|
|
|
}
|