|
@@ -1,5 +1,5 @@
|
|
|
import { View, Text, Image } from "@tarojs/components";
|
|
import { View, Text, Image } from "@tarojs/components";
|
|
|
-import { dotIsOuterRange, getBgRing, getCommon, getDot, getReal, getSchedule, getTarget } from "../hooks/RingData";
|
|
|
|
|
|
|
+import { dotIsOuterRange, getBgRing, getCommon, getDot, getReal, getSchedule, getTarget, timeTotimestamp } from "../hooks/RingData";
|
|
|
import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
|
|
import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
|
|
|
import Rings from "./Rings";
|
|
import Rings from "./Rings";
|
|
|
import './IndexItem.scss'
|
|
import './IndexItem.scss'
|
|
@@ -18,19 +18,26 @@ let useNavigation;
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
|
}
|
|
}
|
|
|
-export default function Component(props: { type: string, data: any, time: any }) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+let popTimer;
|
|
|
|
|
+let currentRecordTemp;
|
|
|
|
|
+export default function Component(props: { type: string, data: any, time: any, showStage?: boolean }) {
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
- const record = props.data.current_record;
|
|
|
|
|
|
|
+ const [record, setRecord] = useState(props.data.current_record);
|
|
|
const user = useSelector((state: any) => state.user);
|
|
const user = useSelector((state: any) => state.user);
|
|
|
const dayNight = useSelector((state: any) => state.dayNight);
|
|
const dayNight = useSelector((state: any) => state.dayNight);
|
|
|
const [stageList, setStageList] = useState([true, false, false])
|
|
const [stageList, setStageList] = useState([true, false, false])
|
|
|
const [isStageMode, setIsStageMode] = useState(false)
|
|
const [isStageMode, setIsStageMode] = useState(false)
|
|
|
- const [showDetailModal, setShowDetailModal] = useState(false)
|
|
|
|
|
let navigation;
|
|
let navigation;
|
|
|
if (useNavigation) {
|
|
if (useNavigation) {
|
|
|
navigation = useNavigation()
|
|
navigation = useNavigation()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ setRecord(props.data.current_record)
|
|
|
|
|
+ currentRecordTemp = props.data.current_record
|
|
|
|
|
+ }, [props.data])
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (props.type == 'FAST_SLEEP') {
|
|
if (props.type == 'FAST_SLEEP') {
|
|
|
global.updateMixItem = (data) => {
|
|
global.updateMixItem = (data) => {
|
|
@@ -70,7 +77,7 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
return <Rings common={common} bgRing={bgRing} currentDot={currentDot1} realRing={realRing1} targetRing={targetBigRing1} canvasId={props.type + props.time + 'big'} />
|
|
return <Rings common={common} bgRing={bgRing} currentDot={currentDot1} realRing={realRing1} targetRing={targetBigRing1} canvasId={props.type + props.time + 'big'} />
|
|
|
}
|
|
}
|
|
|
if (record.status == 'WAIT_FOR_START') {
|
|
if (record.status == 'WAIT_FOR_START') {
|
|
|
- var realRing1 = getSchedule(record, props.type != 'SLEEP', true)
|
|
|
|
|
|
|
+ var realRing1 = getSchedule(props.data.scenario, props.type != 'SLEEP', true, true)//getSchedule(record, props.type != 'SLEEP', true)
|
|
|
var list: any = []
|
|
var list: any = []
|
|
|
if (props.type == 'FAST_SLEEP') {
|
|
if (props.type == 'FAST_SLEEP') {
|
|
|
realRing1.color = ColorType.fast + '66'
|
|
realRing1.color = ColorType.fast + '66'
|
|
@@ -79,12 +86,14 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
currentDot1.color = ColorType.ring
|
|
currentDot1.color = ColorType.ring
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ var detail = timeTotimestamp(props.data.scenario)
|
|
|
|
|
+
|
|
|
if (stageList[0]) {
|
|
if (stageList[0]) {
|
|
|
|
|
|
|
|
const realRingBig: RealRing = {
|
|
const realRingBig: RealRing = {
|
|
|
color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
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)
|
|
|
|
|
|
|
+ startArc: startArc(detail.fast.target_start_time),
|
|
|
|
|
+ durationArc: durationArc(detail.fast.target_start_time, detail.sleep.target_start_time)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
list.push(realRingBig)
|
|
list.push(realRingBig)
|
|
@@ -92,8 +101,8 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
if (stageList[1]) {
|
|
if (stageList[1]) {
|
|
|
const realRingBig: RealRing = {
|
|
const realRingBig: RealRing = {
|
|
|
color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
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)
|
|
|
|
|
|
|
+ startArc: startArc(detail.sleep.target_start_time),
|
|
|
|
|
+ durationArc: durationArc(detail.sleep.target_start_time, detail.sleep.target_end_time)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
list.push(realRingBig)
|
|
list.push(realRingBig)
|
|
@@ -101,8 +110,8 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
if (stageList[2]) {
|
|
if (stageList[2]) {
|
|
|
const realRingBig: RealRing = {
|
|
const realRingBig: RealRing = {
|
|
|
color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
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)
|
|
|
|
|
|
|
+ startArc: startArc(detail.sleep.target_end_time),
|
|
|
|
|
+ durationArc: durationArc(detail.sleep.target_end_time, detail.fast.target_end_time)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
list.push(realRingBig)
|
|
list.push(realRingBig)
|
|
@@ -135,7 +144,7 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
return <Rings common={common} bgRing={bgRing} currentDot={currentDot} canvasId={props.type + props.time + 'small'} targetRing={targetBigRing1} realRing={realRing} />
|
|
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') {
|
|
else if (record.status == 'WAIT_FOR_START' || record.status == 'ONGOING1') {
|
|
|
- realRing = getSchedule(record, false, true)
|
|
|
|
|
|
|
+ realRing = getSchedule(props.data.scenario, false, true, true)//getSchedule(record, false, true)
|
|
|
var currentDot = getDot(record, false)
|
|
var currentDot = getDot(record, false)
|
|
|
if (dotIsOuterRange(true, record.sleep)) {
|
|
if (dotIsOuterRange(true, record.sleep)) {
|
|
|
currentDot.color = ColorType.ring
|
|
currentDot.color = ColorType.ring
|
|
@@ -226,7 +235,7 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- props.type == 'FAST_SLEEP' && user.isLogin && global.showNightRing === true && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
|
|
|
|
|
|
|
+ props.type == 'FAST_SLEEP' && !props.showStage && user.isLogin && global.showNightRing === true && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
|
|
|
{
|
|
{
|
|
|
dayRing()
|
|
dayRing()
|
|
|
}
|
|
}
|
|
@@ -236,16 +245,6 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function getArrowText() {
|
|
|
|
|
- if (record.status == 'WAIT_FOR_START') {
|
|
|
|
|
- return '去开始'
|
|
|
|
|
- }
|
|
|
|
|
- if (record.status == 'ONGOING1' && props.type == 'SLEEP') {
|
|
|
|
|
- return '去开始'
|
|
|
|
|
- }
|
|
|
|
|
- return '去结束'
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
function getDuration(obj) {
|
|
function getDuration(obj) {
|
|
|
if (!obj) {
|
|
if (!obj) {
|
|
|
}
|
|
}
|
|
@@ -296,10 +295,16 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- setShowDetailModal(true)
|
|
|
|
|
- // global.selectData = props.data
|
|
|
|
|
- // global.scenario = props.type
|
|
|
|
|
- // jumpPage('/pages/clock/Clock', 'Clock', navigation)
|
|
|
|
|
|
|
+ if (props.showStage) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ var node = schedules()
|
|
|
|
|
+ global.showIndexModal3(true, node, null);
|
|
|
|
|
+ popTimer = setInterval(() => {
|
|
|
|
|
+ var node = schedules()
|
|
|
|
|
+ global.showIndexModal3(true, node, null);
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+ global.popTimer = popTimer
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function nightDuration() {
|
|
function nightDuration() {
|
|
@@ -322,53 +327,78 @@ export default function Component(props: { type: string, data: any, time: any })
|
|
|
|
|
|
|
|
function schedules() {
|
|
function schedules() {
|
|
|
var timestamp = new Date().getTime()//props.data.first_real_check_time
|
|
var timestamp = new Date().getTime()//props.data.first_real_check_time
|
|
|
-
|
|
|
|
|
return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
- <TimelineStage data={record} title={t('feature.track_time_duration.record_fast_sleep.pop_title')}
|
|
|
|
|
|
|
+ <TimelineStage data={currentRecordTemp} title={t('feature.track_time_duration.record_fast_sleep.pop_title')}
|
|
|
subTitle='今天' first_real_check_time={timestamp} />
|
|
subTitle='今天' first_real_check_time={timestamp} />
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return <View className="time_operate_item" onClick={goClock}>
|
|
|
|
|
|
|
+ function fastPicker() {
|
|
|
|
|
+ var node = schedules()
|
|
|
|
|
+ global.showIndexModal2(true, node, null);
|
|
|
|
|
+ popTimer = setInterval(() => {
|
|
|
|
|
+ var node = schedules()
|
|
|
|
|
+ global.showIndexModal2(true, node, null);
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+ global.popTimer = popTimer
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function sleepPicker(e) {
|
|
|
|
|
+ if (record.status == 'ONGOING3') {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (record.status == 'WAIT_FOR_START') {
|
|
|
|
|
+ Taro.showToast({
|
|
|
|
|
+ title: t('feature.track_time_duration.common.start_fasting_first'),
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ var node = schedules()
|
|
|
|
|
+ global.showIndexModal2(true, node, null);
|
|
|
|
|
+ popTimer = setInterval(() => {
|
|
|
|
|
+ var node = schedules()
|
|
|
|
|
+ global.showIndexModal2(true, node, null);
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+ global.popTimer = popTimer
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return <View className="time_operate_item">
|
|
|
<View className="fast_sleep_item">
|
|
<View className="fast_sleep_item">
|
|
|
{
|
|
{
|
|
|
rings()
|
|
rings()
|
|
|
}
|
|
}
|
|
|
<View className="duration_bg">
|
|
<View className="duration_bg">
|
|
|
{
|
|
{
|
|
|
- props.type == 'FAST_SLEEP' && user.isLogin && global.showNightRing === true &&
|
|
|
|
|
- <Text className="duration_title">夜间</Text>
|
|
|
|
|
|
|
+ props.type == 'FAST_SLEEP' && !props.showStage && user.isLogin && global.showNightRing === true &&
|
|
|
|
|
+ <Text className="duration_title">{t('feature.common.overnight')}</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- props.type == 'FAST_SLEEP' && user.isLogin && global.showNightRing === true &&
|
|
|
|
|
|
|
+ props.type == 'FAST_SLEEP' && !props.showStage && user.isLogin && global.showNightRing === true &&
|
|
|
<Text className="duration_value" style={{ color: ColorType.night }}>{nightDuration()}</Text>
|
|
<Text className="duration_value" style={{ color: ColorType.night }}>{nightDuration()}</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- (props.type == 'FAST' || props.type == 'FAST_SLEEP') && <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.fast')}</Text>
|
|
|
|
|
|
|
+ (props.type == 'FAST' || props.type == 'FAST_SLEEP') && <Text className="duration_title" onClick={fastPicker}>{t('feature.track_time_duration.record_fast_sleep.item.fast')}</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- (props.type == 'FAST' || props.type == 'FAST_SLEEP') && <Text className="duration_value" style={{ color: global.fastColor ? global.fastColor : ColorType.fast }}>{fastDuration()}</Text>
|
|
|
|
|
|
|
+ (props.type == 'FAST' || props.type == 'FAST_SLEEP') && <Text className="duration_value" onClick={fastPicker} style={{ color: global.fastColor ? global.fastColor : ColorType.fast }}>{fastDuration()}</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- (props.type == 'SLEEP' || props.type == 'FAST_SLEEP') && <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.sleep')}</Text>
|
|
|
|
|
|
|
+ (props.type == 'SLEEP' || props.type == 'FAST_SLEEP') && <Text className="duration_title" onClick={sleepPicker}>{t('feature.track_time_duration.record_fast_sleep.item.sleep')}</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- (props.type == 'SLEEP' || props.type == 'FAST_SLEEP') && <Text className="duration_value" style={{ color: global.sleepColor ? global.sleepColor : ColorType.sleep }}>{sleepDuration()}</Text>
|
|
|
|
|
|
|
+ (props.type == 'SLEEP' || props.type == 'FAST_SLEEP') && <Text className="duration_value" onClick={sleepPicker} style={{ color: global.sleepColor ? global.sleepColor : ColorType.sleep }}>{sleepDuration()}</Text>
|
|
|
}
|
|
}
|
|
|
</View>
|
|
</View>
|
|
|
{/* <Image className="arrow1" src={require('@/assets/images/arrow.png')} /> */}
|
|
{/* <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' }} onClick={goClock}>
|
|
|
<View style={{ flex: 1 }} />
|
|
<View style={{ flex: 1 }} />
|
|
|
- <Text className='recordTime'>{getArrowText()}</Text>
|
|
|
|
|
|
|
+ {/* <Text className='recordTime'>{getArrowText()}</Text> */}
|
|
|
<Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
|
|
<Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
|
|
|
- </View> */}
|
|
|
|
|
|
|
+ </View>
|
|
|
|
|
+
|
|
|
|
|
+ {/* <t-popup></t-popup> */}
|
|
|
|
|
|
|
|
</View>
|
|
</View>
|
|
|
- {
|
|
|
|
|
- showDetailModal && <Modal children={schedules()}
|
|
|
|
|
- modalType={ModalType.center}
|
|
|
|
|
- dismiss={() => setShowDetailModal(false)}
|
|
|
|
|
- confirm={() => { }} />
|
|
|
|
|
- }
|
|
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|