|
|
@@ -1,4 +1,4 @@
|
|
|
-import { View, Text, Image } from '@tarojs/components'
|
|
|
+import { View, Text, Image, ScrollView } from '@tarojs/components'
|
|
|
import './schedules_list.scss'
|
|
|
import './edit.scss'
|
|
|
import { useEffect, useState } from 'react'
|
|
|
@@ -12,17 +12,51 @@ import showActionSheet from '@/components/basic/ActionSheet'
|
|
|
import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
|
|
|
import { IconAdd } from '@/components/basic/Icons'
|
|
|
import { rpxToPx } from '@/utils/tools'
|
|
|
+import { useRouter } from '@tarojs/taro'
|
|
|
+import Taro from '@tarojs/taro'
|
|
|
|
|
|
-
|
|
|
+let useRoute;
|
|
|
+let useNavigation;
|
|
|
+let scenario = '';
|
|
|
+if (process.env.TARO_ENV == 'rn') {
|
|
|
+ useRoute = require("@react-navigation/native").useRoute
|
|
|
+ useNavigation = require("@react-navigation/native").useNavigation
|
|
|
+}
|
|
|
export default function SchedulesList() {
|
|
|
+ let navigation, showActionSheetWithOptions;
|
|
|
+
|
|
|
+ let router
|
|
|
+ if (useNavigation) {
|
|
|
+ navigation = useNavigation()
|
|
|
+ }
|
|
|
+
|
|
|
+ if (process.env.TARO_ENV == 'rn') {
|
|
|
+ router = useRoute()
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ router = useRouter()
|
|
|
+ }
|
|
|
+
|
|
|
+ const selMode = router.params.mode;
|
|
|
const [showModal, setShowModal] = useState(false)
|
|
|
const [list, setList] = useState<any>([])
|
|
|
const [labels, setLabels] = useState<any>([])
|
|
|
const [showDel, setShowDel] = useState(false)
|
|
|
+ const [selTab, setSelTab] = useState(0)
|
|
|
const health = useSelector((state: any) => state.health);
|
|
|
- let navigation, showActionSheetWithOptions;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
useEffect(() => {
|
|
|
+ console.log(selMode)
|
|
|
+ if (!selMode || selMode == '') {
|
|
|
+ console.log('oppppp')
|
|
|
+ Taro.setNavigationBarColor({
|
|
|
+ frontColor: '#000000',
|
|
|
+ backgroundColor: '#ffffff'
|
|
|
+ })
|
|
|
+ }
|
|
|
schedules()
|
|
|
}, [])
|
|
|
|
|
|
@@ -32,7 +66,7 @@ export default function SchedulesList() {
|
|
|
|
|
|
function schedules() {
|
|
|
let windows = ''
|
|
|
- switch (health.mode) {
|
|
|
+ switch (selMode) {
|
|
|
case 'FAST':
|
|
|
windows = 'FAST,EAT';
|
|
|
break
|
|
|
@@ -45,6 +79,12 @@ export default function SchedulesList() {
|
|
|
case 'ACTIVE':
|
|
|
windows = 'ACTIVE,SLEEP';
|
|
|
break
|
|
|
+ case 'DAY':
|
|
|
+ windows = 'DAY,NIGHT';
|
|
|
+ break
|
|
|
+ case 'NIGHT':
|
|
|
+ windows = 'NIGHT,DAY';
|
|
|
+ break
|
|
|
}
|
|
|
getSchedules({ window: windows }).then(res => {
|
|
|
if ((res as any).data && (res as any).data.length > 0) {
|
|
|
@@ -146,7 +186,7 @@ export default function SchedulesList() {
|
|
|
}
|
|
|
|
|
|
function getTitle() {
|
|
|
- switch (health.mode) {
|
|
|
+ switch (selMode) {
|
|
|
case 'FAST':
|
|
|
return '断食和进食';
|
|
|
case 'EAT':
|
|
|
@@ -155,55 +195,87 @@ export default function SchedulesList() {
|
|
|
return '睡眠和活动';
|
|
|
case 'ACTIVE':
|
|
|
return '活动和睡眠';
|
|
|
+ case 'DAY':
|
|
|
+ return '白天和夜晚';
|
|
|
+ case 'NIGHT':
|
|
|
+ return '夜晚和白天';
|
|
|
}
|
|
|
- return ''
|
|
|
+ return '全部'
|
|
|
}
|
|
|
|
|
|
- return <View>
|
|
|
- <View className='schedule_header_title'>{getTitle()}</View>
|
|
|
+ function sectionTitle(item) {
|
|
|
+ switch (item.window) {
|
|
|
+ case 'FAST':
|
|
|
+ return '断食'
|
|
|
+ case 'EAT':
|
|
|
+ return '进食'
|
|
|
+ case 'SLEEP':
|
|
|
+ return '睡眠'
|
|
|
+ case 'ACTIVE':
|
|
|
+ return '活动'
|
|
|
+ case 'DAY':
|
|
|
+ return '日间'
|
|
|
+ case 'NIGHT':
|
|
|
+ return '夜间'
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return <View className='schedule_list_bg'>
|
|
|
{
|
|
|
- list.map((item, index) => {
|
|
|
- return <View key={index} style={{ display: 'flex', flexDirection: 'column', marginBottom: rpxToPx(36) }}>
|
|
|
- {
|
|
|
- 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>
|
|
|
- }
|
|
|
+ selMode == '' && <View className='schedule_set_tabbar'>
|
|
|
+ <View onClick={()=>setSelTab(0)} className={selTab==0?'schedule_tab_sel':'schedule_tab_nor'}>按场景</View>
|
|
|
+ <View onClick={()=>setSelTab(1)} className={selTab==1?'schedule_tab_sel':'schedule_tab_nor'}>按时间</View>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ <ScrollView enableFlex style={{ height: Taro.getSystemInfoSync().screenHeight - 220 - (selMode == '' ? rpxToPx(100) : 0) }} scrollY>
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
+ <View className='schedule_header_title'>{getTitle()}</View>
|
|
|
+ {
|
|
|
+ list.map((item, index) => {
|
|
|
+ return <View key={index} style={{ display: 'flex', flexDirection: 'column', marginBottom: rpxToPx(36) }}>
|
|
|
+ <Text className='section_title'>{sectionTitle(item)}</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={() => {
|
|
|
+ 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>
|
|
|
+ <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_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' />
|
|
|
- }
|
|
|
+ <Text className='item_time'>{obj.time}</Text>
|
|
|
+ {
|
|
|
+ i < item.list.length - 1 && <View className='item_line' />
|
|
|
+ }
|
|
|
|
|
|
- </View>
|
|
|
- })
|
|
|
- }
|
|
|
- </View>
|
|
|
- })
|
|
|
- }
|
|
|
+ </View>
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </ScrollView>
|
|
|
|
|
|
<View className="edit_footer_btn" style={{ color: getThemeColor(health.mode), backgroundColor: getThemeColor(health.mode) + '33' }} onClick={tapEdit}>批量编辑</View>
|
|
|
|