leon před 1 rokem
rodič
revize
e0a20a2f4c

+ 12 - 73
src/_health/components/add_label.tsx

@@ -98,10 +98,10 @@ export default function AddLabel(props: {
                 if (props.confirm) {
                     props.confirm(res)
                 }
-                setShowTimePicker(false)
-                if (props.disMiss) {
-                    props.disMiss()
-                }
+                // setShowTimePicker(false)
+                // if (props.disMiss) {
+                //     props.disMiss()
+                // }
                 return;
                 // }
 
@@ -124,6 +124,13 @@ export default function AddLabel(props: {
             props.confirm(value)
         }
         else {
+            if (value.length==0){
+                Taro.showToast({
+                    title:'请选择或输入标签',
+                    icon:'none'
+                })
+                return;
+            }
             setShowTimePicker(true)
         }
     }
@@ -198,6 +205,7 @@ export default function AddLabel(props: {
                         </View>
                         <NewTimePicker
                             color={props.color ? props.color : getThemeColor(health.mode)}
+                            time={strTime}
                             onChange={e => {
                                 console.log(e)
                                 setStrTime(e)
@@ -211,75 +219,6 @@ export default function AddLabel(props: {
         </View>
     }
 
-    function timeContent2() {
-        return <View>
-            <Card>
-                {
-                    isEat() ? <View style={{
-                        position: 'relative',
-                        display: 'flex', flexDirection: 'row',
-                        height: rpxToPx(128),
-                        alignItems: 'center',
-                        boxSizing: 'border-box',
-                        paddingLeft: rpxToPx(54),
-                        paddingRight: rpxToPx(54),
-                        justifyContent: 'center'
-                    }}>
-                        <Text className="h34" style={{ color: MainColorType.eat }}>{strTime}</Text>
-                    </View> :
-                        <View style={{
-                            position: 'relative',
-                            display: 'flex', flexDirection: 'row',
-                            height: rpxToPx(128),
-                            alignItems: 'center',
-                            boxSizing: 'border-box',
-                            paddingLeft: rpxToPx(54),
-                            paddingRight: rpxToPx(54),
-                            justifyContent: 'space-between'
-                        }}>
-                            <Text className="h34">具体时间</Text>
-                            <Switch
-                                color={props.color ? props.color : getThemeColor(health.mode)}
-                                checked={!isFullday}
-                                onChange={(e) => {
-                                    setIsFullday(!e.detail.value)
-                                }} />
-                        </View>
-                }
-            </Card>
-            <View style={{ height: rpxToPx(36) }} />
-
-            {
-                isFullday ? <View>
-                    <Card>
-                        <Input className="input_lb" placeholder="选择或输入时间标签" value={strLabel} onInput={(e: any) => {
-                            setStrLabel(e.target.value)
-                        }} />
-                    </Card>
-                    <ScrollView scrollX style={{ width: rpxToPx(750), height: rpxToPx(164) }} showScrollbar={false}>
-                        <View className="label_bg">
-                            {
-                                timeLabels.map((item, index) => {
-                                    return <View className="label" key={index} onClick={() => setStrLabel(item.title)}>{item.title}</View>
-                                })
-                            }
-                        </View>
-                    </ScrollView>
-                </View> :
-                    <Card>
-                        <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
-                            <NewTimePicker
-                                color={props.color ? props.color : getThemeColor(health.mode)}
-                                onChange={e => {
-                                    console.log(e)
-                                    setStrTime(e)
-                                }} />
-                        </View>
-                    </Card>
-            }
-        </View>
-    }
-
 
     return <NewModal title="标签" dismiss={props.disMiss}
         themeColor={props.color ? props.color : getThemeColor(health.mode)}

+ 3 - 1
src/_health/components/fast_sleep_console.tsx

@@ -120,8 +120,10 @@ export default function FastSleepConsole(props: { step: number, data: any, del:
             content: '确认删除此记录?',
             showCancel: true,
             confirm: () => {
-                delRecord(array[0], { ids: array }).then(res => {
+                delRecord({ ids: array }).then(res => {
                     global.refreshWindow()
+                    if (global.refreshHistory)
+                        global.refreshHistory()
                     props.del()
                 })
             }

+ 1 - 0
src/_health/components/target_progress.scss

@@ -6,6 +6,7 @@
     background-color: #fafafa;
     height: 100px;
     padding-left: 14px;
+    // width: 526px;
     // width: 572px;
 }
 

+ 2 - 2
src/_health/pages/fast_sleep.tsx

@@ -14,7 +14,7 @@ import Card from "../components/card";
 import FastSleepConsole from "../components/fast_sleep_console";
 import { fastWithSleep } from "@/services/health";
 import FastSleepCard from "../components/fast_sleep_card";
-import MainHistory from "@/features/health/MainHistory";
+import MainHistory2 from "@/features/health/MainHistory2";
 import StickyDateList from "../components/sticky_date_list";
 import FastSleepPopup from "../components/fast_sleep_popup";
 import { useTranslation } from "react-i18next";
@@ -151,7 +151,7 @@ export default function FastSleep() {
                 }} showDetail={() => {
                     setShowPopCard(true)
                 }} />
-                <MainHistory type='FAST,SLEEP' ref={historyRef} updateDate={(e) => {
+                <MainHistory2 type='FAST,SLEEP' ref={historyRef} updateDate={(e) => {
                     setShowDate(e.show)
                     setDate(e.date)
                 }} refreshSuccess={() => {

+ 9 - 1
src/_health/pages/guide_active.tsx

@@ -174,6 +174,13 @@ export default function GuideActive() {
                                 })
                                 return
                             }
+                            if (errors.length>0){
+                                Taro.showToast({
+                                    title:'请先解决冲突',
+                                    icon:'none'
+                                })
+                                return
+                            }
                             delSchedule(obj.id).then(res => {
                                 dispatch(setFooter((res as any).footer))
                                 var array = JSON.parse(JSON.stringify(list))
@@ -183,6 +190,7 @@ export default function GuideActive() {
                                     }
                                 }
                                 setList(array)
+                                check(array)
                                 global.refreshWindow()
                             })
                         }}
@@ -336,7 +344,7 @@ export default function GuideActive() {
             />
         </View>
         {
-            showModal && <AddLabel labels={labels}
+             showModal && <AddLabel labels={labels}
                 window='ACTIVE'
                 disMiss={() => setShowModal(false)}
                 onlyCheck={true}

+ 8 - 0
src/_health/pages/guide_eat.tsx

@@ -165,6 +165,13 @@ export default function GuideEat() {
                                 })
                                 return
                             }
+                            if (errors.length>0){
+                                Taro.showToast({
+                                    title:'请先解决冲突',
+                                    icon:'none'
+                                })
+                                return
+                            }
                             delSchedule(obj.id).then(res => {
                                 dispatch(setFooter((res as any).footer))
                                 var array = JSON.parse(JSON.stringify(list))
@@ -174,6 +181,7 @@ export default function GuideEat() {
                                     }
                                 }
                                 setList(array)
+                                check(array)
                                 global.refreshWindow()
                             })
                         }}

+ 2 - 0
src/_health/pages/log_time.tsx

@@ -550,6 +550,8 @@ export default function LogTime() {
                     global.refreshWindow()
                     if (global.refreshHistory)
                         global.refreshHistory()
+                    if (global.refreshOtherHistory)
+                        global.refreshOtherHistory()
                     if (global.refreshFastSleep)
                         global.refreshFastSleep()
 

+ 3 - 3
src/_health/pages/long_fast.tsx

@@ -8,7 +8,7 @@ import { rpxToPx } from "@/utils/tools";
 import NewButton, { NewButtonType } from "../base/new_button";
 import { getScenario, getThemeColor } from "@/features/health/hooks/health_hooks";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
-import MainHistory from "@/features/health/MainHistory";
+import MainHistory2 from "@/features/health/MainHistory2";
 import { useSelector } from "react-redux";
 import showAlert from "@/components/basic/Alert";
 import { clockTimes, delRecord, updateFast } from "@/services/health";
@@ -139,7 +139,7 @@ export default function LongFast() {
     }
 
     function del() {
-        delRecord(health.long_fast.window_id).then(res => {
+        delRecord({ids:[health.long_fast.window_id]}).then(res => {
             global.refreshWindow()
         })
     }
@@ -363,7 +363,7 @@ export default function LongFast() {
 
 
 
-            <MainHistory type='FAST' fast_type="LF" ref={historyRef} updateDate={(e) => {
+            <MainHistory2 type='FAST' fast_type="LF" ref={historyRef} updateDate={(e) => {
                 setShowDate(e.show)
                 setDate(e.date)
             }} refreshSuccess={() => {

+ 1 - 1
src/_health/pages/post_result.tsx

@@ -215,7 +215,7 @@ export default function PostResult() {
                 onClick={() => {
                     if (data.current_window) {
                         Taro.navigateBack({
-                            delta: 7
+                            delta: 10
                         })
                     }
                     else {

+ 48 - 10
src/_health/pages/schedules.tsx

@@ -24,6 +24,7 @@ import NewHeader, { NewHeaderType } from "../components/new_header";
 import ListFooter from "../components/list_footer";
 import Layout from "@/components/layout/layout";
 import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
+import Taro from "@tarojs/taro";
 
 let useRoute;
 let useNavigation;
@@ -33,7 +34,6 @@ if (process.env.TARO_ENV == 'rn') {
     useNavigation = require("@react-navigation/native").useNavigation
 }
 
-let indexError = true
 
 export default function Schedules() {
     let navigation, showActionSheetWithOptions;
@@ -49,6 +49,7 @@ export default function Schedules() {
     else {
         router = useRouter()
     }
+    // const [indexError, setIndexError] = useState(true)
     const [list, setList] = useState<any>([])
     const [labels, setLabels] = useState<any>([])
     const [labels2, setLabels2] = useState<any>([])
@@ -68,6 +69,7 @@ export default function Schedules() {
     const { t } = useTranslation()
 
     useEffect(() => {
+        global.indexError = true
         if (selMode == '' && router.params.schedules) {
             setList(JSON.parse(router.params.schedules))
             if (router.params.errors) {
@@ -88,6 +90,7 @@ export default function Schedules() {
 
 
 
+
     global.tempRefresh = () => {
         schedules()
     }
@@ -128,8 +131,8 @@ export default function Schedules() {
                 setHighlight(false)
             }, 2000)
 
-            if (router.params.error && indexError){
-                indexError = false
+            if (router.params.error && global.indexError) {
+                global.indexError = false
                 checkResultData(JSON.parse(router.params.error))
             }
         }).catch(e => {
@@ -217,8 +220,8 @@ export default function Schedules() {
         }
         else {
             setShowAutoSave(false)
-            setList((res as any).schedules)
-            setErrors((res as any).error_messages ? (res as any).error_messages : [])
+            // 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) {
@@ -246,13 +249,15 @@ export default function Schedules() {
                     confirmText: t('health.check_conflict'),
                     confirm: () => {
                         setSleMode('')
+                        setList((res as any).schedules)
+                        setErrors((res as any).error_messages ? (res as any).error_messages : [])
                         // 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 : [])
+                setList((res as any).schedules)
+                setErrors((res as any).error_messages ? (res as any).error_messages : [])
             }
         }
     }
@@ -383,6 +388,10 @@ export default function Schedules() {
         });
     }
 
+    function reset() {
+        jumpPage('/_health/pages/guide_begin')
+    }
+
     function getOpPage() {
 
         if (selMode == '') return 'SCHEDULE_ALL'
@@ -442,6 +451,7 @@ export default function Schedules() {
                                     key={i * 100}
                                     obj={obj}
                                     highlight={highlight && selMode == obj.window}
+                                    hideReminderIcon={errors.length>0}
                                     showLine={i < list.length - 1}
                                     errors={errors}
                                     selMode={selMode}
@@ -457,6 +467,13 @@ export default function Schedules() {
                                         checkData(array)
                                     }}
                                     onDelete={() => {
+                                        if (errors.length>0){
+                                            Taro.showToast({
+                                                title:'请先解决冲突',
+                                                icon:'none'
+                                            })
+                                            return
+                                        }
                                         delSchedule(obj.id).then(res => {
                                             var array = JSON.parse(JSON.stringify(list))
                                             array.splice(i, 1)
@@ -472,7 +489,7 @@ export default function Schedules() {
                 </Card>
                 <View style={{ height: 20, flexShrink: 0 }} />
                 {
-                    !router.params.isFastSleep && selMode != '' && selMode != 'DAY' && selMode != 'NIGHT' && <Card><View className='item_add'
+                    errors.length == 0 &&!router.params.isFastSleep && selMode != '' && selMode != 'DAY' && selMode != 'NIGHT' && <Card><View className='item_add'
                         onClick={() => add((selMode == 'FAST' || selMode == 'EAT'))}>
                         <StatusIndicator type={StatusType.img}
                             fontColor={getAddColor()}
@@ -487,7 +504,7 @@ export default function Schedules() {
                     </View></Card>
                 }
                 {
-                    selMode == '' && <Card>
+                    errors.length == 0 &&selMode == '' && <Card>
                         <View className='item_add'
                             style={{ position: 'relative' }}
                             onClick={() => add(true)}>
@@ -516,7 +533,7 @@ export default function Schedules() {
                 }
 
                 {
-                    health.finish_setup && <View style={{
+                    errors.length == 0 && health.finish_setup && <View style={{
                         backgroundColor: 'transparent',
                         position: 'relative',
                         display: 'flex',
@@ -546,6 +563,27 @@ export default function Schedules() {
 
                     </View>
                 }
+                {
+                    errors.length > 0 && <View style={{
+                        backgroundColor: 'transparent',
+                        position: 'relative',
+                        display: 'flex',
+                        alignItems: 'center',
+                        justifyContent: 'center',
+                        height: rpxToPx(128),
+                        width: rpxToPx(750)
+                    }}>
+                        <View style={{ width: rpxToPx(316), height: rpxToPx(128), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
+                            <NewButton
+                                type={NewButtonType.link}
+                                title='Reset Schedule'
+                                onClick={reset}
+                            >
+                            </NewButton>
+                        </View>
+
+                    </View>
+                }
 
 
                 {/* <View style={{ height: 100, flexShrink: 0 }} /> */}

+ 28 - 10
src/_health/pages/timeline_detail.tsx

@@ -3,7 +3,7 @@ import { useDispatch, useSelector } from "react-redux";
 import './timeline_detail.scss'
 import '@features/health/History.scss'
 import { useEffect, useState } from "react";
-import Taro, { useRouter } from "@tarojs/taro";
+import Taro, { useRouter, useShareAppMessage } from "@tarojs/taro";
 import dayjs from "dayjs";
 import { getScenario, getThemeColor } from "@/features/health/hooks/health_hooks";
 import { baseUrl } from "@/services/http/api";
@@ -80,6 +80,14 @@ export default function TimelineDetail() {
     const { schedule_id, event_id, window_id, isfastsleep, disable_edit } = router.params
 
 
+    if (process.env.TARO_ENV == 'weapp') {
+        useShareAppMessage((e) => {
+            return {
+                title: t('feature.track_time_duration.common.share_title'),
+                path: '/_health/pages/timeline_detail?type=share'
+            }
+        })
+    }
 
     useEffect(() => {
         Taro.setNavigationBarColor({
@@ -261,7 +269,7 @@ export default function TimelineDetail() {
             })
             return
         }
-        var dt = new Date(selDate + ' ' + time + ':'+dayjs(enterTimestmap).format('ss'))
+        var dt = new Date(selDate + ' ' + time + ':' + dayjs(enterTimestmap).format('ss'))
         dt.setMilliseconds(new Date(enterTimestmap).getMilliseconds())
         var params: any = {
             schedule_id: schedule_id,
@@ -340,7 +348,10 @@ export default function TimelineDetail() {
                 delEvents(event_id).then(res => {
                     Taro.navigateBack()
                     global.refreshWindow()
-                    global.refreshHistory()
+                    if (global.refreshHistory)
+                        global.refreshHistory()
+                    if (global.refreshOtherHistory)
+                        global.refreshOtherHistory()
                     if ((res as any).status_change) {
                         if ((res as any).status_change.previous != (res as any).status_change.current) {
                             //灵动岛弹窗
@@ -360,14 +371,21 @@ export default function TimelineDetail() {
     }
 
     function delHistory() {
+        var ids: any = [window_id]
+        if (isfastsleep=='1') {
+            ids = [detail.windows[0].id, detail.windows[1].id]
+        }
         showAlert({
             title: '删除',
             content: '确认删除此记录吗?',
             showCancel: true,
             confirm: () => {
-                delRecord(window_id).then(res => {
+                delRecord({ ids: ids }).then(res => {
                     global.refreshWindow()
-                    global.refreshHistory()
+                    if (global.refreshHistory)
+                        global.refreshHistory()
+                    if (global.refreshOtherHistory)
+                        global.refreshOtherHistory()
                     Taro.navigateBack()
 
                 })
@@ -486,9 +504,9 @@ export default function TimelineDetail() {
                 // total1={total1()}
                 // total2={total2()}
                 // total3={total3()}
-                step1={stepContent(TimeFormatter.calculateTimeDifference(fast.window_range.start_timestamp, sleep.window_range.start_timestamp,false,true), 0)}
-                step2={stepContent(TimeFormatter.calculateTimeDifference(sleep.window_range.start_timestamp, sleep.window_range.end_timestamp,false,true), 1)}
-                step3={stepContent(TimeFormatter.calculateTimeDifference(sleep.window_range.end_timestamp, fast.window_range.end_timestamp,false,true), 2)}
+                step1={stepContent(TimeFormatter.calculateTimeDifference(fast.window_range.start_timestamp, sleep.window_range.start_timestamp, false, true), 0)}
+                step2={stepContent(TimeFormatter.calculateTimeDifference(sleep.window_range.start_timestamp, sleep.window_range.end_timestamp, false, true), 1)}
+                step3={stepContent(TimeFormatter.calculateTimeDifference(sleep.window_range.end_timestamp, fast.window_range.end_timestamp, false, true), 2)}
             />
         }
         return null
@@ -671,7 +689,7 @@ export default function TimelineDetail() {
                 }
             </View>
         </View>
-        <Text style={{opacity:0}}>{count}</Text>
+        <Text style={{ opacity: 0 }}>{count}</Text>
         <ListFooter />
         {
             !window_id && health.mode != 'ACTIVE' && health.mode != 'EAT' && <View className="add_note"><NewButton type={NewButtonType.link} title="写个笔记" onClick={() => {
@@ -724,7 +742,7 @@ export default function TimelineDetail() {
                     <View style={{ flex: 1 }} />
                     <View className="btn" style={{ backgroundColor: btnDisable ? '#b2b2b2' : getThemeColor(health.mode) }} onClick={tapPost}>发布</View>
                 </View>
-                
+
                 <View style={{ height: bottom, flexShrink: 0 }} />
             </View>
         }

+ 81 - 3
src/features/health/HistoryItem.tsx

@@ -21,6 +21,7 @@ import { jumpPage } from "../trackTimeDuration/hooks/Common";
 import TargetProgress from "@/_health/components/target_progress";
 import Cell from "@/_health/base/cell";
 import { setFirstActiveId, setFirstEatId } from "@/store/health";
+import JournalCover from "../journal/components/journal_cover";
 
 export default function HistoryItem(props: {
     data: any,
@@ -211,8 +212,8 @@ export default function HistoryItem(props: {
 
     function del() {
         const { window_id } = props.data
-        delRecord(window_id).then(res => {
-            
+        delRecord({ ids: [window_id] }).then(res => {
+
             global.refreshWindow()
             global.refreshHistory()
         })
@@ -489,7 +490,7 @@ export default function HistoryItem(props: {
                     props.data.events.map(item => {
                         item.moments && item.moments.map(moment => {
                             if (moment.media && moment.media.length > 0) {
-                                if (moment.media[0].url==url) {
+                                if (moment.media[0].url == url) {
                                     temp = item
                                 }
                             }
@@ -563,6 +564,79 @@ export default function HistoryItem(props: {
             }
         </View>
     }
+
+    function imgText() {
+        if (props.data.texts.length == 0 && props.data.pics.length == 0) {
+            return <View />
+        }
+        // if (props.data.pics.length == 0) {
+        //     return <View style={{ display: 'flex', flexDirection: 'row', marginBottom: rpxToPx(12), flex: 1 }}><View style={{
+        //         display: 'flex',
+        //         flex: 1,
+        //         flexShrink: 0,
+        //         flexDirection: 'column',
+        //         backgroundColor: '#fafafa',
+        //         paddingLeft: rpxToPx(20),
+        //         paddingRight: rpxToPx(20),
+        //         paddingTop: rpxToPx(12),
+        //         paddingBottom: rpxToPx(12)
+        //     }}>{props.data.text.map((detail, j) => {
+        //         return <TimeTitleDesc
+        //             key={j * 100}
+        //             className={'line2'}
+        //             time=''
+        //             title={detail.title}
+        //             desc={detail.description}
+        //         />
+        //     })}</View>
+        //     </View>
+        // }
+
+        return <View style={{ display: 'flex', flexDirection: 'row',
+            // backgroundColor:'pink', 
+            marginBottom: rpxToPx(12),
+            overflow:'hidden',
+            width:rpxToPx(554),
+         flex: 1 }}>
+
+            {
+                props.data.pics.length > 0 && <JournalCover imgs={props.data.pics} />
+            }
+            
+            <View style={{
+                display: 'flex',
+                flexDirection: 'column',
+                flex: 1,
+                overflow: 'hidden',
+                backgroundColor: props.data.pics.length == 0 ? '#fafafa' : 'transparent',
+                paddingLeft: props.data.pics.length == 0 ? rpxToPx(20) : 0,
+                paddingRight: props.data.pics.length == 0 ? rpxToPx(40) : 0,
+                paddingTop: props.data.pics.length == 0 ? rpxToPx(12) : 0,
+                paddingBottom: props.data.pics.length == 0 ? rpxToPx(12) : 0,
+                // marginRight: rpxToPx(40),
+                flexShrink: 0
+            }}>
+                {
+
+                    props.data.texts.map((item2, index2) => {
+                        return <TimeTitleDesc
+                            key={index2 * 1000}
+                            className='line1'//{item.pics.length == 0 ? 'line2' : 'line3'}
+                            // style={{ width: props.data.pics.length > 0 ? rpxToPx(310) : rpxToPx(512) }}
+                            time=''
+                            title={item2.title}
+                            desc={item2.description}
+                        />
+                    })
+                }
+
+
+
+
+            </View>
+        </View>
+    }
+
     return <View className="history_item2" onClick={goDetail}>
         <View className="cell_date" >
             <View className="h42 bold" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate()}</View>
@@ -636,6 +710,10 @@ export default function HistoryItem(props: {
                 })
             }
 
+            {
+                props.mode != 'EAT' && props.mode != 'ACTIVE' && imgText()
+            }
+
             {
                 (props.mode == 'EAT' || props.mode == 'ACTIVE') && props.data.dataArray.map((content, i) => {
                     switch (content.type) {

+ 1 - 1
src/features/health/MainConsole.tsx

@@ -516,7 +516,7 @@ export default function MainConsole(props: { type: WindowType }) {
                         content: '确认删除此记录?',
                         showCancel: true,
                         confirm: () => {
-                            delRecord(obj.window_id).then(res => {
+                            delRecord({ids:[obj.window_id]}).then(res => {
                                 global.refreshWindow()
 
                                 if ((res as any).status_change) {

+ 17 - 6
src/features/health/MainFastEatCard.tsx

@@ -92,12 +92,8 @@ export default function MainFastEatCard(props: {
 
     useEffect(() => {
         const { fast, eat } = health.windows.fast_eat
-        var now = new Date().getTime()
-        if (eat.status == 'OG') {
-            setIsFastMode(false)
-            dispatch(setMode('EAT'))
-        }
-        else if ((fast.status == 'WAIT_FOR_END' || fast.target.start_time <= now && fast.target.end_time >= now) || isCurrentTimeInRange(fast.period.start_time, fast.period.end_time)) {
+
+        if (isTempFast){
             setIsFastMode(true)
             dispatch(setMode('FAST'))
         }
@@ -105,6 +101,21 @@ export default function MainFastEatCard(props: {
             setIsFastMode(false)
             dispatch(setMode('EAT'))
         }
+        // var now = new Date().getTime()
+        // if (eat.status == 'OG') {
+        //     setIsFastMode(false)
+        //     debugger
+        //     dispatch(setMode('EAT'))
+        // }
+        // else if ((fast.status == 'WAIT_FOR_END' || fast.target.start_time <= now && fast.target.end_time >= now) || isCurrentTimeInRange(fast.period.start_time, fast.period.end_time)) {
+        //     setIsFastMode(true)
+        //     dispatch(setMode('FAST'))
+        // }
+        // else {
+        //     setIsFastMode(false)
+        //     debugger
+        //     dispatch(setMode('EAT'))
+        // }
 
 
 

+ 69 - 137
src/features/health/MainHistory.tsx

@@ -27,7 +27,6 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
     const [page, setPage] = useState(1)
     const [total, setTotal] = useState(0)
     const [loaded, setLoaded] = useState(false)
-    const refDemo = useRef()
     const health = useSelector((state: any) => state.health);
     const user = useSelector((state: any) => state.user);
     const [loading, setLoading] = useState(false)
@@ -38,7 +37,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
     const [eatList, setEatList] = useState<any>([])
     const [activeList, setActiveList] = useState<any>([])
     const [sleepList, setSleepList] = useState<any>([])
-    const healthRef = useRef(health)
+
     const dispatch = useDispatch()
     const { t } = useTranslation()
 
@@ -63,16 +62,33 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
         }
     }, [user.isLogin])
 
+
+
+    useEffect(() => {
+        // if (props.type == 'FAST,SLEEP' || (props.fast_type && props.fast_type == 'LF')) {
+        //     global.refreshOtherHistory = () => {
+        //         refresh()
+        //     }
+        // }
+        // else {
+            
+        // }
+    }, [])
+
     global.refreshHistory = () => {
         refresh()
-
-        refreshEat()
-        refreshActive()
+        // refreshFast()
+        // refreshSleep()
+        // refreshEat()
+        // refreshActive()
+        refreshItem('FAST')
+        refreshItem('SLEEP')
+        refreshItem('EAT')
+        refreshItem('ACTIVE')
     }
 
     useEffect(() => {
         if (props.type) {
-            debugger
             loadData(1)
         }
     }, [props.type])
@@ -178,9 +194,10 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
         loadData(index)
     }
 
-    function refreshEat() {
+    function refreshItem(type) {
+        setPage(1)
         var params: any = {
-            window: 'EAT',
+            window: type,
             limit: 10,
             page: 1
         }
@@ -275,112 +292,23 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
 
                 item.dataArray = temps;
             })
-
-            setEatList(array)
+            switch (type) {
+                case 'FAST':
+                    setFastList(array)
+                    break
+                case 'SLEEP':
+                    setSleepList(array)
+                    break
+                case 'EAT':
+                    setEatList(array)
+                    break
+                case 'ACTIVE':
+                    setActiveList(array)
+                    break
+            }
         })
     }
 
-    function refreshActive() {
-        var params: any = {
-            window: 'ACTIVE',
-            limit: 10,
-            page: 1
-        }
-
-        records(params).then(res => {
-            var array = (res as any).data
-
-            array.map(item => {
-                var temps: any = []
-                var lastType = ''
-                var lastTextArray: any = []
-                var lastImageArray: any = []
-                item.events.map(event => {
-                    event.moments && event.moments.map(moment => {
-                        switch (moment.type) {
-                            case 'TEXT':
-                                {
-                                    lastTextArray.push({
-                                        title: moment.title,
-                                        description: moment.description,
-                                        event_id: event.id
-                                    })
-                                    if (lastType == 'PIC') {
-                                        temps.push({
-                                            type: 'PIC',
-                                            data: JSON.parse(JSON.stringify(lastImageArray))
-                                        })
-                                        lastImageArray = []
-                                    }
-                                    lastType = 'TEXT'
-                                }
-                                break;
-                            case 'PIC':
-                                {
-                                    lastImageArray.push(moment.media[0].url)
-                                    if (lastType == 'TEXT') {
-                                        temps.push({
-                                            type: 'TEXT',
-                                            data: JSON.parse(JSON.stringify(lastTextArray))
-                                        })
-                                        lastTextArray = []
-                                    }
-                                    lastType = 'PIC'
-                                }
-                                break;
-                            case 'PIC_TEXT':
-                                if (lastType == 'PIC') {
-                                    temps.push({
-                                        type: 'PIC',
-                                        data: JSON.parse(JSON.stringify(lastImageArray))
-                                    })
-                                    lastImageArray = []
-                                }
-                                if (lastType == 'TEXT') {
-                                    temps.push({
-                                        type: 'TEXT',
-                                        data: JSON.parse(JSON.stringify(lastTextArray))
-                                    })
-                                    lastTextArray = []
-                                }
-                                temps.push({
-                                    type: 'PIC_TEXT',
-                                    data: [
-                                        {
-                                            title: moment.title,
-                                            description: moment.description,
-                                            url: moment.media[0].url,
-                                            event_id: event.id
-                                        }
-                                    ]
-                                })
-                                lastType = 'PIC_TEXT'
-                                break;
-                        }
-                    })
-                })
-
-                if (lastType == 'PIC') {
-                    temps.push({
-                        type: 'PIC',
-                        data: JSON.parse(JSON.stringify(lastImageArray))
-                    })
-                    lastImageArray = []
-                }
-                if (lastType == 'TEXT') {
-                    temps.push({
-                        type: 'TEXT',
-                        data: JSON.parse(JSON.stringify(lastTextArray))
-                    })
-                    lastTextArray = []
-                }
-
-                item.dataArray = temps;
-            })
-
-            setActiveList(array)
-        })
-    }
 
     function loadData(index: number) {
         var params: any = {
@@ -489,9 +417,10 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
             setLoaded(true)
             if (index == 1) {
                 // console.log(props.type,health.mode)
-                if (!props.type && array.length > 0) {
+                if (!props.type && array.length >= 0) {
                     if (health.mode == 'EAT') {
                         setEatList(array)
+                        setList(array)
                         // dispatch(setFirstEatId(array[0].window_id))
                         // if (health.first_eat_id.length > 0 && health.first_eat_id != array[0].window_id) {
                         //     dispatch(setEatTip(true))
@@ -499,6 +428,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
                     }
                     else if (health.mode == 'ACTIVE') {
                         setActiveList(array)
+                        setList(array)
                         // dispatch(setFirstActiveId(array[0].window_id))
                         // if (health.first_active_id.length > 0 && health.first_active_id != array[0].window_id) {
                         //     dispatch(setActiveTip(true))
@@ -506,12 +436,14 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
                     }
                     else if (health.mode == 'FAST') {
                         setFastList(array)
+                        setList(array)
                     }
                     else if (health.mode == 'SLEEP') {
                         setSleepList(array)
+                        setList(array)
                     }
                 }
-                setList(array)
+                
                 setTotal((res as any).total)
                 if (props.refreshSuccess) {
                     props.refreshSuccess()
@@ -756,37 +688,37 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
         {/* {
             archiveContent()
         } */}
-        {
+        {/* {
             newJournalTip()
-        }
+        } */}
         {
             (health.mode == 'EAT' || health.mode == 'ACTIVE') && <RightArrowRow title={health.mode == 'ACTIVE' ? t('health.title_active_journal') : t('health.title_food_journal')}
-                showBadge={(health.mode == 'EAT' && health.eat_journal_tip) ||
-                    (health.mode == 'ACTIVE' && health.active_journal_tip)}
+                // showBadge={(health.mode == 'EAT' && health.eat_journal_tip) ||
+                //     (health.mode == 'ACTIVE' && health.active_journal_tip)}
                 onClick={() => {
-                    if ((health.mode == 'EAT' && health.eat_journal_tip) ||
-                        (health.mode == 'ACTIVE' && health.active_journal_tip)) {
-                        getLatestJournal(false, {
-                            id: health.mode == 'EAT' ? global.eatTipId : global.activeTipId,
-                            user_confirmed: true
-                        }).then(res => {
-
-                        })
-                    }
-
-
-                    setTimeout(() => {
-                        if (health.mode == 'EAT') {
-                            dispatch(setEatTip(false))
-                        }
-                        else {
-                            dispatch(setActiveTip(false))
-                        }
-                    }, 1000)
+                    // if ((health.mode == 'EAT' && health.eat_journal_tip) ||
+                    //     (health.mode == 'ACTIVE' && health.active_journal_tip)) {
+                    //     getLatestJournal(false, {
+                    //         id: health.mode == 'EAT' ? global.eatTipId : global.activeTipId,
+                    //         user_confirmed: true
+                    //     }).then(res => {
+
+                    //     })
+                    // }
+
+
+                    // setTimeout(() => {
+                    //     if (health.mode == 'EAT') {
+                    //         dispatch(setEatTip(false))
+                    //     }
+                    //     else {
+                    //         dispatch(setActiveTip(false))
+                    //     }
+                    // }, 1000)
 
                     var showBadge = (health.mode == 'EAT' && health.eat_journal_tip) ||
                         (health.mode == 'ACTIVE' && health.active_journal_tip)
-                    jumpPage('/pages/account/Journal?type=' + health.mode + `&show_tip=${showTipF() ? '1' : '0'}&show_badge=${showBadge ? 1 : 0}`)
+                    jumpPage('/pages/account/Journal?type=' + health.mode + `&show_tip=${showTipF() && false ? '1' : '0'}&show_badge=${showBadge ? 1 : 0}`)
                 }} />
         }
         {

+ 754 - 0
src/features/health/MainHistory2.tsx

@@ -0,0 +1,754 @@
+import { View, Text, Image } from "@tarojs/components";
+import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
+import { getLatestJournal, records } from "@/services/health";
+import './History.scss'
+import Calendar from "./calendar";
+import { useDispatch, useSelector } from "react-redux";
+import HistoryItem from "./HistoryItem";
+import { rpxToPx } from "@/utils/tools";
+import { jumpPage } from "../trackTimeDuration/hooks/Common";
+import Taro, { useReady } from "@tarojs/taro";
+import { getScenario, getThemeColor } from "./hooks/health_hooks";
+import { TimeFormatter } from "@/utils/time_format";
+import dayjs from "dayjs";
+import { MainColorType } from "@/context/themes/color";
+import { IconArrow, IconCellArrow } from "@/components/basic/Icons";
+import NoRecord from "@/_health/components/no_record";
+import ListFooter from "@/_health/components/list_footer";
+import { useTranslation } from "react-i18next";
+import { setActiveTip, setEatTip, setFirstActiveId, setFirstEatId } from "@/store/health";
+import RightArrowRow from "@/_health/components/right_arrow_row";
+
+let lastMode = ''
+let myScrollTop = 0
+export default forwardRef((props: { type?: string, fast_type?: string, updateDate?: any, refreshSuccess?: any }, ref) => {
+    const [itemLayouts, setItemLayouts] = useState<any>([])
+    const [list, setList] = useState<any>([])
+    const [page, setPage] = useState(1)
+    const [total, setTotal] = useState(0)
+    const [loaded, setLoaded] = useState(false)
+    const health = useSelector((state: any) => state.health);
+    const user = useSelector((state: any) => state.user);
+    const [loading, setLoading] = useState(false)
+    const [showEatArchive, setShowEatArchive] = useState(true)
+    const [showActiveArchive, setShowActiveArchive] = useState(true)
+
+    const [fastList, setFastList] = useState<any>([])
+    const [eatList, setEatList] = useState<any>([])
+    const [activeList, setActiveList] = useState<any>([])
+    const [sleepList, setSleepList] = useState<any>([])
+
+    const dispatch = useDispatch()
+    const { t } = useTranslation()
+
+    useImperativeHandle(ref, () => ({
+        onScroll: onScroll,
+        refresh: refresh,
+        more: more
+    }))
+
+    useEffect(() => {
+        if (list.length > 0) {
+            setTimeout(() => {
+                measureItemLayouts()
+            }, 300)
+        }
+    }, [list])
+
+
+    useEffect(() => {
+        if (!user.isLogin) {
+            setList([])
+        }
+    }, [user.isLogin])
+
+    global.refreshOtherHistory = () => {
+        refresh()
+    }
+
+    useEffect(() => {
+        // if (props.type == 'FAST,SLEEP' || (props.fast_type && props.fast_type == 'LF')) {
+            
+        // }
+        // else {
+        //     global.refreshHistory = () => {
+        //         refresh()
+        //         // refreshFast()
+        //         // refreshSleep()
+        //         // refreshEat()
+        //         // refreshActive()
+        //         refreshItem('FAST')
+        //         refreshItem('SLEEP')
+        //         refreshItem('EAT')
+        //         refreshItem('ACTIVE')
+        //     }
+        // }
+    }, [])
+
+    useEffect(() => {
+        if (props.type) {
+            loadData(1)
+        }
+    }, [props.type])
+
+
+    useEffect(() => {
+        if (lastMode != health.mode) {
+            lastMode = health.mode
+            // loadData(1)
+            setPage(1)
+            switch (health.mode) {
+                case 'DAY':
+                case 'NIGHT':
+                    debugger
+                    setList([])
+                    return
+                case 'FAST':
+                    if (fastList.length > 0) {
+                        setList(fastList)
+                        return;
+                    }
+                    break
+                case 'EAT':
+                    if (eatList.length > 0) {
+                        setList(eatList)
+                        return;
+                    }
+                    break
+                case 'SLEEP':
+                    if (sleepList.length > 0) {
+                        setList(sleepList)
+                        return;
+                    }
+                    break
+                case 'ACTIVE':
+                    if (activeList.length > 0) {
+                        setList(activeList)
+                        return;
+                    }
+                    break
+            }
+            loadData(1)
+        }
+
+    }, [health.mode])
+
+    function measureItemLayouts() {
+        const query = Taro.createSelectorQuery()
+        list.forEach((item, index) => {
+            query.select(`#history-${index}`).boundingClientRect()
+        });
+        query.exec((res) => {
+            var layouts: any = []
+            res.forEach((rect, index) => {
+                if (rect) {
+                    layouts[index] = rect.top + myScrollTop
+                }
+            });
+            setItemLayouts(layouts)
+        })
+    }
+
+    function onScroll(e) {
+        var top = e.detail.scrollTop
+        myScrollTop = top
+        if (itemLayouts.length > 0) {
+            var i = -1
+            var date = ''
+            list.forEach((item, index) => {
+                if (top >= itemLayouts[index] - 50) {
+                    i = index
+                    date = dayjs(item.window_range.start_timestamp).format('YYYY年M月')
+                }
+            })
+            if (props.updateDate) {
+                props.updateDate({
+                    show: i != -1,
+                    date: date
+                })
+            }
+        }
+        else {
+            if (props.updateDate) {
+                props.updateDate({
+                    show: false,
+                    date: ''
+                })
+            }
+
+        }
+    }
+
+    function refresh() {
+        loadData(1)
+        setPage(1)
+    }
+
+    function more() {
+        if (loading) return;
+        if (total == list.length) return;
+        var index = page;
+        index++;
+        setPage(index)
+        loadData(index)
+    }
+
+    function refreshItem(type) {
+        setPage(1)
+        var params: any = {
+            window: type,
+            limit: 10,
+            page: 1
+        }
+
+        records(params).then(res => {
+            var array = (res as any).data
+
+            array.map(item => {
+                var temps: any = []
+                var lastType = ''
+                var lastTextArray: any = []
+                var lastImageArray: any = []
+                item.events.map(event => {
+                    event.moments && event.moments.map(moment => {
+                        switch (moment.type) {
+                            case 'TEXT':
+                                {
+                                    lastTextArray.push({
+                                        title: moment.title,
+                                        description: moment.description,
+                                        event_id: event.id
+                                    })
+                                    if (lastType == 'PIC') {
+                                        temps.push({
+                                            type: 'PIC',
+                                            data: JSON.parse(JSON.stringify(lastImageArray))
+                                        })
+                                        lastImageArray = []
+                                    }
+                                    lastType = 'TEXT'
+                                }
+                                break;
+                            case 'PIC':
+                                {
+                                    lastImageArray.push(moment.media[0].url)
+                                    if (lastType == 'TEXT') {
+                                        temps.push({
+                                            type: 'TEXT',
+                                            data: JSON.parse(JSON.stringify(lastTextArray))
+                                        })
+                                        lastTextArray = []
+                                    }
+                                    lastType = 'PIC'
+                                }
+                                break;
+                            case 'PIC_TEXT':
+                                if (lastType == 'PIC') {
+                                    temps.push({
+                                        type: 'PIC',
+                                        data: JSON.parse(JSON.stringify(lastImageArray))
+                                    })
+                                    lastImageArray = []
+                                }
+                                if (lastType == 'TEXT') {
+                                    temps.push({
+                                        type: 'TEXT',
+                                        data: JSON.parse(JSON.stringify(lastTextArray))
+                                    })
+                                    lastTextArray = []
+                                }
+                                temps.push({
+                                    type: 'PIC_TEXT',
+                                    data: [
+                                        {
+                                            title: moment.title,
+                                            description: moment.description,
+                                            url: moment.media[0].url,
+                                            event_id: event.id
+                                        }
+                                    ]
+                                })
+                                lastType = 'PIC_TEXT'
+                                break;
+                        }
+                    })
+                })
+
+                if (lastType == 'PIC') {
+                    temps.push({
+                        type: 'PIC',
+                        data: JSON.parse(JSON.stringify(lastImageArray))
+                    })
+                    lastImageArray = []
+                }
+                if (lastType == 'TEXT') {
+                    temps.push({
+                        type: 'TEXT',
+                        data: JSON.parse(JSON.stringify(lastTextArray))
+                    })
+                    lastTextArray = []
+                }
+
+                item.dataArray = temps;
+            })
+            switch (type) {
+                case 'FAST':
+                    setFastList(array)
+                    break
+                case 'SLEEP':
+                    setSleepList(array)
+                    break
+                case 'EAT':
+                    setEatList(array)
+                    break
+                case 'ACTIVE':
+                    setActiveList(array)
+                    break
+            }
+        })
+    }
+
+
+    function loadData(index: number) {
+        var params: any = {
+            window: props.type ? props.type : health.mode,
+            limit: 10,
+            page: index
+        }
+        if (props.fast_type) {
+            params.fast_type = props.fast_type
+        }
+        console.log(props.type, health.mode)
+        debugger
+        setPage(index)
+        setLoading(true)
+        records(params).then(res => {
+            var array = (res as any).data
+
+            array.map(item => {
+                var temps: any = []
+                var lastType = ''
+                var lastTextArray: any = []
+                var lastImageArray: any = []
+                item.events.map(event => {
+                    event.moments && event.moments.map(moment => {
+                        switch (moment.type) {
+                            case 'TEXT':
+                                {
+                                    lastTextArray.push({
+                                        title: moment.title,
+                                        description: moment.description,
+                                        event_id: event.id
+                                    })
+                                    if (lastType == 'PIC') {
+                                        temps.push({
+                                            type: 'PIC',
+                                            data: JSON.parse(JSON.stringify(lastImageArray))
+                                        })
+                                        lastImageArray = []
+                                    }
+                                    lastType = 'TEXT'
+                                }
+                                break;
+                            case 'PIC':
+                                {
+                                    lastImageArray.push(moment.media[0].url)
+                                    if (lastType == 'TEXT') {
+                                        temps.push({
+                                            type: 'TEXT',
+                                            data: JSON.parse(JSON.stringify(lastTextArray))
+                                        })
+                                        lastTextArray = []
+                                    }
+                                    lastType = 'PIC'
+                                }
+                                break;
+                            case 'PIC_TEXT':
+                                if (lastType == 'PIC') {
+                                    temps.push({
+                                        type: 'PIC',
+                                        data: JSON.parse(JSON.stringify(lastImageArray))
+                                    })
+                                    lastImageArray = []
+                                }
+                                if (lastType == 'TEXT') {
+                                    temps.push({
+                                        type: 'TEXT',
+                                        data: JSON.parse(JSON.stringify(lastTextArray))
+                                    })
+                                    lastTextArray = []
+                                }
+                                temps.push({
+                                    type: 'PIC_TEXT',
+                                    data: [
+                                        {
+                                            title: moment.title,
+                                            description: moment.description,
+                                            url: moment.media[0].url,
+                                            event_id: event.id
+                                        }
+                                    ]
+                                })
+                                lastType = 'PIC_TEXT'
+                                break;
+                        }
+                    })
+                })
+
+                if (lastType == 'PIC') {
+                    temps.push({
+                        type: 'PIC',
+                        data: JSON.parse(JSON.stringify(lastImageArray))
+                    })
+                    lastImageArray = []
+                }
+                if (lastType == 'TEXT') {
+                    temps.push({
+                        type: 'TEXT',
+                        data: JSON.parse(JSON.stringify(lastTextArray))
+                    })
+                    lastTextArray = []
+                }
+
+                item.dataArray = temps;
+            })
+
+
+            setLoading(false)
+            setLoaded(true)
+            if (index == 1) {
+                // console.log(props.type,health.mode)
+                if (!props.type && array.length > 0) {
+                    if (health.mode == 'EAT') {
+                        setEatList(array)
+                        // dispatch(setFirstEatId(array[0].window_id))
+                        // if (health.first_eat_id.length > 0 && health.first_eat_id != array[0].window_id) {
+                        //     dispatch(setEatTip(true))
+                        // }
+                    }
+                    else if (health.mode == 'ACTIVE') {
+                        setActiveList(array)
+                        // dispatch(setFirstActiveId(array[0].window_id))
+                        // if (health.first_active_id.length > 0 && health.first_active_id != array[0].window_id) {
+                        //     dispatch(setActiveTip(true))
+                        // }
+                    }
+                    else if (health.mode == 'FAST') {
+                        setFastList(array)
+                    }
+                    else if (health.mode == 'SLEEP') {
+                        setSleepList(array)
+                    }
+                }
+                setList(array)
+                setTotal((res as any).total)
+                if (props.refreshSuccess) {
+                    props.refreshSuccess()
+                }
+            }
+            else {
+                setList([...list, ...array])
+            }
+
+            // if ((res as any).data.length > 0) {
+            //     setTimeout(() => {
+            //         // var array:any = [];
+            //         // (res as any).data.map((item,index)=>{
+            //         //     array.push('#history_id_'+index)
+            //         // })
+            //         // var ids = array.join(',')
+            //         // console.log(array)
+            //         // console.log(ids)
+            //         const query = Taro.createSelectorQuery();
+            //         query.selectAll('#history_id_0').boundingClientRect((rect) => {
+            //             console.log(rect)
+            //         }).exec();
+            //     }, 1000)
+            // }
+
+        }).catch(e => {
+            setLoading(false)
+        })
+    }
+
+    function historyMonth(index) {
+        var showDate = false;
+        var dateStr = ''
+        if (index == 0) {
+            var currentDate = global.language == 'en' ? dayjs(list[index].window_range.start_timestamp).format('YYYY') : dayjs(list[index].window_range.start_timestamp).format('YYYY年')
+            var now = global.language == 'en' ? dayjs().format('YYYY') : dayjs().format('YYYY年')
+
+            if (currentDate != now) {
+                showDate = true
+                dateStr = currentDate
+            }
+
+
+        }
+        else {
+            var currentDate = global.language == 'en' ? dayjs(list[index].window_range.start_timestamp).format('YYYY') : dayjs(list[index].window_range.start_timestamp).format('YYYY年')
+            var now = global.language == 'en' ? dayjs(list[index - 1].window_range.start_timestamp).format('YYYY') : dayjs(list[index - 1].window_range.start_timestamp).format('YYYY年')
+            if (currentDate != now) {
+                showDate = true
+                dateStr = currentDate
+            }
+        }
+        if (showDate) {
+            return <View className="history_year_month h42 bold">{dateStr}</View>
+        }
+        return <View />
+    }
+
+
+    function hideLine(index) {
+        var currentDate = dayjs(list[index].window_range.start_timestamp).format('YYYY年M月D日')
+        if (list.length > index + 1) {
+            var nextDate = dayjs(list[index + 1].window_range.start_timestamp).format('YYYY年M月D日')
+            if (currentDate == nextDate) return true
+        }
+        return false
+    }
+
+    function archiveContent() {
+        if (health.mode != 'EAT' && health.mode != 'ACTIVE') {
+            return
+        }
+
+        if (health.mode == 'EAT') {
+            if (!showEatArchive || !health.eatArchived || !health.eatArchived.archived) {
+                return
+            }
+        }
+
+        if (health.mode == 'ACTIVE') {
+            if (!showActiveArchive || !health.activeArchived || !health.activeArchived.archived) {
+                return
+            }
+        }
+
+        return <View style={{
+            display: 'flex',
+            flexDirection: 'column',
+            alignItems: 'center',
+            paddingTop: rpxToPx(82),
+            paddingBottom: rpxToPx(82),
+            backgroundColor: '#fff',
+            position: 'relative'
+        }}>
+            <View className="archived_bg" onClick={() => {
+                jumpPage('/_health/pages/archive')
+                setTimeout(() => {
+                    health.mode == 'EAT' ? setShowEatArchive(false) : setShowActiveArchive(false)
+                }, 1000)
+
+            }}>
+                <Text className="archived_text bold" style={{ color: getThemeColor(health.mode) }}>[{health.eatArchived.real_count}/{health.eatArchived.target_count} Meals] Archived {TimeFormatter.dateDescription(new Date(health.eatArchived.timestamp).getTime(), true, false)}</Text>
+                {
+                    health.eatArchived.images.map((item, index) => {
+                        return <Image src={item} key={index} className="archived_img" mode="aspectFill" />
+                    })
+                }
+                <IconArrow color={MainColorType.g02} width={rpxToPx(34)} />
+            </View>
+            <View className="border_footer_line" />
+        </View>
+    }
+
+    if (!loaded || health.mode == 'DAY' || health.mode == 'NIGHT')
+        return <View />
+
+    if (!user.isLogin) return <View />
+
+    function showTipF() {
+        var showTip = false
+        if (getScenario(health.windows, health.mode).status == 'OG') {
+            if (health.mode == 'EAT') {
+                showTip = !global.hideEatArchiveTip
+            }
+            else if (health.mode == 'ACTIVE') {
+                showTip = !global.hideActiveArchiveTip
+            }
+        }
+        return showTip
+    }
+
+    function newJournalTip() {
+        if (!props.type) {
+            var show = false
+
+            if (health.mode == 'EAT' && health.eat_journal_tip) {
+                show = true
+            }
+            else if (health.mode == 'ACTIVE' && health.active_journal_tip) {
+                show = true
+            }
+
+
+
+            if (show) {
+                return <View style={{
+                    display: 'flex',
+                    flexDirection: 'column',
+                    alignItems: 'center',
+                    paddingTop: rpxToPx(82),
+                    paddingBottom: rpxToPx(82),
+                    backgroundColor: '#fff',
+                    position: 'relative'
+                }}>
+                    <View className="archived_bg" onClick={() => {
+                        // jumpPage('/_health/pages/archive')
+                        var data = list[0]
+                        jumpPage(`/_health/pages/timeline_detail?window_id=${data.window_id}&type=recent&isfastsleep=0&timestamp=${data.publish.timestamp}`)
+
+                        getLatestJournal(false, {
+                            id: health.mode == 'EAT' ? global.eatTipId : global.activeTipId,
+                            user_confirmed: true
+                        }).then(res => {
+
+                        })
+                        setTimeout(() => {
+                            if (health.mode == 'EAT') {
+                                dispatch(setEatTip(false))
+                            }
+                            else {
+                                dispatch(setActiveTip(false))
+                            }
+                        }, 1000)
+
+                    }}>
+                        <Text className="archived_text bold" style={{ color: getThemeColor(health.mode) }}>{t('health.new_journal_created')}</Text>
+                        {/* {
+                            health.eatArchived.images.map((item, index) => {
+                                return <Image src={item} key={index} className="archived_img" mode="aspectFill" />
+                            })
+                        } */}
+                        <IconArrow color={MainColorType.g02} width={rpxToPx(34)} />
+                    </View>
+                    <View className="border_footer_line" />
+                </View>
+                // return <View className="h28 bold" 
+                // onClick={()=>{
+                //     if (health.mode == 'EAT'){
+                //         dispatch(setEatTip(false))
+                //     }
+                //     else {
+                //         dispatch(setActiveTip(false))
+                //     }
+                // }}
+                // style={{
+                //     width:rpxToPx(750),
+                //     height:rpxToPx(156),
+                //     display:'flex',
+                //     alignItems:'center',
+                //     justifyContent:'center',
+                //     backgroundColor:'#fff',
+                //     color:getThemeColor(health.mode),
+
+                // }}>
+                //     New Journal Created {'>'}
+                // </View>
+            }
+        }
+        return <View />
+    }
+
+    return <View style={{ width: rpxToPx(750), marginTop: rpxToPx(60) }}>
+
+        {
+            (list.length >= 0 || health.mode == 'EAT') && <View className="new_header_bg">
+                <Text className="h50 bold">{t('health.recents')}</Text>
+                {
+                    false && (health.mode == 'EAT' || health.mode == 'ACTIVE') && <View onClick={() => {
+                        jumpPage('/pages/account/Journal?type=' + health.mode + `&show_tip=${showTipF() ? '1' : '0'}`)
+                        setTimeout(() => {
+                            health.mode == 'EAT' ? setShowEatArchive(false) : setShowActiveArchive(false)
+                        }, 1000)
+                    }} className="archive_bg" style={{ position: 'relative' }}>
+                        <Image className="archive_bg" src={require('@assets/_health/journal.png')} />
+                        {/* {
+                            ((health.mode == 'EAT' && health.eatArchivedTotal > 0) ||
+                                (health.mode == 'ACTIVE' && health.activeArchivedTotal > 0)) && <View style={{
+                                    width: rpxToPx(12),
+                                    height: rpxToPx(12),
+                                    borderRadius: rpxToPx(6),
+                                    backgroundColor: 'red',
+                                    position: 'absolute',
+                                    right: -6,
+                                    top: 0
+                                }} />
+                        } */}
+
+                    </View>
+                }
+            </View>
+        }
+        {/* {
+            archiveContent()
+        } */}
+        {/* {
+            newJournalTip()
+        } */}
+        {
+            (health.mode == 'EAT' || health.mode == 'ACTIVE') && <RightArrowRow title={health.mode == 'ACTIVE' ? t('health.title_active_journal') : t('health.title_food_journal')}
+                // showBadge={(health.mode == 'EAT' && health.eat_journal_tip) ||
+                //     (health.mode == 'ACTIVE' && health.active_journal_tip)}
+                onClick={() => {
+                    // if ((health.mode == 'EAT' && health.eat_journal_tip) ||
+                    //     (health.mode == 'ACTIVE' && health.active_journal_tip)) {
+                    //     getLatestJournal(false, {
+                    //         id: health.mode == 'EAT' ? global.eatTipId : global.activeTipId,
+                    //         user_confirmed: true
+                    //     }).then(res => {
+
+                    //     })
+                    // }
+
+
+                    // setTimeout(() => {
+                    //     if (health.mode == 'EAT') {
+                    //         dispatch(setEatTip(false))
+                    //     }
+                    //     else {
+                    //         dispatch(setActiveTip(false))
+                    //     }
+                    // }, 1000)
+
+                    var showBadge = (health.mode == 'EAT' && health.eat_journal_tip) ||
+                        (health.mode == 'ACTIVE' && health.active_journal_tip)
+                    jumpPage('/pages/account/Journal?type=' + health.mode + `&show_tip=${showTipF() && false ? '1' : '0'}&show_badge=${showBadge ? 1 : 0}`)
+                }} />
+        }
+        {
+            list.length == 0 && <NoRecord />
+        }
+        {
+            list.length > 0 && <View style={{ minHeight: rpxToPx(464), backgroundColor: '#fff' }}>
+                {
+                    list.map((item, index) => {
+                        return <View id={`history-${index}`} key={index}>
+                            {
+                                historyMonth(index)
+                            }
+                            <HistoryItem
+                                data={item}
+                                preData={index > 0 ? list[index - 1] : null}
+                                index={index}
+                                mode={props.type ?? health.mode}
+                                fast_type={props.fast_type}
+                                type={props.type}
+                                hideLine={hideLine(index)}
+                                onClick={() => {
+
+                                }} />
+
+                        </View>
+                    })
+                }
+            </View>
+        }
+
+
+        <View style={{ height: rpxToPx(40), flexShrink: 0, backgroundColor: '#fff' }} />
+        <ListFooter noMore={(list.length > 0) && (total == list.length)} />
+    </View>
+})

+ 10 - 1
src/features/journal/components/journal_cover.tsx

@@ -2,6 +2,7 @@ import { View, Image } from '@tarojs/components'
 import './journal_cover.scss'
 import { count } from 'console'
 import { rpxToPx } from '@/utils/tools'
+import Taro from '@tarojs/taro'
 
 
 export default function JournalCover(props: { imgs: any }) {
@@ -158,7 +159,15 @@ export default function JournalCover(props: { imgs: any }) {
         }
     }
 
-    return <View className='journal_cover_bg' >
+    return <View className='journal_cover_bg' onClick={(e)=>{
+        if (process.env.TARO_ENV=='weapp'){
+            e.stopPropagation()
+        }
+        Taro.previewImage({
+            current:props.imgs[0],
+            urls:props.imgs
+        })
+    }}>
         {
             content()
         }

+ 83 - 70
src/pages/account/Journal.tsx

@@ -348,9 +348,81 @@ export default function Journal() {
     }
 
     function journalCell(item, index) {
-        if (item.show_ring) {
-            if (item.windows) {
-                return <View key={index}>{
+        // if (item.show_ring) {
+        //     if (item.windows) {
+        //         return <View key={index}>{
+        //             item.windows.map((temp, i) => {
+        //                 return <TargetProgress key={i * 1000} showLine={i < item.windows.length - 1 ? true : false}
+        //                     color={getThemeColor(temp.window)}
+        //                     showRing={true}
+        //                     desc={temp.description}
+        //                     icon={
+        //                         null
+        //                     }
+        //                     canvasId={`${temp.window}${temp.window_range.start_timestamp}${index}`}
+        //                     startTimestamp={temp.window_range.start_timestamp}
+        //                     endTimerstamp={temp.window_range.end_timestamp}
+        //                 />
+        //             })
+        //         }</View>
+
+        //     }
+        //     return <View key={index} />
+        // }
+        return <View style={{ display: 'flex', flexDirection: 'column' }}>
+            {
+                (item.pics.length > 0 || item.texts.length > 0) && <View style={{ display: 'flex', flexDirection: 'row', marginBottom: rpxToPx(12), overflow: 'hidden', flexShrink: 0 }} key={index}>
+                    {
+                        item.pics.length > 0 && <View onClick={(e) => {
+                            if (process.env.TARO_ENV == 'weapp') {
+                                e.stopPropagation()
+                            }
+                            Taro.previewImage({
+                                current: item.pics[0],
+                                urls: item.pics
+                            })
+                        }}>
+                            <JournalCover imgs={item.pics} />
+                        </View>
+                    }
+                    <View style={{
+                        display: 'flex',
+                        flexDirection: 'column',
+                        // flex: 1,
+                        overflow: 'hidden',
+                        backgroundColor: item.pics.length == 0 ? '#fafafa' : 'transparent',
+                        paddingLeft: item.pics.length == 0 ? rpxToPx(20) : 0,
+                        paddingRight: item.pics.length == 0 ? rpxToPx(20) : 0,
+                        paddingTop: item.pics.length == 0 ? rpxToPx(12) : 0,
+                        paddingBottom: item.pics.length == 0 ? rpxToPx(12) : 0,
+                        marginRight: rpxToPx(40),
+                        flexShrink: 0
+                    }}>
+                        {
+
+                            item.texts.map((item2, index2) => {
+                                return <TimeTitleDesc
+                                    key={index2 * 1000}
+                                    className='line1'//{item.pics.length == 0 ? 'line2' : 'line3'}
+                                    style={{ width: item.pics.length > 0 ? rpxToPx(350) : rpxToPx(512) }}
+                                    time=''
+                                    title={item2.title}
+                                    desc={item2.description}
+                                />
+                            })
+                        }
+
+
+
+
+                    </View>
+
+
+                </View>
+            }
+
+            {
+                item.show_ring && item.windows && <View key={index}>{
                     item.windows.map((temp, i) => {
                         return <TargetProgress key={i * 1000} showLine={i < item.windows.length - 1 ? true : false}
                             color={getThemeColor(temp.window)}
@@ -366,67 +438,8 @@ export default function Journal() {
                     })
                 }</View>
 
-            }
-            return <View key={index} />
-        }
-        return <View style={{ display: 'flex', flexDirection: 'row', marginBottom: rpxToPx(12), overflow: 'hidden', flexShrink: 0 }} key={index}>
-            {
-                item.pics.length > 0 && <View onClick={(e) => {
-                    if (process.env.TARO_ENV == 'weapp') {
-                        e.stopPropagation()
-                    }
-                    Taro.previewImage({
-                        current: item.pics[0],
-                        urls: item.pics
-                    })
-                }}>
-                    <JournalCover imgs={item.pics} />
-                </View>
-            }
-            <View style={{
-                display: 'flex',
-                flexDirection: 'column',
-                // flex: 1,
-                overflow: 'hidden',
-                backgroundColor: item.pics.length == 0 ? '#fafafa' : 'transparent',
-                paddingLeft: item.pics.length == 0 ? rpxToPx(20) : 0,
-                paddingRight: item.pics.length == 0 ? rpxToPx(20) : 0,
-                paddingTop: item.pics.length == 0 ? rpxToPx(12) : 0,
-                paddingBottom: item.pics.length == 0 ? rpxToPx(12) : 0,
-                marginRight: rpxToPx(40),
-                flexShrink: 0
-            }}>
-                {
-
-                    item.texts.map((item2, index2) => {
-                        return <TimeTitleDesc
-                            key={index2 * 1000}
-                            className='line1'//{item.pics.length == 0 ? 'line2' : 'line3'}
-                            style={{ width: item.pics.length > 0 ? rpxToPx(350) : rpxToPx(512) }}
-                            time=''
-                            title={item2.title}
-                            desc={item2.description}
-                        />
-                    })
-                }
-
-                {/* {
-                    journalCellText(index).map((obj2, k) => {
-                        if (k >= 3) return <View key={k * 10000} />
-                        return <TimeTitleDesc key={k * 10000}
-                            time=''
-                            className='line1'
-                            style={{ width: item.pics.length > 0 ? rpxToPx(350) : rpxToPx(512) }}
-                            title={obj2.title}
-                            desc={obj2.description}
-                        />
-                    })
-                } */}
-
-
 
-
-            </View>
+            }
         </View>
     }
 
@@ -533,7 +546,7 @@ export default function Journal() {
                     <View style={{ width: rpxToPx(40), flexShrink: 0 }} />
                 </ScrollView>
             } */}
-            <View style={{minHeight:'100vh',backgroundColor:'#fff'}}>
+            <View style={{ minHeight: '100vh', backgroundColor: '#fff' }}>
                 {
                     journals.map((item, index) => {
                         // if (index>0) return <View key={index}/>
@@ -542,16 +555,16 @@ export default function Journal() {
                                 historyYear(index)
                             }
                             <View className="history_item2" id={`history-${index}`} onClick={() => {
-                                if (index == 0) {
-                                    setTimeout(() => { setShowBadge(false) }, 1000)
-                                }
+                                // if (index == 0) {
+                                //     setTimeout(() => { setShowBadge(false) }, 1000)
+                                // }
                                 jumpPage('/pages/account/JournalDetail?date=' + item.date + '&window=' + window) //JSON.stringify(item))
                             }}>
 
                                 <View className="cell_date" >
                                     <View className="h42 bold" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate(item, index)}</View>
                                     <View className="h24 bold" style={{ marginLeft: rpxToPx(6), marginTop: rpxToPx(13), lineHeight: rpxToPx(47) + 'px' }}>{historyMonth(item, index)}</View>
-                                    {
+                                    {/* {
                                         index == 0 && showBadge && <View style={{
                                             position: 'absolute',
                                             backgroundColor: MainColorType.error,
@@ -561,7 +574,7 @@ export default function Journal() {
                                             right: 10,
                                             top: 0
                                         }} />
-                                    }
+                                    } */}
                                 </View>
                                 <View style={{ display: 'flex', flexDirection: 'column', flex: 1, paddingTop: rpxToPx(4) }}>
                                     {/* {
@@ -578,7 +591,7 @@ export default function Journal() {
                     })
                 }
                 {
-                    loaded && journals.length==0 && <NoRecord />
+                    loaded && journals.length == 0 && <NoRecord />
                 }
                 <View style={{ height: rpxToPx(40), flexShrink: 0, backgroundColor: '#fff' }} />
             </View>

+ 44 - 3
src/pages/account/Profile.tsx

@@ -1,6 +1,6 @@
 import Buttons from "@/components/basic/Buttons";
 import { delSession } from "@/services/common";
-import { clear, getInfo, getPerm, logout, uploadPerm } from "@/services/user";
+import { clear, getInfo, getPerm, logout, resetInfo, uploadPerm } from "@/services/user";
 import { View, Text, Image, Switch } from "@tarojs/components";
 import Taro, { useDidShow, usePullDownRefresh, useShareAppMessage } from "@tarojs/taro";
 import { useDispatch, useSelector } from "react-redux";
@@ -157,7 +157,9 @@ export default function Page() {
             e.stopPropagation()
         }
         if (user.isLogin) {
-            jumpPage('/pages/account/ProfileSetting', 'ProfileSetting', navigation)
+            debugger
+            jumpPage(`/pages/account/ProfileSetting?newuser=${user.is_new_user?'1':'0'}`, 'ProfileSetting', navigation)
+            // jumpPage('/pages/account/ProfileSetting?newuser='+user.is_new_user?'1':'0', 'ProfileSetting', navigation)
         }
         else {
             jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
@@ -187,6 +189,27 @@ export default function Page() {
         }
     }
 
+    function resetSchedule() {
+        resetInfo({ finish_setup: false }).then(res => {
+            Taro.showToast({
+                title: '成功',
+                icon: 'none'
+            })
+            Taro.setStorage({ key: '148alert', data: true })
+            global.refreshWindow()
+        })
+    }
+
+    function resetNewUser(){
+        resetInfo({ is_new_user:true }).then(res => {
+            Taro.showToast({
+                title: '成功',
+                icon: 'none'
+            })
+            global.refreshWindow()
+        })
+    }
+
     function goCalendar() {
         jumpPage('/_health/pages/streak_calendar')
     }
@@ -385,9 +408,27 @@ export default function Page() {
             <IconTitleCell
                 onClick={goSetting}
                 title={t('health.settings')}
-                showLine
+                // showLine
                 icon={<Image src={require('@assets/_health/setting_more.png')} className="profile_cell_icon" />}
             />
+            {
+                user.isLogin && user.test_user && <View className="profile_cell_space" />
+            }
+            {
+                user.isLogin && user.test_user && <IconTitleCell
+                    onClick={resetSchedule}
+                    title='重置日程设置'
+                    showLine
+                    icon={<Image src={require('@assets/_health/setting_more.png')} className="profile_cell_icon" />}
+                />
+            }
+            {
+                user.isLogin && user.test_user && <IconTitleCell
+                    onClick={resetNewUser}
+                    title='Reset to New User'
+                    icon={<Image src={require('@assets/_health/setting_more.png')} className="profile_cell_icon" />}
+                />
+            }
             {/* <View className="a1">测试ABCDabcd1234 weight 100</View>
             <View className="a2">测试ABCDabcd1234 weight 200</View>
             <View className="a3">测试ABCDabcd1234 weight 300</View>

+ 3 - 0
src/pages/account/ProfileSetting.tsx

@@ -141,6 +141,9 @@ export default function Page() {
                     url:'/_health/pages/guide_begin'
                 })
             }
+            else {
+                Taro.navigateBack()
+            }
         }
         else {
             navigation.goBack()

+ 20 - 4
src/pages/clock/Clock.tsx

@@ -15,6 +15,7 @@ import HeaderCircadian from "@/features/health/HeaderCircadian";
 import { rpxToPx } from "@/utils/tools";
 import AddLabel from "@/_health/components/add_label";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
+import showAlert from "@/components/basic/Alert";
 
 let useNavigation;
 
@@ -36,7 +37,7 @@ export default function Clock() {
     const systemInfo: any = Taro.getWindowInfo();
     const navigationBarHeight = systemInfo.statusBarHeight + 44;
     const [showModal, setShowModal] = useState(false)
-    const [labels,setLabels] = useState<any>([])
+    const [labels, setLabels] = useState<any>([])
 
     let navigation;
     if (useNavigation) {
@@ -53,7 +54,7 @@ export default function Clock() {
         })
     }
 
-    global.showIndexAddActive = (array)=>{
+    global.showIndexAddActive = (array) => {
         setLabels(array)
         setShowModal(true)
     }
@@ -293,16 +294,31 @@ export default function Clock() {
                 // onlyCheck={true}
                 // schedules={[]}
                 confirm={(res) => {
-                    setShowModal(false)
+                    
                     if ((res as any).result) {
                         global.refreshWindow()
+                        setShowModal(false)
                         // dispatch(setSchedules((res as any).schedules))
                         // dispatch(setFooter((res as any).footer))
                         // setList((res as any).schedules)
                         // setErrors([])
                     }
                     else {
-                        jumpPage('/_health/pages/schedules?mode=' + health.mode + '&error=' + JSON.stringify(res))
+                        showAlert({
+                            title: t('health.schedule_conflict'),
+                            content: t('health.conflict_desc'),
+                            showCancel: false,
+                            confirmText: t('health.check_conflict'),
+                            confirm: () => {
+                                setTimeout(()=>{
+                                    setShowModal(false)
+                                },1000)
+                                
+                                jumpPage('/_health/pages/schedules?mode=' + health.mode + '&error=' + JSON.stringify(res))
+                                // jumpPage(`./schedules?mode=&schedules=${JSON.stringify((res as any).schedules)}&errors=${JSON.stringify((res as any).error_messages)}`)
+                            }
+                        })
+
                         // setList((res as any).schedules)
                         // dispatch(setFooter((res as any).footer))
                         // setErrors((res as any).error_messages ? (res as any).error_messages : [])

+ 7 - 6
src/pages/clock/ClockNew.tsx

@@ -42,7 +42,7 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
     const [date, setDate] = useState('')
     const [isPulling, setIsPulling] = useState(false)
     const healthRef = useRef(health)
-    const historyRef = useRef()
+    const historyRef2 = useRef()
     const dispatch = useDispatch();
     const { t } = useTranslation()
     global.dispatch = dispatch;
@@ -211,6 +211,7 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
     }
 
     function archived() {
+        return
         getLatestJournal(true, {
             window: 'EAT',
         }).then(res => {
@@ -349,8 +350,8 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
                 }
             }}
             loadMore={() => {
-                if (historyRef) {
-                    (historyRef.current as any).more()
+                if (historyRef2) {
+                    (historyRef2.current as any).more()
                 }
             }}
             onScroll={e => {
@@ -361,8 +362,8 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
                 else {
                     dispatch(setTitle(''))
                 }
-                if (historyRef) {
-                    (historyRef.current as any).onScroll(e)
+                if (historyRef2) {
+                    (historyRef2.current as any).onScroll(e)
                 }
             }}
         >
@@ -387,7 +388,7 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
                 <MainSwiper count={count} pageChanged={pageChanged} typeChanged={typeChanged} />
                 <MainConsole type={type} />
 
-                <MainHistory ref={historyRef} updateDate={(e) => {
+                <MainHistory ref={historyRef2} updateDate={(e) => {
                     setShowDate(e.show)
                     setDate(e.date)
                 }} />

+ 8 - 4
src/services/health.tsx

@@ -268,12 +268,14 @@ export const getActiveMoves = (params) => {
 }
 
 export const uploadActiveMoves = (params) => {
-    return new Promise((resolve) => {
+    return new Promise((resolve,reject) => {
         request({
             url: API_ACTIVE_MOVES, method: 'POST', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
+        }).catch(e=>{
+            reject(e)
         })
     })
 }
@@ -412,12 +414,14 @@ export const updateFast = (params) => {
     })
 }
 
-export const delRecord = (id, params = {}) => {
-    return new Promise((resolve) => {
+export const delRecord = ( params) => {
+    return new Promise((resolve, reject) => {
         request({
-            url: API_HEALTH_WINDOWS + '/' + id, method: 'DELETE', data: { ...params }
+            url: API_HEALTH_WINDOWS + '/batch' , method: 'DELETE', data: { ...params }
         }).then(res => {
             resolve(res)
+        }).catch(e => {
+            reject(e)
         })
     })
 }

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

@@ -115,4 +115,6 @@ export const API_ACTIVE_MOVES= `${baseUrl}/api/health/active/moves`
 export const API_ME_JOURNALS = `${baseUrl}/api/health/wo/journals`
 export const API_ME_ALBUMS = `${baseUrl}/api/health/wo/albums`
 export const API_ME_ALBUMS_STAT = `${baseUrl}/api/health/wo/albums-stat`
-export const API_LASTEST_JOURNAL = `${baseUrl}/api/health/journals/latest/generated-info`
+export const API_LASTEST_JOURNAL = `${baseUrl}/api/health/journals/latest/generated-info`
+
+export const API_RESET_TESTINFO = `${baseUrl}/api/user/test-resets`

+ 16 - 1
src/services/user.tsx

@@ -1,5 +1,5 @@
 import Taro from '@tarojs/taro'
-import { API_OAUTH_LOGIN, API_REGISTER, API_LOGIN, API_LOGOUT, API_CLEAR_USER, API_USER_INFO, API_CHECK_UNIQUE, API_CLIENT_ID, API_USER_PERMS, API_USER_LOCATION, API_PAY_UPLOAD, API_USER_ACCESS, API_PRODUCTS, API_CREATE_ORDER, API_ORDER_CHECK } from './http/api'
+import { API_OAUTH_LOGIN, API_REGISTER, API_LOGIN, API_LOGOUT, API_CLEAR_USER, API_USER_INFO, API_CHECK_UNIQUE, API_CLIENT_ID, API_USER_PERMS, API_USER_LOCATION, API_PAY_UPLOAD, API_USER_ACCESS, API_PRODUCTS, API_CREATE_ORDER, API_ORDER_CHECK, API_RESET_TESTINFO } from './http/api'
 import { request } from './http/request'
 import { clearSuccess, getInfoSuccess, loginSuccess, logoutSuccess, registerSuccess, updateSuccess } from '@/store/user'
 import { kIsIOS } from '@/utils/tools'
@@ -254,6 +254,21 @@ export const order = (params) => {
     })
 }
 
+export const resetInfo = (params) => {
+    return new Promise((resolve, reject) => {
+        request({
+            url: API_RESET_TESTINFO, method: 'POST', data: {
+                ...params
+            }
+        }).then(res => {
+            resolve(res)
+            // dispatch(loginSuccess(res));
+        }).catch(e => {
+            reject(e)
+        })
+    })
+}
+
 export const orderCheck = (order_no) => {
     return new Promise((resolve, reject) => {
         request({

+ 2 - 1
src/store/user.tsx

@@ -79,7 +79,7 @@ const userSlice = createSlice({
             Taro.clearStorage();
         },
         getInfoSuccess(state, action: PayloadAction<any>) {
-            const {id, nickname, avatar,scenario_select_count,test_user,token } = action.payload;
+            const {id, nickname, avatar,scenario_select_count,test_user,token,is_new_user } = action.payload;
             state.id = id;
             state.nickname = nickname;
             state.avatar = avatar;
@@ -87,6 +87,7 @@ const userSlice = createSlice({
             state.scenario_select_count = scenario_select_count;
             state.isLogin = true;
             state.test_user = test_user;
+            state.is_new_user = is_new_user;
 
             var obj = JSON.parse(JSON.stringify(action.payload))
             if (token){