|
|
|
@ -14,6 +14,7 @@ import dayjs from 'dayjs';
|
|
|
|
|
import useStyleStore from '@/stores/StyleStore';
|
|
|
|
|
import ComposerTools from './ComposerTools';
|
|
|
|
|
import { useOrderStore, OrderLabelDefaultOptions, OrderStatusDefaultOptions } from "@/stores/OrderStore";
|
|
|
|
|
import { postSendMsg } from '@/actions/WaiAction';
|
|
|
|
|
|
|
|
|
|
const ButtonStyleClsMapped =
|
|
|
|
|
{
|
|
|
|
@ -26,7 +27,7 @@ const InputComposer = ({ channel, currentActive }) => {
|
|
|
|
|
const { message: appMessage, notification: appNotification } = App.useApp();
|
|
|
|
|
const [mobile] = useStyleStore((state) => [state.mobile]);
|
|
|
|
|
|
|
|
|
|
const {userId, whatsAppBusiness} = useAuthStore((state) => state.loginUser);
|
|
|
|
|
const {userId, whatsAppBusiness, whatsAppNo} = useAuthStore((state) => state.loginUser);
|
|
|
|
|
const [customerDetail] = useOrderStore((s) => [s.customerDetail])
|
|
|
|
|
|
|
|
|
|
const websocket = useConversationStore((state) => state.websocket);
|
|
|
|
@ -66,7 +67,8 @@ const InputComposer = ({ channel, currentActive }) => {
|
|
|
|
|
setFromIM(whatsAppBusiness || DEFAULT_WABA)
|
|
|
|
|
break
|
|
|
|
|
case 'wa':
|
|
|
|
|
setFromIM('') // todo: 个人WhatsApp号
|
|
|
|
|
case 'whatsapp':
|
|
|
|
|
setFromIM(whatsAppNo)
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
@ -87,7 +89,7 @@ const InputComposer = ({ channel, currentActive }) => {
|
|
|
|
|
const textInputRef = useRef(null);
|
|
|
|
|
const [textContent, setTextContent] = useState('');
|
|
|
|
|
|
|
|
|
|
const invokeSendMessage = (msgObj) => {
|
|
|
|
|
const invokeSendMessage = async (msgObj) => {
|
|
|
|
|
if (isEmpty(toIM)) {
|
|
|
|
|
appNotification.warning({ message: '缺少WhatsApp号码, 请先在会话列表右键菜单编辑联系人', placement: 'top' });
|
|
|
|
|
return false
|
|
|
|
@ -108,7 +110,13 @@ const InputComposer = ({ channel, currentActive }) => {
|
|
|
|
|
// olog('sendMessage------------------', msgObjMerge)
|
|
|
|
|
const contentToSend = sentMsgTypeMapped[msgObjMerge.type].contentToSend(msgObjMerge);
|
|
|
|
|
// console.log('content to send-------------------------------------', contentToSend);
|
|
|
|
|
websocket.sendMessage({ ...contentToSend, opi_sn: userId, coli_sn: currentConversation.coli_sn || '', conversationid: currentConversation.sn, });
|
|
|
|
|
|
|
|
|
|
if (channel === 'whatsapp') {
|
|
|
|
|
const waObj = { from: fromIM.replace('+', ''), to: toIM.replace('+', ''), content: msgObj.text, };
|
|
|
|
|
await postSendMsg(waObj);
|
|
|
|
|
} else if (channel === 'waba') {
|
|
|
|
|
websocket.sendMessage({ ...contentToSend, opi_sn: userId, coli_sn: currentConversation.coli_sn || '', conversationid: currentConversation.sn, });
|
|
|
|
|
}
|
|
|
|
|
const contentToRender = sentMsgTypeMapped[msgObjMerge.type].contentToRender(msgObjMerge);
|
|
|
|
|
// console.log(contentToRender, 'contentToRender sendMessage------------------');
|
|
|
|
|
sentOrReceivedNewMessage(contentToRender.conversationid, contentToRender);
|
|
|
|
@ -365,6 +373,6 @@ const InputComposer = ({ channel, currentActive }) => {
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
InputComposer.propTypes = { channel: PropTypes.oneOf(['waba', 'wa']) };
|
|
|
|
|
InputComposer.propTypes = { channel: PropTypes.oneOf(['waba', 'whatsapp']) };
|
|
|
|
|
|
|
|
|
|
export default InputComposer;
|
|
|
|
|