|
|
@@ -10,6 +10,8 @@ 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";
|
|
|
+import { useTranslation } from "react-i18next";
|
|
|
+import NoRecord from "@/_health/components/no_record";
|
|
|
|
|
|
let useRoute;
|
|
|
let useNavigation;
|
|
|
@@ -20,10 +22,11 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
}
|
|
|
let timer
|
|
|
export default function UserHome() {
|
|
|
-
|
|
|
+
|
|
|
const user = useSelector((state: any) => state.user);
|
|
|
const [profile, setProfile] = useState<any>(null)
|
|
|
const [loaded, setLoaded] = useState(false)
|
|
|
+ const [loadedList, setLoadedList] = useState(false)
|
|
|
const systemInfo: any = Taro.getWindowInfo ? Taro.getWindowInfo() : Taro.getSystemInfoSync();
|
|
|
const navigationBarHeight = systemInfo.statusBarHeight + 44;
|
|
|
|
|
|
@@ -38,9 +41,10 @@ export default function UserHome() {
|
|
|
const [endSignal, setEndSignal] = useState(0)
|
|
|
const [list, setList] = useState<any>([])
|
|
|
const query = Taro.createSelectorQuery()
|
|
|
+ const { t } = useTranslation()
|
|
|
|
|
|
- const [myScrollTop,setMyScrollTop] = useState(0)
|
|
|
- const [count,setCount] = useState(0)
|
|
|
+ const [myScrollTop, setMyScrollTop] = useState(0)
|
|
|
+ const [count, setCount] = useState(0)
|
|
|
|
|
|
|
|
|
let router
|
|
|
@@ -61,14 +65,14 @@ export default function UserHome() {
|
|
|
moments(1)
|
|
|
}, [])
|
|
|
|
|
|
- useEffect(()=>{
|
|
|
- timer = setInterval(()=>{
|
|
|
- setCount(count=>count+1)
|
|
|
- },1000)
|
|
|
- return ()=>{
|
|
|
+ useEffect(() => {
|
|
|
+ timer = setInterval(() => {
|
|
|
+ setCount(count => count + 1)
|
|
|
+ }, 1000)
|
|
|
+ return () => {
|
|
|
clearInterval(timer)
|
|
|
}
|
|
|
- },[])
|
|
|
+ }, [])
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (list.length == 0) return
|
|
|
@@ -125,7 +129,7 @@ export default function UserHome() {
|
|
|
setList([...list, ...(res as any).data])
|
|
|
}
|
|
|
setLoading(false)
|
|
|
-
|
|
|
+ setLoadedList(true)
|
|
|
if ((res as any).data.length == 0) {
|
|
|
setNoMore(true)
|
|
|
}
|
|
|
@@ -237,7 +241,7 @@ export default function UserHome() {
|
|
|
onScrollToLower={loadMore}
|
|
|
><View>
|
|
|
<View className="home_top">
|
|
|
- <Image className="cover" mode="aspectFill" src={profile.cover}/>
|
|
|
+ <Image className="cover" mode="aspectFill" src={profile.cover} />
|
|
|
<Image className="home_avatar" src={profile.avatar} />
|
|
|
<View className="home_nickname bold">{profile.nickname}</View>
|
|
|
<View style={{
|
|
|
@@ -269,27 +273,27 @@ export default function UserHome() {
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>
|
|
|
- <View style={{height:rpxToPx(62)}}></View>
|
|
|
+ <View style={{ height: rpxToPx(62) }}></View>
|
|
|
{
|
|
|
- router.params.uid != user.id && <View style={{ 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}
|
|
|
- // />
|
|
|
- <View onClick={tapFollowing} className="following h30 bold">following</View>
|
|
|
-
|
|
|
- : <NewButton type={NewButtonType.fill}
|
|
|
- width={rpxToPx(665)}
|
|
|
- height={rpxToPx(72)}
|
|
|
- title="follow"
|
|
|
- color={MainColorType.blue}
|
|
|
- onClick={tapFollow}
|
|
|
- />
|
|
|
+ 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">{t('health.following2')}</View>
|
|
|
+
|
|
|
+ : <NewButton type={NewButtonType.fill}
|
|
|
+ width={rpxToPx(665)}
|
|
|
+ height={rpxToPx(72)}
|
|
|
+ title={t('health.follow')}
|
|
|
+ color={MainColorType.blue}
|
|
|
+ onClick={tapFollow}
|
|
|
+ />
|
|
|
}
|
|
|
</View>
|
|
|
}
|
|
|
@@ -308,6 +312,9 @@ export default function UserHome() {
|
|
|
</View>
|
|
|
})
|
|
|
}
|
|
|
+ {
|
|
|
+ loadedList && list.length == 0 && <NoRecord />
|
|
|
+ }
|
|
|
<ListFooter noMore={noMore} loading={loading} />
|
|
|
<View id="footer" style={{ width: 1, height: 1 }}></View>
|
|
|
</View>
|