import { View, Text } from '@tarojs/components' import './meal_list.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" export default function MealList() { const [showModal, setShowModal] = useState(false) const [list, setList] = useState([]) const [labels, setLabels] = useState([]) const [showDel, setShowDel] = useState(false) useEffect(() => { schedules() }, []) function schedules() { getSchedules({ window: 'EAT' }).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: 'EAT' }).then(res => { setLabels((res as any).labels) }) } function add() { setShowModal(true) } function delItem(index) { delSchedule(list[index].code).then(res => { schedules() }) } return { list.map((item, index) => { // return return { showDel && delItem(index)}>删除 } 第{index + 1}餐 {item.title} {item.time} // }) } 添加一餐 setShowDel(!showDel)}>移除 { showModal && { setShowModal(false) }} confirm={() => { }}> } }