|
@@ -3,7 +3,7 @@ import trackTimeService, { machine } from "@/store/trackTimeMachine";
|
|
|
import { View, Text } from "@tarojs/components";
|
|
import { View, Text } from "@tarojs/components";
|
|
|
import { useEffect, useState } from "react";
|
|
import { useEffect, useState } from "react";
|
|
|
import { TimeFormatter } from "@/utils/time_format";
|
|
import { TimeFormatter } from "@/utils/time_format";
|
|
|
-import Rings2, { BgRing, CurrentDot, RingCommon } from './Rings';
|
|
|
|
|
|
|
+import Rings2, { BgRing, CurrentDot, RealRing, RingCommon } from './Rings';
|
|
|
|
|
|
|
|
export default function Component() {
|
|
export default function Component() {
|
|
|
const [checkData, setCheckData] = useState(null)
|
|
const [checkData, setCheckData] = useState(null)
|
|
@@ -28,7 +28,7 @@ export default function Component() {
|
|
|
radius: 50,
|
|
radius: 50,
|
|
|
lineWidth: 8,
|
|
lineWidth: 8,
|
|
|
isFast: true,
|
|
isFast: true,
|
|
|
- status: 'WAIT_FOR_START'
|
|
|
|
|
|
|
+ status: checkData ? (checkData as any).current_record.status : 'WAIT_FOR_START'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const common2: RingCommon = {
|
|
const common2: RingCommon = {
|
|
@@ -36,7 +36,7 @@ export default function Component() {
|
|
|
radius: 40,
|
|
radius: 40,
|
|
|
lineWidth: 8,
|
|
lineWidth: 8,
|
|
|
isFast: true,
|
|
isFast: true,
|
|
|
- status: 'WAIT_FOR_START'
|
|
|
|
|
|
|
+ status: checkData ? (checkData as any).current_record.status : 'WAIT_FOR_START'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const bgRing: BgRing = {
|
|
const bgRing: BgRing = {
|
|
@@ -55,24 +55,127 @@ export default function Component() {
|
|
|
borderColor: 'black'
|
|
borderColor: 'black'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const realRing: RealRing = {
|
|
|
|
|
+ color: '#AAFF00',
|
|
|
|
|
+ startArc: 0,
|
|
|
|
|
+ durationArc: 0
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const realRing2: RealRing = {
|
|
|
|
|
+ color: '#00FFFF',
|
|
|
|
|
+ startArc: 0,
|
|
|
|
|
+ durationArc: 0
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function startArc(time: number) {
|
|
|
|
|
+ var date = new Date(time);
|
|
|
|
|
+ var hour = date.getHours();
|
|
|
|
|
+ var minute = date.getMinutes();
|
|
|
|
|
+ var second = date.getSeconds();
|
|
|
|
|
+ return (hour * 3600 + minute * 60 + second) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function durationArc(time: number) {
|
|
|
|
|
+ var duration = (new Date().getTime() - time) / 1000;
|
|
|
|
|
+ return duration / (24 * 3600) * 2 * Math.PI;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (common.status == 'ONGOING') {
|
|
|
|
|
+ var obj = (checkData as any).current_record;
|
|
|
|
|
+ if (obj.scenario == 'FAST') {
|
|
|
|
|
+ var start_time = obj.fast.real_start_time;
|
|
|
|
|
+ realRing.startArc = startArc(start_time);
|
|
|
|
|
+ realRing.durationArc = durationArc(start_time);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ var start_time = obj.sleep.real_start_time;
|
|
|
|
|
+ realRing.startArc = startArc(start_time);
|
|
|
|
|
+ realRing.durationArc = durationArc(start_time);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (common.status == 'ONGOING1') {
|
|
|
|
|
+ var obj = (checkData as any).current_record.fast;
|
|
|
|
|
+ var start_time = obj.real_start_time;
|
|
|
|
|
+ realRing.startArc = startArc(start_time);
|
|
|
|
|
+ realRing.durationArc = durationArc(start_time);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (common.status == 'ONGOING2') {
|
|
|
|
|
+ var fast = (checkData as any).current_record.fast;
|
|
|
|
|
+ var start_time = fast.real_start_time;
|
|
|
|
|
+ realRing.startArc = startArc(start_time);
|
|
|
|
|
+ realRing.durationArc = durationArc(start_time);
|
|
|
|
|
+
|
|
|
|
|
+ var sleep = (checkData as any).current_record.sleep;
|
|
|
|
|
+ var start_time2 = sleep.real_start_time;
|
|
|
|
|
+ realRing2.startArc = startArc(start_time2);
|
|
|
|
|
+ realRing2.durationArc = durationArc(start_time2);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (common.status == 'ONGOING3') {
|
|
|
|
|
+ var fast = (checkData as any).current_record.fast;
|
|
|
|
|
+ var start_time = fast.real_start_time;
|
|
|
|
|
+ realRing.startArc = startArc(start_time);
|
|
|
|
|
+ realRing.durationArc = durationArc(start_time);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //外环
|
|
|
|
|
+ function bigRing() {
|
|
|
|
|
+ if (!checkData) {
|
|
|
|
|
+ return <Rings2 common={common} bgRing={bgRing} currentDot={currentDot} canvasId='clock0' />
|
|
|
|
|
+ }
|
|
|
|
|
+ var current_record = (checkData as any).current_record
|
|
|
|
|
+ if (current_record.scenario == 'FAST') {
|
|
|
|
|
+ if (current_record.status == 'ONGOING') {
|
|
|
|
|
+ return <Rings2 common={common} bgRing={bgRing} realRing={realRing} currentDot={currentDot} canvasId='clock1' />
|
|
|
|
|
+ }
|
|
|
|
|
+ return <Rings2 common={common} bgRing={bgRing} currentDot={currentDot} canvasId='clock2' />
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (current_record.scenario == 'SLEEP') {
|
|
|
|
|
+ if (current_record.status == 'ONGOING') {
|
|
|
|
|
+ return <Rings2 common={common} bgRing={bgRing} realRing={realRing2} currentDot={currentDot2} canvasId='clock3' />
|
|
|
|
|
+ }
|
|
|
|
|
+ return <Rings2 common={common} bgRing={bgRing} currentDot={currentDot2} canvasId='clock4' />
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ if (current_record.status == 'WAIT_FOR_START') {
|
|
|
|
|
+ return <Rings2 common={common} bgRing={bgRing} currentDot={currentDot} canvasId='clock5' />
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ return <Rings2 common={common} bgRing={bgRing} realRing={realRing} currentDot={currentDot} canvasId='clock6' />
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //内环
|
|
|
|
|
+ function smallRing() {
|
|
|
|
|
+ var current_record = (checkData as any).current_record
|
|
|
|
|
+ if (current_record.scenario == 'FAST_SLEEP') {
|
|
|
|
|
+ if (current_record.status == 'ONGOING2') {
|
|
|
|
|
+ return <Rings2 common={common2} bgRing={bgRing} realRing={realRing2} currentDot={currentDot2} canvasId='clock7' />
|
|
|
|
|
+ }
|
|
|
|
|
+ if (current_record.status == 'ONGOING3') {
|
|
|
|
|
+ currentDot2.color = 'rgba(0, 255, 255, 0.5)'
|
|
|
|
|
+ }
|
|
|
|
|
+ return <Rings2 common={common2} bgRing={bgRing} currentDot={currentDot2} canvasId='clock8' />
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!checkData)
|
|
if (!checkData)
|
|
|
return <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: '100%', marginTop: 20 }}>
|
|
return <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: '100%', marginTop: 20 }}>
|
|
|
- {/* <Rings radius={50} /> */}
|
|
|
|
|
- <Rings2 common={common} bgRing={bgRing} currentDot={currentDot} canvasId='clock0'/>
|
|
|
|
|
-
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ bigRing()
|
|
|
|
|
+ }
|
|
|
</View>
|
|
</View>
|
|
|
return (
|
|
return (
|
|
|
<View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: '100%', marginTop: 20 }}>
|
|
<View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: '100%', marginTop: 20 }}>
|
|
|
- {/* <Rings radius={50} /> */}
|
|
|
|
|
- {/* <Rings2 common={common} bgRing={bgRing} currentDot={currentDot} /> */}
|
|
|
|
|
-
|
|
|
|
|
<View style={{ position: 'relative', zIndex: 1 }}>
|
|
<View style={{ position: 'relative', zIndex: 1 }}>
|
|
|
- <Rings2 common={common} bgRing={bgRing} currentDot={(checkData as any).current_record.scenario == 'SLEEP' ? currentDot2 : currentDot} canvasId='clock1' />
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ bigRing()
|
|
|
|
|
+ }
|
|
|
<View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
|
|
<View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
|
|
|
- {/* <Rings radius={23} strokeWidth={6} color='#00FFFF' canvasId='4' /> */}
|
|
|
|
|
{
|
|
{
|
|
|
- (checkData as any).current_record.scenario == 'FAST_SLEEP' &&
|
|
|
|
|
- <Rings2 common={common2} bgRing={bgRing} currentDot={currentDot2} canvasId='clock2' />
|
|
|
|
|
|
|
+ smallRing()
|
|
|
}
|
|
}
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|