import { View, Text } from "@tarojs/components";
import trackTimeService, { machine } from "@/store/trackTimeMachine"
import { useEffect, useState } from "react";
import Taro from "@tarojs/taro";
import Box from "@/components/layout/Box";
import './Schedule.scss'
import { useTranslation } from "react-i18next";
import TimelineFastSleep from "./TimelineFastSleep";
import Switch from "@/components/input/Switch";
import { useDispatch, useSelector } from "react-redux";
import { TimeFormatter } from "@/utils/time_format";
import Buttons from "@/components/basic/Buttons";
import { ButtonType } from "@/utils/types";
import { setStep } from "@/store/scenario";
import Segment from "@/components/navigation/Segment";
export default function Component(props: { type?: string, data?: any, delSuccess?: Function }) {
const { t } = useTranslation()
const permission = useSelector((state: any) => state.permission);
const common = useSelector((state: any) => state.common);
const time = useSelector((state: any) => state.time);
const dispatch = useDispatch();
function all() {
if (props.type == 'latest') {
Taro.navigateTo({
url: '/pages/common/RecordsHistory?type=time&title=Time'
})
}
}
function showStage() {
}
function followWxPub() {
const resource = common.resources.filter((item: any) => {
return item.code == 'follow_wx_pub'
})
Taro.showModal({
title: '提示',
content: '关注公众号后可接收提醒\n点击确定,前往关注',
showCancel: true,
success(result) {
if (result.confirm) {
Taro.navigateTo({
url: '/pages/common/H5?title=fast16cc 关注服务号&url=' + resource[0].url,
})
}
},
})
}
function detailHeader() {
var btnStyle;
if (props.data.scenario == 'SLEEP') {
btnStyle = {
fontSize: 14,
lineHeight: 18,
color: '#00FFFF'
}
}
else if (props.data.scenario == 'FAST') {
btnStyle = {
fontSize: 14,
lineHeight: 18,
color: '#AAFF00'
}
}
else if (props.data.scenario == 'FAST_SLEEP') {
btnStyle = {
fontSize: 14,
lineHeight: 18,
// background: 'linear-gradient(90deg, #AAFF00 0%, #00FFFF 100%)',
// WebkitBackgroundClip: 'text',
// backgroundClip: 'text',
// color: 'transparent'
}
}
return
{permission.wxPubFollow ? TimeFormatter.getDateAndWeek() : '日程提醒'}
{
!permission.wxPubFollow &&
followWxPub()} />
}
{
permission.wxPubFollow && props.data.status == 'WAIT_FOR_START' && {
if (props.data.name == 'FAST_SLEEP') {
dispatch(setStep('fast'))
}
else if (props.data.name == 'SLEEP') {
dispatch(setStep('sleep'))
}
else {
dispatch(setStep('fast'))
}
Taro.navigateTo({
url: '/pages/clock/SetSchedule'
})
}} />
}
}
function detailCenter() {
if (!permission.wxPubFollow) {
return
开启后,将显示今天的日程。
}
var nextCheckTimestamp = 0;
if (time.status != 'WAIT_FOR_START') {
if (time.status == 'ONGOING') {
nextCheckTimestamp = time.scenario == 'FAST' ?
time.fast.target_end_time : time.sleep.target_end_time
}
else {
switch (time.status) {
case 'ONGOING1':
nextCheckTimestamp = time.sleep.target_start_time
break;
case 'ONGOING2':
nextCheckTimestamp = time.sleep.target_end_time
break
case 'ONGOING3':
nextCheckTimestamp = time.fast.target_end_time
break
}
}
}
var today = new Date();
today.setHours(0)
today.setMinutes(0)
today.setSeconds(0)
if (nextCheckTimestamp!=0 && today.getTime()>nextCheckTimestamp){
return
完成当前记录,恢复今天的日程。
}
return
show detail
}
function detailFooter() {
}
function detail() {
return
{
detailHeader()
}
{
detailCenter()
}
{
props.data.scenario == 'FAST_SLEEP' && (props.data.status == 'WAIT_FOR_START' ? Duration goals by stage : Current stage)
}
}
return
{
detail()
}
}