leon vor 1 Jahr
Ursprung
Commit
0495d07214

+ 16 - 20
src/_health/components/add_label.tsx

@@ -24,7 +24,9 @@ export default function AddLabel(props: {
     window?: string,
     onlyCheck?: boolean,
     schedules?: any,
-    justLabel?: boolean, confirm?: any
+    justLabel?: boolean,
+    confirm?: any,
+    op_page?: any
 }) {
     const [showTimePicker, setShowTimePicker] = useState(false)
     const health = useSelector((state: any) => state.health);
@@ -74,7 +76,8 @@ export default function AddLabel(props: {
         }
         createSchedule({
             only_check: props.onlyCheck,
-            schedules: array
+            schedules: array,
+            op_page: props.op_page ?? null
         }).then(res => {
             if ((res as any).result) {
                 if (global.refreshWindow) {
@@ -91,24 +94,17 @@ export default function AddLabel(props: {
                 }
             }
             else {
-                if (props.onlyCheck) {
-                    if (props.confirm) {
-                        props.confirm(res)
-                    }
-                    setShowTimePicker(false)
-                    if (props.disMiss) {
-                        props.disMiss()
-                    }
-                    return;
+                // if (props.onlyCheck) {
+                if (props.confirm) {
+                    props.confirm(res)
                 }
-                showAlert({
-                    title: '弹窗标题',
-                    content: '冲突描述',
-                    showCancel: false,
-                    confirm: () => {
-                        // jumpPage(`./schedules_conflict?schedules=${JSON.stringify((res as any).schedules)}&errors=${JSON.stringify((res as any).error_messages)}`)
-                    }
-                })
+                setShowTimePicker(false)
+                if (props.disMiss) {
+                    props.disMiss()
+                }
+                return;
+                // }
+
             }
 
 
@@ -154,7 +150,7 @@ export default function AddLabel(props: {
                     paddingRight: rpxToPx(54),
                     justifyContent: 'center'
                 }}>
-                    <Text className="h34" style={{color:MainColorType.eat}}>{strTime}</Text>
+                    <Text className="h34" style={{ color: MainColorType.eat }}>{strTime}</Text>
                     <View className="border_footer_line" />
                 </View> :
                     <View style={{

+ 0 - 45
src/_health/pages/add_moment.tsx

@@ -468,51 +468,6 @@ export default function AddMoment() {
                     setShowTimePicker(false)
                 }} />
         }
-        {/* {
-            showTitlePicker && <Modal testInfo={null}
-                catchDismiss={true}
-                dismiss={() => {
-                }}
-                confirm={() => { }}>
-                <AddLabel labels={labels}
-                    defaultValue={title}
-                    justLabel={true}
-                    confirm={e => {
-                        setTitle(e)
-                        if (e.length == 0) {
-                            showAlert({
-                                title: '提示',
-                                content: '请输入标题',
-                                showCancel: false
-                            })
-                            return
-                        }
-                        setShowTitlePicker(false)
-                    }}
-                    disMiss={() => {
-                        debugger
-                        // setShowTitlePicker(false)
-                    }} />
-            </Modal>
-        } */}
-
-        {/* {
-            durationPicker && <DurationPicker
-                title='进食时长'
-                done={(time) => {
-                    setDurationT(time)
-                    console.log(time)
-                    setDurationPicker(false)
-                    // updateDuration(time)
-                }}
-                dismiss={() => {
-                    setDurationPicker(false)
-                }} time={durationT} />
-        } */}
-        {
-
-        }
-        {/* <Text> add eat detail</Text> */}
         {
             <View className="tag_list" style={{ bottom: bottom }}>
                 <ScrollView style={{ width: rpxToPx(750), flexDirection: 'row', display: 'flex', height: rpxToPx(108) }} scrollX enableFlex showScrollbar={false}>

+ 0 - 0
src/_health/pages/edit_schedule.config.ts


+ 0 - 55
src/_health/pages/edit_schedule.scss

@@ -1,55 +0,0 @@
-@import "~taro-ui/dist/style/components/swipe-action.scss";
-
-.container {
-    display: flex;
-    flex-direction: column;
-    flex: 1;
-}
-
-.item {
-    padding-left: 46px;
-    padding-right: 46px;
-    height: 114px;
-    align-items: center;
-    display: flex;
-    flex-direction: row;
-    align-items: center;
-    position: relative;
-    background-color: #fff;
-}
-
-.item_left{
-    display: flex;
-    flex-direction: column;
-    flex: 1;
-}
-
-.item_index{
-    color: #B2B2B2;
-    font-size: 18px;
-}
-
-.item_name{
-    color: #4D4D4D;
-    font-size: 34px;
-}
-
-.item_time{
-    color: #B2B2B2;
-    font-size: 34px;
-}
-
-.toolbar{
-    display: flex;
-    flex-direction: row;
-    align-items: center;
-    margin-top: 20px;
-    margin-bottom: 20px;
-    padding-left: 46px;
-    padding-right: 46px;
-}
-
-.toolbar_btn{
-    color: #FF751A;
-    font-size: 30px;
-}

+ 0 - 130
src/_health/pages/edit_schedule.tsx

@@ -1,130 +0,0 @@
-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, getLabelsEvent, 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<any>([])
-    const [labels, setLabels] = useState<any>([])
-    const [showDel, setShowDel] = useState(false)
-    const health = useSelector((state: any) => state.health);
-    let navigation, showActionSheetWithOptions;
-
-    useEffect(() => {
-        schedules()
-    }, [])
-
-    function schedules() {
-        getSchedules({ window: health.mode, specific_time: true }).then(res => {
-            console.log('sss', res)
-            if ((res as any).data && (res as any).data.length > 0) {
-                setList((res as any).data)
-            }
-        }).catch(e => {
-
-        })
-
-        getLabelsEvent({ 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 <View>
-        {
-            list.map((item, index) => {
-                // return <AtSwipeAction key={index} isOpened options={[
-                //     {
-                //         text: '删除',
-                //         style: {
-                //             backgroundColor: '#FF4949'
-                //         }
-                //     }
-                // ]}>
-                return <View className='item' key={index}>
-                    {
-                        showDel && <Text style={{ color: 'red', marginRight: 5 }} onClick={() => delItem(index)}>删除</Text>
-                    }
-
-                    <View className='item_left'>
-                        {
-                            health.mode == 'EAT' && <Text className='item_index'>第{index + 1}餐</Text>
-                        }
-
-                        <Text className='item_name'>{item.title}</Text>
-                    </View>
-                    <Text className='item_time'>{item.time}</Text>
-                    <View className='border_footer_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>
-        }
-
-        <Text onClick={tapEdit}>批量编辑</Text>
-
-        {
-            showModal && <Modal testInfo={null}
-                dismiss={() => {
-                    setShowModal(false)
-                }}
-                confirm={() => { }}>
-                <AddLabel labels={labels} />
-            </Modal>
-        }
-    </View>
-}

+ 0 - 29
src/_health/pages/guide_active.tsx

@@ -313,34 +313,5 @@ export default function GuideActive() {
                 }}
                 color={MainColorType.active} />
         }
-
-        {/* {
-            showModal && <Modal testInfo={null}
-                dismiss={() => {
-                    setShowModal(false)
-                }}
-                confirm={() => { }}>
-                <AddLabel labels={labels}
-                    window='ACTIVE'
-                    disMiss={() => setShowModal(false)}
-                    onlyCheck={true}
-                    schedules={list}
-                    confirm={(res) => {
-                        if ((res as any).result) {
-                            dispatch(setSchedules((res as any).schedules))
-                            dispatch(setFooter((res as any).footer))
-                            setList((res as any).schedules)
-                            setErrors([])
-                        }
-                        else {
-                            setList((res as any).schedules)
-                            dispatch(setFooter((res as any).footer))
-                            setErrors((res as any).error_messages ? (res as any).error_messages : [])
-                        }
-
-                    }}
-                    color={MainColorType.active} />
-            </Modal>
-        } */}
     </View>
 }

+ 77 - 63
src/_health/pages/schedules.tsx

@@ -59,7 +59,7 @@ export default function Schedules() {
     const [btnEnable, setBtnEnable] = useState(true)
     const [selMode, setSleMode] = useState(router.params.mode);
     const [isEat, setIsEat] = useState(false)
-    const [loaded,setLoaded] = useState(false)
+    const [loaded, setLoaded] = useState(false)
     const { t } = useTranslation()
 
     useEffect(() => {
@@ -177,61 +177,65 @@ export default function Schedules() {
             schedules: array,
             // only_check: true
         }).then(res => {
+            checkResultData(res)
 
 
-            if ((res as any).result) {
-                setShowAutoSave(true)
-                setErrors([])
-                setList((res as any).schedules)
-                global.refreshWindow()
-                if (global.refreshSchedules) {
-                    global.refreshSchedules()
-                }
-                if (global.refreshSchedules2) {
-                    global.refreshSchedules2()
-                }
+        })
+    }
+
+    function checkResultData(res) {
+        if ((res as any).result) {
+            setShowAutoSave(true)
+            setErrors([])
+            setList((res as any).schedules)
+            global.refreshWindow()
+            if (global.refreshSchedules) {
+                global.refreshSchedules()
+            }
+            if (global.refreshSchedules2) {
+                global.refreshSchedules2()
+            }
+        }
+        else {
+            setShowAutoSave(false)
+            setList((res as any).schedules)
+            setErrors((res as any).error_messages ? (res as any).error_messages : [])
+            var array = (res as any).conflict_windows;
+            var showMore = false;
+            if (array.length > 2) {
+                showMore = true;
+            }
+            else if (array.length == 1) {
+                showMore = false;
             }
             else {
-                setShowAutoSave(false)
-                setList((res as any).schedules)
-                setErrors((res as any).error_messages ? (res as any).error_messages : [])
-                var array = (res as any).conflict_windows;
-                var showMore = false;
-                if (array.length > 2) {
-                    showMore = true;
-                }
-                else if (array.length == 1) {
-                    showMore = false;
-                }
-                else {
-                    // 判断是否同时存在 FAST 和 EAT
-                    const containsFastAndEat = array.includes('FAST') && array.includes('EAT');
+                // 判断是否同时存在 FAST 和 EAT
+                const containsFastAndEat = array.includes('FAST') && array.includes('EAT');
 
-                    // 判断是否同时存在 SLEEP 和 ACTIVE
-                    const containsSleepAndActive = array.includes('SLEEP') && array.includes('ACTIVE');
+                // 判断是否同时存在 SLEEP 和 ACTIVE
+                const containsSleepAndActive = array.includes('SLEEP') && array.includes('ACTIVE');
 
-                    // 最终结果
-                    const result = containsFastAndEat || containsSleepAndActive;
-                    showMore = !result;
-                }
-                if (selMode != '' && showMore) {
-                    showAlert({
-                        title: t('health.schedule_conflict'),
-                        content: t('health.conflict_desc'),
-                        showCancel: false,
-                        confirmText: t('health.check_conflict'),
-                        confirm: () => {
-                            setSleMode('')
-                            // jumpPage(`./schedules?mode=&schedules=${JSON.stringify((res as any).schedules)}&errors=${JSON.stringify((res as any).error_messages)}`)
-                        }
-                    })
-                }
-                else {
-                    // setList((res as any).schedules)
-                    // setErrors((res as any).error_messages ? (res as any).error_messages : [])
-                }
+                // 最终结果
+                const result = containsFastAndEat || containsSleepAndActive;
+                showMore = !result;
             }
-        })
+            if (selMode != '' && showMore) {
+                showAlert({
+                    title: t('health.schedule_conflict'),
+                    content: t('health.conflict_desc'),
+                    showCancel: false,
+                    confirmText: t('health.check_conflict'),
+                    confirm: () => {
+                        setSleMode('')
+                        // jumpPage(`./schedules?mode=&schedules=${JSON.stringify((res as any).schedules)}&errors=${JSON.stringify((res as any).error_messages)}`)
+                    }
+                })
+            }
+            else {
+                // setList((res as any).schedules)
+                // setErrors((res as any).error_messages ? (res as any).error_messages : [])
+            }
+        }
     }
 
     function add(isEat) {
@@ -343,6 +347,21 @@ export default function Schedules() {
         });
     }
 
+    function getOpPage() {
+
+        if (selMode == '') return 'SCHEDULE_ALL'
+        switch (selMode) {
+            case 'FAST':
+                return 'SCHEDULE_FAST_EAT';
+            case 'EAT':
+                return 'SCHEDULE_EAT_FAST';
+            case 'SLEEP':
+                return 'SCHEDULE_SLEEP_ACTIVE';
+            case 'ACTIVE':
+                return 'SCHEDULE_ACTIVE_SLEEP';
+        }
+    }
+
     if (!loaded) return <View />
 
 
@@ -521,21 +540,16 @@ export default function Schedules() {
                 </Modal>
             }
             {
-                showModal && <AddLabel labels={isEat ? labels : labels2} 
-                window={isEat?'EAT':'ACTIVE'}
-                color={isEat ? MainColorType.eat : MainColorType.active} 
-                disMiss={() => setShowModal(false)} />
-            }
-{/* 
-            {
-                showModal && <Modal testInfo={null}
-                    dismiss={() => {
-                        setShowModal(false)
+                showModal && <AddLabel labels={isEat ? labels : labels2}
+                    window={isEat ? 'EAT' : 'ACTIVE'}
+                    color={isEat ? MainColorType.eat : MainColorType.active}
+                    disMiss={() => setShowModal(false)}
+                    op_page={getOpPage()}
+                    confirm={(res) => {
+                        checkResultData(res)
                     }}
-                    confirm={() => { }}>
-                    <AddLabel labels={isEat ? labels : labels2} color={isEat ? MainColorType.eat : MainColorType.active} disMiss={() => setShowModal(false)} />
-                </Modal>
-            } */}
+                />
+            }
         </View>
     </View>
 }

+ 12 - 10
src/_health/pages/schedules_edit.tsx

@@ -295,7 +295,7 @@ export default function SchedulesEdit() {
                                             })
                                         }}
                                     >
-                                        
+
                                         <View className='schedule_item' style={{ width: rpxToPx(750), boxSizing: 'border-box' }}>
                                             <View style={{ display: 'flex', flexDirection: 'column', justifyContent: 'flex-start', flex: 1 }}>
                                                 <View className='item_left2'>
@@ -371,15 +371,17 @@ export default function SchedulesEdit() {
                 }
             </View>
         </ScrollView>
-        <NewButton
-            btnStyle={{ marginLeft: rpxToPx(40) }}
-            type={NewButtonType.fill}
-            title="完成"
-            color={getThemeColor(health.mode)}
-            width={rpxToPx(670)}
-            height={rpxToPx(96)}
-            onClick={tapDone}
-        />
+        <View className="main_footer">
+            <NewButton
+                type={NewButtonType.fill}
+                title="完成"
+                color={getThemeColor(health.mode)}
+                width={rpxToPx(670)}
+                height={rpxToPx(96)}
+                onClick={tapDone}
+            />
+        </View>
+
         {/* <View className="edit_footer_btn" style={{ color: getThemeColor(health.mode), backgroundColor: getThemeColor(health.mode) + '33' }} onClick={tapDone}>完成</View> */}
         {
             showTimePicker && <Modal

+ 22 - 2
src/_health/pages/timeline_detail.tsx

@@ -8,7 +8,7 @@ import dayjs from "dayjs";
 import { getThemeColor } from "@/features/health/hooks/health_hooks";
 import { baseUrl } from "@/services/http/api";
 import { checkAuthorized } from "@/utils/check_authorized";
-import { createMoment, getEvents } from "@/services/health";
+import { createMoment, delEvents, getEvents } from "@/services/health";
 import NewButton, { NewButtonType } from "../base/new_button";
 import { IconClose } from "@/components/basic/Icons";
 import { rpxToPx } from "@/utils/tools";
@@ -19,6 +19,7 @@ import ChooseDateTime from "../components/choose_date_time";
 import TimeTitleDesc from "../components/time_title_desc";
 import CoverList from "../components/cover_list";
 import ListFooter from "../components/list_footer";
+import showAlert from "@/components/basic/Alert";
 
 let timestamp = 0;
 let useRoute;
@@ -235,6 +236,21 @@ export default function TimelineDetail() {
         return array;
     }
 
+    function tapMore() {
+        showAlert({
+            title:'删除',
+            content:'确认删除此记录吗?',
+            showCancel:true,
+            confirm:()=>{
+                delEvents(event_id).then(res=>{
+                    Taro.navigateBack()
+                    global.refreshWindow()
+                    // global.refreshHistory()
+                })
+            }
+        })
+    }
+
     if (!loaded) return <View />
 
     return <View style={{ display: 'flex', flex: 1 }}>
@@ -287,8 +303,12 @@ export default function TimelineDetail() {
                     <CoverList imgs={imgList()} count={mediaCount()} />
                 </View>
                 {
-                    publish && <View style={{display:'flex',flexDirection:'row',height:rpxToPx(60),alignItems:'center'}}>
+                    publish && <View style={{ display: 'flex', flexDirection: 'row', height: rpxToPx(60), alignItems: 'center', justifyContent: 'space-between' }}>
                         <Text className="h24 g02">发布于{dayjs(publish.timestamp).format('MM-DD HH:mm')}</Text>
+                        <NewButton
+                            type={NewButtonType.more}
+                            onClick={tapMore}
+                        />
                     </View>
                 }
             </View>

+ 14 - 3
src/services/health.tsx

@@ -1,4 +1,4 @@
-import { API_ACTIVE_MOVES, API_ACTIVE_MOVES_CURRENT, API_ACTIVE_MOVES_SCHEDULES, API_HEALTH_ARCHIVED, API_HEALTH_CLOCK, API_HEALTH_EVENTS, API_HEALTH_FAST_SLEEP, API_HEALTH_LABELS_EVENT, API_HEALTH_LABELS_TIME, API_HEALTH_MOMENT, API_HEALTH_RECORD, API_HEALTH_SCHEDULES, API_HEALTH_STREAKS, API_HEALTH_TARGET, API_HEALTH_WINDOWS, API_HEATH_EVENTS, API_HEATH_FAST, API_ME_ALBUMS, API_ME_ALBUMS_STAT, API_ME_JOURNALS } from "./http/api";
+import { API_ACTIVE_MOVES, API_ACTIVE_MOVES_CURRENT, API_ACTIVE_MOVES_SCHEDULES, API_HEALTH_ARCHIVED, API_HEALTH_CLOCK, API_HEALTH_EVENTS, API_HEALTH_FAST_SLEEP, API_HEALTH_LABELS_EVENT, API_HEALTH_LABELS_TIME, API_HEALTH_MOMENT, API_HEALTH_RECORD, API_HEALTH_SCHEDULES, API_HEALTH_STREAKS, API_HEALTH_WINDOWS, API_HEALTH_FAST, API_ME_ALBUMS, API_ME_ALBUMS_STAT, API_ME_JOURNALS } from "./http/api";
 import { request } from "./http/request";
 
 export const getLabelsEvent = (params) => {
@@ -108,7 +108,7 @@ export const delSchedules = (ids: any) => {
 export const updateTarget = (timestamp, id) => {
     return new Promise((resolve, reject) => {
         request({
-            url: `${API_HEALTH_TARGET}/${id}/duration`, method: 'PUT', data: { target_end_timestamp: timestamp }
+            url: `${API_HEALTH_EVENTS}/${id}/duration`, method: 'PUT', data: { target_end_timestamp: timestamp }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -328,6 +328,17 @@ export const getEvents = (id) => {
     })
 }
 
+export const delEvents = (id) => {
+    return new Promise((resolve) => {
+        request({
+            url: API_HEALTH_EVENTS + '/' + id, method: 'DELETE', data: {}
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        })
+    })
+}
+
 export const fastWithSleep = () => {
     return new Promise((resolve) => {
         request({
@@ -342,7 +353,7 @@ export const fastWithSleep = () => {
 export const updateFast = (params) => {
     return new Promise((resolve) => {
         request({
-            url: API_HEATH_FAST, method: 'POST', data: { ...params }
+            url: API_HEALTH_FAST, method: 'POST', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));

+ 1 - 3
src/services/http/api.js

@@ -96,7 +96,6 @@ export const API_ORDER_CHECK = `${baseUrl}/api/payment/member/orders/`
 //health
 export const API_SET_SCHEDULE = `${baseUrl}/api/fast/schedules`
 export const API_HEALTH_FAST_SLEEP = `${baseUrl}/api/health/fast-with-sleep`
-export const API_HEALTH_TARGET = `${baseUrl}/api/health/events`
 export const API_HEALTH_MOMENT = `${baseUrl}/api/health/moments`
 export const API_HEALTH_SCHEDULES = `${baseUrl}/api/health/schedules`
 export const API_HEALTH_LABELS_EVENT = `${baseUrl}/api/health/labels/event`
@@ -107,8 +106,7 @@ export const API_HEALTH_WINDOWS = `${baseUrl}/api/health/windows`
 export const API_HEALTH_CLOCK = `${baseUrl}/api/health/clocks`
 export const API_HEALTH_EVENTS = `${baseUrl}/api/health/events`
 export const API_HEALTH_ARCHIVED = `${baseUrl}/api/health/archived`
-export const API_HEATH_EVENTS = `${baseUrl}/api/health/events`
-export const API_HEATH_FAST = `${baseUrl}/api/health/fast`
+export const API_HEALTH_FAST = `${baseUrl}/api/health/fast`
 
 export const API_ACTIVE_MOVES_CURRENT = `${baseUrl}/api/health/active/moves/current`
 export const API_ACTIVE_MOVES_SCHEDULES = `${baseUrl}/api/health/schedules/active/move`