|
|
@@ -8,7 +8,7 @@ import { jumpPage } from "../trackTimeDuration/hooks/Common";
|
|
|
import Modal from "@/components/layout/Modal.weapp";
|
|
|
import { MainColorType } from "@/context/themes/color";
|
|
|
import ConsolePicker from "../trackTimeDuration/components/ConsolePicker";
|
|
|
-import { clockTimes, delRecord, makeDone, updateEventDuration, updateFast, updateSchedule, updateTarget } from "@/services/health";
|
|
|
+import { clockTimes, delRecord, getLabelsEvent, makeDone, updateEventDuration, updateFast, updateSchedule, updateTarget } from "@/services/health";
|
|
|
import TimePicker from "../common/TimePicker";
|
|
|
import showActionSheet from "@/components/basic/ActionSheet";
|
|
|
import { rpxToPx } from "@/utils/tools";
|
|
|
@@ -28,6 +28,7 @@ import Cell from "@/_health/base/cell";
|
|
|
import ConsoleCell from "@/_health/components/console_cell";
|
|
|
import IconTitleCell from "@/_health/components/icon_title_cell";
|
|
|
import StatusIndicator, { StatusType } from "@/_health/base/status_indicator";
|
|
|
+import AddLabel from "@/_health/components/add_label";
|
|
|
|
|
|
let useNavigation;
|
|
|
let min = 0
|
|
|
@@ -36,6 +37,7 @@ let defaultTimestamp = 0
|
|
|
|
|
|
let lastFastSleepStatus = ''
|
|
|
|
|
|
+
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
|
}
|
|
|
@@ -48,6 +50,9 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
const [selItem, setSelItem] = useState<any>(null)
|
|
|
const [hideGuideTip, setHideGuideTip] = useState(false)
|
|
|
const [hideErrorTip, setHideErrorTip] = useState(false)
|
|
|
+ const [labels, setLabels] = useState<any>([])
|
|
|
+ const [showModal, setShowModal] = useState(false)
|
|
|
+
|
|
|
|
|
|
const [hideEatArchiveTip, setHideEatArchiveTip] = useState(false)
|
|
|
const [hideActiveArchiveTip, setHideActiveArchiveTip] = useState(false)
|
|
|
@@ -59,6 +64,12 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
navigation = useNavigation()
|
|
|
}
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ getLabelsEvent({ window: 'ACTIVE' }).then(res => {
|
|
|
+ setLabels((res as any).labels)
|
|
|
+ })
|
|
|
+ }, [])
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
if (health.fast_with_sleep.status == 'OG2_MISALIGNED' || health.fast_with_sleep.status == 'OG2_NO1') {
|
|
|
if (lastFastSleepStatus != health.fast_with_sleep.status) {
|
|
|
@@ -73,8 +84,8 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
chooseLocation()
|
|
|
}
|
|
|
|
|
|
- global.postMementSuccess = ()=>{
|
|
|
- if (health.mode == 'ACTIVE'){
|
|
|
+ global.postMementSuccess = () => {
|
|
|
+ if (health.mode == 'ACTIVE') {
|
|
|
setHideActiveArchiveTip(false)
|
|
|
global.hideActiveArchiveTip = false
|
|
|
}
|
|
|
@@ -107,7 +118,7 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (item.event == 'FAST_START' && health.long_fast.status == 'OG') {
|
|
|
+ if ((item.event == 'FAST_START' || item.event == 'FAST_END') && health.long_fast.status == 'OG') {
|
|
|
showAlert({
|
|
|
title: '长断食进行中',
|
|
|
content: '当前有一个正在进行的长断食记录,要转换为间歇性断食吗?',
|
|
|
@@ -276,25 +287,6 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
jumpPage(`/_health/pages/timeline_detail?event_id=${item.event_id}&schedule_id=${item.schedule_id}`)
|
|
|
}
|
|
|
|
|
|
- function getIconColor(index) {
|
|
|
- var color = getThemeColor(health.mode)
|
|
|
- const time = new Date().getTime()
|
|
|
- const scenario = getScenario(health.windows, health.mode)
|
|
|
- const timeline = scenario.timeline[index]
|
|
|
- if (health.mode == 'DAY' || health.mode == 'NIGHT') {
|
|
|
- if (time > timeline.target.timestamp) {
|
|
|
- return MainColorType.g03
|
|
|
- }
|
|
|
- }
|
|
|
- if (timeline.real) {
|
|
|
- return MainColorType.g03
|
|
|
- }
|
|
|
- if (timeline.target.timestamp < new Date().getTime()) {
|
|
|
- return MainColorType.error
|
|
|
- }
|
|
|
- return color
|
|
|
- }
|
|
|
-
|
|
|
function processIcon(index) {
|
|
|
const time = new Date().getTime()
|
|
|
const scenario = getScenario(health.windows, health.mode)
|
|
|
@@ -657,7 +649,21 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
return
|
|
|
}
|
|
|
- jumpPage('/_health/pages/active_plan?schedule=' + JSON.stringify(list.length > 0 ? list[0] : '{}'))
|
|
|
+ if (!health.finish_setup) {
|
|
|
+ showAlert({
|
|
|
+ title: '',
|
|
|
+ content: '在整个日程中,创建您的活动安排',
|
|
|
+ showCancel: true,
|
|
|
+ cancelText: '稍后',
|
|
|
+ confirmText: '立即设置',
|
|
|
+ confirm: () => {
|
|
|
+ tapGuide()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ setShowModal(true)
|
|
|
+ // jumpPage('/_health/pages/active_plan?schedule=' + JSON.stringify(list.length > 0 ? list[0] : '{}'))
|
|
|
}}
|
|
|
/>
|
|
|
}
|
|
|
@@ -882,11 +888,11 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
if (scenario.archive_timestamp) {
|
|
|
var today = new Date().getDate()
|
|
|
var date = new Date(scenario.archive_timestamp).getDate()
|
|
|
- if (today == date){
|
|
|
- strTitle = t('health.tonight_at',{time:dayjs(scenario.archive_timestamp).format('HH:mm')})
|
|
|
+ if (today == date) {
|
|
|
+ strTitle = t('health.tonight_at', { time: dayjs(scenario.archive_timestamp).format('HH:mm') })
|
|
|
}
|
|
|
else {
|
|
|
- strTitle = t('health.tomorrow_at',{time:dayjs(scenario.archive_timestamp).format('HH:mm')})
|
|
|
+ strTitle = t('health.tomorrow_at', { time: dayjs(scenario.archive_timestamp).format('HH:mm') })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -895,13 +901,13 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
}}>
|
|
|
<View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
|
|
|
<Text className="h28 bold" style={{ color: getThemeColor(health.mode) }}>{strTitle}</Text>
|
|
|
- <Text className="h24 bold">{t('health.all_logs',{scenario:health.mode=='EAT'?t('health.meals'):t('health.activities')})}<Text style={{fontWeight:'normal'}}>{t('health.will_collected')}</Text>{t('health.journal_end')}</Text>
|
|
|
+ <Text className="h24 bold">{t('health.all_logs', { scenario: health.mode == 'EAT' ? t('health.meals') : t('health.activities') })}<Text style={{ fontWeight: 'normal' }}>{t('health.will_collected')}</Text>{t('health.journal_end')}</Text>
|
|
|
</View>
|
|
|
<NewButton type={NewButtonType.img} btnStyle={{
|
|
|
height: rpxToPx(32),
|
|
|
width: rpxToPx(32)
|
|
|
}} onClick={() => {
|
|
|
- if (health.mode == 'EAT'){
|
|
|
+ if (health.mode == 'EAT') {
|
|
|
setHideEatArchiveTip(true)
|
|
|
}
|
|
|
else {
|
|
|
@@ -1064,5 +1070,32 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
setDurationPicker(false)
|
|
|
}} time={getScenario(health.windows, health.mode).target.duration} />
|
|
|
}
|
|
|
+
|
|
|
+ {
|
|
|
+ showModal && <AddLabel labels={labels}
|
|
|
+ window='ACTIVE'
|
|
|
+ disMiss={() => setShowModal(false)}
|
|
|
+ op_page='SCHEDULE_ACTIVE_SLEEP'
|
|
|
+ // onlyCheck={true}
|
|
|
+ // schedules={[]}
|
|
|
+ confirm={(res) => {
|
|
|
+ setShowModal(false)
|
|
|
+ if ((res as any).result) {
|
|
|
+ global.refreshWindow()
|
|
|
+ // dispatch(setSchedules((res as any).schedules))
|
|
|
+ // dispatch(setFooter((res as any).footer))
|
|
|
+ // setList((res as any).schedules)
|
|
|
+ // setErrors([])
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ jumpPage('/_health/pages/schedules?mode=' + health.mode+'&error='+JSON.stringify(res))
|
|
|
+ // setList((res as any).schedules)
|
|
|
+ // dispatch(setFooter((res as any).footer))
|
|
|
+ // setErrors((res as any).error_messages ? (res as any).error_messages : [])
|
|
|
+ }
|
|
|
+
|
|
|
+ }}
|
|
|
+ color={MainColorType.active} />
|
|
|
+ }
|
|
|
</View >
|
|
|
}
|