|
@@ -1,4 +1,4 @@
|
|
|
-import { View, Text } from "@tarojs/components";
|
|
|
|
|
|
|
+import { View, Text,Image } from "@tarojs/components";
|
|
|
import './MainCard.scss'
|
|
import './MainCard.scss'
|
|
|
import { useEffect, useRef, useState } from "react";
|
|
import { useEffect, useRef, useState } from "react";
|
|
|
import Modal from "@/components/layout/Modal.weapp";
|
|
import Modal from "@/components/layout/Modal.weapp";
|
|
@@ -15,6 +15,7 @@ import { endFast, startFast } from "../actions/TrackTimeActions";
|
|
|
import formatMilliseconds from "@/utils/format_time";
|
|
import formatMilliseconds from "@/utils/format_time";
|
|
|
import TimePicker from "@/features/common/TimePicker";
|
|
import TimePicker from "@/features/common/TimePicker";
|
|
|
import showAlert from "@/components/basic/Alert";
|
|
import showAlert from "@/components/basic/Alert";
|
|
|
|
|
+import showActionSheet from "@/components/basic/ActionSheet";
|
|
|
let useNavigation;
|
|
let useNavigation;
|
|
|
|
|
|
|
|
let Linking, PushNotification;
|
|
let Linking, PushNotification;
|
|
@@ -22,6 +23,7 @@ let checkNotification;
|
|
|
let min = 0
|
|
let min = 0
|
|
|
let max = 0
|
|
let max = 0
|
|
|
let defaultTimestamp = 0
|
|
let defaultTimestamp = 0
|
|
|
|
|
+let useActionSheet;
|
|
|
|
|
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
@@ -29,6 +31,7 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
// JPush = require('jpush-react-native').default;
|
|
// JPush = require('jpush-react-native').default;
|
|
|
PushNotification = require('react-native-push-notification')
|
|
PushNotification = require('react-native-push-notification')
|
|
|
checkNotification = require('@/utils/native_permission_check').checkNotification;
|
|
checkNotification = require('@/utils/native_permission_check').checkNotification;
|
|
|
|
|
+ useActionSheet = require('@expo/react-native-action-sheet').useActionSheet
|
|
|
}
|
|
}
|
|
|
export default function MainFastEatCard(props: { count: any }) {
|
|
export default function MainFastEatCard(props: { count: any }) {
|
|
|
const [isFastMode, setIsFastMode] = useState(true)
|
|
const [isFastMode, setIsFastMode] = useState(true)
|
|
@@ -53,9 +56,10 @@ export default function MainFastEatCard(props: { count: any }) {
|
|
|
|
|
|
|
|
const user = useSelector((state: any) => state.user);
|
|
const user = useSelector((state: any) => state.user);
|
|
|
|
|
|
|
|
- let navigation;
|
|
|
|
|
|
|
+ let navigation,showActionSheetWithOptions;
|
|
|
if (useNavigation) {
|
|
if (useNavigation) {
|
|
|
navigation = useNavigation()
|
|
navigation = useNavigation()
|
|
|
|
|
+ showActionSheetWithOptions = useActionSheet()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -569,13 +573,40 @@ export default function MainFastEatCard(props: { count: any }) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function goAddEat(index) {
|
|
|
|
|
- if (status == 'process') {
|
|
|
|
|
|
|
+ function goAddEat(meal, index) {
|
|
|
|
|
+ if (!enableMeal(meal)) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
jumpPage('/pages/clock/AddEat?meal=' + JSON.stringify(eatData.meals[index]))
|
|
jumpPage('/pages/clock/AddEat?meal=' + JSON.stringify(eatData.meals[index]))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function enableMeal(meal) {
|
|
|
|
|
+ if (meal.real_start_time > 0) {
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+ if (meal.target_start_time > new Date().getTime()) {
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function more(){
|
|
|
|
|
+ showActionSheet({
|
|
|
|
|
+ showActionSheetWithOptions: showActionSheetWithOptions,
|
|
|
|
|
+ title:'Oprate Title',
|
|
|
|
|
+ itemList: [
|
|
|
|
|
+ 'Add Snack',
|
|
|
|
|
+ '自定义餐次列表',
|
|
|
|
|
+ ],
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ switch (res) {
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!loaded) {
|
|
if (!loaded) {
|
|
|
return <View />
|
|
return <View />
|
|
|
}
|
|
}
|
|
@@ -636,15 +667,19 @@ export default function MainFastEatCard(props: { count: any }) {
|
|
|
!isFastMode && <View>
|
|
!isFastMode && <View>
|
|
|
{
|
|
{
|
|
|
eatData.meals.map((item, index) => {
|
|
eatData.meals.map((item, index) => {
|
|
|
- return <View className="log_row" key={index}>
|
|
|
|
|
|
|
+ return <View className="log_row" style={{justifyContent:'flex-start'}} key={index}>
|
|
|
|
|
+ {
|
|
|
|
|
+ item.real_start_time && item.media && item.media.length>0 && item.media[0].url && <Image src={item.media[0].url} style={{width:50,height:50,marginRight:10}}/>
|
|
|
|
|
+ }
|
|
|
<View className="schedule">
|
|
<View className="schedule">
|
|
|
<Text className="schedule_name">{item.name}</Text>
|
|
<Text className="schedule_name">{item.name}</Text>
|
|
|
<Text className="schedule_time">
|
|
<Text className="schedule_time">
|
|
|
- {item.schedule_start_time}
|
|
|
|
|
|
|
+ {item.real_start_time ?dayjs(item.real_start_time).format('HH:mm')+' - '+dayjs(item.real_end_time).format('HH:mm'):item.schedule_start_time}
|
|
|
</Text>
|
|
</Text>
|
|
|
</View>
|
|
</View>
|
|
|
|
|
+ <View style={{flex:1}}/>
|
|
|
{
|
|
{
|
|
|
- item.real_start_time ? <View className="fast_log_btn fast_log_btn_disable">已上传</View> : <View onClick={() => goAddEat(index)} className={status == 'process' ? "fast_log_btn fast_log_btn_disable" : "fast_log_btn fast_log_eat_btn"}>Add</View>
|
|
|
|
|
|
|
+ item.real_start_time ? <View className="fast_log_btn fast_log_btn_disable">已记录</View> : <View onClick={() => goAddEat(item, index)} className={enableMeal(item) ? "fast_log_btn fast_log_eat_btn" : "fast_log_btn fast_log_btn_disable"}>Add</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
</View>
|
|
</View>
|
|
@@ -656,6 +691,9 @@ export default function MainFastEatCard(props: { count: any }) {
|
|
|
|
|
|
|
|
|
|
|
|
|
<Text onClick={switchMode}>Switch</Text>
|
|
<Text onClick={switchMode}>Switch</Text>
|
|
|
|
|
+ {
|
|
|
|
|
+ !isFastMode && <Text onClick={more}>更多</Text>
|
|
|
|
|
+ }
|
|
|
{
|
|
{
|
|
|
showModal && <Modal dismiss={() => setShowModal(false)}>
|
|
showModal && <Modal dismiss={() => setShowModal(false)}>
|
|
|
<View style={{ width: 100, height: 100, backgroundColor: 'red' }}>{props.count}</View>
|
|
<View style={{ width: 100, height: 100, backgroundColor: 'red' }}>{props.count}</View>
|