Leon 1 tahun lalu
induk
melakukan
1f5ed1dda3

+ 5 - 2
src/features/trackTimeDuration/components/RecordFastSleep.tsx

@@ -35,7 +35,7 @@ let stageCanvasId = new Date().getTime()
 
 
 // export default function RecordFastSleep(props: { data: any, type: string, delSuccess?: Function, index: any }) {
-const RecordFastSleep = memo((props: { data: any, type: string }) => {
+const RecordFastSleep = memo((props: { data: any, type: string, index: number }) => {
     const [count, setCount] = useState(0)
     const [showDetailModal, setShowDetailModal] = useState(false)
     const [segmentIndex, setSegmentIndex] = useState(0)
@@ -121,10 +121,13 @@ const RecordFastSleep = memo((props: { data: any, type: string }) => {
         var id = props.data.id
         delRecord(id
         ).then(res => {
-            global.refreshTime()
+            // global.refreshTime()
+            global.indexPageRefresh()
             Taro.showToast({
                 title: t('page.records_history.del_success')
             })
+            if (global.delFastSleep)
+                global.delFastSleep(props.data)
             // props.delSuccess && props.delSuccess(props.data)
             // Taro.navigateBack()
         })

+ 0 - 1
src/features/trackTimeDuration/components/Rings.weapp.tsx

@@ -62,7 +62,6 @@ export default function Rings(props: {
     const user = useSelector((state: any) => state.user);
 
     useEffect(()=>{
-        console.log('ssss')
         // drawCircle()
     },[])
 

+ 0 - 2
src/features/trackTimeDuration/components/WeekCalendar.tsx

@@ -23,8 +23,6 @@ const WeekCalendar = memo(()=>{
     const [isLoading, setIsLoading] = useState(false)
     const pageSize = 7
 
-    console.log('sss')
-
     useEffect(() => {
         pageIndex = -1
         getRecords()

+ 4 - 5
src/pages/clock/Index.tsx

@@ -279,14 +279,15 @@ export default function Page() {
     }
 
     global.changeTargetDuration = (duration: number, isFast: boolean) => {
-        var record = (homeData as any).fast_sleep.current_record
+        var obj = JSON.parse(JSON.stringify(homeData))
+        var record = obj.fast_sleep.current_record
         if (isFast) {
             record.fast.target_end_time = record.fast.target_start_time + duration * 60 * 1000
         }
         else {
             record.sleep.target_end_time = record.sleep.target_start_time + duration * 60 * 1000
         }
-        setHomeData(JSON.parse(JSON.stringify(homeData)))
+        setHomeData(obj)
     }
 
     function modalContent() {
@@ -360,8 +361,6 @@ export default function Page() {
 
     var timestamp = new Date().getTime()
 
-    console.log('page')
-
     function render() {
         return <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
 
@@ -470,7 +469,7 @@ export default function Page() {
 
                 {
                     records.length > 0 && <View className="fast_sleep_item_bg">
-                        <RecordFastSleep data={records[0]} type='record' delSuccess={() => { }} index={-20000} />
+                        <RecordFastSleep data={records[0]} type='record' index={-20000} />
                     </View>
                 }
 

+ 11 - 5
src/pages/common/RecordsHistory.tsx

@@ -267,6 +267,10 @@ export default function Page() {
         setRecords(records.filter(i => i.id != item.id))
     }
 
+    global.delFastSleep = (item) => {
+        removeItem(item)
+    }
+
     global.clearHistory = () => {
         // var page = Taro.getCurrentPages()[0]
         // debugger
@@ -309,7 +313,8 @@ export default function Page() {
         else if (router.params.type == 'time') {
             clearTimeRecords().then(res => {
                 refresh()
-                global.refreshTime()
+                global.indexPageRefresh()
+                // global.refreshTime()
                 // global.refreshMetric()
                 // Taro.getCurrentPages()[0].refresh()
             })
@@ -359,10 +364,11 @@ export default function Page() {
                 {
                     records.map((item, index) => {
                         return <View className="fast_sleep_item_bg">
-                            <RecordFastSleep key={index} 
-                            data={item} 
-                            // index={index+scenario} 
-                            type='record' 
+                            <RecordFastSleep key={index}
+                                data={item}
+                                index={index}
+                                // index={index+scenario} 
+                                type='record'
                             // delSuccess={(item) => removeItem(item)} 
                             />
                         </View>