完善消息功能

This commit is contained in:
al 2024-09-11 14:34:36 +08:00
parent 4a9bda5465
commit 578ea64237
6 changed files with 120 additions and 79 deletions
screeens
HomeTab
NoticeDetail
ActiveNotice
NoticeNav
SystemNotice
components/NoticeItem
SpaceSetting/SpaceSearch

View File

@ -2,7 +2,8 @@ import React, { useState, useEffect, useCallback } from "react";
import { Image, TouchableOpacity, View } from "react-native";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import Stream from "../Stream";
// import NoticeNav from "../NoticeDetail";
// import { Badge } from "@rneui/themed";
// import NoticeDetail from "../NoticeDetail";
import My from "../My";
import Posts from "../Posts";
import Space from "../Space";
@ -145,23 +146,40 @@ export default function HomeTab({ navigation, route }) {
}}
/>
{/* <Tab.Screen
name="NoticeNav"
component={NoticeNav}
name="NoticeDetail"
component={NoticeDetail}
options={{
title: "消息",
headerShown: false,
tabBarIcon: ({ focused, color, size }) => {
if (focused) {
return (
<Image
source={require("../../assets/icon/others/streamfocus.png")}
/>
<View>
<Image
source={require("../../assets/icon/others/streamfocus.png")}
/>
<Badge
status="error"
value="99+"
containerStyle={{ position: "absolute", top: 0, right: 0 }}
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}
/>
</View>
);
} else {
return (
<Image
source={require("../../assets/icon/others/streamblur.png")}
/>
<View>
<Image
source={require("../../assets/icon/others/streamblur.png")}
/>
<Badge
status="error"
value="99+"
containerStyle={{ position: "absolute", top: 0, right: 0 }}
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}
/>
</View>
);
}
},

View File

@ -13,33 +13,33 @@ export default function ActiveNotice({ navigation }) {
<NoticeItem
hasLink={{ url: "", text: "直达帖子" }}
leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" />
<Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
}
/>
<NoticeItem
hasLink={{ url: "", text: "直达帖子" }}
leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" />
<Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
}
/>
<NoticeItem
leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" />
<Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
}
/>
<NoticeItem
leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" />
<Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
}
/>
<NoticeItem
leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" />
<Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
}
/>
<NoticeItem
leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" />
<Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
}
/>
</ScrollView>

View File

@ -7,6 +7,7 @@ import {
import React, { useState, useEffect, useCallback } from "react";
import { useTailwind } from "tailwind-rn";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { Badge } from "@rneui/themed";
import baseRequest from "../../../utils/baseRequest";
import { generateSignature } from "../../../utils/crypto";
export default function Message({ navigation }) {
@ -25,8 +26,8 @@ export default function Message({ navigation }) {
...base,
};
const signature = await generateSignature(body);
const _response = await fetch(
`${apiUrl}/api/notification/list_unread_by_mid?signature=${signature}`,
const notice_response = await fetch(
`${apiUrl}/api/notification/get_unread_count_by_mid?signature=${signature}`,
{
method: "POST",
headers: {
@ -35,16 +36,46 @@ export default function Message({ navigation }) {
body: JSON.stringify(body),
}
);
const _data = await _response.json();
if (_data.ret === -1) {
Toast.show({
type: "error",
text1: _data.msg,
topOffset: 60,
});
return;
}
setData(_data.data.list);
const detailResponse = await fetch(
`${apiUrl}/api/contact_customer_service_session/list_by_mid?signature=${signature}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
...base,
mid: base.b_mid,
}),
}
);
const detailData = await detailResponse.json();
console.log(detailData);
const session_id = detailData.data.session.id;
// const message_response = await fetch(
// `${apiUrl}/api/contact_customer_service/query_unread_num?signature=${signature}`,
// {
// method: "POST",
// headers: {
// "Content-Type": "application/json",
// },
// body: JSON.stringify({ ...base, session_id }),
// }
// );
// console.log(JSON.stringify({ ...base, session_id }));
const notice_data = await notice_response.json();
// const message_data = await message_response.json();
// const _data = await _response.json();
// if (_data.ret === -1) {
// Toast.show({
// type: "error",
// text1: _data.msg,
// topOffset: 60,
// });
// return;
// }
// setData(_data.data.list);
// console.log(message_data);
} catch (error) {
console.error(error);
}
@ -105,29 +136,20 @@ export default function Message({ navigation }) {
官方消息通知
</Text>
</View>
<View style={{ ...tailwind("w-12"), width: 60 }}>
<View
style={{
...tailwind("w-12 flex flex-col items-start"),
width: 60,
}}
>
<Text style={{ ...tailwind("text-xs mb-2"), color: "#ffffff6d" }}>
11:00
</Text>
<View
style={{
...tailwind("rounded-full bg-[#FF669E]"),
width: 20,
height: 20,
}}
>
<Text
style={{
...tailwind("text-white font-medium"),
flexWrap: "nowrap",
lineHeight: 20,
textAlign: "center",
}}
numberOfLines={1}
>
1
</Text>
</View>
<Badge
value="1"
status="error"
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}
/>
</View>
</View>
</TouchableOpacity>
@ -166,11 +188,16 @@ export default function Message({ navigation }) {
展示相关活动推送信息
</Text>
</View>
<View style={{ ...tailwind("w-12"), width: 60 }}>
<View
style={{
...tailwind("w-12 flex flex-col items-start"),
width: 60,
}}
>
<Text style={{ ...tailwind("text-xs mb-2"), color: "#ffffff6d" }}>
11:00
</Text>
<View
{/* <View
style={{
...tailwind("rounded-full bg-[#FF669E]"),
width: 20,
@ -188,7 +215,12 @@ export default function Message({ navigation }) {
>
99
</Text>
</View>
</View> */}
<Badge
value="99+"
status="error"
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}
/>
</View>
</View>
</TouchableOpacity>
@ -240,29 +272,20 @@ export default function Message({ navigation }) {
请回复您的相关消息
</Text>
</View>
<View style={{ ...tailwind("w-12"), width: 60 }}>
<View
style={{
...tailwind("w-12 flex flex-col items-start"),
width: 60,
}}
>
<Text style={{ ...tailwind("text-xs mb-2"), color: "#ffffff6d" }}>
11:00
</Text>
<View
style={{
...tailwind("rounded-full bg-[#FF669E]"),
width: 20,
height: 20,
}}
>
<Text
style={{
...tailwind("text-white font-medium"),
flexWrap: "nowrap",
lineHeight: 20,
textAlign: "center",
}}
numberOfLines={1}
>
1
</Text>
</View>
<Badge
value="1"
status="error"
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}
/>
</View>
</View>
</TouchableOpacity>

View File

@ -16,7 +16,7 @@ export default function SystemNotice({ navigation }) {
type="ionicon"
hasLink={null}
name="megaphone"
size={24}
size={18}
color="white"
/>
}
@ -24,7 +24,7 @@ export default function SystemNotice({ navigation }) {
<NoticeItem
hasLink={{ url: "", text: "直达帖子" }}
leftIcon={
<Icon type="ionicon" name="megaphone" size={24} color="white" />
<Icon type="ionicon" name="megaphone" size={18} color="white" />
}
/>
<NoticeItem
@ -33,7 +33,7 @@ export default function SystemNotice({ navigation }) {
type="ionicon"
hasLink={null}
name="megaphone"
size={24}
size={18}
color="white"
/>
}
@ -44,7 +44,7 @@ export default function SystemNotice({ navigation }) {
type="ionicon"
hasLink={null}
name="megaphone"
size={24}
size={18}
color="white"
/>
}
@ -52,13 +52,13 @@ export default function SystemNotice({ navigation }) {
<NoticeItem
hasLink={{ url: "", text: "直达帖子" }}
leftIcon={
<Icon type="ionicon" name="megaphone" size={24} color="white" />
<Icon type="ionicon" name="megaphone" size={18} color="white" />
}
/>
<NoticeItem
hasLink={{ url: "", text: "直达帖子" }}
leftIcon={
<Icon type="ionicon" name="megaphone" size={24} color="white" />
<Icon type="ionicon" name="megaphone" size={18} color="white" />
}
/>
</ScrollView>

View File

@ -21,8 +21,8 @@ export default function NoticeItem({ leftIcon, hasLink }) {
...tailwind(
"flex justify-center items-center rounded-full p-2 mr-2"
),
width: 42,
height: 42,
width: 34,
height: 34,
backgroundColor: "#ffffff1a",
}}
>

View File

@ -278,7 +278,7 @@ export default function SpaceSearch({ navigation }) {
(item, index) => renderItem(item, index)
// <RenderItem key={index} item={item} />
)}
{data.length === 0 && <Empty type={search ? "search" : "nodata"} />}
{data.length === 0 && <Empty type="nodata" />}
</View>
</ScrollView>
</View>