完善消息功能

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

View File

@ -2,7 +2,8 @@ import React, { useState, useEffect, useCallback } from "react";
import { Image, TouchableOpacity, View } from "react-native"; import { Image, TouchableOpacity, View } from "react-native";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"; import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import Stream from "../Stream"; import Stream from "../Stream";
// import NoticeNav from "../NoticeDetail"; // import { Badge } from "@rneui/themed";
// import NoticeDetail from "../NoticeDetail";
import My from "../My"; import My from "../My";
import Posts from "../Posts"; import Posts from "../Posts";
import Space from "../Space"; import Space from "../Space";
@ -145,23 +146,40 @@ export default function HomeTab({ navigation, route }) {
}} }}
/> />
{/* <Tab.Screen {/* <Tab.Screen
name="NoticeNav" name="NoticeDetail"
component={NoticeNav} component={NoticeDetail}
options={{ options={{
title: "消息", title: "消息",
headerShown: false, headerShown: false,
tabBarIcon: ({ focused, color, size }) => { tabBarIcon: ({ focused, color, size }) => {
if (focused) { if (focused) {
return ( return (
<Image <View>
source={require("../../assets/icon/others/streamfocus.png")} <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 { } else {
return ( return (
<Image <View>
source={require("../../assets/icon/others/streamblur.png")} <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 <NoticeItem
hasLink={{ url: "", text: "直达帖子" }} hasLink={{ url: "", text: "直达帖子" }}
leftIcon={ leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" /> <Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
} }
/> />
<NoticeItem <NoticeItem
hasLink={{ url: "", text: "直达帖子" }} hasLink={{ url: "", text: "直达帖子" }}
leftIcon={ leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" /> <Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
} }
/> />
<NoticeItem <NoticeItem
leftIcon={ leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" /> <Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
} }
/> />
<NoticeItem <NoticeItem
leftIcon={ leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" /> <Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
} }
/> />
<NoticeItem <NoticeItem
leftIcon={ leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" /> <Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
} }
/> />
<NoticeItem <NoticeItem
leftIcon={ leftIcon={
<Icon type="ionicon" name="sparkles" size={24} color="#ff75c8" /> <Icon type="ionicon" name="sparkles" size={18} color="#ff75c8" />
} }
/> />
</ScrollView> </ScrollView>

View File

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

View File

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

View File

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

View File

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