|
|
@@ -14,7 +14,7 @@ import showActionSheet from "@/components/basic/ActionSheet";
|
|
|
import { rpxToPx } from "@/utils/tools";
|
|
|
import { setMode, setShowActionTip } from "@/store/health";
|
|
|
import { getCountownTime, getDuration, getScenario, getThemeColor, getWindowStatus } from "./hooks/health_hooks";
|
|
|
-import { IconCellArrow, IconMore } from "@/components/basic/Icons";
|
|
|
+import { IconCellArrow, IconMore, IconNotification, IconNotificationOff, IconSwitch } from "@/components/basic/Icons";
|
|
|
import DurationPicker from "@/_health/components/duration_picker";
|
|
|
import Taro from "@tarojs/taro";
|
|
|
import { systemLocation } from "@/services/common";
|
|
|
@@ -107,7 +107,7 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
// setOperateType('startFast')
|
|
|
// setShowTimePicker(true)
|
|
|
|
|
|
- jumpPage(`/_health/pages/log_time?index=${health.mode=='FAST'?0:1}&single=1&is_start=1&window=${health.mode}`)
|
|
|
+ jumpPage(`/_health/pages/log_time?index=${health.mode == 'FAST' ? 0 : 1}&single=1&is_start=1&window=${health.mode}`)
|
|
|
}
|
|
|
return;
|
|
|
case 'END':
|
|
|
@@ -120,9 +120,9 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
// setShowTimePicker(true)
|
|
|
console.log(item)
|
|
|
|
|
|
- var sceniaro = getScenario(health.windows,health.mode)
|
|
|
+ var sceniaro = getScenario(health.windows, health.mode)
|
|
|
|
|
|
- jumpPage(`/_health/pages/log_time?type=home&index=${health.mode=='FAST'?3:2}&single=${sceniaro.status == 'OG'?1:0}&is_start=0&window=${health.mode}`)
|
|
|
+ jumpPage(`/_health/pages/log_time?type=home&index=${health.mode == 'FAST' ? 3 : 2}&single=${sceniaro.status == 'OG' ? 1 : 0}&is_start=0&window=${health.mode}`)
|
|
|
}
|
|
|
return;
|
|
|
case 'MARK_DONE':
|
|
|
@@ -141,6 +141,10 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
// }))
|
|
|
// setBtnDisable(false)
|
|
|
// setShowTimePicker(false)
|
|
|
+ Taro.showToast({
|
|
|
+ title: '操作成功',
|
|
|
+ icon: 'success'
|
|
|
+ })
|
|
|
global.refreshWindow()
|
|
|
global.refreshHistory()
|
|
|
}).catch(e => {
|
|
|
@@ -231,6 +235,37 @@ 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
|
|
|
+ }
|
|
|
+ return color
|
|
|
+ }
|
|
|
+
|
|
|
+ function processIcon(index) {
|
|
|
+ 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 <Image style={{ width: rpxToPx(20), height: rpxToPx(20) }} src={require('@assets/_health/checked.png')} />
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (timeline.real) {
|
|
|
+ return <Image style={{ width: rpxToPx(20), height: rpxToPx(20) }} src={require('@assets/_health/checked.png')} />
|
|
|
+ }
|
|
|
+ return timeline.reminder?<IconNotification color="#fff" width={rpxToPx(20)}/>:<IconNotificationOff color="#fff" width={rpxToPx(20)}/>
|
|
|
+ }
|
|
|
+
|
|
|
function timelineItem(item: any, index: number, count: number) {
|
|
|
var hasDescription = item.moment && item.moment.description
|
|
|
return <View key={index}
|
|
|
@@ -244,17 +279,22 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
height: hasDescription ? rpxToPx(28) : rpxToPx(36), flexShrink: 0
|
|
|
}} />
|
|
|
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
|
- {/* {
|
|
|
- !item.reminder && <Image src={require('@assets/images/notification_off.png')} className='notification_icon' />
|
|
|
- } */}
|
|
|
<View style={{
|
|
|
flexShrink: 0,
|
|
|
- width: rpxToPx(28),
|
|
|
- height: rpxToPx(28),
|
|
|
- borderRadius: rpxToPx(14),
|
|
|
+ width: rpxToPx(26),
|
|
|
+ height: rpxToPx(26),
|
|
|
+ borderRadius: rpxToPx(13),
|
|
|
marginRight: rpxToPx(8),
|
|
|
- backgroundColor: 'gray'
|
|
|
- }} />
|
|
|
+ display: 'flex',
|
|
|
+ alignItems: 'center',
|
|
|
+ justifyContent: 'center',
|
|
|
+ backgroundColor: getIconColor(index)
|
|
|
+ }}>
|
|
|
+ {
|
|
|
+ processIcon(index)
|
|
|
+ }
|
|
|
+ {/* <Image style={{ width: rpxToPx(20), height: rpxToPx(20) }} src={finish ? require('@assets/_health/checked.png') : require('@assets/_health/ring.png')} /> */}
|
|
|
+ </View>
|
|
|
<Text className="timeline_time">{itemTitle(item)}</Text>
|
|
|
</View>
|
|
|
|
|
|
@@ -512,7 +552,7 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
setShowTimePicker(false)
|
|
|
global.refreshWindow()
|
|
|
global.refreshHistory()
|
|
|
- jumpPage('/_health/pages/post_result?data='+JSON.stringify(res))
|
|
|
+ jumpPage('/_health/pages/post_result?data=' + JSON.stringify(res))
|
|
|
}).catch(e => {
|
|
|
setBtnDisable(false)
|
|
|
})
|
|
|
@@ -890,7 +930,12 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
str = 'Fast after Wake Up'
|
|
|
break
|
|
|
}
|
|
|
- return <View className="h28" style={{ color: MainColorType.g01 }}>{str}</View>
|
|
|
+ return <View className="h26" style={{ color: MainColorType.g01 }}>{str}</View>
|
|
|
+ }
|
|
|
+
|
|
|
+ function longFastStatus() {
|
|
|
+ const { status } = health.long_fast
|
|
|
+ return <View className="h26" style={{ color: MainColorType.g01 }}>{status == 'OG' ? 'In progress' : ''}</View>
|
|
|
}
|
|
|
|
|
|
return <View className="main-console-bg">
|
|
|
@@ -901,7 +946,7 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
<View className={timePointClass()}
|
|
|
style={{ backgroundColor: getWindowStatus(health.windows, health.mode) == WindowStatusType.upcoming ? '#B2B2B2' : getThemeColor(health.mode) }} />
|
|
|
</View>
|
|
|
- <Text className="main_summary_duration">Total {getDuration(health.windows, health.mode)}</Text>
|
|
|
+ <Text className="main_summary_duration" style={{ color: MainColorType.g01 }}>{getDuration(health.windows, health.mode)}</Text>
|
|
|
<View className="border_footer_line" />
|
|
|
</View>
|
|
|
<View style={{ backgroundColor: '#fff', width: rpxToPx(750) }}>
|
|
|
@@ -916,7 +961,17 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
}
|
|
|
</View>
|
|
|
<View className="main_footer">
|
|
|
- <Text className="main_footer_text" onClick={tapSwitchBtn}>{switchText()}</Text>
|
|
|
+ <View style={{ width: rpxToPx(316), height: rpxToPx(128), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
+ <NewButton
|
|
|
+ type={NewButtonType.link}
|
|
|
+ title={switchText()}
|
|
|
+ onClick={tapSwitchBtn}
|
|
|
+ >
|
|
|
+ <View style={{ marginRight: rpxToPx(8) }}>
|
|
|
+ <IconSwitch color={MainColorType.link} width={rpxToPx(26)} />
|
|
|
+ </View>
|
|
|
+ </NewButton>
|
|
|
+ </View>
|
|
|
{/* {
|
|
|
(health.mode == 'EAT' || health.mode == 'ACTIVE') && <Text style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }} onClick={more}>更多</Text>
|
|
|
} */}
|
|
|
@@ -926,20 +981,27 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
{
|
|
|
(health.mode == 'DAY' || health.mode == 'NIGHT') && <Text onClick={tapClearLocation}>清除位置</Text>
|
|
|
}
|
|
|
- <View className="main_footer_more" onClick={more}>
|
|
|
- <IconMore color="#b2b2b2" width={17} />
|
|
|
- </View>
|
|
|
+ <NewButton
|
|
|
+ btnStyle={{
|
|
|
+ position: 'absolute',
|
|
|
+ top: rpxToPx(42),
|
|
|
+ right: rpxToPx(40)
|
|
|
+ }}
|
|
|
+ type={NewButtonType.more}
|
|
|
+ onClick={more}
|
|
|
+ />
|
|
|
|
|
|
</View>
|
|
|
{
|
|
|
- health.mode == 'ACTIVE' && <View className="console_active_bg" onClick={() => {
|
|
|
- if (!user.isLogin) {
|
|
|
- jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
- return
|
|
|
- }
|
|
|
- jumpPage('/_health/pages/move')
|
|
|
- }}>
|
|
|
- <View className="console_active">
|
|
|
+ health.mode == 'ACTIVE' && <View>
|
|
|
+ <View className="main_column_space" />
|
|
|
+ <View className="console_active" onClick={() => {
|
|
|
+ if (!user.isLogin) {
|
|
|
+ jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ jumpPage('/_health/pages/move')
|
|
|
+ }}>
|
|
|
<Image className="active_icon" src={require('@assets/_health/walk.png')} />
|
|
|
<Text className="active_text">Move More</Text>
|
|
|
<Image className="cell_arrow" src={require('@assets/_health/cell_arrow.png')} />
|
|
|
@@ -948,54 +1010,61 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
</View>
|
|
|
}
|
|
|
{
|
|
|
- (health.mode == 'FAST' || health.mode == 'SLEEP') && <View className="console_active_bg" onClick={() => {
|
|
|
- if (!user.isLogin) {
|
|
|
- jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
- return
|
|
|
- }
|
|
|
- if (health.long_fast.status == 'OG') {
|
|
|
- showAlert({
|
|
|
- title: '长断食进行中',
|
|
|
- content: '当前有一个正在进行的长断食记录,要转换为间歇性断食吗?',
|
|
|
- showCancel: true,
|
|
|
- cancelText: '取消',
|
|
|
- confirmText: '确定',
|
|
|
- confirm: () => {
|
|
|
- updateFast({ fast_type: 'IF' }).then(res => {
|
|
|
- global.refreshWindow()
|
|
|
- jumpPage('/_health/pages/fast_sleep')
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- jumpPage('/_health/pages/fast_sleep')
|
|
|
- }}>
|
|
|
- <View className="console_active">
|
|
|
+ (health.mode == 'FAST' || health.mode == 'SLEEP') && <View >
|
|
|
+ <View className="main_column_space" />
|
|
|
+ <View className="console_active" onClick={() => {
|
|
|
+ if (!user.isLogin) {
|
|
|
+ jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (health.long_fast.status == 'OG') {
|
|
|
+ showAlert({
|
|
|
+ title: '长断食进行中',
|
|
|
+ content: '当前有一个正在进行的长断食记录,要转换为间歇性断食吗?',
|
|
|
+ showCancel: true,
|
|
|
+ cancelText: '取消',
|
|
|
+ confirmText: '确定',
|
|
|
+ confirm: () => {
|
|
|
+ updateFast({ fast_type: 'IF' }).then(res => {
|
|
|
+ global.refreshWindow()
|
|
|
+ jumpPage('/_health/pages/fast_sleep')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ jumpPage('/_health/pages/fast_sleep')
|
|
|
+ }}>
|
|
|
<Image className="active_icon" src={require('@assets/_health/fast.png')} />
|
|
|
<Text className="h34">Fast with sleep</Text>
|
|
|
<View style={{ flex: 1 }} />
|
|
|
{
|
|
|
fastWithSleepStatus()
|
|
|
}
|
|
|
- <Image className="cell_arrow" src={require('@assets/_health/cell_arrow.png')} />
|
|
|
+ <IconCellArrow color='#B2B2B2' width={rpxToPx(34)} />
|
|
|
+ {
|
|
|
+ health.mode == 'FAST' && <View className="border_footer_line" style={{ left: rpxToPx(100) }} />
|
|
|
+ }
|
|
|
</View>
|
|
|
|
|
|
</View>
|
|
|
}
|
|
|
{
|
|
|
- health.mode == 'FAST' && <View className="console_active_bg" onClick={() => {
|
|
|
- if (!user.isLogin) {
|
|
|
- jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
- return
|
|
|
- }
|
|
|
- jumpPage('/_health/pages/long_fast')
|
|
|
- }}>
|
|
|
- <View className="console_active">
|
|
|
+ health.mode == 'FAST' && <View>
|
|
|
+ <View className="console_active" onClick={() => {
|
|
|
+ if (!user.isLogin) {
|
|
|
+ jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ jumpPage('/_health/pages/long_fast')
|
|
|
+ }}>
|
|
|
<Image className="active_icon" src={require('@assets/_health/fast.png')} />
|
|
|
<Text className="h34">Long fast</Text>
|
|
|
<View style={{ flex: 1 }} />
|
|
|
- <Image className="cell_arrow" src={require('@assets/_health/cell_arrow.png')} />
|
|
|
+ {
|
|
|
+ longFastStatus()
|
|
|
+ }
|
|
|
+ <IconCellArrow color='#B2B2B2' width={rpxToPx(34)} />
|
|
|
</View>
|
|
|
|
|
|
</View>
|