|
|
@@ -10,6 +10,8 @@ import { useSelector } from 'react-redux'
|
|
|
import { getThemeColor } from '@/features/health/hooks/health_hooks'
|
|
|
import showActionSheet from '@/components/basic/ActionSheet'
|
|
|
import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
|
|
|
+import { IconAdd } from '@/components/basic/Icons'
|
|
|
+import { rpxToPx } from '@/utils/tools'
|
|
|
|
|
|
|
|
|
export default function SchedulesList() {
|
|
|
@@ -29,10 +31,43 @@ export default function SchedulesList() {
|
|
|
}
|
|
|
|
|
|
function schedules() {
|
|
|
- getSchedules({ window: health.mode }).then(res => {
|
|
|
- console.log('sss', res)
|
|
|
+ let windows = ''
|
|
|
+ switch (health.mode) {
|
|
|
+ case 'FAST':
|
|
|
+ windows = 'FAST,EAT';
|
|
|
+ break
|
|
|
+ case 'EAT':
|
|
|
+ windows = 'EAT,FAST';
|
|
|
+ break
|
|
|
+ case 'SLEEP':
|
|
|
+ windows = 'SLEEP,ACTIVE';
|
|
|
+ break
|
|
|
+ case 'ACTIVE':
|
|
|
+ windows = 'ACTIVE,SLEEP';
|
|
|
+ break
|
|
|
+ }
|
|
|
+ getSchedules({ window: windows }).then(res => {
|
|
|
if ((res as any).data && (res as any).data.length > 0) {
|
|
|
- setList((res as any).data)
|
|
|
+ // setList((res as any).data)
|
|
|
+
|
|
|
+ let grouped: any = {};
|
|
|
+ (res as any).data.forEach(item => {
|
|
|
+ const window = item.window;
|
|
|
+
|
|
|
+ if (!grouped[window]) {
|
|
|
+ grouped[window] = { window: window, list: [] };
|
|
|
+ }
|
|
|
+ grouped[window].list.push(item);
|
|
|
+ });
|
|
|
+ var array = Object.values(grouped)
|
|
|
+ array.map((dt: any) => {
|
|
|
+ if (dt.window == 'EAT' || dt.window == 'ACTIVE') {
|
|
|
+ dt.list.push({
|
|
|
+ add: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ setList(array)
|
|
|
}
|
|
|
}).catch(e => {
|
|
|
|
|
|
@@ -56,6 +91,8 @@ export default function SchedulesList() {
|
|
|
}
|
|
|
|
|
|
function tapEdit() {
|
|
|
+ jumpPage('./schedules_edit')
|
|
|
+ return;
|
|
|
let array: any = []
|
|
|
switch (health.mode) {
|
|
|
case 'DAY':
|
|
|
@@ -108,50 +145,66 @@ export default function SchedulesList() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function getTitle() {
|
|
|
+ switch (health.mode) {
|
|
|
+ case 'FAST':
|
|
|
+ return '断食和进食';
|
|
|
+ case 'EAT':
|
|
|
+ return '进食和断食';
|
|
|
+ case 'SLEEP':
|
|
|
+ return '睡眠和活动';
|
|
|
+ case 'ACTIVE':
|
|
|
+ return '活动和睡眠';
|
|
|
+ }
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+
|
|
|
return <View>
|
|
|
+ <View className='schedule_header_title'>{getTitle()}</View>
|
|
|
{
|
|
|
list.map((item, index) => {
|
|
|
- // return <AtSwipeAction key={index} isOpened options={[
|
|
|
- // {
|
|
|
- // text: '删除',
|
|
|
- // style: {
|
|
|
- // backgroundColor: '#FF4949'
|
|
|
- // }
|
|
|
- // }
|
|
|
- // ]}>
|
|
|
- return <View className='item' key={index}>
|
|
|
+ return <View key={index} style={{ display: 'flex', flexDirection: 'column', marginBottom: rpxToPx(36) }}>
|
|
|
{
|
|
|
- showDel && <Text style={{ color: 'red', marginRight: 5 }} onClick={() => delItem(index)}>删除</Text>
|
|
|
+ item.list.map((obj, i) => {
|
|
|
+ if (obj.add) {
|
|
|
+ return <View key={i * 100} className='item_add'
|
|
|
+ hoverClass='cell_hover'
|
|
|
+ hoverStayTime={50}
|
|
|
+ onClick={add}>
|
|
|
+ <IconAdd color={getThemeColor(item.window)} width={rpxToPx(34)} />
|
|
|
+ <View className='toolbar_btn' style={{ color: getThemeColor(item.window) }} >添加</View>
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
+ {/* <View className='toolbar_btn' style={{ color: getThemeColor(health.mode) }} onClick={() => setShowDel(!showDel)}>移除</View> */}
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+
|
|
|
+ return <View className='schedule_item' key={i * 100} hoverClass='cell_hover' hoverStayTime={50} onClick={() => {
|
|
|
+
|
|
|
+ }}>
|
|
|
+
|
|
|
+ <View className='item_left'>
|
|
|
+ <Text className='item_index'>{i + 1}</Text>
|
|
|
+
|
|
|
+
|
|
|
+ <Text className='item_name'>{obj.title}</Text>
|
|
|
+ </View>
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
+ {
|
|
|
+ !obj.reminder && <Image src={require('@assets/images/notification_off.png')} className='notification_icon' />
|
|
|
+ }
|
|
|
+
|
|
|
+ <Text className='item_time'>{obj.time}</Text>
|
|
|
+ {
|
|
|
+ i < item.list.length - 1 && <View className='item_line' />
|
|
|
+ }
|
|
|
+
|
|
|
+ </View>
|
|
|
+ })
|
|
|
}
|
|
|
-
|
|
|
- <View className='item_left'>
|
|
|
- {
|
|
|
- health.mode == 'EAT' && <Text className='item_index'>第{index + 1}餐</Text>
|
|
|
- }
|
|
|
-
|
|
|
- <Text className='item_name'>{item.title}</Text>
|
|
|
- </View>
|
|
|
- <View style={{ flex: 1 }} />
|
|
|
- {
|
|
|
- !item.reminder && <Image src={require('@assets/images/notification_off.png')} className='notification_icon' />
|
|
|
- }
|
|
|
-
|
|
|
- <Text className='item_time'>{item.time}</Text>
|
|
|
- <View className='item_line' />
|
|
|
</View>
|
|
|
- // </AtSwipeAction>
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- {
|
|
|
- (health.mode == 'EAT' || health.mode == 'ACTIVE') && <View className='toolbar'>
|
|
|
- <View className='toolbar_btn' style={{ color: getThemeColor(health.mode) }} onClick={add}>添加</View>
|
|
|
- <View style={{ flex: 1 }} />
|
|
|
- {/* <View className='toolbar_btn' style={{ color: getThemeColor(health.mode) }} onClick={() => setShowDel(!showDel)}>移除</View> */}
|
|
|
- </View>
|
|
|
- }
|
|
|
-
|
|
|
<View className="edit_footer_btn" style={{ color: getThemeColor(health.mode), backgroundColor: getThemeColor(health.mode) + '33' }} onClick={tapEdit}>批量编辑</View>
|
|
|
|
|
|
{
|