|
|
@@ -18,10 +18,9 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
useRoute = require("@react-navigation/native").useRoute
|
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+let timer
|
|
|
export default function UserHome() {
|
|
|
- let myScrollTop = 0
|
|
|
+
|
|
|
const user = useSelector((state: any) => state.user);
|
|
|
const [profile, setProfile] = useState<any>(null)
|
|
|
const [loaded, setLoaded] = useState(false)
|
|
|
@@ -40,6 +39,9 @@ export default function UserHome() {
|
|
|
const [list, setList] = useState<any>([])
|
|
|
const query = Taro.createSelectorQuery()
|
|
|
|
|
|
+ const [myScrollTop,setMyScrollTop] = useState(0)
|
|
|
+ const [count,setCount] = useState(0)
|
|
|
+
|
|
|
|
|
|
let router
|
|
|
let navigation;
|
|
|
@@ -59,6 +61,15 @@ export default function UserHome() {
|
|
|
moments(1)
|
|
|
}, [])
|
|
|
|
|
|
+ useEffect(()=>{
|
|
|
+ timer = setInterval(()=>{
|
|
|
+ setCount(count=>count+1)
|
|
|
+ },1000)
|
|
|
+ return ()=>{
|
|
|
+ clearInterval(timer)
|
|
|
+ }
|
|
|
+ },[])
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
if (list.length == 0) return
|
|
|
|
|
|
@@ -103,7 +114,7 @@ export default function UserHome() {
|
|
|
page: index,
|
|
|
limit: 10
|
|
|
}
|
|
|
- if (index != 1 && list.length>0) {
|
|
|
+ if (index != 1 && list.length > 0) {
|
|
|
params.last_timestamp = list[list.length - 1].time.timestamp
|
|
|
}
|
|
|
getUserMoments(params).then(res => {
|
|
|
@@ -127,7 +138,7 @@ export default function UserHome() {
|
|
|
function measureItemLayouts() {
|
|
|
if (list.length <= 10) {
|
|
|
list.forEach((item, index) => {
|
|
|
- query.select(`#history2-${index}`).boundingClientRect()
|
|
|
+ query.select(`#history3-${index}`).boundingClientRect()
|
|
|
});
|
|
|
query.exec((res) => {
|
|
|
var layouts: any = []
|
|
|
@@ -145,7 +156,7 @@ export default function UserHome() {
|
|
|
else {
|
|
|
list.forEach((item, index) => {
|
|
|
if (index >= itemLayouts.length) {
|
|
|
- query.select(`#history2-${index}`).boundingClientRect()
|
|
|
+ query.select(`#history3-${index}`).boundingClientRect()
|
|
|
}
|
|
|
});
|
|
|
query.exec((res) => {
|
|
|
@@ -168,10 +179,10 @@ export default function UserHome() {
|
|
|
function onScroll(e) {
|
|
|
// var top = e.detail.scrollTop
|
|
|
// myScrollTop = top
|
|
|
- console.log('deltaY',e.detail.deltaY)
|
|
|
var top = e.detail.scrollTop - e.detail.deltaY
|
|
|
- myScrollTop = e.detail.scrollTop
|
|
|
+ // myScrollTop = e.detail.scrollTop
|
|
|
setPageTop(top)
|
|
|
+ setMyScrollTop(e.detail.scrollTop)
|
|
|
}
|
|
|
|
|
|
function tapFollow() {
|
|
|
@@ -202,7 +213,7 @@ export default function UserHome() {
|
|
|
|
|
|
if (!loaded) return <View />
|
|
|
|
|
|
- console.log(pageTop)
|
|
|
+ // console.log(list.length,pageTop,itemLayouts,)
|
|
|
return <ScrollView style='height:100vh'
|
|
|
enableBackToTop
|
|
|
scrollY={true}
|
|
|
@@ -223,40 +234,56 @@ export default function UserHome() {
|
|
|
}
|
|
|
|
|
|
}}
|
|
|
- onScrollToLower={loadMore}
|
|
|
+ onScrollToLower={loadMore}
|
|
|
><View>
|
|
|
<View className="home_top">
|
|
|
- <View className="cover" />
|
|
|
+ <Image className="cover" mode="aspectFill" src={profile.cover}/>
|
|
|
<Image className="home_avatar" src={profile.avatar} />
|
|
|
- <View className="home_nickname">{profile.nickname}</View>
|
|
|
+ <View className="home_nickname bold">{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',
|
|
|
+ height: navigationBarHeight, width: rpxToPx(750), backgroundColor: pageTop >= rpxToPx(380) ? '#f5f5f5' : '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={() => {
|
|
|
+ {/* <View onClick={() => {
|
|
|
Taro.navigateBack()
|
|
|
- }} style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: 80, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>Back</View>
|
|
|
+ }} style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: 80, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>Back</View> */}
|
|
|
+ <Image src={require('@assets/_health/navi_back.png')} style={{
|
|
|
+ position: 'absolute',
|
|
|
+ width: rpxToPx(92),
|
|
|
+ height: rpxToPx(64),
|
|
|
+ left: 0,
|
|
|
+ top: 22 - rpxToPx(32)
|
|
|
+ }}
|
|
|
+ onClick={() => {
|
|
|
+ Taro.navigateBack()
|
|
|
+ }}
|
|
|
+ />
|
|
|
<Text style={{
|
|
|
- color:pageTop>=rpxToPx(380)?'#000':'transparent'
|
|
|
- }}>{profile.nickname}</Text>
|
|
|
+ color: pageTop >= rpxToPx(380) ? '#000' : 'transparent'
|
|
|
+ }} className="bold">{profile.nickname}</Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>
|
|
|
+ <View style={{height:rpxToPx(62)}}></View>
|
|
|
{
|
|
|
- router.params.uid != user.id && <View style={{ marginTop: rpxToPx(62), marginLeft: rpxToPx(45) }}>
|
|
|
+ router.params.uid != user.id && <View style={{ 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}
|
|
|
+ profile.relation == 'FRIEND' || profile.relation == 'FOLLOWING' ?
|
|
|
+ // <NewButton type={NewButtonType.fill}
|
|
|
+ // width={rpxToPx(665)}
|
|
|
+ // height={rpxToPx(72)}
|
|
|
+ // title="following"
|
|
|
+ // color={MainColorType.g02}
|
|
|
+ // onClick={tapFollowing}
|
|
|
+ // />
|
|
|
+ <View onClick={tapFollowing} className="following h30 bold">following</View>
|
|
|
+
|
|
|
+ : <NewButton type={NewButtonType.fill}
|
|
|
width={rpxToPx(665)}
|
|
|
height={rpxToPx(72)}
|
|
|
title="follow"
|
|
|
@@ -276,7 +303,7 @@ export default function UserHome() {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- return <View key={index} id={`history2-${index}`}>
|
|
|
+ return <View key={index} id={`history3-${index}`}>
|
|
|
<RecentItem data={item} index={index} />
|
|
|
</View>
|
|
|
})
|