修改一些问题

This commit is contained in:
al 2024-12-28 15:53:16 +08:00
parent 01c4f86c9a
commit 9391df34f1
6 changed files with 134 additions and 210 deletions

View File

@ -1,4 +1,4 @@
import { View, Text, Platform } from "react-native";
import { View, Text } from "react-native";
import React, { useState, useCallback, useEffect } from "react";
import {
GiftedChat,
@ -16,9 +16,7 @@ import dayjs from "dayjs";
import { Image } from "expo-image";
import { get } from "../../../utils/storeInfo";
import Toast from "react-native-toast-message";
import baseRequest from "../../../utils/baseRequest";
import { generateSignature } from "../../../utils/crypto";
import requireAPI from "../../../utils/requireAPI";
const blurhash = "LcKUTa%gOYWBYRt6xuoJo~s8V@fk";
/*
@ -53,31 +51,18 @@ export default function MessageDetail({ navigation, route }) {
//
useEffect(() => {
const getData = async () => {
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
const base = await baseRequest();
const signature = await generateSignature({
mid: params.mid,
...base,
});
const detailResponse = await fetch(
`${apiUrl}/api/streamer/list_ext_by_mid?signature=${signature}`,
const _data = await requireAPI(
"POST",
"/api/streamer/list_ext_by_mid",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
mid: params.mid,
...base,
}),
body: { mid: params.mid },
}
);
const detailData = await detailResponse.json();
if (detailData.ret === -1) {
if (_data.ret === -1) {
Toast.show({
type: "error",
text1: detailData.msg,
text1: _data.msg,
topOffset: 60,
});
return;
@ -134,28 +119,15 @@ export default function MessageDetail({ navigation, route }) {
const [sessionId, setSessionId] = useState();
useEffect(() => {
const getSession = async () => {
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
const base = await baseRequest();
const account = await get("account");
const signature = await generateSignature({
mid: account.mid,
...base,
});
const detailResponse = await fetch(
`${apiUrl}/api/contact_customer_service_session/list_by_mid?signature=${signature}`,
const detailData = await requireAPI(
"POST",
"/api/contact_customer_service_session/list_by_mid",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
mid: account.mid,
...base,
}),
body: { mid: account.mid },
}
);
const detailData = await detailResponse.json();
if (detailData.ret === -1) {
Toast.show({
type: "error",
@ -177,30 +149,15 @@ export default function MessageDetail({ navigation, route }) {
//session
const createSession = async () => {
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
const base = await baseRequest();
const account = await get("account");
const signature = await generateSignature({
sub_mid: account.mid,
obj_mid: 0,
...base,
});
const createResponse = await fetch(
`${apiUrl}/api/contact_customer_service_session/create?signature=${signature}`,
const createData = await requireAPI(
"POST",
"/api/contact_customer_service_session/create",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
sub_mid: account.mid,
obj_mid: 0,
...base,
}),
body: { sub_mid: account.mid, obj_mid: 0 },
}
);
const createData = await createResponse.json();
if (createData.ret === -1) {
Toast.show({
type: "error",
@ -223,31 +180,14 @@ export default function MessageDetail({ navigation, route }) {
if (params?.mid !== 1) return;
if (!more) return;
if (sessionId === undefined) return;
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
const base = await baseRequest();
const signature = await generateSignature({
session_id: sessionId,
offset: offset,
limit: 12,
...base,
});
const response = await fetch(
`${apiUrl}/api/contact_customer_service/list_by_session_id?signature=${signature}`,
const data = await requireAPI(
"POST",
"/api/contact_customer_service/list_by_session_id",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
session_id: sessionId,
offset: offset,
limit: 12,
...base,
}),
body: { session_id: sessionId, offset: offset, limit: 12 },
}
);
const data = await response.json();
if (data.ret === -1) {
Toast.show({
type: "error",
@ -294,31 +234,14 @@ export default function MessageDetail({ navigation, route }) {
const updateLatestHistory = async () => {
if (params?.mid !== 1) return;
if (sessionId === undefined) return;
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
const base = await baseRequest();
const signature = await generateSignature({
session_id: sessionId,
offset: 0,
limit: 1,
...base,
});
const response = await fetch(
`${apiUrl}/api/contact_customer_service/list_by_session_id?signature=${signature}`,
const data = await requireAPI(
"POST",
"/api/contact_customer_service/list_by_session_id",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
session_id: sessionId,
offset: 0,
limit: 1,
...base,
}),
body: { session_id: sessionId, offset: 0, limit: 1 },
}
);
const data = await response.json();
if (data.ret === -1) {
Toast.show({
type: "error",
@ -360,6 +283,25 @@ export default function MessageDetail({ navigation, route }) {
return [...temMessages, ...prev];
}
});
if (temMessages.length > 0) {
const data2 = await requireAPI(
"POST",
"/api/contact_customer_service/read_all",
{
body: {
session_id: sessionId,
},
}
);
if (data2.ret === -1) {
Toast.show({
icon: "fail",
content: data2.msg,
position: "top",
});
return;
}
}
} catch (error) {
console.error(error);
}
@ -399,31 +341,18 @@ export default function MessageDetail({ navigation, route }) {
//
setOffset((prev) => prev + 1);
//
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
const base = await baseRequest();
const signature = await generateSignature({
session_id: sessionId,
predicate: 0,
message: messages[0].text,
...base,
});
const response = await fetch(
`${apiUrl}/api/contact_customer_service/create?signature=${signature}`,
const data = await requireAPI(
"POST",
"/api/contact_customer_service/create",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
body: {
session_id: sessionId ? sessionId : _sessionId,
predicate: 0,
message: messages[0].text,
...base,
}),
},
}
);
const data = await response.json();
if (data.ret === -1) {
Toast.show({
type: "error",

View File

@ -13,12 +13,12 @@ import React, {
import { useTailwind } from "tailwind-rn";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import baseRequest from "../../../../utils/baseRequest";
import { generateSignature } from "../../../../utils/crypto";
import { formatDate } from "../../../../utils/tools";
import ScrollNotice from "../ScrollNotice";
import { Badge } from "@rneui/themed";
import { useDispatch } from "react-redux";
import { getNoticeCount } from "../../../../store/reducer";
import requireAPI from "../../../../utils/requireAPI";
import { Image } from "expo-image";
const MessageList = forwardRef(({ navigation }, ref) => {
const dispatch = useDispatch();
const [data, setData] = useState([]);
@ -61,26 +61,29 @@ const MessageList = forwardRef(({ navigation }, ref) => {
]);
useImperativeHandle(ref, () => ({
readAllMsg: async (types) => {
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
const base = await baseRequest();
const body = {
n_types: types,
...base,
};
const signature = await generateSignature(body);
const _response = await fetch(
`${apiUrl}/api/notification/read_all?signature=${signature}`,
const _data = await requireAPI("POST", "/api/notification/read_all", {
body,
});
if (_data.ret === -1) {
Toast.show({
type: "error",
text1: _data.msg,
topOffset: 60,
});
return;
}
const _data2 = await requireAPI(
"POST",
"/api/contact_customer_service/read_all",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
body: { session_id: data.session_id },
}
);
const _data = await _response.json();
if (_data.ret === -1) {
if (_data2.ret === -1) {
Toast.show({
type: "error",
text1: _data.msg,
@ -101,26 +104,18 @@ const MessageList = forwardRef(({ navigation }, ref) => {
});
}, []);
const getData = async () => {
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
const base = await baseRequest();
const body = {
mid: base.b_mid,
...base,
};
const signature = await generateSignature(body);
const _response = await fetch(
`${apiUrl}/api/notification/get_unread_count?signature=${signature}`,
const _data = await requireAPI(
"POST",
"/api/notification/get_unread_count",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
body,
}
);
const _data = await _response.json();
if (_data.ret === -1) {
Toast.show({
type: "error",
@ -135,7 +130,7 @@ const MessageList = forwardRef(({ navigation }, ref) => {
0
);
setData(noticeObj);
setData(_data.data);
setInfoItems((old) => {
const newInfoItems = [...old];
Object.keys(noticeObj).forEach((it) => {
@ -156,27 +151,18 @@ const MessageList = forwardRef(({ navigation }, ref) => {
}
};
const getActiveNotice = async () => {
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
const base = await baseRequest();
const body = {
mid: base.b_mid,
...base,
};
const signature = await generateSignature(body);
const _dataResponse = await fetch(
`${apiUrl}/api/notification/get_banner_info?signature=${signature}`,
const _data = await requireAPI(
"POST",
"/api/notification/get_banner_info",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
body,
}
);
const _data = await _dataResponse.json();
if (_data.ret === -1) {
Toast.show({
type: "error",
@ -185,7 +171,7 @@ const MessageList = forwardRef(({ navigation }, ref) => {
});
return;
}
setScollNotice(_data.data[0]);
// setScollNotice(_data.data[0]);
} catch (error) {
console.error(error);
}
@ -296,7 +282,9 @@ const MessageList = forwardRef(({ navigation }, ref) => {
}}
>
<View style={tailwind("px-4")}>
<NativeImage
<Image
width={54}
height={54}
source={require("../../../../assets/images/icon_border.png")}
/>
</View>
@ -322,28 +310,29 @@ const MessageList = forwardRef(({ navigation }, ref) => {
</View>
</View>
<Text style={{ ...tailwind("text-xs"), color: "#FFFFFFB2" }}>
请回复您的相关消息
{data?.recent_contact_cs_msg || "暂无新消息"}
</Text>
</View>
<View style={{ ...tailwind("w-12"), width: 60 }}>
<Text
style={{ ...tailwind("text-xs mb-2"), color: "#FFFFFF80" }}
></Text>
{/* <View
style={{
...tailwind("relative rounded-full"),
// width: 20,
// height: 20,
// backgroundColor: "#EE2F2F",
}}
>
<Badge
status="error"
value="1"
containerStyle={{ position: "absolute", top: 0, right: 40 }}
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}
/>
</View> */}
{!!data.contact_cs_urc && (
<View
style={{
...tailwind("relative rounded-full"),
}}
>
<Badge
status="error"
value={
data.contact_cs_urc > 99 ? "+99" : data.contact_cs_urc
}
// containerStyle={{ position: "absolute", top: 0, right: 40 }}
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}
/>
</View>
)}
</View>
</View>
</TouchableOpacity>

View File

@ -23,12 +23,13 @@ export default function PendingReview({ zid, navigation }) {
const [more, setMore] = useState(1);
const [data, setData] = useState({ list: [], total: 0 });
const getData = async () => {
console.log("zid", zid);
if (zid === undefined || !more) return;
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
const base = await baseRequest();
const body = {
b_mid: zid,
b_mid: parseInt(zid),
audit_type: 1,
offset: offset,
limit: 20,
@ -44,7 +45,7 @@ export default function PendingReview({ zid, navigation }) {
},
body: JSON.stringify(body),
}
);
).catch((e) => console.log(e));
const _data = await _response.json();
if (_data.ret === -1) {
Toast.show({

View File

@ -28,39 +28,39 @@ export default function Reviewed({ navigation, zid }) {
try {
const base = await baseRequest();
const body = {
b_mid: zid,
b_mid: parseInt(zid),
audit_type: 2,
offset: offset,
limit: 20,
...base,
};
const signature = await generateSignature(body);
const _response = await fetch(
`${apiUrl}/api/zone/refund_list?signature=${signature}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
const _data = await _response.json();
if (_data.ret === -1) {
Toast.show({
type: "error",
text1: _data.msg,
topOffset: 60,
});
return;
}
setData((old) => ({
...old,
list: [...old.list, ..._data.data.list],
total: _data.data.total,
}));
setOffset(_data.data.offset);
setMore(_data.data.more);
// const signature = await generateSignature(body);
// const _response = await fetch(
// `${apiUrl}/api/zone/refund_list?signature=${signature}`,
// {
// method: "POST",
// headers: {
// "Content-Type": "application/json",
// },
// body: JSON.stringify(body),
// }
// );
// const _data = await _response.json();
// if (_data.ret === -1) {
// Toast.show({
// type: "error",
// text1: _data.msg,
// topOffset: 60,
// });
// return;
// }
// setData((old) => ({
// ...old,
// list: [...old.list, ..._data.data.list],
// total: _data.data.total,
// }));
// setOffset(_data.data.offset);
// setMore(_data.data.more);
} catch (error) {
console.error(error);
}

View File

@ -76,7 +76,7 @@ export default function HostList() {
>
<TouchableOpacity
onPress={() =>
navigation.navigate("StreamerSpace", { mid: item.mid })
navigation.navigate("SpaceIntroduce", { mid: item.mid })
}
style={tailwind("flex-row py-3")}
>

View File

@ -199,7 +199,12 @@ export default function Wallet({ navigation, route }) {
style={tailwind("flex-row justify-between items-center py-4")}
>
<View style={tailwind("flex-row items-center")}>
<Icon type="ionicon" name="print" size={32} color="#60a5fa" />
<Icon
type="ionicon"
name="trending-up-outline"
size={32}
color="#60a5fa"
/>
<Text style={tailwind("text-base text-white font-medium ml-2")}>
近一周收益
</Text>