diff --git a/src/actions/CommonActions.js b/src/actions/CommonActions.js
index ce53d31..3ec4543 100644
--- a/src/actions/CommonActions.js
+++ b/src/actions/CommonActions.js
@@ -1,3 +1,10 @@
import { fetchJSON } from '@/utils/request';
import { API_HOST } from '@/config';
+/**
+ * 顾问列表
+ */
+export const fetchSalesAgent = async (q) => {
+ const { errcode, result } = await fetchJSON(`https://p9axztuwd7x8a7.mycht.cn/service-Analyse2/GetOperatorInfo`, { q });
+ return errcode !== 0 ? [] : result.map((ele) => ({ ...ele, label: ele.cn_name, value: ele.op_id }));
+};
diff --git a/src/actions/ConversationActions.js b/src/actions/ConversationActions.js
index 9ae3144..2668d7b 100644
--- a/src/actions/ConversationActions.js
+++ b/src/actions/ConversationActions.js
@@ -24,11 +24,18 @@ export const fetchConversationsList = async (params) => {
/**
*
- * @param {object} params { opisn, whatsappid, }
+ * @param {object} params { opisn, whatsappid, lasttime, pagesize }
*/
export const fetchMessages = async (params) => {
- const { result } = await fetchJSON(`${API_HOST}/getcusmessages`, params);
- return parseRenderMessageList(result || []);
+ const defaultParams = {
+ opisn: '',
+ whatsappid: '',
+ // lasttime: '',
+ lasttime: '2024-01-01T00:25:30', // test:
+ pagesize: 100,
+ };
+ const { errcode, result } = await fetchJSON(`${API_HOST}/getcusmessages`, {...defaultParams, ...params});
+ return errcode !== 0 ? [] : parseRenderMessageList(result || []);
}
export const fetchCustomerProfile = async (colisn) => {
diff --git a/src/assets/noto-color-emoji.0.woff2 b/src/assets/noto-color-emoji.0.woff2
new file mode 100644
index 0000000..c14f2ea
Binary files /dev/null and b/src/assets/noto-color-emoji.0.woff2 differ
diff --git a/src/assets/noto-color-emoji.1.woff2 b/src/assets/noto-color-emoji.1.woff2
new file mode 100644
index 0000000..a611cf4
Binary files /dev/null and b/src/assets/noto-color-emoji.1.woff2 differ
diff --git a/src/assets/noto-color-emoji.3.woff2 b/src/assets/noto-color-emoji.3.woff2
new file mode 100644
index 0000000..a71512d
Binary files /dev/null and b/src/assets/noto-color-emoji.3.woff2 differ
diff --git a/src/assets/noto-color-emoji.4.woff2 b/src/assets/noto-color-emoji.4.woff2
new file mode 100644
index 0000000..8b6455e
Binary files /dev/null and b/src/assets/noto-color-emoji.4.woff2 differ
diff --git a/src/assets/noto-color-emoji.5.woff2 b/src/assets/noto-color-emoji.5.woff2
new file mode 100644
index 0000000..2c27280
Binary files /dev/null and b/src/assets/noto-color-emoji.5.woff2 differ
diff --git a/src/assets/noto-color-emoji.6.woff2 b/src/assets/noto-color-emoji.6.woff2
new file mode 100644
index 0000000..af3862b
Binary files /dev/null and b/src/assets/noto-color-emoji.6.woff2 differ
diff --git a/src/assets/noto-sans.woff2 b/src/assets/noto-sans.woff2
new file mode 100644
index 0000000..b644278
Binary files /dev/null and b/src/assets/noto-sans.woff2 differ
diff --git a/src/components/SearchInput.jsx b/src/components/SearchInput.jsx
new file mode 100644
index 0000000..cf61f9d
--- /dev/null
+++ b/src/components/SearchInput.jsx
@@ -0,0 +1,46 @@
+import React, { useMemo, useRef, useState } from 'react';
+import { Select, Spin } from 'antd';
+import { debounce } from '@/utils/utils';
+
+function DebounceSelect({ fetchOptions, debounceTimeout = 800, ...props }) {
+ const [fetching, setFetching] = useState(false);
+ const [options, setOptions] = useState([]);
+ const fetchRef = useRef(0);
+ const debounceFetcher = useMemo(() => {
+ const loadOptions = (value) => {
+ fetchRef.current += 1;
+ const fetchId = fetchRef.current;
+ setOptions([]);
+ setFetching(true);
+ fetchOptions(value).then((newOptions) => {
+ if (fetchId !== fetchRef.current) {
+ // for fetch callback order
+ return;
+ }
+ setOptions(newOptions);
+ setFetching(false);
+ });
+ };
+ return debounce(loadOptions, debounceTimeout);
+ }, [fetchOptions, debounceTimeout]);
+ return (
+ : null}
+ optionFilterProp='label'
+ >
+ {options.map((d) => (
+
+ {d.label}
+
+ ))}
+
+ );
+}
+
+export default DebounceSelect;
diff --git a/src/lib/msgUtils.js b/src/lib/msgUtils.js
index bb11fe7..ec8ea93 100644
--- a/src/lib/msgUtils.js
+++ b/src/lib/msgUtils.js
@@ -213,6 +213,13 @@ export const msgStatusRenderMapped = {
'read': 'read',
'failed': 'failed',
};
+export const msgStatusRenderMappedCN = {
+ 'accepted': '[发送ing]',
+ 'sent': '[已发送]',
+ 'delivered': '[已送达]',
+ 'read': '[已读]',
+ 'failed': '❗',
+};
export const receivedMsgTypeMapped = {
...cloneDeep(whatsappMsgMapped),
'message': {
@@ -272,7 +279,7 @@ export const whatsappMsgTypeMapped = {
photoURL: msg.image.link,
width: '100%',
height: 200,
- alt: '',
+ alt: msg.image?.caption || '',
}),
},
sticker: {
@@ -333,6 +340,10 @@ export const whatsappMsgTypeMapped = {
audioURL: msg.audio.link,
},
}),
+ renderForReply: (msg) => ({
+ id: msg.wamid,
+ message: '[语音]',
+ }),
},
// unsupported: { type: 'system', data: (msg) => ({ text: 'Message type is currently not supported.' }) },
unsupported: {
@@ -367,6 +378,10 @@ export const whatsappMsgTypeMapped = {
text: msg.contacts.map((ele) => `${ele.name.formatted_name}: ${ele.phones[0].wa_id}`).join('\n'),
data: msg.contacts.map((ele) => ({ id: ele.phones[0].wa_id, wa_id: ele.phones[0].wa_id, name: ele.name.formatted_name })),
}),
+ renderForReply: (msg) => ({
+ id: msg.wamid,
+ message: '[联系人]',
+ }),
},
location: {
type: 'location',
@@ -381,6 +396,10 @@ export const whatsappMsgTypeMapped = {
},
originText: msg.location?.address || '',
}),
+ renderForReply: (msg) => ({
+ id: msg.wamid,
+ message: '[位置]',
+ }),
},
// contact: 'contact',
// 'contact-card': 'contact-card',
@@ -419,7 +438,9 @@ export const parseRenderMessageItem = (msg) => {
whatsapp_name: msg?.customerProfile?.name || '',
whatsapp_phone_number: msg.from,
whatsapp_msg_type: msg.type,
- ...((isEmpty(msg.context) && isEmpty(msg.reaction)) || msg.context?.forwarded === true
+ statusCN: msgStatusRenderMappedCN[msg?.status || 'failed'],
+ statusTitle: msgStatusRenderMappedCN[msg?.status || 'failed'],
+ ...((isEmpty(msg.context) && isEmpty(msg.reaction)) || msg.context?.forwarded === true || isEmpty(msg.messageorigin)
? {}
: {
reply: {
@@ -451,7 +472,7 @@ export const parseRenderMessageList = (messages, conversationid = null) => {
type: msgContent.type,
...(typeof whatsappMsgTypeMapped[msgType].type === 'function' ? whatsappMsgTypeMapped[msgType].type(msg) : { type: whatsappMsgTypeMapped[msgType].type || 'text' }),
date: msgContent?.sendTime || msg.msgtime || '',
- localDate: msg.msgtime || '',
+ localDate: (msg.msgtime || '').replace('T', ' '),
from: msgContent.from,
sender: msgContent.from,
senderName: msgContent?.customerProfile?.name || msgContent.from,
@@ -461,6 +482,8 @@ export const parseRenderMessageList = (messages, conversationid = null) => {
senderName: 'me',
status: msgStatusRenderMapped[msgContent?.status || 'failed'],
dateString: msgStatusRenderMapped[msgContent?.status || 'failed'] === 'failed' ? `发送失败 ${whatsappError?.[msgContent.errorCode] || msgContent.errorMessage} ❌` : '',
+ statusCN: msgStatusRenderMappedCN[msgContent?.status || 'failed'],
+ statusTitle: msgStatusRenderMappedCN[msgContent?.status || 'failed'],
}
: {}),
...((isEmpty(msg.messageorigin_AsJOSN) && isEmpty(msgContent.context))
diff --git a/src/stores/ConversationStore.js b/src/stores/ConversationStore.js
index 8dcd70a..d780c9e 100644
--- a/src/stores/ConversationStore.js
+++ b/src/stores/ConversationStore.js
@@ -27,7 +27,6 @@ const initialConversationState = {
// referenceMsg: {},
- aliOSSToken: {},
};
const templatesSlice = (set) => ({
@@ -144,13 +143,16 @@ const conversationSlice = (set, get) => ({
return set({ conversationsList, activeConversations: conversationsMapped });
},
addToConversationList: (newList) => {
- const { activeConversations } = get();
+ const { activeConversations, conversationsList } = get();
const conversationsIds = Object.keys(activeConversations);
const newConversations = newList.filter((conversation) => !conversationsIds.includes(`${conversation.sn}`));
const newConversationsMapped = newConversations.reduce((r, v) => ({ ...r, [`${v.sn}`]: [] }), {});
+ const newListIds = newList.map((chatItem) => `${chatItem.sn}`);
+ const withoutNew = conversationsList.filter(item => !newListIds.includes(`${item.sn}`));
+
return set((state) => ({
- conversationsList: [...newConversations, ...state.conversationsList],
+ conversationsList: [...newList, ...withoutNew],
activeConversations: { ...activeConversations, ...newConversationsMapped },
totalNotify: state.totalNotify + newConversations.map((ele) => ele.unread_msg_count).reduce((acc, cur) => acc + (cur || 0), 0),
}));
@@ -284,11 +286,10 @@ export const useConversationStore = create(
// state actions
addError: (error) => set((state) => ({ errors: [...state.errors, error] })),
setInitial: (v) => set({ initialState: v }),
- setAliOSSToken: (v) => set({ aliOSSToken: v }),
// side effects
fetchInitialData: async (userId) => {
- const { addToConversationList, setTemplates, setInitial, receivedMessageList, setAliOSSToken } = get();
+ const { addToConversationList, setTemplates, setInitial, receivedMessageList } = get();
const conversationsList = await fetchConversationsList({ opisn: userId });
addToConversationList(conversationsList);
@@ -298,12 +299,12 @@ export const useConversationStore = create(
setInitial(true);
- const autoGetMsgs = conversationsList.length > 5 ? 5 : conversationsList.length;
- for (let index = 0; index < autoGetMsgs; index++) {
- const chatItem = conversationsList[index];
- const msgData = await fetchMessages({ opisn: chatItem.opi_sn, whatsappid: chatItem.whatsapp_phone_number });
- receivedMessageList(chatItem.sn, msgData);
- }
+ // const autoGetMsgs = conversationsList.length > 5 ? 5 : conversationsList.length;
+ // for (let index = 0; index < autoGetMsgs; index++) {
+ // const chatItem = conversationsList[index];
+ // const msgData = await fetchMessages({ opisn: chatItem.opi_sn, whatsappid: chatItem.whatsapp_phone_number });
+ // receivedMessageList(chatItem.sn, msgData);
+ // }
// for (const chatItem of conversationsList) {
// }
},
diff --git a/src/stores/FormStore.js b/src/stores/FormStore.js
index 7fef332..68ef9ef 100644
--- a/src/stores/FormStore.js
+++ b/src/stores/FormStore.js
@@ -1,13 +1,25 @@
import { create } from 'zustand';
-import { RealTimeAPI } from '@/lib/realTimeAPI';
-import { olog, isEmpty } from '@/utils/utils';
-import { receivedMsgTypeMapped, handleNotification } from '@/lib/msgUtils';
-import { fetchConversationsList, fetchTemplates, fetchMessages } from '@/actions/ConversationActions';
import { devtools } from 'zustand/middleware';
-import { WS_URL } from '@/config';
-export const useFormStore = create(devtools((set, get) => ({
- chatHistory: {},
- setChatHistory: (chatHistory) => set({ chatHistory }),
-})));
+export const useFormStore = create(
+ devtools((set, get) => ({
+ // 历史记录页面
+ chatHistoryForm: {},
+ setChatHistoryForm: (chatHistoryForm) => set({ chatHistoryForm, chatHistorySelectChat: {} }),
+ chatHistorySelectChat: {},
+ setChatHistorySelectChat: (chatHistorySelectChat) => set({ chatHistorySelectChat }),
+
+ // 订单跟踪页面
+ orderFollowForm: {
+ type: 'today',
+ // orderStatus: '新状态',
+ // orderNumber: '订单号',
+ // orderLabel: '订单标签',
+ // startDate: '走团时间',
+ },
+ setOrderFollowForm: (orderFollowForm) => set({ orderFollowForm }),
+ orderFollowAdvanceChecked: false,
+ setOrderFollowAdvanceChecked: (orderFollowAdvanceChecked) => set({ orderFollowAdvanceChecked }),
+ }))
+);
export default useFormStore;
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 5f87ef2..ca4784e 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -311,6 +311,20 @@ export const stringToColour = (str) => {
return color;
};
+export const debounce = (func, wait, immediate) => {
+ var timeout;
+ return function () {
+ var context = this,
+ args = arguments;
+ clearTimeout(timeout);
+ if (immediate && !timeout) func.apply(context, args);
+ timeout = setTimeout(function () {
+ timeout = null;
+ if (!immediate) func.apply(context, args);
+ }, wait);
+ };
+}
+
export const olog = (text, ...args) => {
console.log(
`%c ${text} `,
diff --git a/src/views/ChatHistory.jsx b/src/views/ChatHistory.jsx
index 4cfcfa1..50fc561 100644
--- a/src/views/ChatHistory.jsx
+++ b/src/views/ChatHistory.jsx
@@ -8,61 +8,15 @@ import { isEmpty } from '@/utils/utils';
import useFormStore from '@/stores/FormStore';
import { useShallow } from 'zustand/react/shallow';
+import { fetchSalesAgent } from '@/actions/CommonActions';
+// import SearchInput from '@/components/SearchInput2';
+import SearchInput from '@/components/SearchInput';
+
const { Sider, Content, Header, Footer } = Layout;
const { Search } = Input;
const { RangePicker } = DatePicker;
+
// https://media-xsp2-1.cdn.whatsapp.net/v/t61.24694-24/424735646_380563021285029_2962758854250800176_n.jpg?ccb=11-4&oh=01_AdTogiVdUE-ToI9uH-VQKTTLyDbP7bocXUQe1OETOeCgcg&oe=65F7C6AB&_nc_sid=e6ed6c&_nc_cat=104
-const data = [
- {
- title: 'Ann',
- avatarUrl: 'https://api.dicebear.com/7.x/miniavs/svg?seed=0',
- msgTime: '03-04 13:45:29',
- content:
- 'Hi, this is Ann from China Highlights travel and it is my pleasure to help your Beijing trip. I have sent you an email with the general idea about you trip. Please check it and if any question or new idea just let me know. We are specailized in customizing tour and I would like to work with you to create a tour itinerary that you like. Look forward to your reply.',
- },
- {
- title: 'David Azhari',
- avatarUrl: 'https://api.dicebear.com/7.x/miniavs/svg?seed=2',
- msgTime: '03-04 16:33:08',
- content: 'Hi! I just replied to your email saying that I have a few questions and notes',
- },
- {
- title: 'David Azhari',
- avatarUrl: 'https://api.dicebear.com/7.x/miniavs/svg?seed=2',
- msgTime: '03-04 16:33:34',
- content: 'So first, is it possible for you guys to write a PU Invitation letter for visas or no?',
- },
- {
- title: 'Ann',
- avatarUrl: 'https://api.dicebear.com/7.x/miniavs/svg?seed=0',
- msgTime: '03-04 16:33:41',
- content: 'you prefer we discuss here or go on by mail ?',
- },
- {
- title: 'David Azhari',
- avatarUrl: 'https://api.dicebear.com/7.x/miniavs/svg?seed=2',
- msgTime: '03-04 16:34:03',
- content: 'I prefer by mail if it’s ok with you',
- },
- {
- title: 'Ann',
- avatarUrl: 'https://api.dicebear.com/7.x/miniavs/svg?seed=0',
- msgTime: '03-04 16:34:28',
- content: 'both is okay ,I am typing mail to you now lol and receive your message here.',
- },
- {
- title: 'David Azhari',
- avatarUrl: 'https://api.dicebear.com/7.x/miniavs/svg?seed=2',
- msgTime: '03-05 02:56:37',
- content: 'Ok thank you so much',
- },
- {
- title: 'Ann',
- avatarUrl: 'https://api.dicebear.com/7.x/miniavs/svg?seed=0',
- msgTime: '03-04 16:44:03',
- content: 'you are welcome I have sent the mail to you ,please check.it is my pleasure to assist you with your tour.',
- },
-];
// eslint-disable-next-line react/display-name
const SearchForm = memo(function ({ initialValues, onSubmit }) {
@@ -79,47 +33,8 @@ const SearchForm = memo(function ({ initialValues, onSubmit }) {
style={{
maxWidth: 'none',
}}>
-
-