import { View, Text } from '@tarojs/components' import './edit_schedule.scss' import { useEffect, useState } from 'react' import Modal from '@/components/layout/Modal.weapp' import AddLabel from '../components/add_label' import { delSchedule, getLabels, getSchedules } from '@/services/health' import { AtSwipeAction } from "taro-ui" import { useSelector } from 'react-redux' import { getThemeColor } from '@/features/health/hooks/health_hooks' import showActionSheet from '@/components/basic/ActionSheet' export default function EditSchedule() { const [showModal, setShowModal] = useState(false) const [list, setList] = useState([]) const [labels, setLabels] = useState([]) const [showDel, setShowDel] = useState(false) const health = useSelector((state: any) => state.health); let navigation, showActionSheetWithOptions; useEffect(() => { schedules() }, []) function schedules() { getSchedules({ window: health.mode, is_all_day: false }).then(res => { console.log('sss', res) if ((res as any).data && (res as any).data.length > 0) { setList((res as any).data) } }).catch(e => { }) getLabels({ window: health.mode }).then(res => { setLabels((res as any).labels) }) } function add() { setShowModal(true) } function delItem(index) { delSchedule(list[index].id).then(res => { schedules() global.refreshWindow() global.refreshHistory() }) } function tapEdit() { let array:any = [] switch(health.mode){ case 'DAY': case 'NIGHT': array = ['设置提醒'] break case 'FAST': case 'SLEEP': array = ['调整时间','设置提醒'] break; case 'EAT': case 'ACTIVE': array = ['调整时间','设置提醒','编辑标记','删除'] break; } showActionSheet({ showActionSheetWithOptions: showActionSheetWithOptions, title: 'Oprate Title', itemList: array, success: (res) => { // tapActionSheet(res) } }) } return { list.map((item, index) => { // return return { showDel && delItem(index)}>删除 } { health.mode == 'EAT' && 第{index + 1}餐 } {item.title} {item.time} // }) } { (health.mode == 'EAT' || health.mode == 'ACTIVE') && 添加 setShowDel(!showDel)}>移除 } 批量编辑 { showModal && { setShowModal(false) }} confirm={() => { }}> } }