|
@@ -8,12 +8,12 @@ import { jumpPage } from "../trackTimeDuration/hooks/Common";
|
|
|
import Modal from "@/components/layout/Modal.weapp";
|
|
import Modal from "@/components/layout/Modal.weapp";
|
|
|
import { MainColorType } from "@/context/themes/color";
|
|
import { MainColorType } from "@/context/themes/color";
|
|
|
import ConsolePicker from "../trackTimeDuration/components/ConsolePicker";
|
|
import ConsolePicker from "../trackTimeDuration/components/ConsolePicker";
|
|
|
-import { clockTimes, updateSchedule, updateTarget } from "@/services/health";
|
|
|
|
|
|
|
+import { clockTimes, makeDone, updateSchedule, updateTarget } from "@/services/health";
|
|
|
import TimePicker from "../common/TimePicker";
|
|
import TimePicker from "../common/TimePicker";
|
|
|
import showActionSheet from "@/components/basic/ActionSheet";
|
|
import showActionSheet from "@/components/basic/ActionSheet";
|
|
|
import { rpxToPx } from "@/utils/tools";
|
|
import { rpxToPx } from "@/utils/tools";
|
|
|
import { setMode } from "@/store/health";
|
|
import { setMode } from "@/store/health";
|
|
|
-import { getCountownTime, getDuration, getScenario, getWindowStatus } from "./hooks/health_hooks";
|
|
|
|
|
|
|
+import { getCountownTime, getDuration, getScenario, getThemeColor, getWindowStatus } from "./hooks/health_hooks";
|
|
|
import { IconMore } from "@/components/basic/Icons";
|
|
import { IconMore } from "@/components/basic/Icons";
|
|
|
|
|
|
|
|
let useNavigation;
|
|
let useNavigation;
|
|
@@ -95,7 +95,7 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- jumpPage('/pages/clock/AddMoment?moment=' + JSON.stringify(item))
|
|
|
|
|
|
|
+ jumpPage('/_health/pages/clock/add_moment?moment=' + JSON.stringify(item))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function operateTitle(item) {
|
|
function operateTitle(item) {
|
|
@@ -118,7 +118,7 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function itemValue(item: any) {
|
|
function itemValue(item: any) {
|
|
|
- let themeColor: any = getThemeColor()
|
|
|
|
|
|
|
+ let themeColor: any = getThemeColor(health.mode)
|
|
|
const scenario = getScenario(health.windows, health.mode)
|
|
const scenario = getScenario(health.windows, health.mode)
|
|
|
if (item.action == 'END' && !scenario.real) {
|
|
if (item.action == 'END' && !scenario.real) {
|
|
|
themeColor = '#B2B2B2'
|
|
themeColor = '#B2B2B2'
|
|
@@ -181,11 +181,11 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
var title, color;
|
|
var title, color;
|
|
|
switch (selItem.scenario) {
|
|
switch (selItem.scenario) {
|
|
|
case 'FAST':
|
|
case 'FAST':
|
|
|
- title = operateType == 'endFast' ? '结束断食' : '开始断食'
|
|
|
|
|
|
|
+ title = selItem.event == 'FAST_END' ? '结束断食' : '开始断食'
|
|
|
color = MainColorType.fast
|
|
color = MainColorType.fast
|
|
|
break;
|
|
break;
|
|
|
case 'SLEEP':
|
|
case 'SLEEP':
|
|
|
- title = operateType == 'endFast' ? '结束睡眠' : '开始睡眠'
|
|
|
|
|
|
|
+ title = selItem.event == 'SLEEP_END' ? '结束睡眠' : '开始睡眠'
|
|
|
color = MainColorType.sleep
|
|
color = MainColorType.sleep
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -233,7 +233,6 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- console.log('zzz')
|
|
|
|
|
|
|
|
|
|
updateSchedule({
|
|
updateSchedule({
|
|
|
time: strTime
|
|
time: strTime
|
|
@@ -262,16 +261,16 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
var title, color;
|
|
var title, color;
|
|
|
switch (selItem.scenario) {
|
|
switch (selItem.scenario) {
|
|
|
case 'FAST':
|
|
case 'FAST':
|
|
|
- title = operateType == 'endFast' ? '结束断食' : '开始断食'
|
|
|
|
|
|
|
+ title = selItem.event == 'FAST_END' ? '结束断食' : '开始断食'
|
|
|
color = MainColorType.fast
|
|
color = MainColorType.fast
|
|
|
break;
|
|
break;
|
|
|
case 'SLEEP':
|
|
case 'SLEEP':
|
|
|
- title = operateType == 'endFast' ? '结束睡眠' : '开始睡眠'
|
|
|
|
|
|
|
+ title = selItem.event == 'FAST_SLEEP' ? '结束睡眠' : '开始睡眠'
|
|
|
color = MainColorType.sleep
|
|
color = MainColorType.sleep
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var endTimestamp = 0
|
|
var endTimestamp = 0
|
|
|
- if (operateType == 'endFast') {
|
|
|
|
|
|
|
+ if (selItem.envent == 'FAST_END') {
|
|
|
endTimestamp = new Date().getTime()//fastData.target.end_time
|
|
endTimestamp = new Date().getTime()//fastData.target.end_time
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -324,42 +323,138 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function more() {
|
|
function more() {
|
|
|
|
|
+ var list: any = []
|
|
|
|
|
+ switch (health.mode) {
|
|
|
|
|
+ case 'DAY':
|
|
|
|
|
+ case 'NIGHT':
|
|
|
|
|
+ list = ['设置提醒']
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'FAST':
|
|
|
|
|
+ case 'SLEEP':
|
|
|
|
|
+ {
|
|
|
|
|
+ const obj = getScenario(health.windows, health.mode)
|
|
|
|
|
+ if (obj.window_id) {
|
|
|
|
|
+ list.push('编辑本次时长')
|
|
|
|
|
+ if (obj.timeline && obj.timeline[0].moment) {
|
|
|
|
|
+ list.push('删除本次记录')
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ list = ['编辑日程']
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'EAT':
|
|
|
|
|
+ {
|
|
|
|
|
+ list = [
|
|
|
|
|
+ 'Add Snack',
|
|
|
|
|
+ '自定义餐次列表',
|
|
|
|
|
+ ]
|
|
|
|
|
+
|
|
|
|
|
+ if (getScenario(health.windows, health.mode).window_id) {
|
|
|
|
|
+ list.push('Make done')
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'ACTIVE':
|
|
|
|
|
+ {
|
|
|
|
|
+ list = [
|
|
|
|
|
+ '记录一次活动',
|
|
|
|
|
+ '编辑日程',
|
|
|
|
|
+ ]
|
|
|
|
|
+
|
|
|
|
|
+ if (getScenario(health.windows, health.mode).window_id) {
|
|
|
|
|
+ list.push('Make done')
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
showActionSheet({
|
|
showActionSheet({
|
|
|
showActionSheetWithOptions: showActionSheetWithOptions,
|
|
showActionSheetWithOptions: showActionSheetWithOptions,
|
|
|
title: 'Oprate Title',
|
|
title: 'Oprate Title',
|
|
|
- itemList: [
|
|
|
|
|
- 'Add Snack',
|
|
|
|
|
- '自定义餐次列表',
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ itemList: list,
|
|
|
success: (res) => {
|
|
success: (res) => {
|
|
|
- switch (res) {
|
|
|
|
|
- case 0:
|
|
|
|
|
- break;
|
|
|
|
|
- case 1:
|
|
|
|
|
- jumpPage('/_eat/pages/meal_list')
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ tapActionSheet(res)
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function getThemeColor() {
|
|
|
|
|
- switch (health.mode) {
|
|
|
|
|
- case 'DAY':
|
|
|
|
|
- return MainColorType.day;
|
|
|
|
|
- case 'NIGHT':
|
|
|
|
|
- return MainColorType.night;
|
|
|
|
|
- case 'FAST':
|
|
|
|
|
- return MainColorType.fast;
|
|
|
|
|
- case 'EAT':
|
|
|
|
|
- return MainColorType.eat;
|
|
|
|
|
- case 'SLEEP':
|
|
|
|
|
- return MainColorType.sleep;
|
|
|
|
|
- case 'ACTIVE':
|
|
|
|
|
- return MainColorType.active;
|
|
|
|
|
|
|
+ function tapActionSheet(index) {
|
|
|
|
|
+ switch (index) {
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (health.mode) {
|
|
|
|
|
+ case 'DAY':
|
|
|
|
|
+ case 'NIGHT':
|
|
|
|
|
+ jumpPage('/_health/pages/setting_reminder')
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'FAST':
|
|
|
|
|
+ case 'SLEEP':
|
|
|
|
|
+ {
|
|
|
|
|
+ const obj = getScenario(health.windows, health.mode)
|
|
|
|
|
+ if (obj.window_id) {
|
|
|
|
|
+ //编辑本次时长
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ jumpPage('/_health/pages/edit_schedule')
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'EAT':
|
|
|
|
|
+ //add snack
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'ACTIVE':
|
|
|
|
|
+ //记录一次活动
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (health.mode) {
|
|
|
|
|
+ case 'EAT':
|
|
|
|
|
+ jumpPage('/_health/pages/edit_schedule')
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'FAST':
|
|
|
|
|
+ case 'SLEEP':
|
|
|
|
|
+ const obj = getScenario(health.windows, health.mode)
|
|
|
|
|
+ if (obj.window_id) {
|
|
|
|
|
+ //del record
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'ACTIVE':
|
|
|
|
|
+ jumpPage('/_health/pages/edit_schedule')
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (health.mode) {
|
|
|
|
|
+ case 'EAT':
|
|
|
|
|
+ case 'ACTIVE':
|
|
|
|
|
+ tapMakeDone()
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function tapMakeDone() {
|
|
|
|
|
+ makeDone(getScenario(health.windows, health.mode).window_id).then(res => {
|
|
|
|
|
+ global.refreshWindow()
|
|
|
|
|
+ global.refreshHistory()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function detail() {
|
|
function detail() {
|
|
|
const { day, night } = health.windows.night_day
|
|
const { day, night } = health.windows.night_day
|
|
|
const { fast, eat } = health.windows.fast_eat
|
|
const { fast, eat } = health.windows.fast_eat
|
|
@@ -453,8 +548,8 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
return <View className="main-console-bg">
|
|
return <View className="main-console-bg">
|
|
|
<Image className="main_arrow" src={require('@assets/images/center_arrow.png')} />
|
|
<Image className="main_arrow" src={require('@assets/images/center_arrow.png')} />
|
|
|
<View className="main_summary">
|
|
<View className="main_summary">
|
|
|
- <View className="main_summary_status" style={{ color: getThemeColor() }}>{windowStatus()}</View>
|
|
|
|
|
- <Text className="main_summary_time">{getCountownTime(health.windows, health.mode)}</Text>
|
|
|
|
|
|
|
+ <View className="main_summary_status" style={{ color: getThemeColor(health.mode) }}>{windowStatus()}</View>
|
|
|
|
|
+ <Text className="main_summary_time" style={{color:getWindowStatus(health.windows, health.mode)==WindowStatusType.upcoming?'#B2B2B2':'#000'}}>{getCountownTime(health.windows, health.mode)}</Text>
|
|
|
<Text className="main_summary_duration">Total {getDuration(health.windows, health.mode)}</Text>
|
|
<Text className="main_summary_duration">Total {getDuration(health.windows, health.mode)}</Text>
|
|
|
<View className="border_footer_line" />
|
|
<View className="border_footer_line" />
|
|
|
</View>
|
|
</View>
|
|
@@ -468,11 +563,10 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
{/* {
|
|
{/* {
|
|
|
(health.mode == 'EAT' || health.mode == 'ACTIVE') && <Text style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }} onClick={more}>更多</Text>
|
|
(health.mode == 'EAT' || health.mode == 'ACTIVE') && <Text style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }} onClick={more}>更多</Text>
|
|
|
} */}
|
|
} */}
|
|
|
- {
|
|
|
|
|
- (health.mode == 'EAT' || health.mode == 'ACTIVE') && <View className="main_footer_more" onClick={more}>
|
|
|
|
|
- <IconMore color="#b2b2b2" width={17}/>
|
|
|
|
|
- </View>
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ <View className="main_footer_more" onClick={more}>
|
|
|
|
|
+ <IconMore color="#b2b2b2" width={17} />
|
|
|
|
|
+ </View>
|
|
|
|
|
+
|
|
|
</View>
|
|
</View>
|
|
|
|
|
|
|
|
{
|
|
{
|