头像
-
+
+ {/*
*/}
+
+
昵称
- 铁粉空间
+ {userInfo?.name}
ID
- 45676456
+ {userInfo?.user_id}
@@ -65,3 +132,46 @@ export default function SelectUserProfileItem() {
);
}
+
+// const CustomUploadButton = ({ img }) => {
+// const [fileList, setFileList] = useState([
+// {
+// url: img,
+// },
+// ]);
+// const uploadImg = async (file) => {
+// console.log(file);
+// return {
+// url: URL.createObjectURL(file),
+// };
+// };
+// return (
+//
+//
+//
+// );
+// };
diff --git a/app/my/page.js b/app/my/page.js
index 6be61b6..557d658 100644
--- a/app/my/page.js
+++ b/app/my/page.js
@@ -1,12 +1,13 @@
"use client";
-import React,{useEffect,useState} from "react";
+import React, { useEffect, useState } from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faAngleRight } from "@fortawesome/free-solid-svg-icons";
-import { Avatar, Image } from "antd-mobile";
-import { useRouter,useSearchParams } from "next/navigation";
+import { Avatar, Image, Toast } from "antd-mobile";
+import { useRouter, useSearchParams } from "next/navigation";
import withAuth from "@/components/WithAuth";
-import {get} from "@/utils/storeInfo";
+import { get } from "@/utils/storeInfo";
+import require from "@/utils/require";
const My = () => {
const [userInfo, setUserInfo] = useState({});
const searchParams = useSearchParams();
@@ -15,12 +16,31 @@ const My = () => {
const userInfo = get("account");
if (userInfo) {
setUserInfo(userInfo);
+ getData(userInfo);
}
- },[])
+ }, []);
+ const getData = async (oldUserInfo) => {
+ const data =
+ await require("POST", "/api/account_relation/count", null, true);
+ if (data.ret === -1) {
+ Toast.show({
+ icon: "fail",
+ content: data.msg,
+ position: "top",
+ });
+ return;
+ }
+ setUserInfo({ ...oldUserInfo, ...data.data });
+ };
return (
-
router.push("my/editUserProfile/selectUserProfileItem")}>
+
+ router.push("my/editUserProfile/selectUserProfileItem")
+ }
+ >
{
placeholder=""
/>
-
router.push("my/setting")}>
+
router.push("my/setting")}
+ >
{
/>
-
router.push("profile/"+userInfo.mid)}>
+
router.push("profile/" + userInfo.mid)}
+ >
{
size="xl"
className="h-6 mr-2"
onClick={() => {
- searchParams.append()
+ searchParams.append();
router.back();
}}
/>
- - router.push("my/relationship?key=follow")}>
-
1
+ - router.push("my/relationship?key=follow")}
+ >
+
{userInfo?.follow_count}
关注
- - router.push("my/relationship?key=fans")}>
-
0
+ - router.push("my/relationship?key=fans")}
+ >
+
{userInfo?.is_followed_count}
粉丝
- - router.push("my/wallet")}>
+
- router.push("my/wallet")}>
{userInfo.gold_num}
金币
- - router.push("my/wallet")}>
+
- router.push("my/wallet")}>
{userInfo.diamond_num}
钻石
@@ -206,7 +238,10 @@ const My = () => {
{/* 普通用户 */}
- - router.push("my/wallet")}>
+
- router.push("my/wallet")}
+ >
{
);
-}
+};
-
-export default withAuth(My)
\ No newline at end of file
+export default withAuth(My);
diff --git a/app/my/relationship/page.js b/app/my/relationship/page.js
index 1b0e78d..bc4ee0e 100644
--- a/app/my/relationship/page.js
+++ b/app/my/relationship/page.js
@@ -1,16 +1,17 @@
"use client";
import React, { useEffect, useRef, useState } from "react";
-import { JumboTabs, List, InfiniteScroll, Avatar } from "antd-mobile";
+import { JumboTabs, List, InfiniteScroll, Avatar, Toast } from "antd-mobile";
// import { useRouter } from "next/navigation";
import { useRouter } from "next/navigation";
-import {useSearchParams, usePathname,useParams} from "next/navigation"
+import { useSearchParams, usePathname, useParams } from "next/navigation";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faAngleLeft } from "@fortawesome/free-solid-svg-icons";
import Empty from "@/components/Empty";
-import styles from "./index.module.scss"
+import styles from "./index.module.scss";
import webviewBaseRequest from "@/utils/webviewBaseRequest";
import { generateSignature } from "@/utils/crypto";
+import require from "@/utils/require";
export default function Relationship() {
const [currentKey, setCurrentKey] = useState("follow");
const [hasMore, setHasMore] = useState(true);
@@ -20,41 +21,68 @@ export default function Relationship() {
const pathname = usePathname();
const params = useParams();
const [scrollHeight, setScrollHeight] = useState(0);
+ const [data, setData] = useState([]);
+ const [offset, setOffset] = useState(0);
// 获取屏幕高度
// const scrollHeight = 600;
useEffect(() => {
- const data = getData();
- console.log("getData",getData)
- }, []);
+ if(currentKey){
+ setOffset(0);
+ setData([]);
+ getData(currentKey).then(res=>{
+ setData(res);
+ })
+ }
+ }, [currentKey]);
useEffect(() => {
const key = searchParams.get("key");
// console.log('nnnnn',searchParams.get("key"))
- key && setCurrentKey(key)
- }, [searchParams])
- async function loadMore() {
- const append = await mockRequest();
+ key && setCurrentKey(key);
+ }, [searchParams]);
+ async function loadMore(key) {
+ const append = await getData(key);
setData((val) => [...val, ...append]);
setHasMore(append.length > 0);
}
- const getData = async () => {
- const base = webviewBaseRequest();
- const signature = generateSignature({
- ...base,
- b_mid:182308
- });
- return await fetch(
- `/api/vas/income_page?signature=${signature}`,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- ...base,
- b_mid:182308
- }),
- }
- )
+ const getData = async (key) => {
+ // api/account_relation/list_is_followed
+ const followIds = await require("POST", `/api/account_relation/${
+ key == "follow" ? "list_follow" : "list_is_followed"
+ }`, {
+ body: { offset: offset, limit: 12 },
+ }, true);
+ if (followIds.ret === -1) {
+ Toast.show({
+ icon: "fail",
+ content: data.msg,
+ position: "top",
+ });
+ return;
+ }
+ if (!followIds.data.list.length) return [];
+ const followsMids = followIds.data.list.map((item) => item.obj_mid);
+ const streamers = await require("POST", `/api/streamer/${
+ key == "follow" ? "list_ext_by_mids" : "list_others_by_mids"
+ }`, {
+ body: { mids: followsMids, offset: 0, limit: 12 },
+ }, true);
+ if (streamers.ret === -1) {
+ Toast.show({
+ icon: "fail",
+ content: data.msg,
+ position: "top",
+ });
+ return;
+ }
+
+ const followsDataList = streamers.data.list.map((item) => ({
+ ...item,
+ isFollowed: true,
+ }));
+
+ setOffset(streamers.data.offset);
+ return [...data, ...followsDataList];
+ // setMore(temData.data.more);
};
return (
@@ -88,35 +116,35 @@ export default function Relationship() {
destroyOnClose={true}
>
-
-
-
-
-
XXXXXX
-
- 专属圈内容都在空间里,永久更新外面看不到哟
-
+ {data.map((item, index) => (
+
+
+
+
+
{item.name}
+
{item.bio}
+
+
+ {item.isFollowed ? "已关注" : "关注"}
+
-
- 关注
-
-
-
-
-
-
-
-
XXXXXX
-
- 专属圈内容都在空间里,永久更新外面看不到哟
-
-
-
- 已关注
-
-
-
-
+
+ ))}
+ loadMore("follow")}
+ hasMore={hasMore}
+ />
+
+ {data.map((item, index) => (
+
+
+
+
+
{item.name}
+
{item.bio}
+
+
+ {item.isFollowed ? "已关注" : "关注"}
+
+
+
+ ))}
+ loadMore("fans")}
+ hasMore={hasMore}
+ />
+
{
- router.back();
- }}
/>
用户协议
@@ -56,20 +53,14 @@ export default function AboutUs() {
icon={faAngleRight}
size="sm"
className="h-4 text-gray-300"
- onClick={() => {
- router.back();
- }}
/>
- -
+
-
{
- router.back();
- }}
/>
隐私政策
diff --git a/utils/require.js b/utils/require.js
index 77d0523..13906b6 100644
--- a/utils/require.js
+++ b/utils/require.js
@@ -11,12 +11,12 @@ export default function customFetch(method, url, options = {},mid) {
headers: {
'Content-Type': 'application/json',
'X-Req-Source-TF': 'wittgenstein',
- ...options.headers
+ ...options?.headers
// 可以添加其他默认头部信息
}
// 可以添加其他默认选项
};
- let newBody = {...options.body}
+ let newBody = {...options?.body}
if(mid){
newBody.mid=get("account").mid
}
diff --git a/utils/storeInfo.js b/utils/storeInfo.js
index ebd6f9b..b36684a 100644
--- a/utils/storeInfo.js
+++ b/utils/storeInfo.js
@@ -2,7 +2,9 @@ export function save(key,value){
localStorage.setItem(key,value)
}
export function get(key){
- let data = localStorage.getItem(key);
+ let data = localStorage.getItem("account");
+ console.log(key,data)
+
return data ? JSON.parse(data) : {};
}
export function remove(key){
diff --git a/utils/upload.js b/utils/upload.js
index 05592f6..4178923 100644
--- a/utils/upload.js
+++ b/utils/upload.js
@@ -84,7 +84,7 @@ async function calculateFileMetadata(file) {
reject(error);
};
- file.type.startsWith("image/")
+ file.type?.startsWith("image/")
? reader.readAsDataURL(file)
: reader.readAsArrayBuffer(file);
});