更新消息中心时间显示

This commit is contained in:
al 2025-01-16 15:50:25 +08:00
parent 5bcc93de87
commit e7b05ed3c2
2 changed files with 22 additions and 8 deletions

View File

@ -9,7 +9,9 @@ import React, {
useEffect, useEffect,
forwardRef, forwardRef,
useImperativeHandle, useImperativeHandle,
useCallback,
} from "react"; } from "react";
import { Day } from "react-native-gifted-chat";
import { useTailwind } from "tailwind-rn"; import { useTailwind } from "tailwind-rn";
import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useSafeAreaInsets } from "react-native-safe-area-context";
import baseRequest from "../../../../utils/baseRequest"; import baseRequest from "../../../../utils/baseRequest";
@ -20,6 +22,7 @@ import { getNoticeCount } from "../../../../store/reducer";
import requireAPI from "../../../../utils/requireAPI"; import requireAPI from "../../../../utils/requireAPI";
import { Image } from "expo-image"; import { Image } from "expo-image";
import { connect } from "react-redux"; import { connect } from "react-redux";
import dayjs from "dayjs";
const MessageList = ({ navigation, noticeCount, refInstance }) => { const MessageList = ({ navigation, noticeCount, refInstance }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const [data, setData] = useState([]); const [data, setData] = useState([]);
@ -139,7 +142,7 @@ const MessageList = ({ navigation, noticeCount, refInstance }) => {
newInfoItems[parseInt(it)]["count"] = noticeObj[it].unread_cnt; newInfoItems[parseInt(it)]["count"] = noticeObj[it].unread_cnt;
if (noticeObj[it]["most_recent_notif"]) { if (noticeObj[it]["most_recent_notif"]) {
const time = noticeObj[it]["most_recent_notif"]["push_time"]; const time = noticeObj[it]["most_recent_notif"]["push_time"];
newInfoItems[parseInt(it)]["time"] = formatDate( newInfoItems[parseInt(it)]["time"] = renderDay(
time ? time : noticeObj[it]["most_recent_notif"]["ct"] time ? time : noticeObj[it]["most_recent_notif"]["ct"]
); );
newInfoItems[parseInt(it)]["subtitle"] = newInfoItems[parseInt(it)]["subtitle"] =
@ -178,6 +181,17 @@ const MessageList = ({ navigation, noticeCount, refInstance }) => {
console.error(error); console.error(error);
} }
}; };
//
const renderDay = (time) => {
const now = dayjs();
if (now.diff(dayjs(time * 1000), "hour") - now.hour() < 1) {
return dayjs(time * 1000).format("HH:mm");
} else if (now.diff(dayjs(time * 1000), "hour") - now.hour() < 24) {
return "昨天" + dayjs(time * 1000).format("HH:mm");
} else {
return dayjs(time * 1000).format("MM-DD");
}
};
const renderSystemItem = ( const renderSystemItem = (
{ title, subtitle, time, count, icon }, { title, subtitle, time, count, icon },
index, index,
@ -231,7 +245,7 @@ const MessageList = ({ navigation, noticeCount, refInstance }) => {
> >
<Badge <Badge
status="error" status="error"
value={count > 99 ? "+99" : count} value={count > 99 ? "99+" : count}
// containerStyle={{ position: "absolute", top: 0, right: 40 }} // containerStyle={{ position: "absolute", top: 0, right: 40 }}
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }} badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}
/> />
@ -332,7 +346,7 @@ const MessageList = ({ navigation, noticeCount, refInstance }) => {
<Badge <Badge
status="error" status="error"
value={ value={
data.contact_cs_urc > 99 ? "+99" : data.contact_cs_urc data.contact_cs_urc > 99 ? "99+" : data.contact_cs_urc
} }
// containerStyle={{ position: "absolute", top: 0, right: 40 }} // containerStyle={{ position: "absolute", top: 0, right: 40 }}
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }} badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}

View File

@ -348,11 +348,11 @@ export default function SpacePaymentSetting({ navigation, route }) {
}); });
return; return;
} }
Toast.show({ // Toast.show({
icon: "success", // icon: "success",
content: "修改成功,请重进空间刷新查看", // content: "",
position: "top", // position: "top",
}); // });
navigation.goBack(); navigation.goBack();
} catch (error) { } catch (error) {
console.error(error); console.error(error);