!2415 功能:登录界面新增联系客服功能

pull/2418/head
黄诗津 1 year ago committed by ChenX
parent c80fb79e1f
commit b86fd26a4d

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

@ -13,6 +13,7 @@ import { FileServer } from '../../../DatabaseServices/FileServer';
import { userConfig } from '../../../Editor/UserConfig'; import { userConfig } from '../../../Editor/UserConfig';
import { TopPanelStore } from '../../Store/TopPanelStore'; import { TopPanelStore } from '../../Store/TopPanelStore';
import { userConfigStore } from '../../Store/UserConfigStore'; import { userConfigStore } from '../../Store/UserConfigStore';
import { ChatButton } from '../ChatButton';
import { AppConfirm } from '../Common/Confirm'; import { AppConfirm } from '../Common/Confirm';
import GalleryStore from '../Gallery/GalleryStore'; import GalleryStore from '../Gallery/GalleryStore';
import { AppToaster } from '../Toaster'; import { AppToaster } from '../Toaster';
@ -243,7 +244,7 @@ export default class Login extends React.Component<{ store?: TopPanelStore; }, I
<img src={`${ResourcesCDN_HOST}wechat.webp`} alt="" /> <img src={`${ResourcesCDN_HOST}wechat.webp`} alt="" />
</a> </a>
</div> </div>
<div> <div className='account-operation'>
<a <a
style={{ textDecoration: 'underline', color: '#2d72d2', fontWeight: "bold" }} style={{ textDecoration: 'underline', color: '#2d72d2', fontWeight: "bold" }}
target="_blank" target="_blank"
@ -253,7 +254,10 @@ export default class Login extends React.Component<{ store?: TopPanelStore; }, I
target="_blank" target="_blank"
onClick={() => this.props.store.openRegist = true}></a> onClick={() => this.props.store.openRegist = true}></a>
</div> </div>
<div> <div className='account-operation'>
<ChatButton isLoginInterface={true} />
</div>
<div className='filing-number'>
<a target="_blank" href="https://beian.miit.gov.cn/"> <a target="_blank" href="https://beian.miit.gov.cn/">
<p>ICP14007219-4</p> <p>ICP14007219-4</p>
</a> </a>

@ -146,7 +146,7 @@
} }
} }
&>div:nth-child(6) { .account-operation {
padding: 0 40px; padding: 0 40px;
margin-top: 20px; margin-top: 20px;
@ -159,7 +159,7 @@
justify-content: space-between; justify-content: space-between;
} }
&>div:nth-child(7) { .filing-number {
position: absolute; position: absolute;
width: 100%; width: 100%;
text-align: center; text-align: center;

@ -1,5 +1,5 @@
import { Alignment, Button, Classes, HTMLSelect, Intent, Navbar, Position, ProgressBar, Switch, Tooltip } from '@blueprintjs/core'; import { Alignment, Button, Classes, HTMLSelect, Intent, Navbar, Position, ProgressBar, Switch, Tooltip } from '@blueprintjs/core';
import { observable } from 'mobx'; import { action, observable } from 'mobx';
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import { end } from 'xaop'; import { end } from 'xaop';
@ -91,6 +91,7 @@ export class TopPanel extends React.Component<{ store?: TopPanelStore; }, {}>
} }
this.props.store.onToggleTheme(); this.props.store.onToggleTheme();
}; };
@action
handleLoginOut = async () => handleLoginOut = async () =>
{ {
if (!app.Saved) if (!app.Saved)
@ -98,13 +99,17 @@ export class TopPanel extends React.Component<{ store?: TopPanelStore; }, {}>
let status = await AppConfirm.show({ message: "您当前图纸还未保存,是否继续?" }); let status = await AppConfirm.show({ message: "您当前图纸还未保存,是否继续?" });
if (!status) return; if (!status) return;
} }
this.props.store.isLogin = false;
let data = await Post(SignUrl.loginOut); let data = await Post(SignUrl.loginOut);
if (data.err_code === RequestStatus.Ok) if (data.err_code === RequestStatus.Ok)
{ {
DownPanelStore.GetInstance().isLayout = false; DownPanelStore.GetInstance().isLayout = false;
userConfigStore.ClearUserData(); userConfigStore.ClearUserData();
} }
if (IsOpenChat.get())
{
IsOpenChat.set(false);
}
this.props.store.isLogin = false;
}; };
render() render()
{ {
@ -155,7 +160,7 @@ export class TopPanel extends React.Component<{ store?: TopPanelStore; }, {}>
onClick={() => window.open("https://jq.qq.com/?_wv=1027&k=GiGl8Vlp")} onClick={() => window.open("https://jq.qq.com/?_wv=1027&k=GiGl8Vlp")}
/> />
} }
<ChatButton /> {this.props.store.isLogin && <ChatButton />}
{ {
IsOpenChat.get() && <Button IsOpenChat.get() && <Button
className={"TopPanel_Btn04"} className={"TopPanel_Btn04"}

Loading…
Cancel
Save