官网/H5 支持企微客服跳转;用户资料新增 WecomKfUrl;工作台与下单相关体验一并更新。 Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { isMobileUserAgent, isWeChatBrowser } from '@/utils/device';
|
||
|
||
/**
|
||
* 企业微信客服(微信外接入链接)
|
||
* 管理后台 → 微信客服 → 在微信外接入 → 复制
|
||
* 可用 VITE_WECOM_KF_URL 覆盖;顾问资料里的 wecomKfUrl 优先
|
||
*/
|
||
export const WECOM_KF_URL = (
|
||
(import.meta.env.VITE_WECOM_KF_URL as string | undefined) ||
|
||
'https://work.weixin.qq.com/kfid/kfcae09c206f6c7045a'
|
||
).trim();
|
||
|
||
/**
|
||
* 微信内 / 手机:直跳唤起客服会话
|
||
* PC:打开企业微信客服页(自带扫码)
|
||
* @param url 可选,优先使用顾问个人接入链接
|
||
*/
|
||
export function openWecomKf(url?: string | null): void {
|
||
const target = (url?.trim() || WECOM_KF_URL).trim();
|
||
if (!target) return;
|
||
|
||
if (isWeChatBrowser() || isMobileUserAgent()) {
|
||
window.location.href = target;
|
||
return;
|
||
}
|
||
|
||
const w = 480;
|
||
const h = 720;
|
||
const left = Math.max(0, Math.round((window.screen.width - w) / 2));
|
||
const top = Math.max(0, Math.round((window.screen.height - h) / 2));
|
||
const popup = window.open(
|
||
target,
|
||
'ide_wecom_kf',
|
||
`width=${w},height=${h},left=${left},top=${top},noopener,noreferrer`,
|
||
);
|
||
if (!popup) {
|
||
window.location.href = target;
|
||
}
|
||
}
|