|
|
@@ -1,5 +1,6 @@
|
|
|
import { ScrollView, Text, View } from "@tarojs/components";
|
|
|
import {
|
|
|
+ ArrowLeft,
|
|
|
Heart,
|
|
|
HeartFill,
|
|
|
Message,
|
|
|
@@ -12,9 +13,15 @@ import {
|
|
|
GridItem,
|
|
|
Image,
|
|
|
ImagePreview,
|
|
|
+ NavBar,
|
|
|
Tabs,
|
|
|
} from "@nutui/nutui-react-taro";
|
|
|
-import { navigateTo, getSystemInfoSync, useDidShow } from "@tarojs/taro";
|
|
|
+import {
|
|
|
+ navigateTo,
|
|
|
+ getSystemInfoSync,
|
|
|
+ useDidShow,
|
|
|
+ navigateBack,
|
|
|
+} from "@tarojs/taro";
|
|
|
import "./index.scss";
|
|
|
import { useState, useEffect, useCallback } from "react";
|
|
|
import { strSlice } from "../../utils";
|
|
|
@@ -152,219 +159,246 @@ const Self = () => {
|
|
|
getPostList(true, false);
|
|
|
}, []);
|
|
|
return (
|
|
|
- <View className="min-h-screen bg-[#f7f8fa]">
|
|
|
- <View className="p-[10px] bg-[#fff]">
|
|
|
- <View className="flex items-center justify-between">
|
|
|
- <View className="flex items-center">
|
|
|
- <View className="w-[50px] h-[50px] bg-[#1874d0] rounded-[50%] overflow-hidden">
|
|
|
- {userInfo.avatar_url ? (
|
|
|
- <Image src={userInfo.avatar_url} mode="aspectFill" />
|
|
|
- ) : (
|
|
|
- <Image src={userInfo.avatar_url} mode="aspectFill" />
|
|
|
- )}
|
|
|
- </View>
|
|
|
- <View className="flex-1 ml-[10px]">
|
|
|
- <View className="text-[16px] font-bold">
|
|
|
- {userInfo.nickname || userInfo.username}
|
|
|
+ <>
|
|
|
+ <NavBar
|
|
|
+ back={
|
|
|
+ <>
|
|
|
+ <ArrowLeft />
|
|
|
+ 返回
|
|
|
+ </>
|
|
|
+ }
|
|
|
+ onBackClick={(e) => {
|
|
|
+ e.preventDefault();
|
|
|
+ navigateBack({ delta: 1 });
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 消息
|
|
|
+ </NavBar>
|
|
|
+
|
|
|
+ <View className="min-h-screen bg-[#f7f8fa]">
|
|
|
+ <View className="p-[10px] pt-[0px] bg-[#fff]">
|
|
|
+ <View className="flex items-center justify-between">
|
|
|
+ <View className="flex items-center">
|
|
|
+ <View className="w-[50px] h-[50px] bg-[#1874d0] rounded-[50%] overflow-hidden">
|
|
|
+ <Image
|
|
|
+ src={userInfo.avatar_url}
|
|
|
+ width="100%"
|
|
|
+ height="100%"
|
|
|
+ mode="aspectFill"
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className="flex-1 ml-[10px]">
|
|
|
+ <View className="text-[16px] font-bold">
|
|
|
+ {userInfo.nickname || userInfo.username}
|
|
|
+ </View>
|
|
|
</View>
|
|
|
</View>
|
|
|
+ <Badge top="2" right="8" value={userInfo.notification_count}>
|
|
|
+ <Notice
|
|
|
+ onClick={() => {
|
|
|
+ navigateTo({ url: "/pages/message/index" });
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Badge>
|
|
|
</View>
|
|
|
- <Badge top="2" right="8" value={userInfo.notification_count}>
|
|
|
- <Notice
|
|
|
- onClick={() => {
|
|
|
- navigateTo({ url: "/pages/message/index" });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Badge>
|
|
|
- </View>
|
|
|
- <View className="flex items-center justify-between text-[14px] mt-[10px]">
|
|
|
- <View className="flex">
|
|
|
+ <View className="flex items-center justify-between text-[14px] mt-[10px]">
|
|
|
<View className="flex">
|
|
|
- <Text className="text-[#949494]">关注我</Text>
|
|
|
- <Text className="ml-[5px]">{userInfo.follow_count}</Text>
|
|
|
+ <View className="flex">
|
|
|
+ <Text className="text-[#949494]">关注我</Text>
|
|
|
+ <Text className="ml-[5px]">{userInfo.follow_count}</Text>
|
|
|
+ </View>
|
|
|
+ <View className="flex ml-[20px]">
|
|
|
+ <Text className="text-[#949494]">获得互动</Text>
|
|
|
+ <Text className="ml-[5px]">{userInfo.interaction_count}</Text>
|
|
|
+ </View>
|
|
|
</View>
|
|
|
- <View className="flex ml-[20px]">
|
|
|
- <Text className="text-[#949494]">获得互动</Text>
|
|
|
- <Text className="ml-[5px]">{userInfo.interaction_count}</Text>
|
|
|
+ <View
|
|
|
+ className="bg-[#f7f7f7] w-[70px] h-[30px] rounded-[15px] flex items-center justify-around"
|
|
|
+ onClick={() => {
|
|
|
+ navigateTo({ url: "/pages/publish/index" });
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <View className="flex items-center">
|
|
|
+ <Plus />
|
|
|
+ <Text>发布</Text>
|
|
|
+ </View>
|
|
|
</View>
|
|
|
</View>
|
|
|
- <View
|
|
|
- className="bg-[#f7f7f7] w-[70px] h-[30px] rounded-[15px] flex items-center justify-around"
|
|
|
- onClick={() => {
|
|
|
- navigateTo({ url: "/pages/publish/index" });
|
|
|
+ </View>
|
|
|
+ <View className="mt-[10px]">
|
|
|
+ <Tabs
|
|
|
+ className="tabs-self"
|
|
|
+ align="left"
|
|
|
+ value={tab1value}
|
|
|
+ onChange={(value) => {
|
|
|
+ setTab1value(value);
|
|
|
}}
|
|
|
>
|
|
|
- <View className="flex items-center">
|
|
|
- <Plus />
|
|
|
- <Text>发布</Text>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- <View className="mt-[10px]">
|
|
|
- <Tabs
|
|
|
- className="tabs-self"
|
|
|
- align="left"
|
|
|
- value={tab1value}
|
|
|
- onChange={(value) => {
|
|
|
- setTab1value(value);
|
|
|
- }}
|
|
|
- >
|
|
|
- <Tabs.TabPane title="帖子">
|
|
|
- <ScrollView
|
|
|
- scrollY
|
|
|
- style={{ height: `${scrollHeight}px` }}
|
|
|
- onScrollToLower={loadMore}
|
|
|
- refresherEnabled
|
|
|
- refresherTriggered={refreshing}
|
|
|
- onRefresherRefresh={onRefresh}
|
|
|
- lowerThreshold={50}
|
|
|
- className="bg-[#f7f8fa]"
|
|
|
- >
|
|
|
- {postList.map((item) => (
|
|
|
- <View
|
|
|
- className="post-list-item bg-[#fff] p-[10px] mt-[10px]"
|
|
|
- onClick={() =>
|
|
|
- navigateTo({ url: `/pages/detail/index?id=${item.id}` })
|
|
|
- }
|
|
|
- >
|
|
|
- <View className="flex items-center justify-between">
|
|
|
- <View className="flex items-center">
|
|
|
- <View className="w-[80rpx] h-[80rpx] rounded-[50%] bg-[#000] overflow-hidden bg-[url('https://m.360buyimg.com/mobilecms/s750x366_jfs/t1/26597/30/4870/174583/5c35c5d2Ed55eedc6/50e27870c25e7a82.png')] bg-cover bg-center"></View>
|
|
|
- <View className="ml-[10rpx]">
|
|
|
- <View className="text-[14px] font-[800] text-[#9c9dee]">
|
|
|
- {item.user.nickname || "微信用户"}
|
|
|
- </View>
|
|
|
- {item.user.is_official ? (
|
|
|
- <View className="text-[12px] text-[#949494]">
|
|
|
- 《心动女友》官方账号
|
|
|
+ <Tabs.TabPane title="帖子">
|
|
|
+ <ScrollView
|
|
|
+ scrollY
|
|
|
+ style={{ height: `${scrollHeight}px` }}
|
|
|
+ onScrollToLower={loadMore}
|
|
|
+ refresherEnabled
|
|
|
+ refresherTriggered={refreshing}
|
|
|
+ onRefresherRefresh={onRefresh}
|
|
|
+ lowerThreshold={50}
|
|
|
+ className="bg-[#f7f8fa]"
|
|
|
+ >
|
|
|
+ {postList.map((item) => (
|
|
|
+ <View
|
|
|
+ className="post-list-item bg-[#fff] p-[10px] mt-[10px]"
|
|
|
+ onClick={() =>
|
|
|
+ navigateTo({ url: `/pages/detail/index?id=${item.id}` })
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <View className="flex items-center justify-between">
|
|
|
+ <View className="flex items-center">
|
|
|
+ <View
|
|
|
+ className="w-[40px] h-[40px] rounded-[50%] bg-[#000] overflow-hidden bg-cover bg-center"
|
|
|
+ style={{
|
|
|
+ backgroundImage: item.user.avatar_url
|
|
|
+ ? `url('${item.user.avatar_url}')`
|
|
|
+ : "none",
|
|
|
+ }}
|
|
|
+ ></View>
|
|
|
+ <View className="ml-[10rpx]">
|
|
|
+ <View className="text-[14px] font-[800] text-[#9c9dee]">
|
|
|
+ {item.user.nickname || "微信用户"}
|
|
|
</View>
|
|
|
+ {item.user.is_official ? (
|
|
|
+ <View className="text-[12px] text-[#949494]">
|
|
|
+ 《心动女友》官方账号
|
|
|
+ </View>
|
|
|
+ ) : (
|
|
|
+ <></>
|
|
|
+ )}
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ <View className="text-[14px] text-[#333] pt-[10px]">
|
|
|
+ {strSlice(item.content, 100)}
|
|
|
+ {item.content.length > 100 && (
|
|
|
+ <Text className="text-[#1874d0]">全文</Text>
|
|
|
+ )}
|
|
|
+ </View>
|
|
|
+ <View className="mt-[10px]">
|
|
|
+ <Grid
|
|
|
+ columns={item.media_url.length < 3 ? 2 : 3} // 这里,如果图片小于3张,则columns为2,如果图片大于等于3张,则columns为3
|
|
|
+ gap={7}
|
|
|
+ style={
|
|
|
+ {
|
|
|
+ "--nutui-grid-item-content-padding": "0px",
|
|
|
+ "--nutui-grid-item-content-margin": "0px",
|
|
|
+ } as any
|
|
|
+ }
|
|
|
+ >
|
|
|
+ {item.media_url.map((ite: any, index: number) => {
|
|
|
+ return (
|
|
|
+ <GridItem>
|
|
|
+ <Image
|
|
|
+ width="100%"
|
|
|
+ height="100px"
|
|
|
+ src={ite.src}
|
|
|
+ mode="widthFix"
|
|
|
+ onClick={(e) => {
|
|
|
+ e.stopPropagation();
|
|
|
+ setMediaUrl(item.media_url);
|
|
|
+ setInit(index + 1);
|
|
|
+
|
|
|
+ setShowPreview(true);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </GridItem>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </Grid>
|
|
|
+ </View>
|
|
|
+ <View className="mt-[10px] pl-[20px] pr-[20px] flex items-center justify-between">
|
|
|
+ <View className="flex items-center">
|
|
|
+ <Message size={16} color="#949494" />
|
|
|
+ <Text className="ml-[5px] text-[16px] text-[#949494]">
|
|
|
+ {item.comment_count}
|
|
|
+ </Text>
|
|
|
+ </View>
|
|
|
+ <View
|
|
|
+ className="flex items-center"
|
|
|
+ onClick={(e) => {
|
|
|
+ e.stopPropagation();
|
|
|
+ handleInteraction(
|
|
|
+ item.id,
|
|
|
+ item.interaction_type === "praise"
|
|
|
+ ? "dispraise"
|
|
|
+ : "praise"
|
|
|
+ );
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {item.interaction_type === "praise" ? (
|
|
|
+ <HeartFill size={16} color="#ec4342" />
|
|
|
) : (
|
|
|
- <></>
|
|
|
+ <Heart size={16} color="#949494" />
|
|
|
)}
|
|
|
+ <Text className="ml-[5px] text-[16px] text-[#949494]">
|
|
|
+ {item.like_count}
|
|
|
+ </Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>
|
|
|
- <View className="text-[14px] text-[#333] pt-[10px]">
|
|
|
- {strSlice(item.content, 100)}
|
|
|
- {item.content.length > 100 && (
|
|
|
- <Text className="text-[#1874d0]">全文</Text>
|
|
|
- )}
|
|
|
- </View>
|
|
|
- <View className="mt-[10px]">
|
|
|
- <Grid
|
|
|
- columns={item.media_url.length < 3 ? 2 : 3} // 这里,如果图片小于3张,则columns为2,如果图片大于等于3张,则columns为3
|
|
|
- gap={7}
|
|
|
- style={
|
|
|
- {
|
|
|
- "--nutui-grid-item-content-padding": "0px",
|
|
|
- "--nutui-grid-item-content-margin": "0px",
|
|
|
- } as any
|
|
|
- }
|
|
|
- >
|
|
|
- {item.media_url.map((ite: any, index: number) => {
|
|
|
- return (
|
|
|
- <GridItem>
|
|
|
- <Image
|
|
|
- src={ite.src}
|
|
|
- mode="aspectFill"
|
|
|
- height="100"
|
|
|
- onClick={(e) => {
|
|
|
- e.stopPropagation();
|
|
|
- setMediaUrl(item.media_url);
|
|
|
- setInit(index + 1);
|
|
|
+ ))}
|
|
|
|
|
|
- setShowPreview(true);
|
|
|
- }}
|
|
|
- />
|
|
|
- </GridItem>
|
|
|
- );
|
|
|
- })}
|
|
|
- </Grid>
|
|
|
- </View>
|
|
|
- <View className="mt-[10px] pl-[20px] pr-[20px] flex items-center justify-between">
|
|
|
- <View className="flex items-center">
|
|
|
- <Message size={16} color="#949494" />
|
|
|
- <Text className="ml-[5px] text-[16px] text-[#949494]">
|
|
|
- {item.comment_count}
|
|
|
- </Text>
|
|
|
- </View>
|
|
|
+ {/* 错误状态 */}
|
|
|
+ {error && (
|
|
|
+ <View className="p-[20px] text-center">
|
|
|
+ <View className="text-[#ff4d4f] mb-[10px]">{error}</View>
|
|
|
<View
|
|
|
- className="flex items-center"
|
|
|
- onClick={() => {
|
|
|
- handleInteraction(
|
|
|
- item.id,
|
|
|
- item.interaction_type === "praise"
|
|
|
- ? "dispraise"
|
|
|
- : "praise"
|
|
|
- );
|
|
|
- }}
|
|
|
+ className="text-[#1874d0] underline cursor-pointer"
|
|
|
+ onClick={() => getPostList()}
|
|
|
>
|
|
|
- {item.interaction_type === "praise" ? (
|
|
|
- <HeartFill size={16} color="#ec4342" />
|
|
|
- ) : (
|
|
|
- <Heart size={16} color="#949494" />
|
|
|
- )}
|
|
|
- <Text className="ml-[5px] text-[16px] text-[#949494]">
|
|
|
- {item.like_count}
|
|
|
- </Text>
|
|
|
+ 点击重试
|
|
|
</View>
|
|
|
</View>
|
|
|
- </View>
|
|
|
- ))}
|
|
|
+ )}
|
|
|
|
|
|
- {/* 错误状态 */}
|
|
|
- {error && (
|
|
|
- <View className="p-[20px] text-center">
|
|
|
- <View className="text-[#ff4d4f] mb-[10px]">{error}</View>
|
|
|
- <View
|
|
|
- className="text-[#1874d0] underline cursor-pointer"
|
|
|
- onClick={() => getPostList()}
|
|
|
- >
|
|
|
- 点击重试
|
|
|
+ {/* 加载更多状态 */}
|
|
|
+ {loadingMore && (
|
|
|
+ <View className="p-[20px] text-center text-[#999]">
|
|
|
+ 加载更多...
|
|
|
</View>
|
|
|
- </View>
|
|
|
- )}
|
|
|
+ )}
|
|
|
|
|
|
- {/* 加载更多状态 */}
|
|
|
- {loadingMore && (
|
|
|
- <View className="p-[20px] text-center text-[#999]">
|
|
|
- 加载更多...
|
|
|
- </View>
|
|
|
- )}
|
|
|
-
|
|
|
- {/* 没有更多数据 */}
|
|
|
- {!hasMore && postList.length > 0 && !loading && !refreshing && (
|
|
|
- <View className="p-[20px] text-center text-[#999]">
|
|
|
- 没有更多内容了
|
|
|
- </View>
|
|
|
- )}
|
|
|
+ {/* 没有更多数据 */}
|
|
|
+ {!hasMore && postList.length > 0 && !loading && !refreshing && (
|
|
|
+ <View className="p-[20px] text-center text-[#999]">
|
|
|
+ 没有更多内容了
|
|
|
+ </View>
|
|
|
+ )}
|
|
|
|
|
|
- {/* 空状态 */}
|
|
|
- {!loading && !refreshing && postList.length === 0 && !error && (
|
|
|
- <View className="p-[40px] text-center text-[#999]">
|
|
|
- 暂无帖子
|
|
|
- </View>
|
|
|
- )}
|
|
|
+ {/* 空状态 */}
|
|
|
+ {!loading && !refreshing && postList.length === 0 && !error && (
|
|
|
+ <View className="p-[40px] text-center text-[#999]">
|
|
|
+ 暂无帖子
|
|
|
+ </View>
|
|
|
+ )}
|
|
|
|
|
|
- {/* 初始加载状态 */}
|
|
|
- {loading && postList.length === 0 && (
|
|
|
- <View className="p-[40px] text-center text-[#999]">
|
|
|
- 加载中...
|
|
|
- </View>
|
|
|
- )}
|
|
|
- </ScrollView>
|
|
|
- </Tabs.TabPane>
|
|
|
- </Tabs>
|
|
|
+ {/* 初始加载状态 */}
|
|
|
+ {loading && postList.length === 0 && (
|
|
|
+ <View className="p-[40px] text-center text-[#999]">
|
|
|
+ 加载中...
|
|
|
+ </View>
|
|
|
+ )}
|
|
|
+ </ScrollView>
|
|
|
+ </Tabs.TabPane>
|
|
|
+ </Tabs>
|
|
|
+ </View>
|
|
|
+ <ImagePreview
|
|
|
+ images={mediaUrl}
|
|
|
+ visible={showPreview}
|
|
|
+ defaultValue={init}
|
|
|
+ onClose={() => setShowPreview(false)}
|
|
|
+ indicator
|
|
|
+ />
|
|
|
</View>
|
|
|
- <ImagePreview
|
|
|
- images={mediaUrl}
|
|
|
- visible={showPreview}
|
|
|
- defaultValue={init}
|
|
|
- onClose={() => setShowPreview(false)}
|
|
|
- indicator
|
|
|
- />
|
|
|
- </View>
|
|
|
+ </>
|
|
|
);
|
|
|
};
|
|
|
|