Leon hace 1 año
padre
commit
eb47a0dea1

+ 5 - 5
src/_health/components/timeline_date.tsx

@@ -4,7 +4,7 @@ import dayjs from "dayjs";
 import { TimeFormatter } from "@/utils/time_format";
 import { rpxToPx } from "@/utils/tools";
 
-export default function TimelineDate(props: { timestamp: number, pre_timestamp?: number, isJournal?: boolean }) {
+export default function TimelineDate(props: { timestamp: number, pre_timestamp?: number, isJournal?: boolean, hideDate?: boolean }) {
 
     function detail() {
         if (props.pre_timestamp && dayjs(props.timestamp).format('YYYY-MM-DD') == dayjs(props.pre_timestamp).format('YYYY-MM-DD')) {
@@ -24,7 +24,7 @@ export default function TimelineDate(props: { timestamp: number, pre_timestamp?:
                 subtitle = global.language == 'en' ? 'Today' : dayjs(props.timestamp).format('ddd')
             }
 
-            
+
         }
         else if (TimeFormatter.isYesterday(props.timestamp)) {
             if (props.isJournal) {
@@ -36,13 +36,13 @@ export default function TimelineDate(props: { timestamp: number, pre_timestamp?:
                 title = global.language == 'en' ? dayjs(props.timestamp).format('ddd') : '昨天'
                 subtitle = global.language == 'en' ? 'Yesterday' : dayjs(props.timestamp).format('ddd')
             }
-            
+
         }
         else if (TimeFormatter.isTimestampInThisWeek(props.timestamp)) {
             if (props.isJournal) {
                 title = dayjs(props.timestamp).format('DD')
                 month = dayjs(props.timestamp).format('MMM')
-                subtitle = global.language == 'en' ?dayjs(props.timestamp).format('dddd'):dayjs(props.timestamp).format('ddd')
+                subtitle = global.language == 'en' ? dayjs(props.timestamp).format('dddd') : dayjs(props.timestamp).format('ddd')
             }
             else {
                 title = dayjs(props.timestamp).format('ddd')
@@ -64,7 +64,7 @@ export default function TimelineDate(props: { timestamp: number, pre_timestamp?:
 
     return <View className="timeline_date_content">
         {
-            detail()
+            !props.hideDate && detail()
         }
     </View>
 }

+ 0 - 0
src/_moment/components/recent_item.scss


+ 99 - 0
src/_moment/components/recent_item.tsx

@@ -0,0 +1,99 @@
+import TargetProgress from "@/_health/components/target_progress";
+import TimeTitleDesc from "@/_health/components/time_title_desc";
+import TimelineDate from "@/_health/components/timeline_date";
+import { IconActive } from "@/components/basic/Icons";
+import { MainColorType } from "@/context/themes/color";
+import { getThemeColor } from "@/features/health/hooks/health_hooks";
+import JournalCover from "@/features/journal/components/journal_cover";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
+import { rpxToPx } from "@/utils/tools";
+import { View, Text, Image, ScrollView } from "@tarojs/components";
+import dayjs from "dayjs";
+
+export default function RecentItem(props: { data: any, index: number }) {
+    const { time, moment, link } = props.data
+
+    function historyMonth(index) {
+        var showDate = time.is_start_year ? true : false;
+        var dateStr = global.language == 'en' ? dayjs(time.timestamp).format('YYYY') : dayjs(time.timestamp).format('YYYY年')
+        if (index == 0) {
+            var now = global.language == 'en' ? dayjs().format('YYYY') : dayjs().format('YYYY年')
+            if (dateStr == now) {
+                showDate = false
+            }
+        }
+        if (showDate) {
+            return <View className="history_year_month h42 bold" style={{ marginBottom: rpxToPx(60) }}>{dateStr}</View>
+        }
+        return <View />
+    }
+
+    function medias() {
+        var pics = moment.media.map(obj => obj.url);
+        return <JournalCover imgs={pics} />
+    }
+
+    function goDetail() {
+        jumpPage(`/_health/pages/timeline_detail?window_id=${link.window_id}`)
+    }
+
+    return <View>
+        {
+            historyMonth(props.index)
+        }
+        <View className="history_item2" style={{ display: 'flex', flexDirection: 'row' }} onClick={goDetail}>
+            <TimelineDate timestamp={time.timestamp} pre_timestamp={0} isJournal={false} hideDate={!time.is_start_day} />
+            <View className="history_content" style={{ paddingTop: rpxToPx(0) }}>
+                <View style={{ display: 'flex', flexDirection: 'row', marginBottom: rpxToPx(12), flex: 1 }}>
+                    {
+                        moment.media.length > 0 && medias()
+                    }
+                    {
+                        (moment.title || moment.description) && <View style={{
+                            display: 'flex',
+                            flex: 1,
+                            flexShrink: 0,
+                            flexDirection: 'column',
+                            backgroundColor: moment.media.length > 0 ? 'transparent' : '#fafafa',
+                            paddingLeft: moment.media.length > 0 ? 0 : rpxToPx(20),
+                            paddingRight: rpxToPx(20),
+                            paddingTop: rpxToPx(12),
+                            paddingBottom: rpxToPx(12)
+                        }}>
+                            <TimeTitleDesc
+                                className={'line2'}
+                                time=''
+                                title={moment.title}
+                                desc={moment.description} />
+                        </View>
+                    }
+
+                </View>
+                {
+                    link && link.ring && <View style={{ marginTop: rpxToPx(24) }}>
+                        <TargetProgress
+                            color={getThemeColor(link.window)}
+                            showRing={true}
+                            desc={link.ring.description}
+                            og={link.status == 'OG'}
+                            startTimestamp={link.ring.start_timestamp}
+                            endTimerstamp={link.ring.end_timestamp ?? new Date().getTime()}
+                        />
+                    </View>
+                }
+                {
+                    link && link.move && <View style={{ marginTop: rpxToPx(24) }}>
+                        <TargetProgress
+                            color={getThemeColor(link.window)}
+                            showRing={false}
+                            desc={link.move.description}
+                            icon={
+                                <IconActive color={MainColorType.active} width={rpxToPx(32)} />
+                            }
+                        />
+                    </View>
+                }
+            </View>
+        </View>
+    </View>
+}

+ 1 - 0
src/_moment/pages/home.config.ts

@@ -7,4 +7,5 @@ export default definePageConfig({
     "navigationBarBackgroundColor": "#f5f5f5",
     "backgroundColor": "#ffffff",
     "navigationStyle": "custom",
+    "disableScroll": true
 })

+ 3 - 0
src/_moment/pages/home.scss

@@ -1,3 +1,6 @@
+page{
+    background-color: #fff;
+}
 .home_top{
     position: relative;
 }

+ 209 - 39
src/_moment/pages/home.tsx

@@ -1,13 +1,15 @@
-import { View, Text, Image } from "@tarojs/components";
+import { View, Text, Image, ScrollView } from "@tarojs/components";
 import './home.scss'
 import Taro, { useRouter } from "@tarojs/taro";
 import { useEffect, useState } from "react";
-import { followUser, getUserProfile, unfollowUser } from "@/services/friend";
+import { followUser, getFriendMoments, getUserMoments, getUserProfile, unfollowUser } from "@/services/friend";
 import { useSelector } from "react-redux";
 import NewButton, { NewButtonType } from "@/_health/base/new_button";
 import { rpxToPx } from "@/utils/tools";
 import { MainColorType } from "@/context/themes/color";
 import showActionSheet from "@/components/basic/ActionSheet";
+import ListFooter from "@/_health/components/list_footer";
+import RecentItem from "../components/recent_item";
 
 let useRoute;
 let useNavigation;
@@ -17,6 +19,7 @@ if (process.env.TARO_ENV == 'rn') {
     useNavigation = require("@react-navigation/native").useNavigation
 }
 
+let myScrollTop = 0
 export default function UserHome() {
     const user = useSelector((state: any) => state.user);
     const [profile, setProfile] = useState<any>(null)
@@ -24,6 +27,18 @@ export default function UserHome() {
     const systemInfo: any = Taro.getWindowInfo ? Taro.getWindowInfo() : Taro.getSystemInfoSync();
     const navigationBarHeight = systemInfo.statusBarHeight + 44;
 
+    const observerObjBottom = Taro.createIntersectionObserver().relativeToViewport({ bottom: 100 })
+
+    const [loading, setLoading] = useState(false)
+    const [noMore, setNoMore] = useState(false)
+    const [itemLayouts, setItemLayouts] = useState<any>([])
+    const [itemHeights, setItemHeights] = useState<any>([])
+    const [pageTop, setPageTop] = useState(0)
+    const [page, setPage] = useState(1)
+    const [endSignal, setEndSignal] = useState(0)
+    const [list, setList] = useState<any>([])
+    const query = Taro.createSelectorQuery()
+
 
     let router
     let navigation;
@@ -40,8 +55,29 @@ export default function UserHome() {
 
     useEffect(() => {
         getProfile()
+        moments(1)
     }, [])
 
+    useEffect(() => {
+        if (list.length == 0) return
+
+        setTimeout(() => {
+            measureItemLayouts()
+        }, 300)
+
+        observerObjBottom.observe('#footer', (res) => {
+            setEndSignal(endSignal => endSignal + 1)
+            // console.log(moments.length)
+            // if (moments.length==0) return
+            // loadMore()
+        })
+    }, [list])
+
+    useEffect(() => {
+        if (moments.length == 0) return
+        loadMore()
+    }, [endSignal])
+
     function getProfile() {
         getUserProfile({ user_id: router.params.uid }).then(res => {
             setProfile(res)
@@ -49,6 +85,98 @@ export default function UserHome() {
         })
     }
 
+    function loadMore() {
+        if (loading) return;
+        if (noMore) return;
+        setLoading(true)
+        console.log('more page:',page)
+        var index = page;
+        index++;
+        setPage(index)
+        moments(index)
+    }
+
+    function moments(index) {
+        setPage(index)
+        var params: any = {
+            user_id: router.params.uid,
+            page: index,
+            limit: 10
+        }
+        if (index != 1 && list.length>0) {
+            params.last_timestamp = list[list.length - 1].time.timestamp
+        }
+        console.log('load data page',index)
+        getUserMoments(params).then(res => {
+            console.log('result page',index)
+            if (index == 1) {
+                setList((res as any).data)
+            }
+            else {
+                setList([...list, ...(res as any).data])
+            }
+            setLoading(false)
+
+            if ((res as any).data.length == 0) {
+                setNoMore(true)
+            }
+            else {
+                setNoMore(false)
+            }
+        })
+    }
+
+    function measureItemLayouts() {
+        if (list.length <= 10) {
+            list.forEach((item, index) => {
+                query.select(`#history2-${index}`).boundingClientRect()
+            });
+            query.exec((res) => {
+                var layouts: any = []
+                var heights: any = []
+                res.forEach((rect, index) => {
+                    if (rect) {
+                        layouts[index] = rect.top + myScrollTop
+                        heights[index] = rect.height
+                    }
+                });
+                setItemLayouts(layouts)
+                setItemHeights(heights)
+            })
+        }
+        else {
+            list.forEach((item, index) => {
+                if (index >= itemLayouts.length) {
+                    query.select(`#history2-${index}`).boundingClientRect()
+                }
+            });
+            query.exec((res) => {
+                var layouts: any = []
+                var heights: any = []
+                // console.log(res)
+                res.forEach((rect, index) => {
+
+                    if (rect) {
+                        layouts[index] = rect.top + myScrollTop
+                        heights[index] = rect.height
+                    }
+                });
+                setItemLayouts([...itemLayouts, ...layouts])
+                setItemHeights([...itemHeights, ...heights])
+                console.log('结束计算位置', new Date().getTime())
+            })
+
+        }
+    }
+
+    function onScroll(e) {
+        // var top = e.detail.scrollTop
+        // myScrollTop = top
+        var top = e.detail.scrollTop - e.detail.deltaY
+        myScrollTop = e.detail.scrollTop
+        setPageTop(top)
+    }
+
     function tapFollow() {
         var params: any = {
             follow_origin: 'WECHAT_PRIVATE_CHAT',
@@ -77,44 +205,86 @@ export default function UserHome() {
 
     if (!loaded) return <View />
 
-    return <View>
-        <View className="home_top">
-            <View className="cover" />
-            <Image className="home_avatar" src={profile.avatar} />
-            <View className="home_nickname">{profile.nickname}</View>
-            <View style={{
-                position: 'absolute',
-                top:0,
-                left: 0,
-                zIndex: 10,
-                height: navigationBarHeight, width: rpxToPx(750), backgroundColor: 'transparent', display: 'flex',
-                flexDirection: 'column', justifyContent: 'flex-end'
-            }}>
-                <View style={{ height: 44, width: rpxToPx(750), position: 'relative', display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }}>
-                    <View onClick={()=>{
-                        Taro.navigateBack()
-                    }} style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: 80, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>Back</View>
+    return <ScrollView style='height:100vh'
+        enableBackToTop
+        scrollY={true}
+        // refresherEnabled={props.onRefresherRefresh}
+        // upperThreshold={70}
+        // lowerThreshold={140}
+        // refresherBackground={MainColorType.g05}
+        // onRefresherRefresh={props.onRefresherRefresh}
+        // refresherTriggered={props.isPulling}
+        onScroll={onScroll}
+        onScrollToUpper={() => {
+            setPage(1)
+            setPageTop(0)
+            if (moments.length > 10) {
+                setList(list.slice(0, 10))
+                setItemHeights(itemHeights.slice(0, 10))
+                setItemLayouts(itemLayouts.slice(0, 10))
+            }
+
+        }}
+    // onScrollToLower={props.loadMore}
+    ><View>
+            <View className="home_top">
+                <View className="cover" />
+                <Image className="home_avatar" src={profile.avatar} />
+                <View className="home_nickname">{profile.nickname}</View>
+                <View style={{
+                    position: 'fixed',
+                    top: 0,
+                    left: 0,
+                    zIndex: 10,
+                    height: navigationBarHeight, width: rpxToPx(750), backgroundColor: pageTop>=rpxToPx(380)?'#fff':'transparent', display: 'flex',
+                    flexDirection: 'column', justifyContent: 'flex-end'
+                }}>
+                    <View style={{ height: 44, width: rpxToPx(750), position: 'relative', display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }}>
+                        <View onClick={() => {
+                            Taro.navigateBack()
+                        }} style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: 80, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>Back</View>
+                        <Text style={{
+                            color:pageTop>=rpxToPx(380)?'#000':'transparent'
+                        }}>{profile.nickname}</Text>
+                    </View>
                 </View>
             </View>
+            {
+                router.params.uid != user.id && <View style={{ marginTop: rpxToPx(62), marginLeft: rpxToPx(45) }}>
+                    {
+                        profile.relation == 'FRIEND' || profile.relation == 'FOLLOWING' ? <NewButton type={NewButtonType.fill}
+                            width={rpxToPx(665)}
+                            height={rpxToPx(72)}
+                            title="following"
+                            color={MainColorType.g02}
+                            onClick={tapFollowing}
+                        /> : <NewButton type={NewButtonType.fill}
+                            width={rpxToPx(665)}
+                            height={rpxToPx(72)}
+                            title="follow"
+                            color={MainColorType.blue}
+                            onClick={tapFollow}
+                        />
+                    }
+                </View>
+            }
+            <View style={{height:rpxToPx(60)}}/>
+            {
+                list.map((item, index) => {
+                    if (itemLayouts.length >= index + 1 && pageTop > 0 && index > 5) {
+                        if (Math.abs(itemLayouts[index] - pageTop) > 2500) {
+                            return <View style={{ height: itemHeights[index] }} id={`history—temp-${index}`}>
+                            </View>
+                        }
+
+                    }
+                    return <View key={index} id={`history2-${index}`}>
+                        <RecentItem data={item} index={index} />
+                    </View>
+                })
+            }
+            <ListFooter noMore={noMore} loading={loading} />
+            <View id="footer" style={{ width: 1, height: 1 }}></View>
         </View>
-        {
-            router.params.uid != user.id && <View style={{ marginTop: rpxToPx(62), marginLeft: rpxToPx(45) }}>
-                {
-                    profile.relation == 'FRIEND' || profile.relation == 'FOLLOWING' ? <NewButton type={NewButtonType.fill}
-                        width={rpxToPx(665)}
-                        height={rpxToPx(72)}
-                        title="following"
-                        color={MainColorType.g02}
-                        onClick={tapFollowing}
-                    /> : <NewButton type={NewButtonType.fill}
-                        width={rpxToPx(665)}
-                        height={rpxToPx(72)}
-                        title="follow"
-                        color={MainColorType.blue}
-                        onClick={tapFollow}
-                    />
-                }
-            </View>
-        }
-    </View>
+    </ScrollView>
 }

+ 3 - 8
src/_moment/pages/message.tsx

@@ -63,20 +63,15 @@ export default function Message() {
 
       </View>
       {
-        item.relation == 'FOLLOWER' || item.relation == 'NA' ? <NewButton
+        item.relation == 'FOLLOWER' ? <NewButton
           type={NewButtonType.fill}
           height={rpxToPx(72)}
           color={MainColorType.blue}
           title='Follow back'
           onClick={() => tapFollow(item)}
         /> :
-          <NewButton
-            type={NewButtonType.fill}
-            height={rpxToPx(72)}
-            color={MainColorType.g02}
-            title='Following'
-            onClick={() => { }}
-          />
+        item.relation == 'FRIEND' ?<Text className="h30 g02">Friend</Text>:
+        item.relation == 'FOLLOWING' ? <Text className="h30 g02">Following</Text>:null
       }
     </View>
   }

+ 14 - 12
src/features/health/HistoryItem.tsx

@@ -40,11 +40,11 @@ export default function HistoryItem(props: {
     const health = useSelector((state: any) => state.health);
     const scale = '?x-oss-process=image/format,webp/resize,w_400'
 
-    useEffect(()=>{
-        return ()=>{
+    useEffect(() => {
+        return () => {
             console.log('dealloc history item')
         }
-    },[])
+    }, [])
 
     function goDetail(event_id?: any) {
         // debugger
@@ -57,7 +57,7 @@ export default function HistoryItem(props: {
 
     }
 
-    function singleItem(type, url, obj, key,urls=[]) {
+    function singleItem(type, url, obj, key, urls = []) {
         return <View
             onClick={(e) => {
                 if (process.env.TARO_ENV == 'weapp') {
@@ -106,7 +106,7 @@ export default function HistoryItem(props: {
                 type == 'PIC' && <CoverList imgs={[url]} count={1} />
             }
             {
-                type == 'PIC_TEXT' && <View  onClick={(e) => {
+                type == 'PIC_TEXT' && <View onClick={(e) => {
                     if (process.env.TARO_ENV == 'weapp') {
                         e.stopPropagation()
                     }
@@ -117,7 +117,7 @@ export default function HistoryItem(props: {
                 }}>
                     <JournalCover imgs={urls} />
                 </View>
-                
+
                 // <Image
                 //     className="gray_bg"
                 //     style={{ width: rpxToPx(178), height: rpxToPx(178), marginRight: rpxToPx(7), flexShrink: 0 }}
@@ -209,18 +209,20 @@ export default function HistoryItem(props: {
         </View>
     }
 
+    
+
     return <View className="history_item2" onClick={goDetail}>
+
         <TimelineDate timestamp={props.data.window_range.start_timestamp}
             pre_timestamp={props.preData ? props.preData.window_range.start_timestamp : null}
         />
         <View className="history_content" style={{ paddingTop: rpxToPx(0) }}>
             {
                 props.mode != 'EAT' && props.mode != 'ACTIVE' && props.data.dataArray.map((content, i) => {
-                    var urlArray:any = []
-                    if (content.type == 'PIC_TEXT'){
+                    var urlArray: any = []
+                    if (content.type == 'PIC_TEXT') {
                         urlArray = content.data[0].urls.map(obj => obj.url);
                     }
-                    
 
                     return <View style={{ display: 'flex', flexDirection: 'row', marginBottom: rpxToPx(12), flex: 1 }} key={i}>
                         {
@@ -248,8 +250,8 @@ export default function HistoryItem(props: {
                             content.type == 'PIC' && <CoverList imgs={content.data} count={content.data.length} />
                         }
                         {
-                            
-                            content.type == 'PIC_TEXT' && <View style={{marginRight: rpxToPx(7)}} onClick={(e) => {
+
+                            content.type == 'PIC_TEXT' && <View style={{ marginRight: rpxToPx(7) }} onClick={(e) => {
                                 if (process.env.TARO_ENV == 'weapp') {
                                     e.stopPropagation()
                                 }
@@ -323,7 +325,7 @@ export default function HistoryItem(props: {
                             break
                         case 'PIC_TEXT':
                             const urlArray = content.data[0].urls.map(obj => obj.url);
-                            return singleItem('PIC_TEXT', content.data[0].url, content.data[0], i,urlArray)
+                            return singleItem('PIC_TEXT', content.data[0].url, content.data[0], i, urlArray)
                             break
                     }
                 })

+ 1 - 0
src/pages/friend/friend.config.ts

@@ -7,4 +7,5 @@ export default definePageConfig({
     "navigationBarBackgroundColor": "#f5f5f5",
     "backgroundColor": "#ffffff",
     "navigationStyle": "custom",
+    "disableScroll": true
 })

+ 21 - 7
src/pages/friend/friend_main.tsx

@@ -18,6 +18,7 @@ import showActionSheet from "@/components/basic/ActionSheet";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import './friend.scss'
 import ListFooter from "@/_health/components/list_footer";
+import { MainColorType } from "@/context/themes/color";
 
 let useRoute;
 let useNavigation;
@@ -45,6 +46,7 @@ export default function FriendMain() {
 
     const [itemLayouts, setItemLayouts] = useState<any>([])
     const [itemHeights, setItemHeights] = useState<any>([])
+    const [isPulling, setIsPulling] = useState(false)
     const [pageTop, setPageTop] = useState(0)
 
 
@@ -210,12 +212,18 @@ export default function FriendMain() {
         getMoments(1)
     }
 
+    function onRefresh(){
+        setIsPulling(true)
+        getMoments(1)
+    }
+
     function getMoments(index) {
         setPage(index)
         getFriendMoments({
             page: index,
             limit: 10
         }).then(res => {
+            setIsPulling(false)
             console.log(index)
             if (index == 1) {
                 console.log('ss')
@@ -234,6 +242,9 @@ export default function FriendMain() {
                 setNoMore(false)
             }
 
+        }).catch(e => {
+            setIsPulling(false)
+            setLoading(false)
         })
     }
 
@@ -338,15 +349,18 @@ export default function FriendMain() {
                     <View onClick={more} style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: 80, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>More</View>
                 </View>
             </View>
-            <ScrollView style='height:100vh'
+            <ScrollView style={{
+                marginTop:navigationBarHeight,
+                height:'90vh'
+            }}
                 enableBackToTop
                 scrollY={true}
-                // refresherEnabled={props.onRefresherRefresh}
-                // upperThreshold={70}
+                refresherEnabled={true}
+                upperThreshold={70}
                 // lowerThreshold={140}
-                // refresherBackground={MainColorType.g05}
-                // onRefresherRefresh={props.onRefresherRefresh}
-                // refresherTriggered={props.isPulling}
+                refresherBackground={MainColorType.g05}
+                onRefresherRefresh={onRefresh}
+                refresherTriggered={isPulling}
                 onScroll={onScroll}
                 onScrollToUpper={() => {
                     setPage(1)
@@ -359,7 +373,7 @@ export default function FriendMain() {
                 }}
             // onScrollToLower={props.loadMore}
             >
-                <View style={{ backgroundColor: '#fff', minHeight: '100vh', paddingTop: navigationBarHeight, marginTop: rpxToPx(60), paddingBottom: 100 }}>
+                <View style={{ backgroundColor: '#fff', minHeight: '100vh', paddingTop: rpxToPx(60), paddingBottom: 100 }}>
                     {
                         dashBoard && dashBoard.new_message && <View className="new_message_bg">
 

+ 14 - 1
src/services/friend.tsx

@@ -1,4 +1,4 @@
-import { API_FOLLOW_USER, API_USER_MESSAGES, API_FRIEND_MOMENTS, API_MY_FOLLOWINGS, API_MY_FRIENDS, API_USER_DASHBOARD, API_USER_PROFILE } from "./http/api";
+import { API_FOLLOW_USER, API_USER_MESSAGES, API_FRIEND_MOMENTS, API_MY_FOLLOWINGS, API_MY_FRIENDS, API_USER_DASHBOARD, API_USER_PROFILE, API_USER_MOMENTS } from "./http/api";
 import { request } from "./http/request";
 
 //关注
@@ -121,3 +121,16 @@ export const getFriendMoments = (params) => {
     })
 }
 
+export const getUserMoments = (params) => {
+    return new Promise((resolve, reject) => {
+        request({
+            url: API_USER_MOMENTS, method: 'GET', data: { ...params }
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        }).catch(e => {
+            reject(e)
+        })
+    })
+}
+

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

@@ -127,5 +127,6 @@ export const API_MY_FRIENDS = `${baseUrl}/api/user/friends`
 export const API_MY_FOLLOWINGS = `${baseUrl}/api/user/followings`
 export const API_USER_DASHBOARD = `${baseUrl}/api/user/dashboard`
 export const API_FRIEND_MOMENTS = `${baseUrl}/api/user/feeds`
+export const API_USER_MOMENTS = `${baseUrl}/api/user/moments`
 export const API_USER_PROFILE = `${baseUrl}/api/user/profile`
 export const API_USER_MESSAGES = `${baseUrl}/api/user/messages`