Leon 1 年間 前
コミット
71e2879b24

+ 22 - 2
src/_health/components/list_footer.scss

@@ -1,9 +1,10 @@
 .list_footer {
     height: 128px;
     flex-shrink: 0;
-    margin-bottom: constant(safe-area-inset-bottom);
-    margin-bottom: env(safe-area-inset-bottom);
+    padding-bottom: constant(safe-area-inset-bottom);
+    padding-bottom: env(safe-area-inset-bottom);
     display: flex;
+    flex-direction: row;
     align-items: center;
     justify-content: center;
     width: 750px;
@@ -18,4 +19,23 @@
     text-align: center;
     height: 128px;
     font-size: 26px;
+}
+
+.list_footer_loading {
+    width: 30px;
+    height: 30px;
+    margin-right: 15px;
+    animation: rotate 2s infinite;
+}
+
+@keyframes rotate {
+    0% {
+        transform: rotate(0deg); /* 起始角度 */
+    }
+
+    
+
+    100% {
+        transform: rotate(360deg); /* 结束角度 */
+    }
 }

+ 9 - 1
src/_health/components/list_footer.tsx

@@ -1,11 +1,19 @@
 import { View,Text,Image } from "@tarojs/components";
 import './list_footer.scss'
 
-export default function ListFooter(props:{noMore?:boolean}){
+export default function ListFooter(props:{noMore?:boolean,loading?:boolean}){
     return <View className="list_footer">
         {/* {
             props.noMore&&<Text className="no_more g02">没有更多了</Text>
         } */}
+        {
+            props.loading && <Image src={require('@assets/_health/loading.png')} className="list_footer_loading"/>
+        }
+        {
+            props.loading && <View>
+                <Text className="h30">正在加载...</Text>
+            </View>
+        }
         {
             props.noMore&& <Image src={require('@assets/_health/no_more.png')} style={{width:68,height:4}}/>
         }

+ 2 - 11
src/_health/components/sticky_date_list.tsx

@@ -11,7 +11,6 @@ export default function StickyDateList(props: {
     showDate: boolean,
     date: string,
     disable?: boolean,
-    scrollUpper?: any
 }) {
 
     function headerDate() {
@@ -45,21 +44,13 @@ export default function StickyDateList(props: {
             enableBackToTop
             scrollY={!props.disable}
             refresherEnabled
-            upperThreshold={30}
-            onScrollToUpper={props.scrollUpper}
+            upperThreshold={70}
+            lowerThreshold={80}
             refresherBackground={MainColorType.g05}
             onRefresherRefresh={props.onRefresherRefresh}
             refresherTriggered={props.isPulling}
             onScroll={props.onScroll}
             onScrollToLower={props.loadMore}
-            enhanced
-            onDragEnd={(e)=>{
-                console.log('end drag',e.detail.scrollTop)
-                props.onScroll(e)
-            }}
-            onRefresherPulling={(e)=>{
-                console.log('pulling page')
-            }}
         >
             {
                 props.header

+ 6 - 6
src/_health/pages/guide_active.tsx

@@ -174,10 +174,10 @@ export default function GuideActive() {
                                 })
                                 return
                             }
-                            if (errors.length>0){
+                            if (errors.length > 0) {
                                 Taro.showToast({
-                                    title:'请先解决冲突',
-                                    icon:'none'
+                                    title: '请先解决冲突',
+                                    icon: 'none'
                                 })
                                 return
                             }
@@ -197,7 +197,7 @@ export default function GuideActive() {
                         onChange={(time) => {
                             var array = JSON.parse(JSON.stringify(list))
                             array.map(item => {
-                                if (item.id == obj.id) {
+                                if ((item.id && item.id == obj.id) || (!item.id && item.title == obj.title)) {
                                     item.time = time
                                     item.op_ms = new Date().getTime()
                                 }
@@ -264,7 +264,7 @@ export default function GuideActive() {
                         onChange={(time) => {
                             var array = JSON.parse(JSON.stringify(list))
                             array.map(item => {
-                                if (item.id == obj.id) {
+                                if ((item.id && item.id == obj.id) || (!item.id && item.title == obj.title)) {
                                     item.time = time
                                     item.op_ms = new Date().getTime()
                                 }
@@ -344,7 +344,7 @@ export default function GuideActive() {
             />
         </View>
         {
-             showModal && <AddLabel labels={labels}
+            showModal && <AddLabel labels={labels}
                 window='ACTIVE'
                 disMiss={() => setShowModal(false)}
                 onlyCheck={true}

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

@@ -188,7 +188,7 @@ export default function GuideEat() {
                         onChange={(time) => {
                             var array = JSON.parse(JSON.stringify(list))
                             array.map(item => {
-                                if (item.id == obj.id) {
+                                if ((item.id && item.id == obj.id) || (!item.id && item.title == obj.title)) {
                                     item.time = time
                                     item.op_ms = new Date().getTime()
                                 }
@@ -244,7 +244,7 @@ export default function GuideEat() {
                         onChange={(time) => {
                             var array = JSON.parse(JSON.stringify(list))
                             array.map(item => {
-                                if (item.id == obj.id) {
+                                if ((item.id && item.id == obj.id) || (!item.id && item.title == obj.title)) {
                                     item.time = time
                                     item.op_ms = new Date().getTime()
                                 }

+ 7 - 0
src/_health/pages/guide_sleep.tsx

@@ -87,6 +87,13 @@ export default function GuideSleep() {
     }
 
     function more() {
+        if (errors.length>0){
+            Taro.showToast({
+                title:'请先解决冲突',
+                icon:'none'
+            })
+            return;
+        }
         setShowPopCard(true)
     }
 

BIN
src/assets/_health/loading.png


+ 7 - 4
src/features/health/MainHistory.tsx

@@ -158,8 +158,11 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
     }
 
     function onScroll(e) {
-        var top = e.detail.scrollTop
-        myScrollTop = top
+        // var top = e.detail.scrollTop
+        // myScrollTop = top
+        var top = e.detail.scrollTop - e.detail.deltaY
+        myScrollTop = e.detail.scrollTop
+
         if (itemLayouts.length > 0) {
             var i = -1
             var date = ''
@@ -504,7 +507,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
             }
         }
         if (showDate) {
-            return <View className="history_year_month h42 bold">{dateStr}</View>
+            return <View className="history_year_month h42 bold" style={{marginBottom:rpxToPx(60)}}>{dateStr}</View>
         }
         return <View />
     }
@@ -762,6 +765,6 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
 
 
         <View style={{ height: rpxToPx(40), flexShrink: 0, backgroundColor: '#fff' }} />
-        <ListFooter noMore={(list.length > 0) && (total == list.length)} />
+        <ListFooter noMore={(list.length > 0) && (total == list.length)} loading={loading}/>
     </View>
 })

+ 6 - 4
src/features/health/MainHistory2.tsx

@@ -150,8 +150,10 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
     }
 
     function onScroll(e) {
-        var top = e.detail.scrollTop
-        myScrollTop = top
+        // var top = e.detail.scrollTop
+        // myScrollTop = top
+        var top = e.detail.scrollTop - e.detail.deltaY
+        myScrollTop = e.detail.scrollTop
         if (itemLayouts.length > 0) {
             var i = -1
             var date = ''
@@ -494,7 +496,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
             }
         }
         if (showDate) {
-            return <View className="history_year_month h42 bold">{dateStr}</View>
+            return <View className="history_year_month h42 bold" style={{marginBottom:rpxToPx(60)}}>{dateStr}</View>
         }
         return <View />
     }
@@ -728,6 +730,6 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
 
 
         <View style={{ height: rpxToPx(40), flexShrink: 0, backgroundColor: '#fff' }} />
-        <ListFooter noMore={(list.length > 0) && (total == list.length)} />
+        <ListFooter noMore={(list.length > 0) && (total == list.length)} loading={loading}/>
     </View>
 })

+ 3 - 3
src/pages/account/Album.tsx

@@ -129,8 +129,8 @@ export default function Album() {
     }
 
     function onScroll(e) {
-        var top = e.detail.scrollTop
-        myScrollTop = top
+        var top = e.detail.scrollTop - e.detail.deltaY
+        myScrollTop = e.detail.scrollTop
 
         // if (e.detail.scrollTop > 60) {
         //     Taro.setNavigationBarTitle({
@@ -343,7 +343,7 @@ export default function Album() {
                     medias.length > 0 && <View style={{ height: rpxToPx(40), flexShrink: 0, backgroundColor: '#fff' }} />
                 }
 
-                <ListFooter noMore={(medias.length > 0) && (total == medias.length)} />
+                <ListFooter noMore={(medias.length > 0) && (total == medias.length)} loading={loading}/>
 
                 {
                     loaded && medias.length == 0 && <NoRecord />

+ 1 - 0
src/pages/account/Journal.config.ts

@@ -3,6 +3,7 @@ export default definePageConfig({
       // 'ec-canvas': '../../lib/ec-canvas/ec-canvas',
       // 'demo':'../../components/demo'
     },
+    "disableScroll":true,
     "navigationBarTitleText":"",
     "navigationBarBackgroundColor":"#f5f5f5"
   })

+ 19 - 26
src/pages/account/Journal.tsx

@@ -69,9 +69,9 @@ export default function Journal() {
         getJounalsData(1)
     }, [window])
 
-    useEffect(()=>{
-        console.log('last show status',showDate)
-    },[showDate])
+    useEffect(() => {
+        console.log('last show status', showDate)
+    }, [showDate])
 
     useEffect(() => {
         if (journals.length > 0) {
@@ -92,6 +92,7 @@ export default function Journal() {
 
     function getJounalsData(index = 1) {
         setLoading(true)
+        setPage(index)
         var params: any = {
             page: index,
             limit: 10,
@@ -149,10 +150,10 @@ export default function Journal() {
     }
 
     function onScroll(e) {
-        var top = e.detail.scrollTop
-        myScrollTop = top
+        var top = e.detail.scrollTop - e.detail.deltaY
+        myScrollTop = e.detail.scrollTop
 
-        if (e.detail.scrollTop > 60) {
+        if (top > 60) {
 
             Taro.setNavigationBarTitle({
                 title: pageTitle()
@@ -184,14 +185,14 @@ export default function Journal() {
             setDate('')
         }
 
-        if (itemLayouts.length > 0 && itemLayouts[0] > top) {
-            setShowDate(false)
-            setDate('')
-            console.log(itemLayouts[0], showDate, date, top)
-        }
-        else {
-            console.log(itemLayouts[0], showDate, date, top)
-        }
+        // if (itemLayouts.length > 0 && itemLayouts[0] > top) {
+        //     setShowDate(false)
+        //     setDate('')
+        //     console.log(itemLayouts[0], showDate, date, top, e.detail.deltaY)
+        // }
+        // else {
+        //     console.log(itemLayouts[0], showDate, date, top, e.detail.deltaY)
+        // }
 
     }
 
@@ -278,7 +279,7 @@ export default function Journal() {
             }
         }
         if (showDate) {
-            return <View className="history_year_month h42 bold">{dateStr2}</View>
+            return <View className="history_year_month h42 bold" style={{marginBottom:rpxToPx(60)}}>{dateStr2}</View>
         }
         return <View />
     }
@@ -513,17 +514,10 @@ export default function Journal() {
 
     return <StickyDateList onRefresherRefresh={() => {
         setIsPulling(true)
-        getJounalsData()
+        getJounalsData(1)
     }} isPulling={isPulling}
         onScroll={onScroll}
         showDate={showDate}
-        scrollUpper={
-            () => {
-                console.log('9527')
-                setDate('')
-                setShowDate(false)
-            }
-        }
         date={date}
         loadMore={() => {
             more()
@@ -567,7 +561,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', paddingTop: rpxToPx(60) }}>
                 {
                     journals.map((item, index) => {
                         // if (index>0) return <View key={index}/>
@@ -614,8 +608,7 @@ export default function Journal() {
                 {
                     loaded && journals.length == 0 && <NoRecord />
                 }
-                <View style={{ height: rpxToPx(40), flexShrink: 0, backgroundColor: '#fff' }} />
             </View>
-            <ListFooter noMore={(journals.length > 0) && (total == journals.length)} />
+            <ListFooter noMore={(journals.length > 0) && (total == journals.length)} loading={loading} />
         </View></StickyDateList>
 }