添加红点

This commit is contained in:
张成
2025-11-21 08:42:58 +08:00
parent 35b9d07a91
commit fe523ac2bc
10 changed files with 814 additions and 25 deletions

View File

@@ -1,12 +1,36 @@
import { useState, useEffect } from "react";
import { View, Text } from "@tarojs/components";
import Taro from "@tarojs/taro";
import Taro, { useDidShow } from "@tarojs/taro";
import { redirectTo } from "@/utils/navigation";
import messageService from "@/services/messageService";
import "./index.scss";
import PublishMenu from "../PublishMenu";
export type currentPageType = "games" | "message" | "personal";
const GuideBar = (props) => {
const { currentPage, guideBarClassName, onPublishMenuVisibleChange, onTabChange } = props;
const [hasReddot, setHasReddot] = useState(false);
// 获取红点状态
const checkReddot = async () => {
try {
const res = await messageService.getReddotInfo();
if (res.code === 0) {
setHasReddot(res.data.has_reddot || false);
}
} catch (e) {
console.error("获取红点状态失败:", e);
}
};
useEffect(() => {
checkReddot();
}, []);
// 每次页面显示时刷新红点状态
useDidShow(() => {
checkReddot();
});
const guideItems = [
{
@@ -64,8 +88,12 @@ const GuideBar = (props) => {
<View
className={`guide-bar-pages-item ${currentPage === item.code ? "guide-bar-pages-item-active" : ""}`}
onClick={() => handlePageChange(item.code)}
key={item.code}
>
<Text>{item.text}</Text>
{/* {item.code === "message" && hasReddot && (
<View className="reddot"></View>
)} */}
</View>
))}
</View>