|
|
|
@ -33,7 +33,7 @@ export const ChatReset = () =>
|
|
|
|
|
document.title = "WebCAD";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const ChatButton = () =>
|
|
|
|
|
export const ChatButton = ({ isLoginInterface = false }) =>
|
|
|
|
|
{
|
|
|
|
|
const [load, setLoad] = useState(false);
|
|
|
|
|
const configId = "c7b08187-4adb-40ec-9b08-588ca829099f";
|
|
|
|
@ -58,7 +58,7 @@ export const ChatButton = () =>
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function createEasemobim()
|
|
|
|
|
function createOrUpdateEasemobim()
|
|
|
|
|
{
|
|
|
|
|
const { username, password } = userConfig.chat;
|
|
|
|
|
const login_name = localStorage.getItem(StoreageKeys.UserName);
|
|
|
|
@ -92,23 +92,29 @@ export const ChatButton = () =>
|
|
|
|
|
email: "",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (!isLoginInterface)
|
|
|
|
|
setLoad(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() =>
|
|
|
|
|
{
|
|
|
|
|
let myScript;
|
|
|
|
|
if (!window["easemobim"] && userConfig.chat.timeStamp)
|
|
|
|
|
if (!window["easemobim"] && (userConfig.chat.timeStamp || isLoginInterface))
|
|
|
|
|
{
|
|
|
|
|
myScript = document.createElement("script");
|
|
|
|
|
myScript.id = "easemob";
|
|
|
|
|
myScript.src = "https://kefu.easemob.com/webim/easemob.js";
|
|
|
|
|
myScript.async = false;
|
|
|
|
|
document.body.appendChild(myScript);
|
|
|
|
|
myScript.onload = function ()
|
|
|
|
|
{
|
|
|
|
|
createEasemobim();
|
|
|
|
|
createOrUpdateEasemobim();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else if (window["easemobim"])
|
|
|
|
|
{
|
|
|
|
|
createOrUpdateEasemobim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return () =>
|
|
|
|
|
{
|
|
|
|
@ -121,12 +127,12 @@ export const ChatButton = () =>
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{load ? (
|
|
|
|
|
{load || isLoginInterface ? (
|
|
|
|
|
<Button
|
|
|
|
|
className={"TopPanel_Btn04"}
|
|
|
|
|
small={true}
|
|
|
|
|
icon="people"
|
|
|
|
|
text="在线客服"
|
|
|
|
|
icon={isLoginInterface ? null : "people"}
|
|
|
|
|
text={isLoginInterface ? "联系客服" : "在线客服"}
|
|
|
|
|
style={{ position: "relative" }}
|
|
|
|
|
intent={Intent.PRIMARY}
|
|
|
|
|
onClick={(e) =>
|
|
|
|
@ -148,7 +154,8 @@ export const ChatButton = () =>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window["easemobim"].bind({
|
|
|
|
|
const easemobim = window["easemobim"];
|
|
|
|
|
easemobim.bind({
|
|
|
|
|
configId,
|
|
|
|
|
onmessage(message)
|
|
|
|
|
{
|
|
|
|
|