|
|
@@ -10,6 +10,9 @@ import { TimeFormatter } from "@/utils/time_format";
|
|
|
import { useSelector } from "react-redux";
|
|
|
import { useEffect, useState } from "react";
|
|
|
import Taro from "@tarojs/taro";
|
|
|
+import Modal from "@/components/layout/Modal.weapp";
|
|
|
+import { ModalType } from "@/utils/types";
|
|
|
+import TimelineStage from "./TimelineStage";
|
|
|
|
|
|
let useNavigation;
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
@@ -22,6 +25,7 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
const dayNight = useSelector((state: any) => state.dayNight);
|
|
|
const [stageList, setStageList] = useState([true, false, false])
|
|
|
const [isStageMode, setIsStageMode] = useState(false)
|
|
|
+ const [showDetailModal, setShowDetailModal] = useState(false)
|
|
|
let navigation;
|
|
|
if (useNavigation) {
|
|
|
navigation = useNavigation()
|
|
|
@@ -58,140 +62,117 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
common.lineWidth = 9;
|
|
|
var bgRing = getBgRing()
|
|
|
|
|
|
- if (props.type == 'SLEEP') {
|
|
|
- var realRing = getReal(record, false, true)
|
|
|
- var currentDot1 = getDot(record, true)
|
|
|
- var targetBigRing1 = getTarget(record, true)
|
|
|
- if (record.status == 'ONGOING') {
|
|
|
- var realRing1 = getReal(record, true, false)
|
|
|
-
|
|
|
- return <Rings common={common} bgRing={bgRing} currentDot={currentDot1} realRing={realRing1} targetRing={targetBigRing1} canvasId={props.type + props.time + 'big'} />
|
|
|
- }
|
|
|
+ var currentDot1 = getDot(record, true)
|
|
|
+ var targetBigRing1 = getTarget(record, true)
|
|
|
+ if (record.status == 'ONGOING') {
|
|
|
+ var realRing1 = getReal(record, true, false)
|
|
|
|
|
|
- if (record.status == 'WAIT_FOR_START' || record.status == 'ONGOING1') {
|
|
|
- var realRing1 = getSchedule(record, props.type != 'SLEEP', true)
|
|
|
- var currentDot1 = getDot(record, true)
|
|
|
- return <Rings common={common} bgRing={bgRing} realRing={realRing1} currentDot={currentDot1} canvasId={props.type + props.time + 'big'} />
|
|
|
- }
|
|
|
- if (props.data.status == 'ONGOING3') {
|
|
|
- realRing.color = 'rgba(0,0,0,0)'
|
|
|
- // bgRing.color = 'rgba(0,0,0,0)'
|
|
|
- }
|
|
|
- return <Rings common={common} bgRing={bgRing} canvasId={props.type + props.time + 'big'} realRing={realRing} />
|
|
|
+ return <Rings common={common} bgRing={bgRing} currentDot={currentDot1} realRing={realRing1} targetRing={targetBigRing1} canvasId={props.type + props.time + 'big'} />
|
|
|
}
|
|
|
- else {
|
|
|
- var currentDot1 = getDot(record, true)
|
|
|
- var targetBigRing1 = getTarget(record, true)
|
|
|
- if (record.status == 'ONGOING') {
|
|
|
- var realRing1 = getReal(record, true, false)
|
|
|
-
|
|
|
- return <Rings common={common} bgRing={bgRing} currentDot={currentDot1} realRing={realRing1} targetRing={targetBigRing1} canvasId={props.type + props.time + 'big'} />
|
|
|
- }
|
|
|
- if (record.status == 'WAIT_FOR_START') {
|
|
|
- var realRing1 = getSchedule(record, props.type != 'SLEEP', true)
|
|
|
- var list: any = []
|
|
|
- if (props.type == 'FAST_SLEEP') {
|
|
|
- realRing1.color = ColorType.fast + '66'
|
|
|
-
|
|
|
- if (dotIsOuterRange(true, record.fast)) {
|
|
|
- currentDot1.color = ColorType.ring
|
|
|
- }
|
|
|
+ if (record.status == 'WAIT_FOR_START') {
|
|
|
+ var realRing1 = getSchedule(record, props.type != 'SLEEP', true)
|
|
|
+ var list: any = []
|
|
|
+ if (props.type == 'FAST_SLEEP') {
|
|
|
+ realRing1.color = ColorType.fast + '66'
|
|
|
|
|
|
- if (stageList[0]) {
|
|
|
+ if (dotIsOuterRange(true, record.fast)) {
|
|
|
+ currentDot1.color = ColorType.ring
|
|
|
+ }
|
|
|
|
|
|
- const realRingBig: RealRing = {
|
|
|
- color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
|
- startArc: startArc(record.fast.target_start_time),
|
|
|
- durationArc: durationArc(record.fast.target_start_time, record.sleep.target_start_time)
|
|
|
- }
|
|
|
+ if (stageList[0]) {
|
|
|
|
|
|
- list.push(realRingBig)
|
|
|
+ const realRingBig: RealRing = {
|
|
|
+ color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
|
+ startArc: startArc(record.fast.target_start_time),
|
|
|
+ durationArc: durationArc(record.fast.target_start_time, record.sleep.target_start_time)
|
|
|
}
|
|
|
- if (stageList[1]) {
|
|
|
- const realRingBig: RealRing = {
|
|
|
- color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
|
- startArc: startArc(record.sleep.target_start_time),
|
|
|
- durationArc: durationArc(record.sleep.target_start_time, record.sleep.target_end_time)
|
|
|
- }
|
|
|
-
|
|
|
- list.push(realRingBig)
|
|
|
- }
|
|
|
- if (stageList[2]) {
|
|
|
- const realRingBig: RealRing = {
|
|
|
- color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
|
- startArc: startArc(record.sleep.target_end_time),
|
|
|
- durationArc: durationArc(record.sleep.target_end_time, record.fast.target_end_time)
|
|
|
- }
|
|
|
-
|
|
|
- list.push(realRingBig)
|
|
|
+
|
|
|
+ list.push(realRingBig)
|
|
|
+ }
|
|
|
+ if (stageList[1]) {
|
|
|
+ const realRingBig: RealRing = {
|
|
|
+ color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
|
+ startArc: startArc(record.sleep.target_start_time),
|
|
|
+ durationArc: durationArc(record.sleep.target_start_time, record.sleep.target_end_time)
|
|
|
}
|
|
|
+
|
|
|
+ list.push(realRingBig)
|
|
|
}
|
|
|
+ if (stageList[2]) {
|
|
|
+ const realRingBig: RealRing = {
|
|
|
+ color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
|
+ startArc: startArc(record.sleep.target_end_time),
|
|
|
+ durationArc: durationArc(record.sleep.target_end_time, record.fast.target_end_time)
|
|
|
+ }
|
|
|
|
|
|
- if (!isStageMode) {
|
|
|
- list = []
|
|
|
+ list.push(realRingBig)
|
|
|
}
|
|
|
- return <Rings common={common} bgRing={bgRing} currentDot={isStageMode ? null : currentDot1} stageList={list} realRing={realRing1} canvasId={props.type + props.time + 'big'} />
|
|
|
}
|
|
|
- var realRing1 = getReal(record, true, false)
|
|
|
- return <Rings common={common} bgRing={bgRing} realRing={realRing1} currentDot={currentDot1} targetRing={targetBigRing1} canvasId={props.type + props.time + 'big'} />
|
|
|
+
|
|
|
+ if (!isStageMode) {
|
|
|
+ list = []
|
|
|
+ }
|
|
|
+ return <Rings common={common} bgRing={bgRing} currentDot={isStageMode ? null : currentDot1} stageList={list} realRing={realRing1} canvasId={props.type + props.time + 'big'} />
|
|
|
}
|
|
|
+ var realRing1 = getReal(record, true, false)
|
|
|
+ return <Rings common={common} bgRing={bgRing} realRing={realRing1} currentDot={currentDot1} targetRing={targetBigRing1} canvasId={props.type + props.time + 'big'} />
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function smallRing() {
|
|
|
- if (record.scenario == 'FAST_SLEEP') {
|
|
|
- var common = getCommon(null, false)
|
|
|
- common.radius = 28;
|
|
|
- common.lineWidth = 9;
|
|
|
- var bgRing = getBgRing()
|
|
|
- var realRing = getReal(record, false, false)
|
|
|
- if (props.type == 'SLEEP' || props.type == 'FAST_SLEEP') {
|
|
|
- if (record.sleep.status == 'WAIT_FOR_END') {
|
|
|
- var targetBigRing1 = getTarget(record, false)
|
|
|
- targetBigRing1.color = ColorType.sleep + '66'
|
|
|
- var currentDot = getDot(record, false)
|
|
|
- realRing.durationArc = durationArc(record.sleep.target_start_time, (new Date()).getTime())
|
|
|
- return <Rings common={common} bgRing={bgRing} currentDot={currentDot} canvasId={props.type + props.time + 'small'} targetRing={targetBigRing1} realRing={realRing} />
|
|
|
- }
|
|
|
- else if (record.status == 'WAIT_FOR_START' || record.status == 'ONGOING1') {
|
|
|
- realRing = getSchedule(record, false, true)
|
|
|
- var currentDot = getDot(record, false)
|
|
|
- if (dotIsOuterRange(true, record.sleep)) {
|
|
|
- currentDot.color = ColorType.ring
|
|
|
- }
|
|
|
|
|
|
- return <Rings common={common} bgRing={bgRing} currentDot={isStageMode ? null : currentDot} realRing={realRing} canvasId={props.type + props.time + 'small'} />
|
|
|
- }
|
|
|
- else if (record.sleep.status == 'NOT_COMPLETED') {
|
|
|
- realRing.durationArc = 0.01
|
|
|
- var currentDot = getDot(record, false)
|
|
|
- return <Rings common={common} bgRing={bgRing} currentDot={currentDot} canvasId={props.type + props.time + 'small'} realRing={realRing} />
|
|
|
- }
|
|
|
- else if (record.sleep.status == 'COMPLETED') {
|
|
|
- realRing = getReal(record, false, true)
|
|
|
- return <Rings common={common} bgRing={bgRing} canvasId={props.type + props.time + 'small'} realRing={realRing} />
|
|
|
- }
|
|
|
- else if (record.sleep.status == 'ONGOING2') {
|
|
|
- var currentDot = getDot(record, false)
|
|
|
- return <Rings common={common} bgRing={bgRing} currentDot={currentDot} canvasId={props.type + props.time + 'small'} />
|
|
|
- }
|
|
|
- return <Rings common={common} bgRing={bgRing} canvasId={props.type + props.time + 'small'} />
|
|
|
+ var common = getCommon(null, false)
|
|
|
+ common.radius = 28;
|
|
|
+ common.lineWidth = 9;
|
|
|
+ var bgRing = getBgRing()
|
|
|
+ var realRing = getReal(record, false, false)
|
|
|
+ if (props.type == 'SLEEP' || props.type == 'FAST_SLEEP') {
|
|
|
+ if (record.sleep.status == 'WAIT_FOR_END') {
|
|
|
+ var targetBigRing1 = getTarget(record, false)
|
|
|
+ targetBigRing1.color = ColorType.sleep + '66'
|
|
|
+ var currentDot = getDot(record, false)
|
|
|
+ realRing.durationArc = durationArc(record.sleep.target_start_time, (new Date()).getTime())
|
|
|
+ return <Rings common={common} bgRing={bgRing} currentDot={currentDot} canvasId={props.type + props.time + 'small'} targetRing={targetBigRing1} realRing={realRing} />
|
|
|
}
|
|
|
- else {
|
|
|
-
|
|
|
-
|
|
|
+ else if (record.status == 'WAIT_FOR_START' || record.status == 'ONGOING1') {
|
|
|
+ realRing = getSchedule(record, false, true)
|
|
|
var currentDot = getDot(record, false)
|
|
|
- var targetRing = getTarget(record, false)
|
|
|
- if (record.status == 'ONGOING2') {
|
|
|
- var realRing = getReal(record, false, false)
|
|
|
- return <Rings common={common} bgRing={bgRing} realRing={realRing} currentDot={currentDot} targetRing={targetRing} canvasId={props.type + props.time + 'small'} />
|
|
|
- }
|
|
|
- if (record.status == 'ONGOING3') {
|
|
|
- currentDot.color = 'rgba(0, 255, 255, 0.5)'
|
|
|
+ if (dotIsOuterRange(true, record.sleep)) {
|
|
|
+ currentDot.color = ColorType.ring
|
|
|
}
|
|
|
+
|
|
|
+ return <Rings common={common} bgRing={bgRing} currentDot={isStageMode ? null : currentDot} realRing={realRing} canvasId={props.type + props.time + 'small'} />
|
|
|
+ }
|
|
|
+ else if (record.sleep.status == 'NOT_COMPLETED') {
|
|
|
+ realRing.durationArc = 0.01
|
|
|
+ var currentDot = getDot(record, false)
|
|
|
+ return <Rings common={common} bgRing={bgRing} currentDot={currentDot} canvasId={props.type + props.time + 'small'} realRing={realRing} />
|
|
|
+ }
|
|
|
+ else if (record.sleep.status == 'COMPLETED') {
|
|
|
+ realRing = getReal(record, false, true)
|
|
|
+ return <Rings common={common} bgRing={bgRing} canvasId={props.type + props.time + 'small'} realRing={realRing} />
|
|
|
+ }
|
|
|
+ else if (record.sleep.status == 'ONGOING2') {
|
|
|
+ var currentDot = getDot(record, false)
|
|
|
return <Rings common={common} bgRing={bgRing} currentDot={currentDot} canvasId={props.type + props.time + 'small'} />
|
|
|
}
|
|
|
+ return <Rings common={common} bgRing={bgRing} canvasId={props.type + props.time + 'small'} />
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+
|
|
|
+ var currentDot = getDot(record, false)
|
|
|
+ var targetRing = getTarget(record, false)
|
|
|
+ if (record.status == 'ONGOING2') {
|
|
|
+ var realRing = getReal(record, false, false)
|
|
|
+ return <Rings common={common} bgRing={bgRing} realRing={realRing} currentDot={currentDot} targetRing={targetRing} canvasId={props.type + props.time + 'small'} />
|
|
|
+ }
|
|
|
+ if (record.status == 'ONGOING3') {
|
|
|
+ currentDot.color = 'rgba(0, 255, 255, 0.5)'
|
|
|
+ }
|
|
|
+ return <Rings common={common} bgRing={bgRing} currentDot={currentDot} canvasId={props.type + props.time + 'small'} />
|
|
|
}
|
|
|
- return null
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function dayRing() {
|
|
|
@@ -205,16 +186,16 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
startArc: 0,
|
|
|
durationArc: 2
|
|
|
}
|
|
|
- var sunRise = 24 * 60 + 6 * 60
|
|
|
+ var sunRise = 24 * 60 + 6 * 60
|
|
|
var sunSet = 18 * 60
|
|
|
|
|
|
- if (dayNight.gpsInfo && user.test_user){
|
|
|
+ if (dayNight.gpsInfo && user.test_user) {
|
|
|
var sunRiseObj = dayNight.gpsInfo.daylights[0].sunrise
|
|
|
var sunSetObj = dayNight.gpsInfo.daylights[0].sunset
|
|
|
- sunRise = 24*60+parseInt(sunRiseObj.split(':')[0])*60+parseInt(sunRiseObj.split(':')[1])
|
|
|
- sunSet = parseInt(sunSetObj.split(':')[0])*60+parseInt(sunSetObj.split(':')[1])
|
|
|
- if (sunSetObj.indexOf('PM')!=-1){
|
|
|
- sunSet+=12*60
|
|
|
+ sunRise = 24 * 60 + parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
|
|
|
+ sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
|
|
|
+ if (sunSetObj.indexOf('PM') != -1) {
|
|
|
+ sunSet += 12 * 60
|
|
|
}
|
|
|
}
|
|
|
var duration = sunRise - sunSet
|
|
|
@@ -286,8 +267,20 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
|
|
|
function fastDuration() {
|
|
|
if (record.fast.status == 'WAIT_FOR_END') {
|
|
|
+
|
|
|
return TimeFormatter.formateTimeDifference(record.fast.real_start_time, new Date().getTime(), false)
|
|
|
}
|
|
|
+ if (isStageMode && record.scenario == 'FAST_SLEEP') {
|
|
|
+ if (stageList[0]) {
|
|
|
+ return TimeFormatter.durationFormate(record.fast.target_start_time, record.sleep.target_start_time)
|
|
|
+ }
|
|
|
+ if (stageList[1]) {
|
|
|
+ return TimeFormatter.durationFormate(record.sleep.target_start_time, record.sleep.target_end_time)
|
|
|
+ }
|
|
|
+ if (stageList[2]) {
|
|
|
+ return TimeFormatter.durationFormate(record.sleep.target_end_time, record.fast.target_end_time)
|
|
|
+ }
|
|
|
+ }
|
|
|
return getDuration(record.fast)
|
|
|
}
|
|
|
|
|
|
@@ -303,29 +296,39 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
return
|
|
|
}
|
|
|
- global.selectData = props.data
|
|
|
- global.scenario = props.type
|
|
|
- jumpPage('/pages/clock/Clock', 'Clock', navigation)
|
|
|
+ setShowDetailModal(true)
|
|
|
+ // global.selectData = props.data
|
|
|
+ // global.scenario = props.type
|
|
|
+ // jumpPage('/pages/clock/Clock', 'Clock', navigation)
|
|
|
}
|
|
|
|
|
|
- function nightDuration(){
|
|
|
- if (dayNight.gpsInfo && dayNight.isMember){
|
|
|
+ function nightDuration() {
|
|
|
+ if (dayNight.gpsInfo && dayNight.isMember) {
|
|
|
var sunRiseObj = dayNight.gpsInfo.daylights[0].sunrise
|
|
|
var sunSetObj = dayNight.gpsInfo.daylights[0].sunset
|
|
|
- var sunRise = 24*60+parseInt(sunRiseObj.split(':')[0])*60+parseInt(sunRiseObj.split(':')[1])
|
|
|
- var sunSet = parseInt(sunSetObj.split(':')[0])*60+parseInt(sunSetObj.split(':')[1])
|
|
|
- if (sunSetObj.indexOf('PM')!=-1){
|
|
|
- sunSet+=12*60
|
|
|
+ var sunRise = 24 * 60 + parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
|
|
|
+ var sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
|
|
|
+ if (sunSetObj.indexOf('PM') != -1) {
|
|
|
+ sunSet += 12 * 60
|
|
|
}
|
|
|
|
|
|
- var duration = (sunRise-sunSet)*60*1000
|
|
|
+ var duration = (sunRise - sunSet) * 60 * 1000
|
|
|
|
|
|
- return TimeFormatter.calculateTimeDifference(new Date().getTime(),new Date().getTime()+duration);
|
|
|
- }else {
|
|
|
+ return TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
|
|
|
+ } else {
|
|
|
return '12小时'
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function schedules() {
|
|
|
+ var timestamp = new Date().getTime()//props.data.first_real_check_time
|
|
|
+
|
|
|
+ return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
+ <TimelineStage data={record} title={t('feature.track_time_duration.record_fast_sleep.pop_title')}
|
|
|
+ subTitle='今天' first_real_check_time={timestamp} />
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+
|
|
|
return <View className="time_operate_item" onClick={goClock}>
|
|
|
<View className="fast_sleep_item">
|
|
|
{
|
|
|
@@ -354,12 +357,18 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
}
|
|
|
</View>
|
|
|
{/* <Image className="arrow1" src={require('@/assets/images/arrow.png')} /> */}
|
|
|
- <View className="record_arrow_bg" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
|
|
|
+ {/* <View className="record_arrow_bg" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
|
|
|
<View style={{ flex: 1 }} />
|
|
|
<Text className='recordTime'>{getArrowText()}</Text>
|
|
|
<Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
|
|
|
- </View>
|
|
|
+ </View> */}
|
|
|
|
|
|
</View>
|
|
|
+ {
|
|
|
+ showDetailModal && <Modal children={schedules()}
|
|
|
+ modalType={ModalType.center}
|
|
|
+ dismiss={() => setShowDetailModal(false)}
|
|
|
+ confirm={() => { }} />
|
|
|
+ }
|
|
|
</View>
|
|
|
}
|