PageSourceSearch

https://www.mtegg.com/npublic/commonjs/smartService/smartService.js

js mtegg.com collected 2026-10-07 13:05:14 UTC 220,127 bytes, 3,154 lines download raw bytes

1var domain = ''
2if (__ce.env == "local") {
3    domain = "http://" + tenant.makeDomain
4}
5var lann = tenant.language == 'hn' ? 'es' : tenant.language
6var interwords = domain + "/npublic/commonjs/language/" + lann + ".js"
7$define([
8    'pl_util',
9    '/npublic/commonjs/emoji/emoji.js',
10    `/npublic/commonjs/cEditor/cEditor.js`,
11    'pl_toast',
12    interwords,
13    'cmsAjax',
14    '/npublic/commonjs/nouglify/marked.js',
15    '/npublic/commonjs/phoneCode/phoneCode.js',
16    'css!/npublic/commonjs/datePicker/datepicker.css',
17    '/npublic/commonjs/datePicker/datepicker.js',
18    'pl_multSelect'
19], function(u,emo,cEditor,plt,int,c,m,phoneCode,dpc,dp) {
20    class smartService {
21        constructor(option) {
22            this.res = option
23            this.settings = option.setting
24            this.automaticReply = JSON.parse(this.settings.automaticReply)
25            this.kefuHead = this.settings.headImg ? JSON.parse(this.settings.headImg).detail.watermarkUrl_symbol : ""
26            this.colorLayout = JSON.parse(this.settings.colorLayout)
27            this.color = this.colorLayout.windowColor
28            this.id = +new Date()
29            this.iconId = "smartIcon_" + this.id
30            this.conId = "smartService_" + this.id
31            this.nim = null
32            this.time = 7200
33            this.tTime=0
34            this.logout=false
35            this.tmpMsg=""
36            this.erroMsg = null
37            this.cEditor1 = null
38            this.sendBtn = null
39            this.timeLogoutEvent = null
40
41            this.greeting = null //自动话术定时任务
42            this.companyNoAnswerTimeout = null  //企业无应答计时任务
43            this.customreNoAnswerTimeout = null  //访客无应答计时任务
44            this.behaviorReportTimer = null; //上报行为轨迹计时任务
45            this.memberData = null;
46            this.isLoginFlag = null //是否登录
47            this.unreadMessageCount = 0; // 添加未读消息计数器
48            this.currentLang = ''
49            this.hasAlerted = false;
50            this.isWakeUp = false
51            this.resizeTimer = null //窗口resize防抖计时器
52
53            this.inviteSet = this.res?.inviteSet || {};
54            
55            console.log(this.res)
56            //判断是否需要显示表单
57            if(!this.res.submitChatFormFlag && this.res.enableChatForm){
58                //是否主动开启用户调查,默认开启
59                let formSet = this.settings.moreSetting ? JSON.parse(this.settings.moreSetting) : {}
60                this.needForm = formSet.chatSurveyForm ? formSet.chatSurveyForm.activeFlag !== false : true
61            }else{
62                this.needForm = false
63            }
64            this.init(this.needForm)
65
66
67            const root = document.documentElement;
68            root.style.setProperty('--smt-color', this.color);
69        }
70        //渲染dom
71        init(key){
72            if(this.res.enableAgentFlag) {
73                if(location.pathname == '/login.html') {
74                    return false;
75                }
76                setTimeout(() => {
77                    this.isLogin()
78                }, 1000);
79
80                // 初始化页面对象监听 30秒推荐商品
81                this.initPageObjListener();
82            }
83            if(key){//显示表单
84                $("body").append(this.getFormlog())
85                this.renderForm()
86            }else{//显示对话框
87                $("body").append(this.getDialog())
88                this.renderEvent()
89            }
90            //根据分辨率计算聊天内容区域高度,使弹窗更协调
91            this.calcOutputHeight()
92            $(window).on("resize."+this.conId,()=>{
93                clearTimeout(this.resizeTimer)
94                this.resizeTimer = setTimeout(()=>{
95                    this.calcOutputHeight()
96                },150)
97            })
98            //显示底部图标
99            if(this.colorLayout.entranceLocation==1){
100                $("body").append(this.getIcon())
101            }
102            //点击icon或按钮
103            $(document).on("click","[smartService]",()=>{
104                if($(".smartService.show").length>0){
105                    this.closeDialog()
106                }else{
107                    $(".greeting-btn").trigger('click')
108                    this.showFun()
109                }
110            })
111            //点击遮罩,还原对话框
112            $(document).on("click",".smartService-mask",()=>{
113                this.toggleExpand()
114            })
115            //自动弹出
116            let smartServiceClose = sessionStorage.getItem('smartServiceClose')
117            if(this.colorLayout.showFlag==1 && smartServiceClose!='true'){
118                this.showFun()
119            } else {
120                if(this.res.enableAgentFlag && this.colorLayout.showFlag==2) {
121                    this.createGreetingPopup();
122                }
123            }
124            //表单未提交前不建立IM连接,避免后台AI流程的唤起消息在.sm_output未渲染时被丢弃
125            if(!key){
126                this.logNim();
127            }
128
129            window.addEventListener('beforeunload', function() {
130                // 保存当前页面的 URL 和标题到 sessionStorage
131                sessionStorage.setItem('currentPageUrl', window.location.href);
132                sessionStorage.setItem('currentPageTitle', document.title);
133
134                // 在页面卸载前清理定时器
135                if (this.behaviorReportTimer) {
136                    clearTimeout(this.behaviorReportTimer);
137                    this.behaviorReportTimer = null;
138                }
139            });
140            if(this.res.enableInvite) {
141                // 初始化行为轨迹上报
142                this.initBehaviorReport();
143                this.initScrollListener();
144                this.inviteSetFn();
145            }
146
147            if(window.ZQSensorsObj && this.res.memberFlag && !this.isWakeUp){
148                this.isWakeUp = true
149                console.log("md智慧客服唤起")
150                let obj = {
151                    tenantId: tenant.tenantId, 
152                    iBusinessCode : "01",
153                    iBusinessName : "智慧客服业务线",
154                    iBusinessCustId : this.res.account
155                }
156                ZQSensorsObj.track('SmartServiceWakeUp',obj);
157            }
158
159            
160        }
161        isLogin(){
162            return c.cmsAjax.get('/fwebapi/member/detail/getMemberDetail').then(res => {
163                if (!res.data && (res.data.code || !res.data.user)) {
164                    this.isLoginFlag = false;
165                }else{
166                    if(res.data.code == 401) {
167                        // 未登录
168                        this.isLoginFlag = false;
169                        this.bindMember()
170                    } else {
171                        this.isLoginFlag = true;
172                        this.memberData = res;
173                    }
174                }
175                return this.isLoginFlag;
176            }).catch(err => {
177                this.isLoginFlag = false;
178                return false;
179            });
180        }
181
182        bindMember(){
183            c.cmsAjax.postJson(
184                `${this.res.domain}/visitormanager/intelligent/front/bindMember?tenantId=${tenant.tenantId}&instance=${tenant.bossProductInstance}`,
185                {
186                    "account":localStorage.getItem(`account_${tenant.tenantId}`),
187                    "memberId":getCookie('_memberId'),
188                }
189            ).then(res => {
190                if (res.data && res.data.code == 0) {
191                    this.createGreetingPopup
192                }
193            }).catch(err => {
194                // toLogin()
195            })
196        }
197        //表单初始化
198        renderForm(){
199            $("#"+this.conId+"-form").on("click",".sm_close",()=>{//关闭对话框
200                this.closeDialog()
201            }).on("input blur change valid",".msgform .p_inp",(e)=>{//表单校验
202                this.formValid($(e.currentTarget))
203            }).on("click",".msgform.workOrderMsgformBox .p_sub2",(e)=>{//表单提交
204                this.submitForm($(e.target),false, 'workOrder')
205            }).on("click",".msgform .p_sub",(e)=>{//表单提交
206                this.submitForm($(e.target),true)
207            }).on("click",".msgform .aggree input",(e)=>{//表单提交
208                if($(e.target).prop("checked")){
209                    $(e.target).parent().removeClass("noAggree")
210                }
211            }).on("click",".msgform .p_currentCode",(e)=>{//国家码
212                e.stopPropagation()
213                $(e.currentTarget).next(".p_codeList").toggle()
214            }).off("click",".p_phoneCode .p_codeItem").on("click",".p_phoneCode .p_codeItem",function(e){
215                e.stopPropagation()
216                $(e.currentTarget).addClass("p_active").siblings().removeClass("p_active")
217                let dialCode = $(e.currentTarget).find(".p_enDial").text()
218                let iso2 = $(e.currentTarget).find(".p_enCode").text()
219                let dialCodeDom = $(e.currentTarget).parents(".p_phoneCode").find(".p_currentCode span").eq(0)
220                let iso2Dom = $(e.currentTarget).parents(".p_phoneCode").find("[name='mobilePrefix']")
221                dialCodeDom.text(dialCode)
222                iso2Dom.val(dialCode+","+iso2)
223                $(e.currentTarget).parent(".p_codeList").hide()
224            })
225            //时间初始化
226            let dateInput = $("#"+this.conId+"-form").find(".j_date");
227            dateInput.each((i,e)=>{
228                let inp = $(e)
229                let subType = inp.find('.p_inp').attr('sub-type')
230                let dataP = inp.datePicker({
231                    hasShortcut: false,
232                    format: subType=='allDate'?'YYYY-MM-DD HH:mm:ss':'YYYY-MM-DD',
233                    hide: (type)=>{
234                        inp.find('.p_inp').trigger('change')
235                    }
236                });
237            })
238            //下拉初始化
239            let selectItem = $("#"+this.conId+"-form").find(".p_select");
240            selectItem.each((i,e)=>{
241                let inp = $(e)
242                let vinp = inp.find('.p_inp')
243                let subType = vinp.attr('sub-type')
244                let optInp = inp.find("input[name='dataItem']").val()
245                let placeholder = inp.find("input[name='dataItem']").attr('placeholder') || ''
246                if(optInp){
247                    let opts = []
248                    optInp = JSON.parse(optInp)
249                    optInp.forEach(e=>{
250                        opts.push({label:e.showValue,value:e.value})
251                    })
252                    let params = { 
253                        mult:subType=='selMulti'?true:false,//true为多选,false为单选
254                        option:opts,
255                        placeholder:placeholder,
256                        onChange:function(res){//选择框值变化返回结果
257                            if(subType=='selMulti'){
258                                vinp.val(res.join(",")).trigger("change");
259                            }else{
260                                vinp.val(res).trigger("change");
261                            }
262                        }
263                    }
264                    let multSelect= inp.find(".multSelect").multSelect(params);
265                    let presetVal = vinp.val()
266                    if(presetVal){
267                        multSelect.setResult(subType=='selMulti'?presetVal.split(","):presetVal)
268                    }
269                }
270            })
271        }
272        //初始化窗口方法
273        renderEvent(){
274            //发送按钮
275            this.sendBtn = $("#"+this.conId).find(".sm_sendBtn")
276            //错误提示
277            this.erroMsg = $("#"+this.conId).find(".erroMsg")
278            //初始化编辑器
279            this.cEditor1 = new cEditor({
280                element:'.sm_editor',
281                height:50,
282                windowStyle:this.colorLayout.windowStyle,
283                voiceSwitch:this.settings.voiceSwitch,
284                onchange:(data)=>{
285                    if(data){
286                        this.sendBtn.removeClass("disabled")
287                    }else{
288                        this.sendBtn.addClass("disabled")
289                    }
290                },
291                onenter:()=>{
292                    this.sendBtn.trigger('click')
293                }
294            })
295            $("#"+this.conId).on("click",".sm_close",()=>{//关闭对话框
296                this.closeDialog()
297            }).on("click",".sm_expand",(e)=>{//放大/还原对话框
298                e.stopPropagation()
299                this.toggleExpand()
300            }).on("click",".sm_sendBtn",(e)=>{//发送消息
301                if($(e.currentTarget).hasClass("disabled")){
302                    return
303                }
304                $(e.currentTarget).addClass("disabled")
305                let msg = this.handleEditorData(emo.emojiToHTML(this.cEditor1.getData()))
306                if(msg.length>5000){
307                    this.errorMsgFun(i18n.sms_tolong,'warning')
308                    return
309                }
310                let regstr = msg.replace(/\&nbsp\;/g,'').replace(/\n/g,'').trim()
311                let ar = encodeURI(regstr)
312                ar = ar.replace(/\%E2\%80\%8C/g,"")
313                if(ar==''){
314                    this.errorMsgFun(i18n.sms_empty,'warning')
315                    return
316                }
317                if(this.logout){
318                    this.tmpMsg = msg
319                    this.logNim()
320                    return 
321                }
322                
323                // 记录发送按钮点击时间
324                this.lastSendTime = new Date().getTime();
325                
326                this.sendText(msg)
327            }).on("click",".msgbtn a,.quea a",(e)=>{//选项按钮click,问题引导click
328                let url = $(e.target).attr("data-url")
329                if(url){
330                    window.open(url,"_blank")
331                }else{
332                    let msg = $(e.target).text()
333                    this.sendText(msg)
334                }
335            }).on("click",".confirmDialogTag",(e)=>{//确认卡片标签click
336                let msg = $(e.currentTarget).text()
337                this.sendText(msg)
338            }).on("click",".confirmDialogConfirmBtn",(e)=>{//确认卡片输入确认
339                let $input = $(e.currentTarget).siblings(".confirmDialogInput")
340                let msg = $input.val().trim()
341                if(!msg){
342                    return
343                }
344                this.sendText(msg)
345                $input.val("")
346            }).on("keydown",".confirmDialogInput",(e)=>{//确认卡片输入回车确认
347                if(e.which==13 || e.keyCode==13){
348                    e.preventDefault()
349                    $(e.currentTarget).siblings(".confirmDialogConfirmBtn").trigger("click")
350                }
351            }).on("click",".cardInfo",(e)=>{//名片click
352                let url = $(e.currentTarget).attr("data-url")
353                if(url){
354                    window.open(url,"_blank")
355                }
356            }).on("click",".msgform.workOrderMsgformBox .p_sub2",(e)=>{//表单提交
357                // this.submitForm($(e.target),false, 'workOrder');
358                this.checkLoginAndSubmit($(e.target), false, 'workOrder');
359            }).on("input blur change valid",".msgform .p_inp",(e)=>{//表单校验
360                this.formValid($(e.target))
361            }).on("click",".msgform .p_sub",(e)=>{//表单提交
362                this.submitForm($(e.target))
363            }).on("click",".ktitle a",(e)=>{//知识库换一换
364                let cg = $(e.target).attr("cg")
365                let ag = $(e.target).attr("ag")
366                let p = $(e.target).parent(".ktitle").next(".faq")
367                if(ag>cg){
368                    cg++
369                }else if(ag==cg){
370                    cg=0
371                }
372                $(e.target).attr("cg",cg)
373                p.find('.knoa').hide()
374                p.find(`.knoa[group="${cg}"]`).show()
375            }).on("click",'.knoa a',(e)=>{//点击知识
376                let id = $(e.target).attr("biz")
377                this.clickKnowledge(id)
378            }).on("click",".reply a",(e)=>{//是否
379                if($(e.target).hasClass("disabled")){
380                    return
381                }
382                let obj = {
383                    accid:this.res.account,
384                    progressId:$(e.target).attr("progressid"),
385                    operateType:$(e.target).attr("data-id"),
386                    msg:decodeURIComponent($(e.target).attr("msg")),
387                }
388                $(e.target).addClass("clicked")
389                $(e.target).parent(".reply").find("a").addClass("disabled")
390                let url = `${this.res.domain}/visitormanager/intelligent/front/contentResearch?tenantId=${tenant.tenantId}&instance=${tenant.bossProductInstance}`
391                c.cmsAjax.postJson(url,obj).then((res)=>{
392                    console.log(res)
393                })
394            }).on("click",".msgform .p_currentCode",(e)=>{//国家码
395                e.stopPropagation()
396                $(e.currentTarget).next(".p_codeList").toggle()
397            }).off("click",".p_phoneCode .p_codeItem").on("click",".p_phoneCode .p_codeItem",(e)=>{
398                e.stopPropagation()
399                $(e.currentTarget).addClass("p_active").siblings().removeClass("p_active")
400                let dialCode = $(e.currentTarget).find(".p_enDial").text()
401                let iso2 = $(e.currentTarget).find(".p_enCode").text()
402                let dialCodeDom = $(e.currentTarget).parents(".p_phoneCode").find(".p_currentCode span").eq(0)
403                let iso2Dom = $(e.currentTarget).parents(".p_phoneCode").find("[name='mobilePrefix']")
404                dialCodeDom.text(dialCode)
405                iso2Dom.val(dialCode+","+iso2)
406                $(e.currentTarget).parent(".p_codeList").hide()
407            }).on("click",".sms_read",(e)=>{
408                let _this = $(e.currentTarget)
409                let item = _this.parents(".sm_msg")
410                let content = item.find(".msgcon").text()
411                if(content){
412                    if(_this.hasClass("active")){
413                        $(".ttsAudio").remove()
414                        _this.removeClass("active")
415                    }else{
416                        $require(['/npublic/commonjs/nouglify/bdAudio.js'],()=>{
417                            $("#"+this.conId).find(".sms_read").removeClass("active")
418                            _this.addClass("active")
419                            $.bdAudio({
420                                text:content,
421                                onEnd:()=>{
422                                    _this.removeClass("active")
423                                },
424                                onError:()=>{
425                                    _this.removeClass("active")
426                                }
427                            })
428                        })
429                    }
430                }
431            }).on("click", ".sm_tab_link", (e) => {
432                const tabId = $(e.currentTarget).data("tab");
433                
434                // 更新激活状态
435                $(".sm_tab_link").removeClass("active");
436                $(e.currentTarget).addClass("active");
437                
438                // 显示对应的内容区域
439                $(".sm_tab_content").removeClass("active").hide();
440                $("#" + tabId + "-tab").addClass("active").show();
441
442                if (tabId === "member") {
443                    this.loadMemberInfo();
444                }
445            }).on("click", ".quick_label_item", (e) => {
446                // 获取 data-type 和 data-index
447                const dataType = $(e.currentTarget).data("type");
448                const index = $(e.currentTarget).data("index");
449                
450                // 检查数据是否存在
451                if (!this.res.quickLabel || !Array.isArray(this.res.quickLabel) || index >= this.res.quickLabel.length) {
452                    return;
453                }
454                
455                // 获取对应的数据
456                const data = this.res.quickLabel[index];
457                
458                // 根据 data-type 处理不同逻辑
459                switch (dataType) {
460                    case 0: // AI搜索
461                        // 在文本框中添加 "#AI搜索:" 并聚焦
462                        const currentText = this.cEditor1.getData();
463                        
464                        // 检查是否已经包含 "#AI搜索:",如果包含则不重复添加
465                        const trimmedText = currentText.trim();
466                        if (trimmedText.startsWith(`#${i18n.aiSearch || 'AI搜索' }:`)) {
467                            // 如果已经包含,则直接聚焦到编辑器
468                            this.cEditor1.focus();
469                            
470                            // 将光标移到 "#AI搜索:" 之后
471                            setTimeout(() => {
472                                const editorElement = document.querySelector('.cEditor-area');
473                                if (editorElement) {
474                                    const textContent = editorElement.textContent || editorElement.innerText;
475                                    const aiSearchIndex = textContent.indexOf(`#${i18n.aiSearch || 'AI搜索' }:`);
476                                    
477                                    if (aiSearchIndex !== -1) {
478                                        const range = document.createRange();
479                                        const selection = window.getSelection();
480                                        
481                                        // 找到 "#AI搜索:" 后面的位置
482                                        const targetPosition = aiSearchIndex + `#${i18n.aiSearch || 'AI搜索' }:`.length;
483                                        
484                                        // 遍历节点找到正确的位置
485                                        let currentCharIndex = 0;
486                                        let found = false;
487                                        
488                                        const traverseNodes = (node) => {
489                                            if (found) return;
490                                            
491                                            if (node.nodeType === Node.TEXT_NODE) {
492                                                const nodeText = node.textContent;
493                                                const nodeEndIndex = currentCharIndex + nodeText.length;
494                                                
495                                                if (targetPosition >= currentCharIndex && targetPosition <= nodeEndIndex) {
496                                                    // 光标应该放在这个文本节点的特定位置
497                                                    range.setStart(node, targetPosition - currentCharIndex);
498                                                    range.collapse(true); // 光标放在插入点
499                                                    selection.removeAllRanges();
500                                                    selection.addRange(range);
501                                                    found = true;
502                                                    return;
503                                                }
504                                                currentCharIndex = nodeEndIndex;
505                                            } else if (node.nodeType === Node.ELEMENT_NODE) {
506                                                for (let child of node.childNodes) {
507                                                    if (found) break;
508                                                    traverseNodes(child);
509                                                }
510                                            }
511                                        };
512                                        
513                                        traverseNodes(editorElement);
514                                    }
515                                }
516                            }, 0);
517                            return;
518                        }
519                        
520                        // 如果没有包含 "#AI搜索:",则添加并聚焦到末尾
521                        // 使用正确的方法设置编辑器内容
522                        if (typeof this.cEditor1.setData === 'function') {
523                            this.cEditor1.setData(`#${i18n.aiSearch || 'AI搜索' }:` + currentText);
524                        } else if (typeof this.cEditor1.setValue === 'function') {
525                            this.cEditor1.setValue(`#${i18n.aiSearch || 'AI搜索' }:` + currentText);
526                        } else {
527                            // 如果没有专门的设置方法,尝试直接操作DOM
528                            const editorElement = document.querySelector('.cEditor-area');
529                            if (editorElement) {
530                                editorElement.innerHTML = `#${i18n.aiSearch || 'AI搜索' }:` + currentText;
531                            }
532                        }
533                        this.cEditor1.focus();
534                        
535                        // 将光标移到文本末尾
536                        setTimeout(() => {
537                            const editorElement = document.querySelector('.cEditor-area');
538                            if (editorElement) {
539                                const range = document.createRange();
540                                const selection = window.getSelection();
541                                range.selectNodeContents(editorElement);
542                                range.collapse(false); // 将光标移到末尾
543                                selection.removeAllRanges();
544                                selection.addRange(range);
545                            }
546                        }, 0);
547                        break;
548                    case 1: // 发送文本消息
549                        if (data.desc) {
550                            this.sendText(data.desc);
551                        }
552                        break;
553                    case 2: // 打开链接
554                        let url = '';
555                        let _self = '';
556                        if (data.linkUrl) {
557                            if(data.linkUrl.indexOf('http')>-1) {
558                                url = data.linkUrl;
559                            } else {
560                                url = location.origin + data.linkUrl
561                            }
562                        }
563                        _self = data.windowType == 0 ? '_self' : '_blank'
564                        window.open(url, _self);
565                        break;
566                    case 3: // 唤起第三方应用
567                        if (data.threePartyTools && data.threePartyTools.account) {
568                            this.launchThirdPartyApp(data.threePartyTools.type, data.threePartyTools.account, data.threePartyTools, $(e.currentTarget));
569                        }
570                        break;
571                    default:
572                        console.warn("未知的 data-type:", dataType);
573                }
574            }).on("click", ".m_tags_info_item", (e) =>{
575                const dataTag = $(e.currentTarget).data("tag");
576                switch (dataTag) {
577                    case i18n.myProfile || '我的资料':
578                        window.open('/sys/information')
579                        break;
580                    case i18n.myOrder || '我的订单':
581                        window.open('/sys/order/list')
582                        break;
583                    case i18n.myFavorite || '我的收藏':
584                        window.open('/sys/collection')
585                        break;
586                    case i18n.myService || '我的服务':
587                        window.open('/sys/workorder/list')
588                        break;
589                    default:
590                        console.warn("未知的 data-tag:", dataTag);
591                }
592            }).on('click', '.relatedIssuesItem', (e) => {
593                let msg = $(e.currentTarget).text();
594                this.sendText(msg)
595            }).on("click",".replys a",(e)=>{//是否
596                let wtText = $(e.target).parents('.sm_msg').prev().find('.msgcon').text();
597                if($(e.target).hasClass("disabled")){
598                    return
599                }
600                let obj = {
601                    accid:this.res.account,
602                    operateType:$(e.target).attr("data-id"),
603                    msg:decodeURIComponent(wtText),
604                }
605                $(e.target).addClass("clicked")
606                let $replys = $(e.target).closest(".replys")
607                $replys.find("a").addClass("disabled")
608                let msgTime = $replys.attr("data-time")
609                if(msgTime){
610                    localStorage.setItem('replyResearch_' + msgTime, '1')
611                }
612                let isResolved = $(e.target).attr("data-id") == "1"
613                let tipText = isResolved ? i18n.solved : i18n.ApologyReminder
614                this.handleMsg(`<p class="prompt">${tipText}</p>`)
615                let url = `${this.res.domain}/visitormanager/intelligent/front/agentContentResearch?tenantId=${tenant.tenantId}&instance=${tenant.bossProductInstance}`
616                c.cmsAjax.postJson(url,obj).then((res)=>{
617                    console.log(res)
618                })
619            }).on('click', '.addWechat', (e) => {
620                $(e.target).parents('.cards').toggleClass('wx');
621            });
622        }
623
624        loadMemberInfo() {
625            const memberTab = $("#member-tab");
626            if (memberTab.find(".memberBox").length > 0) {
627                // 如果已经加载过,直接显示
628                return;
629            }
630            
631            // 显示加载状态
632            memberTab.find(".member-loading").show();
633            
634            // 重新检查登录状态
635            this.isLogin().then(() => {
636                // 隐藏加载状态
637                memberTab.find(".member-loading").hide();
638                
639                // 重新生成会员中心内容
640                this.renderMemberInfo();
641            }).catch(() => {
642                // 隐藏加载状态
643                memberTab.find(".member-loading").hide();
644                
645                // 重新生成会员中心内容
646                this.renderMemberInfo();
647            });
648        }
649
650        // 渲染会员信息
651        renderMemberInfo() {
652            const memberTab = $("#member-tab");
653            const memberType = this.memberData && this.memberData.data && this.memberData.data.user && this.memberData.data.user.type || '';
654            
655            let img = $.handleDataImg(this.memberData?.data?.user?.avatar || this.kefuHead) || '/npublic/commonjs/smartService/kefu.png';
656            
657            // 动态生成会员标签
658            let memberTags = '';
659            if (this.res.memberSet && Array.isArray(this.res.memberSet)) {
660                memberTags = this.res.memberSet.map((tag, index) => {
661                    switch (tag) {
662                        case '我的资料':
663                            tag = i18n.myProfile;
664                            break;
665                        case '我的订单':
666                            tag = i18n.myOrder;
667                            break;
668                        case '我的服务':
669                            tag = i18n.myService;
670                            break;
671                        case '我的收藏':
672                            tag = i18n.myFavorite;
673                            break;
674                        default:
675                            break;
676                    }
677                    return `<div class="m_tags_info_item" data-tag="${tag}" data-index="${index}">
678                        <span class="tag-icon"></span>${tag}
679                    </div>`
680                }).join('');
681            }
682            
683            let memberContent = '';
684            let memberIcon = '';
685            if(memberType == 1) {
686                memberIcon = '<svg t="1767579004512" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="55622" width="200" height="200"><path d="M928.914286 934.765714H103.862857c-21.942857 0-40.96-10.24-40.96-33.645714 0-23.405714 17.554286-35.108571 40.96-35.108571h23.405714v-687.542858c0-42.422857 32.182857-76.068571 73.142858-76.068571h396.434285c39.497143 0 73.142857 33.645714 73.142857 76.068571v106.788572h168.228572c39.497143 0 73.142857 33.645714 73.142857 76.068571v504.685715h20.48c21.942857 0 40.96 11.702857 40.96 35.108571-2.925714 21.942857-20.48 33.645714-43.885714 33.645714zM610.011429 340.845714V159.451429H188.708571v705.097142h421.302858V340.845714z m242.834285 0H668.525714v525.165715h182.857143V340.845714z m-512 35.108572h-70.217143c-21.942857 0-40.96-19.017143-40.96-42.422857 0-23.405714 17.554286-42.422857 40.96-42.422858h70.217143c21.942857 0 40.96 19.017143 40.96 42.422858 0 23.405714-19.017143 42.422857-40.96 42.422857z m0 156.525714h-70.217143c-21.942857 0-40.96-19.017143-40.96-42.422857 0-23.405714 17.554286-42.422857 40.96-42.422857h70.217143c21.942857 0 40.96 19.017143 40.96 42.422857 0 23.405714-19.017143 42.422857-40.96 42.422857z m0 156.525714h-70.217143c-21.942857 0-40.96-19.017143-40.96-42.422857 0-23.405714 17.554286-42.422857 40.96-42.422857h70.217143c21.942857 0 40.96 19.017143 40.96 42.422857 0 23.405714-19.017143 42.422857-40.96 42.422857z m184.32-313.051428h-70.217143c-21.942857 0-40.96-19.017143-40.96-42.422857 0-23.405714 17.554286-42.422857 40.96-42.422858h70.217143c21.942857 0 40.96 19.017143 40.96 42.422858 0 23.405714-19.017143 42.422857-40.96 42.422857z m223.817143 181.394285c-21.942857 0-40.96-19.017143-40.96-42.422857v-40.96c0-23.405714 17.554286-42.422857 40.96-42.422857 21.942857 0 40.96 19.017143 40.96 42.422857v40.96c-1.462857 23.405714-19.017143 42.422857-40.96 42.422857z m0 190.171429c-21.942857 0-40.96-19.017143-40.96-42.422857v-40.96c0-23.405714 17.554286-42.422857 40.96-42.422857 21.942857 0 40.96 19.017143 40.96 42.422857v40.96c-1.462857 23.405714-19.017143 42.422857-40.96 42.422857zM525.165714 532.48h-70.217143c-21.942857 0-40.96-19.017143-40.96-42.422857 0-23.405714 17.554286-42.422857 40.96-42.422857h70.217143c21.942857 0 40.96 19.017143 40.96 42.422857 0 23.405714-19.017143 42.422857-40.96 42.422857z m0 156.525714h-70.217143c-21.942857 0-40.96-19.017143-40.96-42.422857 0-23.405714 17.554286-42.422857 40.96-42.422857h70.217143c21.942857 0 40.96 19.017143 40.96 42.422857 0 23.405714-19.017143 42.422857-40.96 42.422857z m0 0" fill="" p-id="55623"></path></svg>'
687            } else {
688                memberIcon = '<svg t="1767579610704" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="56692" width="200" height="200"><path d="M817.75830078125 230.556640625H206.24082031250003c-48.2361328125 0-87.36767578125 38.7703125-87.36767578125 86.5775390625v389.69824218749994c0 47.82392578125 39.131542968750004 86.61181640625 87.36767578125 86.61181640625h611.5174804687499c48.251953125 0 87.36767578125-38.787890625 87.36767578125-86.61181640625v-389.69824218749994c0-47.8072265625-39.11396484375-86.5775390625-87.36767578125-86.5775390625zM354.45341796875 359.9580078125c42.08466796875 0 82.90019531249999 34.80205078125 82.90019531249999 72.30234375s-39.268652343750006 75.27392578125-82.90019531249999 75.27392578125c-42.08642578125 0-80.73808593749999-41.75947265625-80.73808593749999-79.224609375 0-37.4994140625 38.651660156249996-68.35166015625 80.73808593749999-68.35166015625zM504.43261718749994 664.0419921875H206.08613281249995v-15.33955078125c0-73.69365234374999 46.9125-128.28515625 149.46503906249998-128.28515625 102.53583984375 0 148.88144531249998 51.996972656249994 148.88144531249998 121.809375 0 2.78173828125 0.18896484375 19.032714843750004 0 21.8162109375z m313.61923828125003-54.333984375c0 5.97744140625-6.2525390624999995 10.787695312499999-14.0185546875 10.787695312499999H570.01923828125c-7.7642578124999995 0-14.034375-4.81025390625-14.034375-10.787695312499999v-21.64306640625c0-5.961621093750001 6.270996093749999-10.8228515625 14.034375-10.8228515625h234.0140625c7.766015625 0 14.0185546875 4.86123046875 14.0185546875 10.8228515625v21.64306640625z m0-87.36679687499999c0 5.97744140625-6.2525390624999995 10.8228515625-14.0185546875 10.8228515625H570.01923828125c-7.7642578124999995 0-14.034375-4.84541015625-14.034375-10.8228515625v-21.64306640625c0-5.9607421875 6.270996093749999-10.82197265625 14.034375-10.82197265625h234.0140625c7.766015625 0 14.0185546875 4.86123046875 14.0185546875 10.82197265625v21.64306640625z m0-86.16357421874999c0 5.95986328125-6.2525390624999995 10.82109375-14.0185546875 10.82109375H570.01923828125c-7.7642578124999995 0-14.034375-4.8603515625-14.034375-10.82109375v
688-21.6439453125c0-5.9958984375 6.270996093749999-10.8228515625 14.034375-10.8228515625h234.0140625c7.766015625 0 14.0185546875 4.826953124999999 14.0185546875 10.8228515625v21.6439453125z m0 0" p-id="56693" fill=""></path></svg>'
689            }
690            if(this.isLoginFlag) {
691                memberContent = `
692                    <div class="memberBox">
693                        <div class="m_cards">
694                            <div class="m_icons">
695                                ${memberIcon}
696                            </div>
697                            <div class="member_img">
698                                <img src="${img}" alt="${this.settings.name}" la="la" />
699                            </div>
700                            <div class="member_info">
701                                <div class="member_title">${i18n.memberNum || '会员号'}:${getCookie('_memberId') || '******'}</div>
702                                <div style="display: none;"><svg t="1766114967975" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="10638" width="200" height="200"><path d="M68.266667 955.733333V519.304533c0-63.488 48.196267-114.8928 107.656533-114.8928h78.848v86.152534H175.9232c-14.882133 0-26.965333 12.9024-26.965333 28.740266v350.208H273.066667V242.688C273.066667 184.046933 321.536 136.533333 381.201067 136.533333h329.864533C770.798933 136.533333 819.2 184.046933 819.2 242.688V273.066667l28.8768 0.068266C907.537067 273.066667 955.733333 324.539733 955.733333 387.959467V955.733333H68.266667z m642.798933-739.601066H381.201067a26.760533 26.760533 0 0 0-27.0336 26.624v626.756266H409.6v-65.672533C409.6 736.938667 455.4752 682.666667 512 682.666667s102.4 54.272 102.4 121.173333v65.672533h123.630933l0.068267-626.824533a26.760533 26.760533 0 0 0-27.0336-26.555733z m137.0112 143.086933H819.2v510.293333h55.773867V387.959467a28.330667 28.330667 0 0 0-21.435734-28.125867l-5.461333-0.6144zM512 768c-16.725333 0-30.242133 16.042667-30.242133 35.84l-0.068267 65.672533h60.552533v-65.672533c0-19.797333-13.5168-35.84-30.242133-35.84zM637.815467 477.866667c24.7808 0 44.8512 15.291733 44.8512 34.133333s-20.0704 34.133333-44.8512 34.133333H454.4512C429.6704 546.133333 409.6 530.8416 409.6 512s20.0704-34.133333 44.8512-34.133333h183.364267z m0-136.533334c24.7808 0 44.8512 15.291733 44.8512 34.133334s-20.0704 34.133333-44.8512 34.133333H454.4512C429.6704 409.6 409.6 394.308267 409.6 375.466667s20.0704-34.133333 44.8512-34.133334h183.364267z" fill="#FFFFFF" p-id="10639"></path></svg>xxx公司</div>
703                            </div>
704                            <div class="m_mark"></div>
705                        </div>
706                        <div class="${memberTags == '' ? 'hideDom' : ''}">
707                            <div class="m_tags_title"><svg t="1766114780148" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="10493" width="200" height="200"><path d="M519.68 27.136c25.984 5.632 46.528 25.6 53.12 51.392l75.264 295.168a25.6 25.6 0 0 0 19.2 18.624l276.928 62.336a70.4 70.4 0 0 1-4.608 138.24l-268.8 41.856a25.6 25.6 0 0 0-21.184 20.416l-58.24 297.152a70.4 70.4 0 0 1-137.984 0.64l-61.44-297.792a25.6 25.6 0 0 0-21.248-20.16L88.32 592.32a70.4 70.4 0 0 1-5.12-138.24l269.376-61.312a25.6 25.6 0 0 0 19.328-19.456l63.936-292.48a70.4 70.4 0 0 1 83.84-53.76zM169.984 732.16a118.4 118.4 0 1 1 0 236.8 118.4 118.4 0 0 1 0-236.8zM504.96 123.584l-58.112 266.112a102.4 102.4 0 0 1-77.312 77.952l-236.416 53.76 248.96 37.696a102.4 102.4 0 0 1 82.752 71.68l2.24 8.896 54.976 266.432 52.096-265.728a102.4 102.4 0 0 1 75.776-79.68l8.96-1.856 235.52-36.672-244.096-54.912a102.4 102.4 0 0 1-73.984-65.472l-2.752-9.152L504.96 123.584z m-334.976 685.44a41.6 41.6 0 1 0 0 83.2 41.6 41.6 0 0 0 0-83.2zM850.816 32.832a38.4 38.4 0 0 1 38.4 38.4v60.48l64 0.384a38.4 38.4 0 0 1-0.448 76.8l-63.552-0.384v59.2a38.4 38.4 0 0 1-76.8 0v-59.584l-50.88-0.256a38.4 38.4 0 0 1 0.384-76.8l50.496 0.256v-60.096a38.4 38.4 0 0 1 38.4-38.4z" fill="#165DFC" p-id="10494"></path></svg>${i18n.quickOperation || '快捷操作'}</div>
708                            <div class="m_tags_info">
709                                ${memberTags}
710                            </div>
711                        </div>
712                    </div>
713                `
714            } else {
715                memberContent = `<div class="memberBox">
716                    <div class="member_info">
717                        <div class="member_title toLogin">
718                            <svg t="1775179815896" class="member_svg icon" viewB
718ox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="25331" width="200" height="200"><path d="M527.36 272.384a169.984 169.984 0 1 0 169.984 169.984 169.984 169.984 0 0 0-169.984-169.984z m0 256A84.992 84.992 0 1 1 614.4 442.368a84.992 84.992 0 0 1-87.04 84.992z m0-424.96a424.96 424.96 0 1 0 425.472 424.96A424.96 424.96 0 0 0 527.36 102.4z m0 764.928a339.456 339.456 0 0 1-162.816-41.472 127.488 127.488 0 0 1 120.32-86.016h106.496a107.008 107.008 0 0 1 102.4 83.456 340.48 340.48 0 0 1-166.4 43.008zM768 768a190.976 190.976 0 0 0-175.104-114.176H484.864a212.48 212.48 0 0 0-190.976 119.296A340.48 340.48 0 1 1 768 768z" p-id="25332" data-spm-anchor-id="a313x.search_index.0.i0.243e3a81EgyJdc" class="selected"></path></svg>
719                            <p>${i18n.loginMore || '登录后享受更多会员服务'}</p>
720                            <a href="/login.html" target="_blank"><svg t="1775180776389" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="27197" width="200" height="200"><path d="M0 0h1024v1024H0z" fill="#ffffff" fill-opacity="0" p-id="27198"></path><path d="M885.333333 298.666667v426.666666A202.922667 202.922667 0 0 1 682.666667 928h-170.666667a32 32 0 1 1 0-64h170.666667A138.837333 138.837333 0 0 0 821.333333 725.333333V298.666667A138.837333 138.837333 0 0 0 682.666667 160h-170.666667a32 32 0 1 1 0-64h170.666667A202.922667 202.922667 0 0 1 885.333333 298.666667z m-265.386666 190.72l-170.666667-170.666667a32 32 0 1 0-45.269333 45.269333l116.053333 116.053334H170.666667a32 32 0 1 0 0 64h349.397333l-116.053333 116.053333a32 32 0 1 0 45.226666 45.269333l170.666667-170.666666a32.042667 32.042667 0 0 0 0.042667-45.312z" fill="#ffffff" p-id="27199"></path></svg>${i18n.toLogin || '去登录'}</a>
721                        </div>
722                    </div>
723                </div>`
724            }
725            
726            memberTab.html(memberContent);
727            
728            // 重新绑定会员标签点击事件
729            memberTab.off("click", ".m_tags_info_item").on("click", ".m_tags_info_item", (e) => {
730                const dataTag = $(e.currentTarget).data("tag");
731                switch (dataTag) {
732                    case i18n.myProfile || '我的资料':
733                        window.open('/sys/information')
734                        break;
735                    case i18n.myOrder || '我的订单':
736                        window.open('/sys/order/list')
737                        break;
738                    case i18n.myFavorite || '我的收藏':
739                        window.open('/sys/collection')
740                        break;
741                    case i18n.myService || '我的服务':
742                        window.open('/sys/workorder/list')
743                        break;
744                    default:
745                        console.warn("未知的 data-tag:", dataTag);
746                }
747            });
748        }
749        // 唤起三方应用
750        launchThirdPartyApp(type, account, dataThreePartyTools, item) {
751            switch (type) {
752                case 1: // QQ企业版
753                    window.location.href = `tencent://message/?uin=${account}`;
754                    break;
755                case 2: // 阿里旺旺
756                    // window.location.href = `wangwang://sendmsg?uid=${account}`;
757                    break;
758                case 3: // 阿里旺旺E客服
759                    window.location.href = `http://amos.alicdn.com/getcid.aw?v=2&uid=${account}&site=cntaobao&s=2&groupid=0&charset=utf-8`;
760                    break;
761                case 4: // Skype
762                    window.location.href = `skype:${account}?chat`;
763                    break;
764                case 5: // WhatsApp
765                    window.location.href = `https://api.whatsapp.com/send?phone=${account}&text=Hello`;
766                    break;
767                case 6: // 微信
768                    // 微信通常无法直接通过链接唤起,可以提示用户复制微信号
769                    console.log(`微信:${account}`, dataThreePartyTools);
770                    this.showWeChatPrompt(dataThreePartyTools, item)
771                    break;
772                case 7: // 微信
773                    // 微信通常无法直接通过链接唤起,可以提示用户复制微信号
774                    console.log(`名片:${account}`, dataThreePartyTools);
775                    this.showWeChatPrompt(dataThreePartyTools, item)
776                    break;
777                case 8: // 邮件
778                    window.location.href = `mailto:${account}`;
779                    break;
780                case 9: // 电话
781                    window.location.href = `tel:${account}`;
782                    break;
783                case 10: // 链接
784                    window.location.href = `tel:${link}`;
785                    break;
786                case 11: // 自定义
787                    window.location.href = `tel:${link}`;
788                    break;
789                case 12: // 智慧客服
790                    window.location.href = `tel:${link}`;
791                    break;
792                default:
793                    console.warn("不支持的第三方应用类型:", type, account);
794                    // alert("暂不支持该第三方应用的唤起功能");
795            }
796        }
797        // 在 smartService 类中添加显示微信提示框的方法
798        showWeChatPrompt(data, item) {
799            item.addClass('active')
800            if(item.siblings().hasClass('active')) {
801                $('.wechat-prompt').remove();
802                // 移除已存在的提示框
803                item.siblings().removeClass('active');
804            }
805            
806            // 创建微信提示框 HTML
807            const wechatPromptHtml = `
808                <div class="wechat-prompt">
809                    <div style="text-align: center;">
810                        <img src="${__ce.imgStaticUrl[0] + '/' + data.imageUrlArr[0].detail.watermarkUrl_symbol}" alt="微信二维码" style="width: 120px; height: 120px; margin: 0 auto; display: block;" />
811                    </div>
812                    <div class="custom_close">
812<svg t="1767872926130" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="30359" width="200" height="200"><path d="M512 70.772034c-243.685892 0-441.227966 197.550776-441.227966 441.227966 0 243.685892 197.542074 441.227966 441.227966 441.227966S953.227966 755.685892 953.227966 512C953.227966 268.32281 755.685892 70.772034 512 70.772034zM713.983275 656.253462c15.919864 15.960476 15.919864 41.780941 0 57.700805-15.948873 15.960476-41.780941 15.960476-57.729813 0L512 569.712408l-144.294074 144.241858c-15.908261 15.960476-41.740329 15.960476-57.692102 0-15.908261-15.919864-15.908261-41.740329 0-57.700805l144.28247-144.241858-144.28247-144.28247c-15.908261-15.919864-15.908261-41.751932 0-57.700805 15.948873-15.919864 41.780941-15.919864 57.692102 0l144.294074 144.28247 144.253462-144.28247c15.948873-15.919864 41.780941-15.919864 57.729813 0 15.919864 15.948873 15.919864 41.780941 0 57.700805l-144.28247 144.28247L713.983275 656.253462z" p-id="30360"></path></svg></div>
813                </div>
814            `;
815            
816            // 获取触发点击的元素位置
817            const $triggerElement = $(event.target).closest('.quick_label_item');
818            const offset = $triggerElement.offset();
819            const windowWidth = $(window).width();
820            
821            // 添加提示框到页面
822            const $prompt = $(wechatPromptHtml);
823
824            $('body').append($prompt);
825
826            $prompt.css({
827                top: offset.top - $prompt.outerHeight() - 10,
828                left: offset.left - 23
829            });
830            
831            // 检查右侧边界
832            if (offset.left + $('.wechat-prompt').width() > windowWidth) {
833                $('.wechat-prompt').addClass('windowRight');
834                $prompt.css({
835                    top: top,
836                    left: 'auto',
837                    right: 20
838                });
839            }
840
841            $('.custom_close').on('click', function() {
842                $('.wechat-prompt').remove();
843                item.removeClass('active')
844            })
845
846            $(window).on('scroll', function() {
847                $('.wechat-prompt').remove();
848                item.removeClass('active')
849            })
850
851            $('.quick_labels').on('scroll', function() {
852                $('.wechat-prompt').remove();
853                item.removeClass('active')
854            })
855        }
856        //点击知识
857        clickKnowledge(id){
858            this.handleReply(true)
859            let obj = {
860                accid:this.res.account,
861                bizId:id,
862            }
863            let url = `${this.res.domain}/visitormanager/intelligent/front/knowledgeTitleClick?tenantId=${tenant.tenantId}&instance=${tenant.bossProductInstance}`
864            c.cmsAjax.postJson(url,obj).then((res)=>{
865                console.log(res)
866            })
867        }
868        //正在回复
869        handleReply(key){
870            if(key){
871                $(".sm_reply").remove()
872                let msg = {
873                    type:"text",
874                    from:"reply",
875                    text:`<div class="dot-loader"><div class="dot"></div><div class="dot"></div><div class="dot"></div></div>`
876                }
877                this.handleMsg(msg)
878            }else{//清除回复
879                $(".sm_reply").remove()
880            }
881        }
882        getFormValue(item){
883            if(item.hasClass('p_checkbox') || item.hasClass('p_radio')){//复选框
884                let inp = item.find("input:checked"),tmpValue=[]
885                inp.each(function(i,e){
886                    tmpValue.push($(e).val())
887                })
888                return tmpValue.join(",")
889            }else{
890                return item.val() ? item.val().trim() : ""
891            }
892        }
893        //表单项校验
894        formValid(input){
895            let code = input.attr("data-type")
896            let formId = input.parents(".formIt")
897            let errorMsg = formId.find(".errorMsg")
898            let v = this.getFormValue(input)
899            let required = formId.attr('required')
900            if(!v){
901                if(required){
902                    formId.addClass("invalid")
903                    errorMsg.text(i18n.sms_error2)
904                }else{
905                    formId.removeClass("invalid")
906                    errorMsg.text("")
907                }
908            }else{
909                if(code=='mobile' && !/^[0-9\+-]+$/.test(v)){
910                    formId.addClass("invalid")
911                    errorMsg.text(i18n.form_invalidMobile)
912                }else if(code=='email' && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v)){
913                    formId.addClass("invalid")
914                    errorMsg.text(i18n.form_invalidEmail)
915                }else{
916                    formId.removeClass("invalid")
917                    errorMsg.text("")
918                }
919            }
920        }
921        //提交表单
922        submitForm(e,isForm, workOrder){
923            let form = e.parents(".msgform")
924            form.find(".p_inp").trigger("valid")
925            let invalid = form.find(`.invalid`).length
926            if(invalid==0){
927                let aggree = form.find(".aggree input")
928                if(aggree.length>0 && !aggree.prop("checked") && isForm){
929                    aggree.parent().addClass("noAggree")
930                    return
931                }else{
932                    aggree.parent().removeClass("noAggree")
933                }
934                let obj = {
935                    accid:this.res.account,
936                    terminal:this.getTerminal(),
937                    source:location.href
938                }
939                if(localStorage.getItem("ga4_cbo_custom_id")){
940                    obj.deviceNo = localStorage.getItem("ga4_cbo_custom_id")
941                }
942                if(!isForm){
943                    obj.progressId = form.attr("progressId")
944                }
945                form.find(".p_inp").each((i,e)=>{
946                    obj[$(e).attr("name")]=this.getFormValue($(e))
947                })
948                //将表单内容作为消息发送
949                let msgParts = []
950                form.find(".formIt").not(".aggree").each((i,e)=>{
951                    let formIt = $(e)
952                    let label = formIt.find(".formItLabel").text().trim()
953                    let val = formIt.find(".p_inp").not("[name='mobilePrefix']").map((i,inp)=>this.getFormValue($(inp))).get().filter(v=>v).join(",")
954                    if(label && val){
955                        msgParts.push(`${label}:${val}`)
956                    }
957                })
958                if(msgParts.length>0){
959                    this.sendText(msgParts.join("\n"))
960                }
961                if(!isForm){
962                    this.handleReply(true)
963                }
964                let url = ``;
965                if(workOrder) {
966                    url = `${this.res.domain}/visitormanager/intelligent/front/addWork?tenantId=${tenant.tenantId}&instance=${tenant.bossProductInstance}`;
967                    obj.memberId = getCookie('_memberId') || '';
968                } else {
969                    url = `${this.res.domain}/visitormanager/intelligent/front/addClue?tenantId=${tenant.tenantId}&instance=${tenant.bossProductInstance}`
970                    obj.formType = form.attr("formType") || ''
971                }
972                
973                c.cmsAjax.postJson(url,obj).then((res)=>{
974                    console.log(res)
975                    if(res.status==200 && res.data){
976                        if(res.data.code==200){
977                            if(isForm){
978                                this.needForm = false
979                                this.init(false)
980                                this.showFun()
981                            }else{
982                                if(workOrder) {
983                                    form.hide().siblings('.successBox').show();
984                                }
985                                this.handleReply(false)
986                                this.errorMsgFun(i18n.sms_success,'success')
987                            }
988                        }else if(res.data.code==10004){
989                            if(isForm){
990                                $.pl_toast({msg:i18n.sms_error1})
991                            }else{
992                                this.handleReply(false)
993                                this.errorMsgFun(i18n.sms_error1,'warning')
994                            }
995                        }
996                    }
997                })
998            }
999        }
1000        //放大/还原对话框
1001        toggleExpand(){
1002            let $win = $("#"+this.conId)
1003            let maskId = this.conId+"-mask"
1004            if($win.hasClass("expanded")){
1005                $win.removeClass("expanded")
1006                $("#"+maskId).remove()
1007            }else{
1008                $win.addClass("expanded")
1009                if($("#"+maskId).length==0){
1010                    $("body").append(`<div class="smartService-mask" id="${maskId}"></div>`)
1011                }
1012            }
1013            this.calcOutputHeight()
1014        }
1015        //根据当前分辨率/窗口尺寸,动态计算聊天内容区(sm_output)的高度,避免固定高度在不同屏幕下显得过高/过矮或超出可视区域
1016        calcOutputHeight(){
1017            let $win = $("#"+this.conId)
1018            let $output = $win.find(".sm_output")
1019            if($win.length==0 || $output.length==0){
1020                return
1021            }
1022            //放大模式下由flex布局自适应撑满,交还给CSS控制
1023            if($win.hasClass("expanded")){
1024                $output.css("height","")
1025                return
1026            }
1027            let vh = window.innerHeight || document.documentElement.clientHeight
1028            let isSmall = $win.hasClass("smallWindow")
1029            //标题栏、快捷标签、输入区等已占用的高度
1030            let reserved = ($win.find(".sm_title").outerHeight(true) || 0)
1031                + ($win.find(".sm_tabs_nav").outerHeight(true) || 0)
1032                + ($win.find(".sm_quickLabel").outerHeight(true) || 0)
1033                + ($win.find(".sm_input").outerHeight(true) || 0)
1034            //顶部/底部预留的安全边距,避免窗口贴边、超出可视区域
1035            let margin = isSmall ? 40 : 70
1036            let availableHeight = vh - reserved - margin
1037            //不同窗口样式下的基准高度及合理区间
1038            let baseHeight = isSmall ? 200 : 354
1039            let minHeight = isSmall ? 160 : 260
1040            let maxHeight = isSmall ? 320 : 560
1041            let height = Math.max(minHeight, Math.min(baseHeight, availableHeight, maxHeight))
1042            $output.css("height", height + "px")
1043        }
1044        //关闭窗口
1045        closeDialog(){
1046            //加入主动关闭标识
1047            sessionStorage.setItem('smartServiceClose','true')
1048            if(this.needForm){
1049                $("#"+this.conId+"-form").removeClass("show")
1050                return
1051            }
1052            $("#"+this.conId).removeClass("show expanded")
1053            $("#"+this.conId+"-mask").remove()
1054            this.cEditor1.clear()
1055            //清除自动话术
1056            clearInterval(this.greeting)
1057            //清除访客无应答计时
1058            clearTimeout(this.customreNoAnswerTimeout)
1059            //清除企业无应答计时
1060            clearTimeout(this.companyNoAnswerTimeout)
1061            if(!this.logout){
1062                this.renderLogout(true)
1063            }
1064            this.cleanup();
1065        }
1066        //登出,渲染提示
1067        renderLogout(k){
1068            console.log('退出')
1069            this.logout=true
1070            clearInterval(this.timeLogoutEvent)
1071            // this.nim.disconnect()
1072            if(!k){
1073                this.handleMsg(`<p class="prompt">———  ${i18n.sms_dk}   ———</p>`)
1074            }
1075        }
1076        //html转symbol
1077        handleEditorData(msg){
1078            //span前边
1079            let reg1 = /<span[\w\W]*?name=("|')/g
1080            let arr = msg.match(reg1)
1081            if(arr){
1082                arr.forEach(e=>{
1083                    msg = msg.replace(new RegExp(e,'g'),'')
1084                })
1085            }
1086            //span后边
1087            let reg2 = new RegExp(/\][\w\W]*?<\/span>/,'g')
1088            let arr2 = msg.match(reg2)
1089            if(arr2){
1090                arr2.forEach(e=>{
1091                    msg = msg.replace(new RegExp(e,'g'),']')
1092                })
1093            }
1094            //div前边
1095            msg = msg.replace(/<div>/g,'\n')
1096            //div后边
1097            msg = msg.replace(/<\/div>/g,'')
1098            //br
1099            msg = msg.replace(/<br>/g,'\n')
1100            //空格
1101            msg = msg.replace(/\&nbsp\;/g,' ')
1102            return msg
1103        }
1104        //错误提示
1105        errorMsgFun(txt,type){
1106            let ttype = type || "error"
1107            this.errorToast({type:ttype,msg:txt})
1108        }
1109        //错误提示-新
1110        errorToast(obj){
1111            let dialog = $("#"+this.conId+" .sm_dialog")
1112            let id = "toast_"+ +new Date()
1113            let iconObj = {
1114                'success':`<svg t="1723688024929" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="1723" width="200" height="200"><path d="M511.434623 63.564711c-247.428276 0-448.010617 200.582341-448.010617 448.01164 0 247.430322 200.581318 448.01164 448.010617 448.01164 247.432369 0 448.012663-200.581318 448.012663-448.01164C959.447287 264.147052 758.865969 63.564711 511.434623 63.564711zM773.519714 382.576325 447.871959 704.039781 245.771031 507.044128l63.996546-68.093864 138.15964 138.15964 261.086343-261.087367L773.519714 382.576325z" p-id="1724"></path></svg>`,
1115                'warning':`<svg t="1723688042921" class="icon" viewB
1115ox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="1869" width="200" height="200"><path d="M511.6 64.6c-247.4 0-448 200.6-448 448s200.6 448 448 448 448-200.6 448-448-200.6-448-448-448z m-0.1 717.9c-29.8 0-54-24.2-54-54s24.2-54 54-54 54 24.2 54 54c-0.1 29.9-24.2 54-54 54z m51.4-216.1c-1.5 27.9-24.1 50.1-51 53 2 0.2 3.7 1.1 5.7 1.1h-11.2c1.9 0 3.7-0.9 5.6-1.1-27-2.9-49.1-24.6-50.4-53l-12.4-269.7c-1.4-29.9 22-54.2 51.9-54.2H526c30 0 53.1 23.7 51.4 54.2l-14.5 269.7z" p-id="1870"></path></svg>`,
1116                'error':`<svg t="1723686236199" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="1577" width="200" height="200"><path d="M827.392 195.584q65.536 65.536 97.792 147.456t32.256 167.936-32.256 167.936-97.792 147.456-147.456 98.304-167.936 32.768-168.448-32.768-147.968-98.304-98.304-147.456-32.768-167.936 32.768-167.936 98.304-147.456 147.968-97.792 168.448-32.256 167.936 32.256 147.456 97.792zM720.896 715.776q21.504-21.504 18.944-49.152t-24.064-49.152l-107.52-107.52 107.52-107.52q21.504-21.504 24.064-49.152t-18.944-49.152-51.712-21.504-51.712 21.504l-107.52 106.496-104.448-104.448q-21.504-20.48-49.152-23.04t-49.152 17.92q-21.504 21.504-21.504 52.224t21.504 52.224l104.448 104.448-104.448 104.448q-21.504 21.504-21.504 51.712t21.504 51.712 49.152 18.944 49.152-24.064l104.448-104.448 107.52 107.52q21.504 21.504 51.712 21.504t51.712-21.504z" p-id="1578"></path></svg>`
1117            }
1118            dialog.append(`
1119                <div class="errorCon">
1120                    <div class="errorToast ${obj.type}" id="${id}">
1121                        ${iconObj[obj.type]||iconObj.error}<span>${obj.msg}</span>
1122                    </div>
1123                </div>
1124            `)
1125            var st = setTimeout(()=>{
1126                $("#"+id).remove()
1127            },2000)
1128        }
1129        //发送消息
1130        sendText(msg){
1131            this.sensitiveFun(msg,(words)=>{
1132                if(words.length>0){
1133                    this.errorToast({type:'error',msg:window.i18n.form_mgc+":"+words.join(",")})
1134                    return
1135                }
1136                var tms = this.nim.sendText({
1137                    scene: 'p2p',
1138                    to: this.settings.account,
1139                    text: msg,
1140                    custom: this.tdk,
1141                    done: (error, msg)=>{
1142                        $(window).trigger("sms_sendMsg",{account:this.res.account})
1143                        if(error){
1144                            this.errorMsgFun(i18n.sms_fail,'error')
1145                            return
1146                        }
1147                        console.log('发送消息' ,msg);
1148                        this.handleMsg(msg)
1149                        this.handleReply(true)
1150                        this.cEditor1.clear()
1151                        this.cEditor1.focus()
1152                        if(!this.res.enableSmartCustomer){
1153                            //启动企业无应答计时
1154                            this.companyNoAnswerFun()
1155                            //清除自动话术
1156                            clearInterval(this.greeting)
1157                            //清除访客无应答计时
1158                            clearTimeout(this.customreNoAnswerTimeout)
1159                        }
1160                    }
1161                });
1162            })
1163            
1164        }
1165        //敏感词过滤
1166        sensitiveFun(v,callback){
1167            let url = "/fwebapi/cms/sensitive/findContentContainWords"
1168            c.cmsAjax.postJson(url,{content:v,type:1}).then((res)=>{
1169                try{
1170                    callback(res.data.result)
1171                }catch(e){
1172                    callback([])
1173                }
1174            }).catch((err)=>{
1175                callback([])
1176            })
1177        }
1178        //登录nim
1179        logNim(){
1180            $require(['/npublic/commonjs/smartService/NIM_Web_SDK_v9.6.4.js'],()=>{
1181                this.tTime=0
1182                this.timeLogout()
1183                if(this.nim){
1184                    this.nim.connect()
1185                    return
1186                }
1187                this.tdk = {
1188                    title: document.title || '',
1189                    keywords: $('meta[name="keywords"]').attr('content') || '',
1190                    description: $('meta[name="description"]').attr('content') || ''
1191                }
1192                console.log('当前页面tdk', this.tdk)
1193                this.nim = SDK.NIM.getInstance({
1194                    debug: false,   // 是否开启日志,将其打印到console。集成开发阶段建议打开。
1195                    appKey: this.res.appKey,
1196                    account: this.res.account,
1197                    token: this.res.token,
1198                    db:false, //若不要开启数据库请设置false。SDK默认为true。
1199                    onconnect: ()=> {
1200                        console.log('连接成功');
1201                        this.logout=false
1202                        if(this.tmpMsg){
1203                            this.sendText(this.tmpMsg)
1204                            this.tmpMsg=""
1205                        }
1206                        
1207                        // 连接成功后隐藏 loading 消息
1208                        this.hideLoadingMessage();
1209                        
1210                        if(!this.res.enableSmartCustomer){
1211                            console.log('启动默认话术',this.automaticReply)
1212                            //启动默认话术
1213                            this.greetingFun()
1214                        }
1215                        // $("#"+this.conId+" .cEditor-area").focus()
1216                        this.unreadMessageCount = this.getUnreadCountFromStorage(); // 添加未读消息计数器
1217                        this.updateUnreadBadge(); // 更新未读消息角标
1218                    },
1219                    onwillreconnect: (obj)=> {
1220                        // 此时说明 SDK 已经断开连接, 请开发者在界面上提示用户连接已断开, 而且正在重新建立连接
1221                        console.log('即将重连',obj.retryCount,obj.duration);
1222                    },
1223                    ondisconnect: (error)=> {
1224                        // 此时说明 SDK 处于断开状态, 开发者此时应该根据错误码提示相应的错误信息, 并且跳转到登录页面
1225                        console.log('丢失连接',error);
1226                    },
1227                    onerror: (error)=> {
1228                        console.log('发生错误',error);
1229                    },
1230                    onroamingmsgs: (obj)=> {
1231                        console.log('收到漫游消息', obj);
1232                        obj.msgs.forEach(e=>{
1233                            this.handleMsg(e)
1234                        })
1235                    },
1236                    onofflinemsgs: (obj)=> {
1237                        console.log('收到离线消息', obj);
1238                        obj.msgs.forEach(e=>{
1239                            this.handleMsg(e)
1240                        })
1241                    },
1242                    onmsg: (msg)=> {
1243                        console.log('收到消息', msg);
1244                        this.handleReply(false)
1245                        // 收到消息时也隐藏 loading 消息
1246                        this.hideLoadingMessage();
1247
1248                        // 检测窗口是否显示
1249                        const isWindowVisible = $(".smartService.show").length > 0;
1250                        
1251                        if (!isWindowVisible) {
1252                            // 窗口隐藏状态下收到消息,增加未读计数
1253                            this.unreadMessageCount++;
1254                        }
1255                        
1256                        this.handleMsg(msg,true)
1257
1258                        // 更新未读角标
1259                        this.updateUnreadBadge();
1260
1261                        // 跑马灯:仅在窗口未打开且是客服消息时触发
1262                        if (!isWindowVisible && msg.from == this.settings.account) {
1263                            let invitationType = this.inviteSet && this.inviteSet.invitation && this.inviteSet.invitation.invitationType
1264                            if (invitationType == 1 || invitationType == 3) {
1265                                let hasStrategyType = false
1266                                if (msg.type === 'custom') {
1267                                    try {
1268                                        let msgObject = JSON.parse(msg.content)
1269                                        hasStrategyType = !!(msgObject.aiAgent && msgObject.aiAgent.strategyType)
1270                                    } catch(e) {}
1271                                }
1272                                if (hasStrategyType) {
1273                                    this.showMarquee(msg)
1274                                }
1275                            }
1276                        }
1277                        
1278                        if(!this.res.enableSmartCustomer){
1279                            //启动访客无应答计时
1280                            this.noAnswerFun()
1281                            //清除企业无应答任务
1282                            clearTimeout(this.companyNoAnswerTimeout)
1283                        }
1284                    }
1285                });
1286            })
1287        }
1288        //企业无应答话术
1289        companyNoAnswerFun(){
1290            console.log('企业无应答开始计时')
1291            let time = this.automaticReply.companyNoAnswerInterval
1292            let unit = this.automaticReply.companyNoAnswerIntervalUnit == 'm' ? 60 : 1
1293            this.companyNoAnswerTimeout = setTimeout(()=>{
1294                let msg = {
1295                    type:"text",
1296                    from:this.settings.account,
1297                    text:this.automaticReply.companyNoAnswerSpeech
1298                }
1299                this.handleMsg(msg)
1300                clearTimeout(this.companyNoAnswerTimeout)
1301            },time*unit*1000)                     
1302        }
1303        //访客无应答话术
1304        noAnswerFun(){
1305            console.log('访客无应答开始计时')
1306            let time = this.automaticReply.noAnswerInterval
1307            let unit = this.automaticReply.noAnswerIntervalUnit == 'm' ? 60 : 1
1308            this.customreNoAnswerTimeout = setTimeout(()=>{
1309                let msg = {
1310                    type:"text",
1311                    from:this.settings.account,
1312                    text:this.automaticReply.noAnswerSpeech
1313                }
1314                this.handleMsg(msg)
1315                clearTimeout(this.customreNoAnswerTimeout)
1316            },time*unit*1000)                               
1317        }
1318        //默认自动话术
1319        greetingFun(){
1320            //同一会话(标签页)只问候一次,避免每次刷新/重连都重发欢迎语
1321            let greetedKey = 'smtGreeted_' + this.res.account
1322            if(sessionStorage.getItem(greetedKey) === '1'){
1323                return
1324            }
1325            sessionStorage.setItem(greetedKey, '1')
1326            let msgList = []
1327            for(var i = 0; i<this.automaticReply.greetingRotationNum; i++){
1328                if(this.automaticReply.greeting1){
1329                    msgList.push({
1330                        type:"text",
1331                        from:this.settings.account,
1332                        text:this.automaticReply.greeting1
1333                    })
1334                }
1335                if(this.automaticReply.greeting2){
1336                    msgList.push({
1337                        type:"text",
1338                        from:this.settings.account,
1339                        text:this.automaticReply.greeting2
1340                    })
1341                }
1342                if(this.automaticReply.greeting3){
1343                    msgList.push({
1344                        type:"text",
1345                        from:this.settings.account,
1346                        text:this.automaticReply.greeting3
1347                    })
1348                }
1349            }
1350            console.log(msgList)
1351            var i = 0
1352            this.handleMsg(msgList[i])
1353            this.greeting = setInterval(()=>{
1354                i++
1355                if(i>=msgList.length){
1356                    i = 0
1357                    clearInterval(this.greeting)
1358                    return 
1359                }
1360                this.handleMsg(msgList[i])
1361            },this.automaticReply.speechContentInterval*1000)
1362        }
1363        //定时退出任务
1364        timeLogout(){
1365            this.timeLogoutEvent = setInterval(()=>{
1366                this.tTime++
1367                // console.log(this.tTime,this.time)
1368                if(this.tTime>=this.time){
1369                    this.renderLogout()
1370                }
1371            },1000)
1372        }
1373        //渲染消息
1374        handleMsg(msg,k){
1375            if(msg.from == this.settings.account){
1376                if(!msg.time){
1377                    msg.time = +new Date()
1378                }
1379                $('.sm_output').append(this.adminHtml(msg,k))
1380            }else if(msg.from == this.res.account){
1381                if(!msg.time){
1382                    msg.time = +new Date()
1383                }
1384                $('.sm_output').append(this.customerHtml(msg))
1385            }else if(msg.from == 'reply'){
1386                if(!msg.time){
1387                    msg.time = +new Date()
1388                }
1389                $('.sm_output').append(this.adminHtml(msg))
1390            }else{
1391                $('.sm_output').append(msg)
1392            }
1393
1394            // 只显示最后一个 aiAgent_reply
1395            const $allReplies = $('.sm_output .aiAgent_reply')
1396            $allReplies.hide()
1397            $allReplies.last().show()
1398            $allReplies.each(function() {
1399                if($(this).find('a.clicked').length) {
1400                    $(this).show()
1401                }
1402            })
1403            // adminHtml 执行完后:sm_msg 下有可见的 aiAgent_reply 则给 msgcon 加 mb20,否则移除
1404            $('.sm_output .sm_msg').each(function() {
1405                const $aiAgentReply = $(this).find('.aiAgent_reply')
1406                $(this).find('.msgcon').toggleClass('mb20', $aiAgentReply.length > 0 && $aiAgentReply.is(':visible'))
1407            })
1408
1409            // 如果用户未登录,检查是否需要添加登录提示到当天第一条消息
1410            if (this.res.memberFlag) {
1411                // 检查是否已确认未登录
1412                if (this.isLoginFlag === false) {
1413                    // 延迟执行,确保DOM已渲染
1414                    setTimeout(() => {
1415                        this.addLoginPromptToFirstMessage();
1416                    }, 0);
1417                } else if (this.isLoginFlag === null) {
1418                    // 如果尚未确定登录状态,先获取状态再决定
1419                    // this.isLogin().then(() => {
1420                    //     if (this.isLoginFlag === false) {
1421                    //         setTimeout(() => {
1422                    //             this.addLoginPromptToFirstMessage();
1423                    //         }, 0);
1424                    //     }
1425                    // });
1426                }
1427            }
1428
1429    
1430            $('.sm_output').scrollTop(99999999)
1431            $('.sm_output a[href!="javascript:;"]').attr("target","_blank")
1432            $('.sm_output a[href^="mailto:"],.sm_output a[href^="tel:"]').attr("rel","nofollow")
1433            setTimeout(()=>{
1434                $('.sm_output').scrollTop(99999)
1435            },1000)
1436
1437            this.tTime=0;
1438            
1439            // 检查是否是漫游消息并且窗口已经显示
1440            const isRoamingMsg = (msg.from == this.settings.account || msg.from == this.res.account || msg.from == 'reply') && 
1441                                !k; // k 参数为 false 或 undefined 时表示是漫游消息
1442            const isWindowVisible = $(".smartService.show").length > 0;
1443            if (isRoamingMsg && isWindowVisible && this.lastSendTime) {
1444                // 如果是漫游消息且窗口已显示,且之前点击过发送按钮
1445                const msgTime = msg.time || +new Date();
1446                if (msgTime > this.lastSendTime) {
1447                    // 如果消息时间在点击发送按钮之后,添加提示
1448                    this.addCurrentSessionTipIfNeeded();
1449                    // 清除发送时间记录,避免重复添加提示
1450                    // this.lastSendTime = null;
1451                }
1452            } else {
1453                if (!this.lastSendTime && this.res.enableAgentFlag) {
1454                    this.manageMessagesDisplay();
1455                }
1456            }
1457
1458            // 显示最后一个 .sm_msg.ad 中的 .aiAgent_relatedIssues
1459            this.showLastRelatedIssues();
1460        }
1461        // 添加登录提示到消息内容中
1462        addLoginPromptToFirstMessage() {
1463            // 暂时只有两种语言
1464            const langArr = [
1465                { "zh_CN": "登录会员,可享受更多专属服务和优惠" },
1466                { "en": "Logged-in members, can enjoy more exclusive services and discounts" },
1467                // { "de": "Angemeldete Mitglieder, können mehr exklusive Dienste und Rabatte genießen" },
1468                // { "fr": "Les membres connectés, peuvent profiter de plus de services exclusifs et de réductions" },
1469                // { "ru": "Авторизованные участники, могут наслаждаться большим количеством эксклюзивных услуг и скидок" },
1470                // { "pt": "Membros conectados, podem desfrutar de mais serviços exclusivos e descontos" },
1471                // { "ko": "로그인한 회원, 더 많은 독점 서비스와 할인 혜택을 누릴 수 있습니다" },
1472                // { "ja": "ログイン会員, より多くの専用サービスと割引をお楽しみいただけます" },
1473                // { "es": "Los miembros conectados, pueden disfrutar de más servicios exclusivos y descuentos" },
1474                // { "ar": "الأعضاء المسجلين, يمكنهم الاستمتاع بمزيد من الخدمات والحسومات الحصرية" },
1475                // { "it": "I membri connessi, possono godere di più servizi esclusivi e sconti" },
1476                // { "bn": "লগইন করা সদস্য, আরও বিশেষ সেবা এবং ছাড় উপভোগ করতে পারেন" },
1477                // { "da": "Loggede medlemmer, kan nyde flere eksklusive tjenester og rabatte" },
1478                // { "idn": "Anggota yang masuk, dapat menikmati lebih banyak layanan eksklusif dan diskon" },
1479                // { "th": "สมาชิกที่ล็อกอิน, สามารถใช้บริการและสิทธิพิเศษเพิ่มเติมได้" },
1480                // { "vi": "Thành viên đã đăng nhập, có thể tận hưởng nhiều dịch vụ và ưu đãi độc quyền hơn" },
1481                // { "tr": "Giriş yapmış üyeler, daha fazla özel hizmet ve indirimden yararlanabilir" },
1482                // { "nl": "Ingelogde leden, kunnen genieten van meer exclusieve services en kortingen" },
1483                // { "pl": "Zalogowani członkowie, mogą korzystać z więcej wyłącznych usług i rabatów" },
1484                // { "zh_HN": "登錄會員,可享受更多專屬服務和優惠" },
1485                // { "cs": "Přihlášení členové, mohou užívat více exkluzivních služeb a slev" },
1486                // { "ee": "Sisse logitud liikmed, saavad nautida rohkem eksklusiivseid teenuseid ja soodustusi" },
1487                // { "fi": "Kirjautuneet jäsenet, voivat nauttia enemmän yksityiskohtaisia palveluita ja alennuksia" },
1488                // { "el": "Οι συνδεδεμένοι μέλη, μπορούν να απολαύσουν περισσότερες αποκλειστικές υπηρεσίες και προσφορές" },
1489                // { "hu": "A bejelentkezett tagok, élvezhetik a további kizárólagos szolgáltatásokat és kedvezményeket" },
1490                // { "gg": "Вхід здійснивші членів, можуть скористатися додатковими ексклюзивними послугами та знижками" },
1491                // { "hr": "Prijavljeni članovi, mogu uživati više ekskluzivnih usluga i popusta" },
1492                // { "ga": "Is féidir le baill logáilte isteach, tairbhe a bhaint as níos mó seirbhísí agus lascainní eisiacha" },
1493                // { "ro": "Membrii conectați, pot beneficia de mai multe servicii și reduceri exclusive" },
1494                // { "lv": "Pierakstījušies biedri, var izmantot vairāk ekskluzīvu pakalpojumu un atlaidi" },
1495                // { "mt": "Il-membri logġati, jistgħu jgawdu aktar servizzi u sconti eksklużivi" },
1496                // { "sk": "Prihlásení členovia, môžu užívať viac exkluzívnych služieb a zľav" },
1497                // { "si": "ප්‍රවේශ කර ඇති සభ్యుల, වැඩි ප්‍රමාණයක විශේෂ සේවා සහ සкид දීම් ලබා ගත හැකිය" },
1498                // { "sv": "Inloggade medlemmar, kan njuta av fler exklusiva tjänster och rabatter" },
1499                // { "lt": "Prisijungę nariai, gali naudotis daugiau išskirtinių paslaugų ir nuolaidų" },
1500                // { "ml": "ലോഗിൻ ചെയ്ത അംഗങ്ങൾ, കൂടുതൽ പ്രത്യേക സേവനങ്ങളും കിഴിവുകളും ലഭിക്കും" },
1501                // { "bur": "ဝင်ရောက်ထားသောအဖွဲ့ဝင်များ, ပိုမိုအထူးသတ်မှတ်ထားသောဝန်ဆောင်မှုများနှင့်လျှော့စျေးများကိုသုံးစွဲနိုင်သည်" },
1502                // { "kh": "សមាជិកដែលបានចូលគណនី, អាចទទួលបានសេវាកម្ម និងការបញ្ចុះតម្លៃពិសេសបន្ថែមទៀត" },
1503                // { "la": "Membri qui sunt logati, pot profita de mai multe servicii si reduceri exclusive" },
1504                // { "ph": "Ang mga miyembrong nakalog-in, ay maaaring mag-enjoy ng higit pang mga eksklusibong serbisyo at diskwento" },
1505                // { "fa": "اعضای وارد شده, می‌توانند از خدمات و تخفیف‌های انحصاری بیشتری لذت ببرند" },
1506                // { "uk": "Увійшовші члени, можуть скористатися додатковими ексклюзивними послугами та знижками" },
1507                // { "ta": "உள்நுழைந்த உறுப்பினர்கள், மேலும் சிறப்பு சேவைகள் மற்றும் தள்ளுபடிகள் கிடைக்கும்" },
1508                // { "mn": "Нэвтэрсэн гишүүд, илүү дэлхийдээ шилдэг үйлчилгээ болон хямдрал авах боломжтой" },
1509                // { "kk": "Кіруші мүшелер, көбірек есклюзивті қызметтер мен жеңілдіктер беріледі" },
1510                // { "hi": "लॉग इन किए गए सदस्य, अधिक विशेष सेवाओं और छूटों का आनंद ले सकते हैं" }
1511            ]
1512            let lang = this.currentLang || 'zh_CN';
1513            console.log('当前使用语言', lang);
1514            let custText = langArr.filter(item => item[lang])[0][lang]
1515            const $output = $('.sm_output');
1516            const $messages = $output.find('.sm_msg');
1517            
1518            // 获取今天的日期(时间戳)
1519            const today = new Date();
1520            today.setHours(0, 0, 0, 0);
1521            const todayTimestamp = today.getTime();
1522            
1523            // 找到今天的第一条消息
1524            let firstTodayMessage = null;
1525            $messages.each(function() {
1526                const msgTime = parseInt($(this).attr('data-time')) || 0;
1527                if (msgTime >= todayTimestamp) {
1528                    firstTodayMessage = $(this);
1529                    return false; // 跳出循环
1530                }
1531            });
1532            
1533            // 如果找到了今天的第一条消息,并且还没有添加登录提示,则添加
1534            if (firstTodayMessage && !firstTodayMessage.find('.login-prompt').length) {
1535                const $msgCon = firstTodayMessage.find('.msgcon .cItem').last();
1536                if ($msgCon.length > 0) {
1537                    // 在msgcon中添加登录提示
1538                    const loginPrompt = $(`<div class="cItem login-prompt" style="font-weight: 600;"><a href="/login.html" target="_blank">
1538${custText.split(',')[0] || i18n.loginMember || '登录会员'}</a>${custText.split(',')[1] || i18n.loginMore2 || '可享受更多专属服务和优惠'}</div>`);
1539                    $msgCon.after(loginPrompt);
1540                } else {
1541                    // 如果没有msgcon,添加到消息主体中
1542                    // const loginPrompt = $(`<div class="cItem login-prompt" style="font-weight: 600;"><a href="/login.html">${custText.split(',')[0] || i18n.loginMember || '登录会员'}</a>${custText.split(',')[1] || i18n.loginMore2 || '可享受更多专属服务和优惠'}</div>`);
1543                    // firstTodayMessage.after(loginPrompt);
1544                }
1545            }
1546        }
1547        addCurrentSessionTipIfNeeded() {
1548            const $output = $('.sm_output');
1549            const $messages = $output.find('.sm_msg');
1550            
1551            // 检查是否已存在提示
1552            if ($output.find('.current-session-tip').length > 0) {
1553                return; // 已存在提示,无需再次添加
1554            }
1555            
1556            // 只有在有消息时添加提示
1557            if ($messages.length > 0 && this.lastSendTime) {
1558                let firstNewMessage = null;
1559                
1560                // 遍历所有消息,找到第一条时间大于 lastSendTime 的消息
1561                $messages.each(function() {
1562                    const msgTime = $(this).data('time') || +new Date($(this).find('.time').text());
1563                    if (msgTime > this.lastSendTime) {
1564                        firstNewMessage = $(this);
1565                        return false; // 跳出循环
1566                    }
1567                }.bind(this));
1568                
1569                // 如果找到了第一条新消息,在它前面添加提示
1570                if (firstNewMessage) {
1571                    const tipElement = $(`<div class="current-session-tip" style="text-align: center; padding: 5px; color: #666; font-size: 12px;display:none">以下是当前会话</div>`);
1572                    firstNewMessage.before(tipElement);
1573                } else {
1574                    // 如果没找到,说明所有消息都是旧的,在最后添加提示
1575                    const tipElement = $(`<div class="current-session-tip" style="display: block; overflow: hidden; text-align: center; padding: 20px 5px; color: #666; font-size: 12px;display:none">以下是当前会话</div>`);
1576                    $messages.last().before(tipElement);
1577                }
1578            }
1579        }
1580        //客服消息
1581        adminHtml(obj,k){
1582            // mock 数据
1583            // aiAgent自定义消息&相关内容
1584            // obj.content = '{"aiAgent":{"msg":"公司的详细地址信息如下:\\n\\n- **公司名称**:北京市****科技股份有限公司\\n- **办公地点**:北京市大兴区亦庄经济开发区\\n- **联系方式**:\\n  - 客服电话:400-000-0000\\n  - 总机电话:+86-(0)000-8800880\\n  - 邮箱:[email protected]\\n\\n以上信息提供了该公司的基本联系渠道和地址,方便您进行进一步的沟通和联系。","source":[{"http://1292842294.xuoumaill.cn/leader/1866749757845753856.html":"UU原创文章文件查看编辑åŽ
1584†å²ä¹¦ç­¾å·¥å…·çª—口帮助中心呀呀呀24892iworiowir……&#……&¥……uwir伞兵粉白不orio"},{"http://1292842294.xuoumaill.cn/leader/1866749757845753856.html":"UU原创文章文件查看编辑历史书签工具窗口帮助中心呀呀呀24892iworiowir……&#……&¥……uwir伞兵粉白不orio"},{"http://1292842294.xuoumaill.cn/leader/1866749757845753856.html":"UU原创文章文件查看编辑历史书签工具窗口帮助中心呀呀呀24892iworiowir……&#……&¥……uwir伞兵粉白不orio"}],"relatedIssues":["你的功能和主要用途是什么?","我可以如何更好地使用你来解决我的问题?","你与其他人智能助手相比有什么特色或优势?"]},"AIFlag":"机器人","lang":"zh_CN","paramSort":["aiAgent"]}'
1585            // {"msg":"{\"AIFlag\":\"机器人\",\"title\":\"您好!欢迎访问中企动力科技股份有限公司,我是官网智能客服,很高兴为您服务!北京大兴的您初次来访,为您介绍下,我们有建站、SEO等服务,请问有什么可以帮您?\",\"lang\":\"zh_CN\",\"paramSort\":[\"title\"]}"}
1586            // workOrder类型
1587            // obj.content = '{"workOrder":{"button":"提交","input":[{"dataItem":[{"name":"测试","value":"2223e09c89354279a30de70432403fea"},{"name":"特 殊 字 符","value":"bb0f933e46024a4e8155df363ee6df67"}],"code":"woClassifyId","dataType":"select","dataSubType":"redio","name":"工单类型","required":1},{"code":"custDesc","dataType":"multiTxt","dataSubType":"","name":"工单描述","required":0},{"code":"custLinkName","dataType":"text","dataSubType":"singleText","name":"联系人","required":1},{"code":"custLinkMobile","dataType":"mobile","dataSubType":"","name":"联系人手机","required":1},{"code":"custLinkEmail","dataType":"email","dataSubType":"","name":"联系人邮箱","required":0}],"method":"post","title":"创建工单","url":"/visitormanager/intelligent/front/addWork?instance=DEMO_d7b32a226a134f7a9daf2e2e8720249f&tenantId=311227"},"AIFlag":"机器人","paramSort":["workOrder"]}'
1588            // thirdTool
1589            // obj.content = '{"thirdTool":{"name":"fddfdfdf","type":1,"account":"233445","threePartyTools":{"name":"","type":1,"account":""}},"AIFlag":"机器人","paramSort":["thirdTool"]}'
1590            // confirmDialog类型(测试用,联调完成后请注释/删除)
1591            // obj.content = '{"aiAgent":{"msg":"为了更好地帮到您,想先确认一下~"},"confirmDialog":{"title":"想确认下您具体想了解哪方面?","stepId":"default","context":"","input":[{"name":"想确认下您具体想了解哪方面?","required":0,"code":"scenario","dataType":"select","dataSubType":"redio","dataItem":[{"name":"产品价格与套餐","value":"产品价格与套餐"},{"name":"部署与集成方式","value":"部署与集成方式"},{"name":"售后与技术支持","value":"售后与技术支持"}]},{"name":"其他,请描述","required":0,"code":"userInput","dataType":"multiTxt","dataSubType":"","placeholder":"请输入您的具体需求"}]},"paramSort":["aiAgent","confirmDialog"],"AIFlag":"机器人"}'
1592            // obj.content = {
1593            //         "AIFlag": "机器人",
1594            //         "internationalEntry": "正在为您转接中...",
1595            //         "paramSort": [
1596            //             "internationalEntry"
1597            //         ]
1598            //     }
1599
1600            let msg = []
1601            let msg2 = []
1602            let w100 = ''
1603            let reply = ``
1604            let mb20 = ''
1605            // console.log(obj, this.res.replyResearch, k, 'adasdasdasdobj');
1606            if(obj.content) {
1607                try {
1608                    let contentObj = JSON.parse(obj.content)
1609                    if(contentObj.aiAgent && contentObj.aiAgent.relatedIssues) {
1610                        if(this.res.replyResearch && k) {
1611                            const _isClicked = localStorage.getItem('replyResearch_' + obj.time)
1612                            const _dc = _isClicked ? ' disabled' : ''
1613                            reply = `<div class="replys aiAgent_reply" data-time="${obj.time}">
1614                                <a href="javascript:;" class="replyBtn replyY${_dc}" data-id="1" msg="${encodeURIComponent(contentObj.aiAgent.msg)}">
1614<svg t="1727148138116" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="957" width="200" height="200"><path d="M881.504 356.352l-200.864 0.576c11.2-20.32 66.432-127.488 51.808-242.144-6.144-48.16-37.568-85.376-88.576-104.768-19.936-7.552-117.6-20.928-147.168 6.336-20.512 20.224-18.944 47.552-17.088 79.232 0.864 15.264 1.888 32.576 1.056 50.592-4.992 52.032-11.936 79.744-25.696 102.272-41.6 68.288-112 105.536-127.04 107.968H35.648c-19.68 0-35.648 15.36-35.648 34.336v447.552c0 18.976 15.968 34.336 35.648 34.336l299.776-0.192 0.896 0.736c26.592 21.248 97.28 77.664 214.24 77.664h234.752c65.28 0 117.984-34.496 137.504-90.016l0.64-1.984c2.4-8.576 9.152-27.872 16.96-50.24 31.296-89.6 83.68-239.552 83.68-321.088 0-84.576-50.624-131.168-142.592-131.168zM71.264 804h112.8V425.056H71.264v378.944z m801.6-17.28c-8.48 24.384-14.72 42.24-17.824 52.928-14.048 38.4-53.344 42.56-69.728 42.56h-234.752c-91.296 0-145.6-43.36-168.768-61.888-11.52-9.216-20.672-16.512-35.328-16.512H255.296V425.056h72.64c40.64 0 136.48-56.576 188.48-141.824 22.4-36.736 30.08-77.248 35.296-132.288a534.4 534.4 0 0 0-0.96-59.2c-0.448-7.616-0.96-16.384-0.96-22.976 20.416-1.184 57.28 1.216 67.968 5.12 27.04 10.272 40.992 25.92 43.968 49.28 12.256 96.192-38.176 191.008-43.968 201.504l-1.152 2.176a66.848 66.848 0 0 0 4.864 66.464 72.64 72.64 0 0 0 60.8 31.68h199.232c59.68 0 71.36 22.944 71.36 62.528 0 70.304-52.032 219.2-80 299.2z" p-id="958"></path></svg>${i18n.sms_resolved}</a><a href="javascript:;" class="replyBtn replyN${_dc}" data-id="0" msg="${encodeURIComponent(contentObj.aiAgent.msg)}"><svg t="1727148138116" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="957" width="200" height="200"><path d="M881.504 356.352l-200.864 0.576c11.2-20.32 66.432-127.488 51.808-242.144-6.144-48.16-37.568-85.376-88.576-104.768-19.936-7.552-117.6-20.928-147.168 6.336-20.512 20.224-18.944 47.552-17.088 79.232 0.864 15.264 1.888 32.576 1.056 50.592-4.992 52.032-11.936 79.744-25.696 102.272-41.6 68.288-112 105.536-127.04 107.968H35.648c-19.68 0-35.648 15.36-35.648 34.336v447.552c0 18.976 15.968 34.336 35.648 34.336l299.776-0.192 0.896 0.736c26.592 21.248 97.28 77.664 214.24 77.664h234.752c65.28 0 117.984-34.496 137.504-90.016l0.64-1.984c2.4-8.576 9.152-27.872 16.96-50.24 31.296-89.6 83.68-239.552 83.68-321.088 0-84.576-50.624-131.168-142.592-131.168zM71.264 804h112.8V425.056H71.264v378.944z m801.6-17.28c-8.48 24.384-14.72 42.24-17.824 52.928-14.048 38.4-53.344 42.56-69.728 42.56h-234.752c-91.296 0-145.6-43.36-168.768-61.888-11.52-9.216-20.672-16.512-35.328-16.512H255.296V425.056h72.64c40.64 0 136.48-56.576 188.48-141.824 22.4-36.736 30.08-77.248 35.296-132.288a534.4 534.4 0 0 0-0.96-59.2c-0.448-7.616-0.96-16.384-0.96-22.976 20.416-1.184 57.28 1.216 67.968 5.12 27.04 10.272 40.992 25.92 43.968 49.28 12.256 96.192-38.176 191.008-43.968 201.504l-1.152 2.176a66.848 66.848 0 0 0 4.864 66.464 72.64 72.64 0 0 0 60.8 31.68h199.232c59.68 0 71.36 22.944 71.36 62.528 0 70.304-52.032 219.2-80 299.2z" p-id="958"></path></svg>${i18n.sms_unresolved}</a>
1615                            </div>`
1616                        }
1617                    }
1618                } catch(e) {}
1619            }
1620            if(obj.type=="text"){
1621                msg.push(this.getMsg(obj.text,"text"))
1622            }else if(obj.type=="custom"){
1623                try{
1624                    let msgObject = JSON.parse(obj.content)
1625                    if(msgObject.lang) {
1626                        this.currentLang = msgObject.lang;
1627                    }
1628                    for(var i in msgObject.paramSort){
1629                        let key = msgObject.paramSort[i]
1630                        let msgDom = this.getMsg(msgObject[key],key,k)
1631                        if(key!="card" && key!="form" && key!="knowledge"){
1632                            if(msgDom){
1633                                msg.push(msgDom)
1634                            }
1635                            if(key=='questionTip'){
1636                                w100 = 'w100'
1637                            }
1638                            if(key=='aiAgent') {
1639                                mb20 = 'mb20'
1640                                msg.push(reply)
1641                            }
1642                        }else{
1643                            msg2.push(msgDom)
1644                        }
1645                    }
1646                }catch(e){}
1647            }
1648            let msgdom = ``
1649            if(msg.length>0){
1650                msgdom = `<div class="msgcon ${w100} ${mb20}">${msg.join("")}</div>`
1651            }
1652            let readdom = ``
1653            if(this.settings.voiceSwitch==1){
1654                readdom = `<a href="javascript:;" class="sms_read"><svg t="1758765065638" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="19162" width="128" height="128"><path d="M534.002 120.373c-9.072 0-18.606 3.172-26.314 9.534L280.869 325.875H121.643c-34.475 0-62.154 27.679-62.154 61.702l-0.452 268.551c0 34.023 28.131 62.145 62.606 62.145h161.494l223.648 176.016c8.159 6.805 17.241 9.517 26.313 9.517 21.761 0 41.73-16.782 41.73-41.271l0.904-700.873c0.462-24.508-19.951-41.289-41.73-41.289z m-20.873 699.968L321.244 669.276c-10.889-8.612-24.498-13.148-38.107-13.148H120.73l0.913-268.108 159.226-0.442c14.973 0 29.034-5.458 40.375-14.974L514.04 206.121l-0.911 614.22zM696.409 308.633c-14.07-9.516-33.58-5.44-42.652 8.63-9.517 14.052-5.44 33.562 8.629 42.635 48.075 32.215 77.119 85.288 77.119 141.992 0 54.879-27.219 106.605-72.582 138.803-14.07 9.994-17.242 29.044-7.266 43.096 5.901 8.63 15.417 13.166 25.41 13.166 6.344 0 12.688-1.824 17.686-5.9 61.702-44 98.436-114.775 98.436-189.625-0.001-77.118-39.002-149.241-104.78-192.797z" p-id="19163"></path><path d="M827.503 195.684c-12.705-11.341-32.215-10.438-43.557 2.268-11.34 12.705-10.419 32.198 2.269 43.539 74.407 66.699 117.043 161.502 117.043 260.399 0 96.629-39.003 186.435-109.777 253.134-12.244 11.784-13.148 31.294-1.364 43.539 5.9 6.361 14.07 9.533 22.682 9.533 7.708 0 15.435-2.729 21.318-8.63C919.135 720.541 964.96 614.839 964.96 501.43c0.442-115.678-49.458-227.263-137.457-305.746z" p-id="19164"></path></svg></svg></a>`
1655            }
1656            if(msg.length>0 || msg2.length>0){
1657                return `
1658                    <div class="sm_msg ad ${obj.from=='reply'?'sm_reply':''}" data-time="${obj.time}">
1659                        <div class="msgtitle">
1660                            <span class="name">${this.settings.name}</span>
1661                            <span class="time">${$.formatDate(new Date(obj.time),'yyyy-MM-dd hh:mm')}</span>
1662                            ${readdom}
1663                        </div>
1664                        ${msgdom}
1665                        ${msg2.join("")}
1666                    </div>
1667                `
1668            }else{
1669                return ``
1670            }
1671        }
1672        isArray(it){
1673            return Object.prototype.toString.call(it) === "[object Array]"
1674        }
1675        //消息按类型返回结构
1676        getMsg(value,type,k){
1677            if(!value || value.length==0 || (value.input && value.input.length==0)){
1678                return ``
1679            }
1680            switch(type){
1681                case 'text':
1682                case 'title':
1683                    return `<div class="cItem">${marked.parse(emo.symbolToHtml(value))}</div>`;
1684                case 'image':
1685                    return `<div class="cItem"><img src="${$.handleDataImg(value)}" alt="img" la="la" /></div>`;
1686                case 'button':
1687                    let arr = []
1688                    value.forEach(e=>{
1689                        arr.push(`<a href="javascript:;" data-url="${e.url}" >${e.name}</a>`)
1690                    })
1691                    return `<div class="cItem msgbtn">${arr.join("")}</div>`;
1692                case 'questionTip':
1693                    let tips = []
1694                    value.forEach((e,i)=>{
1695                        tips.push(`<div class="quea"><a href="javascript:;" data-url="${e.url}">${e.name}</a></div>`)
1696                    })
1697                    return `<div class="cItem msgquestion">${tips.join("")}</div>`;
1698                case 'knowledge':
1699                    return this.getKnowledge(value,type,k)
1700                case 'card':
1701                    return `<div class="cardInfo" data-url="${value.url}">
1702                        <div class="cardmark"><span>${i18n.sms_card}</span><img src="/npublic/commonjs/smartService/zs.png" alt="zs" la="la" /></div>
1703                        <div class="cinfo">
1704                            <div class="cardImg"><img src="${$.handleDataImg(value.headImg)}" alt="head" la="la" /></div>
1705                            <div class="cardName">
1706                                <p class="name">${value.name}</p>
1707                                <p class="label">${value.role}</p>
1708                            </div>
1709                        </div>
1710                    </div>`;
1711                case 'form':
1712                    let formItems = []
1713                    console.log(value.input,12345)
1714                    value.input.forEach(e=>{
1715                        let item = ``
1716                        if(e.fixed==1){
1717                            if(e.ishide===false || e.showName || e.note){
1718                                item = this.getFixedFormItem(e)
1719                            }else if(e.ishide===undefined){
1720                                let k = e.noRequired ? false : true
1721                                item = this.getFixedFormItem(e,k)
1722                            }
1723                        }else if(e.fixed==0 && !e.ishide){
1724                            item = this.getFormItem(e)
1725                        }else if(e.fixed == undefined){
1726                            item = this.getFixedFormItem(e,true)
1727                        }
1728                        if(item){
1729                            formItems.push(item)
1730                        }
1731                    })
1732                    let aggree = ``
1733                    let icon = ``
1734                    if(value.msgAuthFlag){
1735                        aggree = `<div class="formIt aggree">
1736                            <input type="checkbox" name="as" id="as" />
1737                            <label class="formItLabel" for="as">${value.msgAuth}</label>
1738                        </div>`
1739                        icon = `<svg t="1723621189390" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="1223" width="200" height="200"><path d="M417.1264 947.4048L315.392 621.568l442.368-293.6832-476.928 233.8304L50.0736 311.552a45.568 45.568 0 0 1 30.7712-76.3904l841.6256-50.4832a45.568 45.568 0 0 1 40.7552 70.6048L498.688 958.9248a45.568 45.568 0 0 1-81.5104-11.52z" p-id="1224"></path></svg>`
1740                    }
1741                    return `<div class="msgcon msgform" progressId="${value.progressId}" formType="${this.escapeAttr(value.formType)}">
1742                        ${formItems.join("")}
1743                        ${aggree}
1744                        <div class="formIt"><a href="javascript:;" class="p_sub">${icon}${i18n.sms_submit}</a></div>
1745                    </div>`;
1746                case "thirdTool":
1747                    let thirdItems = this.isArray(value) ? value : [value];
1748                    let links = thirdItems.map(item => {
1749                    let itemLink = '';
1750                    switch (item.type) {
1751                            
1752                        case 1: // QQ企业版
1753                            itemLink = `<a href="tencent://message/?uin=${item.account}" data-name="${item.name}" class="thirdToolMedia"><svg t="1766971256390" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="77662" width="200" height="200"><path d="M499.073251 971.1616c-6.8096-4.096-16.384-10.8544-23.9616-10.8544-5.9392 0-13.7216 5.7344-20.48 9.3696a71.0144 71.0144 0 0 1-20.48 5.12l3.1744-17.3568 25.2416-17.3568h47.5648l5.6832 34.4064a43.52 43.52 0 0 1-16.896-3.4304z m-193.9456 50.1248c-96.2048 4.5056-176.0256-28.16-178.2784-72.96s73.9328-84.736 170.1376-89.0368 176.0256 28.16 178.2784 72.96-73.9328 84.5312-170.1376 89.0368z m340.0704 0c-96.1536-4.5056-172.288-44.4416-170.0352-89.2416s81.92-77.4656 178.1248-72.96 172.288 44.4416 170.0352 89.2416-81.92 77.4656-178.1248 72.96z m0 0" fill="#F2B624" p-id="77663"></path><path d="M474.702051 961.6896c-198.2976 0-359.8848-131.072-359.8848-338.6368 0-203.7248 160.768-368.64 359.0656-368.64s359.0656 165.1712 359.0656 368.64c0 206.336-159.9488 338.6368-358.4 338.6368z m421.8368-162.2016c-25.088 51.6096-167.3728-145.92-98.6624-348.16 0 0 174.08 174.4896 98.6624 348.16z m-841.2672 0.0512c-78.1824-170.3424 92.7744-349.8496 92.7744-349.8496 70.0416 200.8064-67.6864 401.1008-92.7744 349.8496z m0 0" fill="#191919" p-id="77664"></path><path d="M198.631651 644.2496c0 164.9152 109.312 296.192 276.7872 296.192s275.6096-131.2768 275.6096-296.192c0-157.2864-119.3984-277.0432-276.224-277.0432s-276.1728 119.552-276.1728 277.0432z m0 0" fill="#FAFAFB" p-id="77665"></path><path d="M790.708451 390.8608c10.24 0 18.6368 4.0448 18.6368 9.0624s-7.0656 29.7472-17.3568 29.7472-19.9168-24.7808-19.9168-29.7472 8.3456-9.0624 18.6368-9.0624z m-632.064 1.3312c10.24 0 18.3296 4.5056 18.3296 10.24s-8.0896 30.72-18.176 30.72-18.432-24.9856-18.432-30.72 8.192-10.24 18.3296-10.24z m0 0" fill="#D32F19" p-id="77666"></path><path d="M801.562851 343.1424c-5.12 183.808-56.32 230.0928-327.68 230.0928s-327.68-44.032-327.68-227.9424C146.049251 144.5888 292.583651 0 473.268451 0s333.312 163.0208 328.2432 343.04z m0 0" fill="#191919" p-id="77667"></path><path d="M352.231651 777.0112c-26.5728 0.7168-88.6784-7.2192-104.704-24.9344-6.7584-7.424-8.0384-12.032-8.0384-29.0304a655.36 655.36 0 0 1 20.1728-165.8368c64.6656-72.8064 112.64 32.4608 112.64 32.4608v167.2192a19.7632 19.7632 0 0 1-20.0704 20.1216z m122.88-134.2464c-165.5808 0-323.328-82.4832-364.3392-144.9472 1.7408-3.84 21.4016-73.1648 29.4912-97.536 16.9472 35.84 112.64 144.1792 334.7968 144.1792s321.792-119.7568 333.7728-148.48c12.1856 35.84 26.6752 94.4128 28.4672 101.632-64.512 84.7872-216.064 144.9472-362.2912 144.9472z m0 0" fill="#D32F19" p-id="77668"></path><path d="M331.751651 252.5184c-1.8944-48.0768 24.1152-88.2176 58.0608-89.5488s62.976 35.84 64.8192 84.1728S430.465251 335.36 396.519651 337.0496 333.492451 300.544 331.751651 252.5184z m163.84-2.56c0-48.0768 27.5456-87.04 61.44-87.04s61.44 38.9632 61.44 87.04-27.5456 87.04-61.44 87.04-61.44-38.9632-61.44-87.04z m0 0" fill="#FFFFFF" p-id="77669"></path><path d="M622.311651 461.3632c-71.68 37.376-90.624 59.0336-148.48 59.0848-56.32 0-76.4928-21.7088-148.48-59.0848-112.9984-58.7264-62.5664-63.6416 9.4208-85.0944 42.6496-12.6976 101.3248-18.7392 139.1616-18.7392s96.4608 6.1952 139.1616 18.8928c71.936 21.4016 122.368 26.368 9.2672 85.0944z m0 0" fill="#EFB024" p-id="77670"></path><path d="M649.191651 408.7296s-22.272 31.4368-82.944 53.6576c-31.744 11.6224-45.056 39.1168-91.3408 39.1168s-59.392-27.3408-91.0848-39.1168c-59.6992-22.4768-82.7904-53.6576-82.7904-53.6576 13.4656 9.9328 67.072 49.6128 174.08 49.6128s160.8192-39.8848 174.08-49.6128z m0 0" fill="#8A3322" p-id="77671"></path><path d="M579.252451 275.6096a8.1408 8.1408 0 0 1-8.3968-7.8336v-1.792c0-20.48-8.2944-36.3008-18.944-36.3008s-18.944 15.9232-18.944 36.3008v1.792a8.448 8.448 0 0 1-16.7936 0v-1.792c0-30.72 14.7456-51.968 35.84-51.968s35.84 21.3504 35.84 51.968v1.792a8.1408 8.1408 0 0 1-8.6016 7.8336z m-145.1008-24.4736c1.792 22.6304-10.5472 42.7008-27.5456 44.9024
1753s-32.2048-14.336-33.9968-36.9664 10.3424-42.7008 27.4944-44.9024 32.256 14.336 34.048 36.9664z m0 0" fill="#191919" p-id="77672"></path><path d="M423.911651 249.088c0 8.448-4.096 15.7184-9.7792 16.1792s-10.24-5.9904-10.6496-14.4896 4.1472-15.7184 9.7792-16.2304 10.24 6.0416 10.6496 14.5408z m0 0" fill="#FFFFFF" p-id="77673"></path></svg>${item.name}</a>`;
1754                            break;
1755                        case 2: // 阿里旺旺
1756                            // itemLink = `wangwang://sendmsg?uid=${item.account}`;
1757                            itemLink = `<a href="http://amos.alicdn.com/getcid.aw?v=2&uid=${item.account}&site=cntaobao&s=2&groupid=0&charset=utf-8" data-name="${item.name}"><svg t="1766971781975" class="icon" viewBox="0 0 1097 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="78267" width="200" height="200"><path d="M597.15072 121.12384c-86.82496-68.02432-246.528-120.17152-246.528-120.17152s39.92576 66.85184 47.36 141.97248c-179.63008 59.54048-308.74624 222.208-308.74624 413.84448 0 241.88416 205.8752 438.05184 459.77088 438.05184S1008.64 798.64832 1008.64 556.69248c0-226.45248-180.224-412.60032-411.42272-435.56352l-0.06656-0.00512z" fill="#33C9F2" p-id="78268"></path><path d="M580.75648 384.14848c-38.76352 9.87648-56.39168 22.08768-91.86816 29.25568 39.35232 22.16448 70.72768 98.37568 29.84448 171.008 37.15584 0 59.24352-1.82784 92.96384-1.82784 24.64768-39.49568 25.52832-152.86784-31.01184-198.43584h0.07168z m245.53984-28.38016c-38.62016 9.94816-56.24832 22.16448-91.79648 29.25568 39.424 22.08768 70.72768 98.37568 29.98784 171.008 37.08416 0 59.17184-1.82784 92.96384-1.82784 24.576-39.49568 25.45664-152.72448-31.1552-198.43584z" fill="" p-id="78269"></path><path d="M217.53856 594.7136c-10.368 19.59936-39.34208 16.91648-45.3888-4.41344-14.70976-51.84-27.25376-131.5584 1.93024-206.15168 63.09888-161.28 258.92864-222.0544 258.92864-222.0544s-22.59456-105.37984-51.90144-122.12736C476.19072 65.5872 548.50048 139.8272 548.50048 139.8272s93.30688 0.80384 186.79296 47.96928c21.62688 10.91072 15.56992 43.38176-8.48896 46.16704-165.91872 19.23072-391.0656 137.2928-509.26592 360.75008z" fill="#78DBF6" p-id="78270"></path><path d="M386.6368 39.96672s55.8848 70.90176 52.224 108.44672l-19.5072 7.7568s4.05504-57.40032-32.7168-116.20352zM401.92 164.1472s-312.32 90.88-261.12 404.48c6.4 35.84 15.62112 39.34208 15.62112 39.34208s-17.7152-163.93728 45.81888-267.18208 199.68-176.64 199.68-176.64z" fill="#FFFFFF" p-id="78271"></path></svg>${item.name}</a>`;
1758                            break;
1759                        case 3: // 阿里旺旺E客服
1760                            itemLink = `<a href="http://amos.alicdn.com/getcid.aw?v=2&uid=${item.account}&site=cntaobao&s=2&groupid=0&charset=utf-8" data-name="${item.name}"><svg t="1766971781975" class="icon" viewBox="0 0 1097 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="78267" width="200" height="200"><path d="M597.15072 121.12384c-86.82496-68.02432-246.528-120.17152-246.528-120.17152s39.92576 66.85184 47.36 141.97248c-179.63008 59.54048-308.74624 222.208-308.74624 413.84448 0 241.88416 205.8752 438.05184 459.77088 438.05184S1008.64 798.64832 1008.64 556.69248c0-226.45248-180.224-412.60032-411.42272-435.56352l-0.06656-0.00512z" fill="#33C9F2" p-id="78268"></path><path d="M580.75648 384.14848c-38.76352 9.87648-56.39168 22.08768-91.86816 29.25568 39.35232 22.16448 70.72768 98.37568 29.84448 171.008 37.15584 0 59.24352-1.82784 92.96384-1.82784 24.64768-39.49568 25.52832-152.86784-31.01184-198.43584h0.07168z m245.53984-28.38016c-38.62016 9.94816-56.24832 22.16448-91.79648 29.25568 39.424 22.08768 70.72768 98.37568 29.98784 171.008 37.08416 0 59.17184-1.82784 92.96384-1.82784 24.576-39.49568 25.45664-152.72448-31.1552-198.43584z" fill="" p-id="78269"></path><path d="M217.53856 594.7136c-10.368 19.59936-39.34208 16.91648-45.3888-4.41344-14.70976-51.84-27.25376-131.5584 1.93024-206.15168 63.09888-161.28 258.92864-222.0544 258.92864-222.0544s-22.59456-105.37984-51.90144-122.12736C476.19072 65.5872 548.50048 139.8272 548.50048 139.8272s93.30688 0.80384 186.79296 47.96928c21.62688 10.91072 15.56992 43.38176-8.48896 46.16704-165.91872 19.23072-391.0656 137.2928-509.26592 360.75008z" fill="#78DBF6" p-id="78270"></path><path d="M386.6368 39.96672s55.8848 70.90176 52.224 108.44672l-19.5072 7.7568s4.05504-57.40032-32.7168-116.20352zM401.92 164.1472s-312.32 90.88-261.12 404.48c6.4 35.84 15.62112 39.34208 
176015.62112 39.34208s-17.7152-163.93728 45.81888-267.18208 199.68-176.64 199.68-176.64z" fill="#FFFFFF" p-id="78271"></path></svg>${item.name}</a>`;
1761                            break;
1762                        case 4: // Skype
1763                            itemLink = `<a href="skype:${item.account}?chat" data-name="${item.name}"><svg t="1766971736736" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="78116" width="200" height="200"><path d="M36.865067 421.013333c-0.32 1.749333-0.554667 3.52-0.853334 5.269334 0.896 1.621333 1.706667 3.264 2.624 4.864l-1.770666-10.133334zM986.881067 602.688c0.341333-1.792 0.554667-3.626667 0.874666-5.418667-0.896-1.621333-1.685333-3.285333-2.624-4.906666l1.728 10.325333zM592.043733 982.976c1.642667 0.96 3.306667 1.770667 4.906667 2.688 1.834667-0.32 3.626667-0.533333 5.418667-0.874667l-10.325334-1.813333z" fill="#444444" p-id="78117"></path><path d="M987.755733 597.269333c-0.32 1.792-0.533333 3.626667-0.896 5.418667l-1.728-10.304c0.938667 1.6 1.728 3.264 2.624 4.885333 5.290667-28.757333 8.064-58.218667 8.064-87.637333 0-65.28-12.8-128.618667-38.037333-188.224a481.28 481.28 0 0 0-103.637333-153.706667 481.664 481.664 0 0 0-341.866667-141.589333c-30.762667 0-61.568 2.88-91.562667 8.64-0.064 0-0.149333 0-0.213333 0.042667 1.664 0.874667 3.392 1.664 5.034667 2.602666l-10.176-1.6 5.12-1.002666A286.570667 286.570667 0 0 0 286.273067 1.237333a284.309333 284.309333 0 0 0-202.410667 83.84A284.437333 284.437333 0 0 0 0.001067 287.509333c0 48.64 12.501333 96.490667 36.010666 138.773334 0.298667-1.749333 0.533333-3.52 0.853334-5.269334l1.770666 10.133334c-0.917333-1.6-1.706667-3.242667-2.624-4.864a486.997333 486.997333 0 0 0-7.274666 83.349333c0 65.28 12.778667 128.597333 38.016 188.202667a481.216 481.216 0 0 0 103.594666 153.706666 481.002667 481.002667 0 0 0 153.728 103.594667 479.402667 479.402667 0 0 0 188.202667 38.037333c28.416 0 56.896-2.56 84.693333-7.509333-1.621333-0.917333-3.285333-1.728-4.928-2.688l10.325334 1.813333c-1.792 0.341333-3.584 0.554667-5.397334 0.874667a285.973333 285.973333 0 0 0 140.8 37.12 284.16 284.16 0 0 0 202.389334-83.84A284.224 284.224 0 0 0 1024.001067 736.533333c0-48.832-12.586667-96.832-36.245334-139.264z" fill="#00AEF3" p-id="78118"></path><path d="M514.219733 805.76c-171.797333 0-248.64-84.458667-248.64-147.754667 0-32.469333 23.957333-55.232 57.002667-55.232 73.514667 0 54.464 105.578667 191.637333 105.578667 70.186667 0 108.992-38.144 108.992-77.162667 0-23.466667-11.584-49.472-57.813333-60.864l-152.810667-38.144c-123.050667-30.848-145.365333-97.386667-145.365333-159.914666 0-129.834667 122.24-178.56 237.034667-178.56 105.749333 0 230.4 58.410667 230.4 136.32 0 33.365333-28.885333 52.778667-61.909334 52.778666-62.741333 0-51.2-86.826667-177.557333-86.826666-62.72 0-97.472 28.373333-97.472 69.034666 0 40.533333 49.536 53.504 92.544 63.296l113.109333 25.109334c123.861333 27.584 155.264 99.925333 155.264 168.042666 0 105.514667-80.96 184.298667-244.416 184.298667z" fill="#FFFFFF" p-id="78119"></path></svg>${item.name}</a>`;
1764                            break;
1765                        case 5: // WhatsApp
1766                            itemLink = `<a href="https://api.whatsapp.com/send?phone=${item.account}&text=Hello" data-name="${item.name}"><svg t="1766971676789" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="77967" width="200" height="200"><path d="M511.88787529 62h0.225C760.250375 62 962.00037529 263.86250029 962.00037529 512s-201.78749971 450-449.8875 450c-91.50000029 0-176.4-27.26250029-247.5-74.32499971L91.62537471 942.94999971l56.06250029-167.21249942A446.69999971 446.69999971 0 0 1 62.00037529 512C62.00037529 263.86250029 263.787875 62 511.88787529 62zM383.150375 309.34999971c-8.58750029-20.51250029-15.11250029-21.30000029-28.125-21.825A250.94999971 250.94999971 0 0 0 340.175375 287c-16.94999971 0-34.65 4.95-45.37500029 15.8625C281.86287471 316.09999971 249.500375 347.00000029 249.500375 410.48749971c0 63.41249971 46.38750029 124.7625 52.61249971 133.35000029 6.525 8.55 90.45 140.625 220.68750058 194.43750029 101.88749971 42.11250029 132.11250029 38.21249971 155.32499971 33.26249971 33.8625-7.27499971 76.31250029-32.24999971 87.00000029-62.3
17666250029 10.6875-30.18750029 10.6875-55.9125 7.57499942-61.38749971-3.15-5.43750029-11.73750029-8.55-24.75-15.075-13.05-6.48749971-76.34999971-37.6875-88.34999942-41.85-11.73750029-4.3875-22.91249971-2.85000029-31.76250029 9.63749971-12.52500029 17.39999971-24.75 35.1-34.68750029 45.75000058-7.80000029 8.325-20.5875 9.37500029-31.23749971 4.95-14.32500029-6.00000029-54.45-20.025-103.98750029-63.97500058-38.28750029-34.04999971-64.35-76.42500029-71.8875-89.13749942-7.57500029-13.01249971-0.7875-20.54999971 5.21250029-27.5625 6.48749971-8.06249971 12.75000029-13.76250029 19.27500029-21.30000029 6.525-7.5375 10.125-11.43749971 14.32499942-20.28750029 4.42500029-8.58750029 1.31249971-17.4375-1.83749942-23.92499971-3.11249971-6.48749971-29.17500029-69.93749971-39.86250029-95.625z" fill="#25D366" p-id="77968"></path></svg>${item.name}</a>`;
1767                            break;
1768                        case 6: // 微信
1769                            // 微信通常无法直接通过链接唤起,可以提示用户复制微信号  注释类名 wx
1770                            itemLink = `<div class="cards wx"><span data-name="${item.name}"><svg t="1767598764099" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18714" width="200" height="200"><path d="M670.48 368.94c10.19 0 20.38 0.94 30.52 1.83-27.27-126.56-164.08-221.12-319.93-221.12C206.8 150.26 64 268.04 64 417.61c0 86.22 47.6 157.34 126.67 212.4l-31.92 94.45 110.99-55c39.76 7.78 71.68 15.56 110.94 15.56 10.19 0 19.88-0.44 29.57-1.34a240.59 240.59 0 0 1-9.69-66.11C401.01 480.45 519.84 369 670.54 369l-0.06-0.06zM499.9 283.71c24.08 0 39.76 15.56 39.76 39.44 0 23.34-15.68 39.45-39.76 39.45-23.58 0-47.6-15.61-47.6-39.45 0-23.88 24.03-39.44 47.6-39.44zM277.97 362.6c-23.52 0-47.6-15.61-47.6-39.45 0-23.89 24.08-39.44 47.6-39.44 23.58 0 39.76 15.56 39.76 39.44 0.01 23.34-15.67 39.45-39.76 39.45zM960 614.28c0-125.67-126.67-228.4-269.59-228.4-150.69 0-269.53 102.73-269.53 228.4 0 126.12 118.83 228.46 269.53 228.46 31.47 0 63.39-7.78 95.26-15.61l86.91 47.22-24.02-78.45C912.4 747.79 960 684.9 960 614.28z m-356.95-39.45c-15.68 0-31.92-15.56-31.92-31.67 0-15.56 16.24-31.67 31.92-31.67 24.08 0 39.76 15.61 39.76 31.67 0.01 16.12-15.68 31.67-39.76 31.67z m174.33 0c-15.74 0-31.47-15.56-31.47-31.67 0-15.56 15.68-31.67 31.47-31.67 24.02 0 39.76 15.61 39.76 31.67 0 16.12-15.73 31.67-39.76 31.67z" fill="#09BB07" p-id="18715"></path></svg>${item.name}<i class="addWechat">添加微信客服</i></span>
1771                            <div class="card-imgs"><img src="${__ce.imgStaticUrl[0] + '/' + item.imageUrlArr[0].detail.watermarkUrl_symbol}" /></div></div>`;
1772                            break;
1773                        case 7: // 数字名片
1774                            itemLink = `<div class="cards"><span data-name="${item.name}"><svg t="1767599127009" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18864" width="200" height="200"><path d="M870.4512 204.8c26.2144 0 47.9232 19.8144 50.8416 45.2608l0.3584 5.9392v563.2c0 26.2144-19.8144 47.872-45.2096 50.8416L870.4 870.4h-128a12.8512 12.8512 0 0 1-12.4416-9.8816l-0.3584-2.9184v-9.5744a3.2256 3.2256 0 0 0-1.5872-2.7648l-1.6384-0.4608h-121.6a3.2256 3.2256 0 0 0-2.7648 1.5872l-0.4096 1.6384v9.5744a12.8 12.8 0 0 1-9.8816 12.4416L588.8 870.4H434.432a12.8512 12.8512 0 0 1-12.4928-9.8816l-0.3072-2.9184v-9.5744a3.2256 3.2256 0 0 0-1.5872-2.7648l-1.6384-0.4608h-120.832a3.2256 3.2256 0 0 0-2.7136 1.5872l-0.4608 1.6384v9.5744a12.8 12.8 0 0 1-9.8816 12.4416L281.6 870.4H153.6c-26.2144 0-47.872-19.8144-50.8416-45.2096L102.4 819.2V256c0-26.2144 19.8144-47.872 45.2608-50.8416L153.6 204.8h716.8512z m-12.8 51.2h-691.2a12.8512 12.8512 0 0 0-12.4928 9.8816L153.6 268.8v537.6c0 6.0416 4.2496 11.1104 9.8816 12.4416L166.4 819.2h73.6256a3.2256 3.2256 0 0 0 2.7648-1.5872l0.4096-1.5872v-9.6256a12.8 12.8 0 0 1 9.8816-12.4416L256 793.6h204.8a12.8 12.8 0 0 1 12.4928 9.8816l0.3584 2.9184v9.6256c0 1.1264 0.6144 2.2016 1.536 2.7136l1.6384 0.4608h70.4a3.2256 3.2256 0 0 0 2.7648-1.5872l0.4608-1.5872v-9.6256a12.8 12.8 0 0 1 9.8816-12.4416L563.2 793.6h204.8a12.8 12.8 0 0 1 12.4416 9.8816l0.3584 2.9184v9.6256c0 1.1264 0.6144 2.2016 1.5872 2.7136l1.6384 0.4608h73.5744a12.8512 12.8512 0 0 0 12.4416-9.8816l0.3584-2.9184V268.8a12.8 12.8 0 0 0-12.8-12.8zM343.3984 320a128.4096 128.4096 0 0 1 129.5872 125.952 127.744 127.744 0 0 1-42.9568 97.74
177408 6.4512 6.4512 0 0 0 0.4096 9.984 140.6976 140.6976 0 0 1 55.4496 112.0256 25.6 25.6 0 0 1-20.992 25.1904l-4.608 0.4096h-230.4a25.6 25.6 0 0 1-25.6-25.6c0-45.7216 21.7088-86.272 55.3984-112.0256a6.4512 6.4512 0 0 0 0.4096-9.9328 128 128 0 0 1 83.3024-223.744z m469.4528 281.6c3.5328 0 6.4 2.8672 6.4 6.4v38.4a6.4 6.4 0 0 1-6.4 6.4h-243.2a6.4 6.4 0 0 1-6.4-6.4v-38.4c0-3.5328 2.8672-6.4 6.4-6.4h243.2z m-467.968-25.6c-23.9104 0-46.3872 9.2672-63.3344 26.2656-8.3968 8.3968-14.8992 18.2272-19.3536 28.8768a6.4 6.4 0 0 0 3.7376 8.4992l2.1504 0.3584h153.6c4.6592 0 7.68-4.608 5.9392-8.8576a88.9856 88.9856 0 0 0-19.3536-28.8768 88.9856 88.9856 0 0 0-63.3856-26.2656z m467.968-76.8c3.5328 0 6.4 2.8672 6.4 6.4v38.4a6.4 6.4 0 0 1-6.4 6.4h-243.2a6.4 6.4 0 0 1-6.4-6.4v-38.4c0-3.5328 2.8672-6.4 6.4-6.4h243.2z m-467.8656-128c-42.3424 0-76.8 34.4576-76.8 76.8s34.4576 76.8 76.8 76.8c42.2912 0 76.8-34.4576 76.8-76.8s-34.5088-76.8-76.8-76.8z m467.8656 25.6c3.5328 0 6.4 2.8672 6.4 6.4v38.4a6.4 6.4 0 0 1-6.4 6.4h-243.2A6.4 6.4 0 0 1 563.2 441.6v-38.4c0-3.5328 2.8672-6.4 6.4-6.4h243.2z" p-id="18865" fill="#09BB07"></path></svg>${item.name}</span><div class="card-imgs"><img src="${__ce.imgStaticUrl[0] + '/' + item.imageUrlArr[0].detail.watermarkUrl_symbol}" /></div></div>`;
1775                            break;
1776                        case 8: // 邮件
1777                            itemLink = `<a href="mailto:${item.account} data-name="${item.name}"><svg t="1766971919508" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="88756" width="200" height="200"><path d="M512 0C229.224296 0 0 229.224296 0 512c0 282.775704 229.224296 512 512 512 282.775704 0 512-229.224296 512-512C1024 229.224296 794.775704 0 512 0zM798.72 311.296l-285.847704 298.287407-288.559407-298.287407L798.72 311.296zM204.8 354.702222l159.706074 162.721185L204.8 677.072593 204.8 354.702222zM224.881778 720.896l169.870222-176.82963 117.475556 119.694222 115.730963-119.694222 171.595852 176.82963L224.881778 720.896zM819.2 677.072593l-164.067556-160.085333 164.067556-164.67437L819.2 677.072593z" fill="#FFB600" p-id="88757"></path></svg>${item.name}</a>`;
1778                            break;
1779                        case 9: // 电话
1780                            itemLink = `<a href="tel:${item.account}" data-name="${item.name}"><svg t="1766971966478" class="icon" viewBox="0 0 1029 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="90728" width="200" height="200"><path d="M512.024292 0A512 512 0 1 1 0.024292 512 512 512 0 0 1 512.024292 0z m-108.783323 205.251553a104.98617 104.98617 0 0 0-77.27721 25.04069l-9.23632 5.747043-8.312688 5.233915c-63.730607 39.921427-36.842654 202.070154 67.117258 354.05893s247.635999 239.939066 310.442974 201.043896c4.002405-2.463019 19.498898-11.391461 21.346162-12.520344a106.012427 106.012427 0 0 0 49.978753-48.028864 82.100621 82.100621 0 0 0-24.835438-85.692524c-44.334336-51.312888-77.790339-63.935859-115.65925-46.592102a149.012628 149.012628 0 0 0-17.343756 9.338946l-16.728002 10.262577c-12.725596 7.799559-51.312888-29.453598-98.212868-97.391862s-65.783123-115.65925-54.18641-123.150932c1.128884-0.821006 13.341351-8.107436 16.728001-10.262578 47.61836-29.966727 55.828423-63.012227 18.780517-132.592503a92.363199 92.363199 0 0 0-62.601723-55.110042z" fill="#FF5E34" p-id="90729"></path></svg>${item.name}</a>`;
1781                            break;
1782                        case 10: // 链接
1783                            itemLink = `<a href="tel:${item.account}" data-name="${item.name}"><svg t="1766972007995" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="93464" width="200" height="200"><path d="M512 1024C229.228 1024 0 794.772 0 512S229.228 0 512 0s512 229.228 512 512-229.228 512-512 512z m54.545-565.02l-1.798-1.764a102.207 102.207 0 0 0-11.002-9.523l-35.453 35.442c4.176 2.446 8.078 5.393 11.605 8.92l1.866 1.763a58.277 58.277 0 0 1 0 82.341l-96.904 96.882a58.334 58.334 0 0 1-82.341 0l-1.832-1.798a58.243 58.243 0 0 1 0-82.306l43.816-43.828a149.675 149.675 0 0 1-10.866-58.732l-67.812 67.72c-41.836 41.825-41.836 110.251 0 152.053l1.787 1.798c41.836 41.79 110.228 41.79 152.052 0l96.882-96.916c41.757-41.825 41.757-110.25 0-152.052z m141.38-141.37l-1.82-1.797c-41.802-41.825-110.228-41.825-152.053 0l-96.882 96.916c-41.824 41.79-41.824 110.216 0 152.053l1.798 1.763c3.505 3.425 7.225 6.576 11.002 9.523l35.454-35.476a57.845 57.845 0 0 1-11.583-8.92l-1.798-1.763a58.311 58.311 0 0 1 0-82.375l96.905-96.882a58.197 58.197 0 0 1 82.284 0l1.798 1.797a58.277 58.277 0 0 1 0 82.341l-43.76 43.828c7.612 18.796 11.196 38.81 10.844 58.766l67.789-67.755c41.824-41.79 41.824-110.216 0.022-152.007z" p-id="93465" fill="#f8aeae"></path></svg>${item.name}</a>`;
1784                            break;
1785                        case 11: // 自定义
1786                            itemLink = `<a href="tel:${item.account}" data-name="${item.name}">
1786<svg t="1766972117295" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="96446" width="200" height="200"><path d="M682.507372 400.939555c-6.304589-23.760147-14.045901-46.267766-22.691815-67.686588-80.645738 17.824971-106.931405-52.202942-73.087599-101.162004-12.589736-18.912745-30.946826-32.406061-56.166207-39.059598-33.843806 51.834552-126.175701 25.733081-117.8992-45.014216-26.466792 0-52.922327 0-79.023798 0 6.65763 75.797313-84.609003 91.816149-123.481336 45.014216-19.10001 12.589736-45.201481 17.990746-50.768267 44.811602 37.069267 44.460608 3.225461 113.954355-73.087599 95.411023-8.276501 21.419845-16.387225 43.926442-22.319331 67.686588 63.905472 10.082636 63.905472 108.000759 0 118.083395 5.933129 23.575952 14.042831 46.083571 22.319331 67.502393 80.645738-17.824971 107.650789 52.202942 73.087599 101.180424 12.773931 19.078521 30.949896 32.756031 56.516178 39.226397 33.843806-51.834552 126.009925-25.733081 117.733425 45.198411 26.101471 0 52.555983 0 79.023798 0-6.838755-76.148307 84.609003-92.000344 123.668601-45.198411 19.081591-12.589736 45.364187-18.359137 50.396807-44.995797-36.719296-44.645826-2.87549-113.77016 73.087599-95.411023 8.644891-21.419845 16.387225-43.926442 22.691815-67.502393C615.889115 502.635725 615.889115 417.142585 682.507372 400.939555zM373.23354 577.161069c-64.792679 0-117.177769-52.552913-117.177769-117.179816 0-64.811098 52.384068-117.179816 117.177769-117.179816 64.442708 0 117.198236 52.368718 117.198236 117.179816C490.432799 524.608156 437.676248 577.161069 373.23354 577.161069z" fill="#2B629D" p-id="96447"></path><path d="M960.610274 695.982268c-2.157129-12.958126-4.497431-25.38311-7.90811-37.087687-43.739177 4.313236-53.824883-34.562167-32.220842-58.138118-6.119371-10.986215-14.765285-19.262716-27.723412-24.313755-20.884656 25.216311-68.771293 6.119371-59.594283-31.134091-13.861706-1.806135-27.723412-3.243881-41.936111-4.866844-0.719384 40.331567-50.231031 43.392276-67.871807 15.85306-11.336186 5.750981-25.197892 7.188726-29.693276 20.866237 16.734126 25.935696-5.40408 60.497862-44.833091 46.083571-5.750981 10.80202-11.336186 22.156626-16.018835 34.212196 33.124422 9.364275 27.005051 61.567217-7.188726 62.820768 1.787716 13.143345 4.313236 25.197892 7.557116 36.903491 43.926442-4.313236 53.640688 34.562167 32.756031 58.323337 5.40101 10.80202 14.045901 19.078521 26.820855 24.12956 21.419845-25.197892 68.590168-5.7694 59.761082 31.668257 14.230096 1.27197 28.27702 2.89391 41.769312 4.681626 1.25355-40.682561 50.765197-43.558052 68.409043-16.553001 10.983145-5.585205 25.010627-6.65456 29.693276-20.516266-16.553001-25.935696 5.40101-60.497862 44.645826-46.267766 5.585205-10.80202 11.17041-22.138206 16.018835-34.028001C919.042553 745.659691 924.078243 700.479699 960.610274 695.982268zM785.644357 770.139222c-34.381042-3.963265-58.676377-35.097356-54.897308-69.475328 4.497431-34.028001 34.912138-58.691727 69.291133-54.544267 34.212196 3.963265 59.225893 34.727942 54.547337 69.291133C851.17177 749.622956 820.019259 774.102487 785.644357 770.139222z" fill="#2B629D" p-id="96448"></path></svg>${item.name}</a>`;
1787                            break;
1788                        case 12: // 智慧客服
1789                            itemLink = `<a href="tel:${item.account}" data-name="${item.name}"><svg t="1766972055705" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="94508" width="200" height="200"><path d="M516.426808 807.930831c5.168874 0 10.440102-0.307062 15.71133-0.870008 50.716378-5.885352 93.807387-40.173922 109.672247-87.410266a7.164776 7.164776 0 0 0-4.04298-8.853616 7.676546 7.676546 0 0 0-9.570094 2.968265c-0.204708 0.255885-20.368434 31.729722-98.771553 41.965115-11.770703 1.535309-23.183168 2.354141-34.032685 2.354141-54.964066 0-79.477835-20.061372-79.682543-20.26608a7.727723 7.727723 0 0 0-9.825978-0.102354 7.164776 7.164776 0 0 0-1.535309 9.416562 133.827778 133.827778 0 0 0 112.077565 60.798241z m421.851767-470.009296c-0.716478 0-1.330601 0.153531-1.995902 0.153531-45.956919-192.425409-221.596282-335.925633-432.189515-335.925633-216.376231 0-396.109751 151.483832-435.925433 351.790494C29.477935 360.695287 0 393.602079 0 433.366585v159.262732c0 44.626318 37.00095 80.808436 82.753161 80.808436 25.793193 0 48.515768-11.770703 63.664151-29.836174 36.591534 93.551502 111.054026 168.935179 205.322005 208.750862a42.988655 42.988655 0 0 1 4.196512-6.499475c1.484132-1.842371 3.121795-3.37768 4.55475-3.37768a7.164776 7.164776 0 0 1 3.991804 1.279424c-21.801389-15.660153-100.613924-96.366235-117.707032-209.006747-7.471838-49.590484 30.962067-98.259783 75.690739-106.294567 71.801289-12.896597 143.24434-27.635564 215.04563-40.327453 45.649858-8.034784 76.867809-32.241491 95.956819-72.568944 4.452396-9.416563 10.900695-28.454396 13.868959-55.936428a8.802439 8.802439 0 0 1 8.700085-7.215953c2.968264 0 5.475936 1.432955 7.164776 3.582388l1.944725-1.228247c28.300865 39.764506 84.442001 127.686541 92.527962 220.470388 9.211855 106.038683 4.094158 178.607627-79.887251 252.916587a6.499475 6.499475 0 0 0-2.200609 4.861813c0 2.302964 1.228247 4.247689 3.070618 5.424758l2.047079 0.921186c0.614124 0.153531 1.125893 0.307062 1.68884 0.307062 0.614124 0 1.074716-0.153531 1.586486-0.307062l3.480034-1.893548c84.953771-45.240442 150.050877-120.77765 180.142936-211.565595 12.231296 17.502524 31.269129 30.092059 53.428757 34.493278-35.516817 156.243291-179.73352 254.093658-358.341147 268.934979a73.183068 73.183068 0 0 0-68.06537-43.909841c-40.37863 
17890-73.183068 30.91089-73.183068 69.08891 0 38.126843 32.804438 69.037733 73.183068 69.037733 32.650907 0 59.928232-20.214903 69.395971-48.055175 206.75496-16.2231 372.568344-135.056025 407.163977-319.651357 30.552651-12.384827 52.046979-41.350992 52.046978-75.230146V419.548803c0-45.035734-38.024489-81.576091-84.95377-81.576091z m-76.253686 46.315158c-53.940527-141.248438-193.704833-242.118247-358.136439-242.118246-163.715128 0-302.967665 100.050977-357.419961 240.327053-2.661202-3.172972-5.885352-5.936529-8.95597-8.700085 30.808536-170.982258 183.008846-300.971763 366.580639-300.971763 182.701784 0 334.390324 128.71008 366.2224 298.515268-3.121795 4.094158-6.038883 8.341846-8.341846 12.947773z m-510.183218 468.115748c-0.153531 0.255885-0.153531 0.307062 0 0z" fill="#ffafaf" p-id="94509"></path></svg>${item.name}</a>`;
1790                            break;
1791                        default:
1792                            break;
1793                    }
1794                    return itemLink;
1795                    }).join('')
1796                    return `<div class="thirdTool">
1797                        <div class="linksBtn">
1798                            <div>${i18n.transfered || '目前人工坐席繁忙,您也可以按以下方式直接联系。'}</div>
1799                            ${links}
1800                        </div>
1801                    </div>`;
1802                case "workOrder":
1803                    let workOrderformItems = []
1804                    value.input.forEach((e,i)=>{
1805                        if(i==0) {
1806                            e.fixed = 0;
1807                        }
1808                        let item = ``
1809                        if(e.fixed==1){
1810                            if(e.ishide===false || e.showName || e.note){
1811                                item = this.getFixedFormItem(e)
1812                            }else if(e.ishide===undefined){
1813                                let k = e.noRequired ? false : true
1814                                item = this.getFixedFormItem(e,k)
1815                            }
1816                        }else if(e.fixed==0 && !e.ishide){
1817                            item = this.getFormItem(e)
1818                        }else if(e.fixed == undefined){
1819                            item = this.getFixedFormItem(e,e.required == 0 ? false : true)
1820                        }
1821                        if(item){
1822                            workOrderformItems.push(item)
1823                        }
1824                    })
1825                    let workOrderaggree = ``
1826                    let workOrdericon = ``
1827                    if(value.msgAuthFlag){
1828                        workOrderaggree = `<div class="formIt aggree">
1829                            <input type="checkbox" name="as" id="as" />
1830                            <label class="formItLabel" for="as">${value.msgAuth}</label>
1831                        </div>`
1832                        workOrdericon = `<svg t="1723621189390" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="1223" width="200" height="200"><path d="M417.1264 947.4048L315.392 621.568l442.368-293.6832-476.928 233.8304L50.0736 311.552a45.568 45.568 0 0 1 30.7712-76.3904l841.6256-50.4832a45.568 45.568 0 0 1 40.7552 70.6048L498.688 958.9248a45.568 45.568 0 0 1-81.5104-11.52z" p-id="1224"></path></svg>`
1833                    }
1834                    return `
1835                        <div class="msgcon msgform workOrderMsgformBox" progressId="${value.progressId}">
1836                            ${workOrderformItems.join("")}
1837                            ${workOrderaggree}
1838                            <div class="formIt workOrderMsgform"><a href="javascript:;" class="p_sub2">${workOrdericon}${i18n.sms_submit}</a></div>
1839                        </div>
1840                    `
1841
1842                        // <div class="successBox">
1843                        //     <div>工单已提交成功,我们会尽快联系您!</div>
1844                        //     <a>点击查看</a>
1845                        // </div>
1846                    ;
1847                case "aiAgent":
1848                    let msg = value.msg;
1849                    let source = value.source;
1850                    let relatedIssues = value.relatedIssues;
1851                    let sourceHtml = '';
1852                    let relatedIssuesHtml = '';
1853                    
1854                    if (Array.isArray(source) && source.length > 0) {
1855                        // 将 source 数组转换为链接列表
1856                        let links = [];
1857                        source.forEach(item => {
1858                            if (typeof item === 'object' && item !== null) {
1859                                for (let key in item) {
1860                                    if (item.hasOwnProperty(key) && item[key]) {
1861                                        links.push(`<div class="sourceItem"><a href="${key}" target="_blank">${item[key]}</a></div>`);
1862                                    }
1863                                }
1864                            }
1865                        });
1866                        
1867                        if (links.length > 0) {
1868                            sourceHtml = `<div class="aiAgent_source">${links.join('')}</div>`;
1869                        }
1870                    } else if (typeof source === 'string') {
1871                        // 如果 source 是单个字符串
1872                        sourceHtml = `<div class="aiAgent_source"><a href="${source}" target="_blank">${source}</a></div>`;
1873                    }
1874                    
1875                    // relatedIssues
1876                    if (Array.isArray(relatedIssues) && relatedIssues.length > 0) {
1877                        // 将 relatedIssues 数组转换为链接列表
1878                        let links = [];
1879                        relatedIssues.forEach(item => {
1880                            links.push(`<li class="relatedIssuesItem"><svg t="1767492010358" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="19529" width="200" height="200"><path d="M995.765248 550.5024a679.8336 679.8336 0 0 0-445.2352 445.2352 40.3456 40.3456 0 0 1-76.9024 0A679.7312 679.7312 0 0 0 28.392448 550.5024a40.3456 40.3456 0 0 1 0-77.0048A679.7312 679.7312 0 0 0 473.627648 28.2624a40.3456 40.3456 0 0 1 76.9024 0 679.8336 679.8336 0 0 0 445.2352 445.2352 40.3456 40.3456 0 0 1 0 77.0048z" fill="#9812FA" p-id="19530"></path></svg><p class="related_text">${item}<p></li>`);
1881                        });
1882                        if (links.length > 0) {
1883                            // 只添加类名,不设置显示,后续通过CSS控制
1884                            relatedIssuesHtml = `<div><ul class="aiAgent_relatedIssues hidden"><div class="related_title">${i18n.relatedQuestions || '相关问题'}:</div>${links.join('')}</ul></div>`;
1885                        }
1886                    } else if (typeof relatedIssues === 'string') {
1887                        // 如果 source 是单个字符串
1888                        relatedIssuesHtml = `<div><div class="related_title">${i18n.related || '相关问题'}:</div><div class="aiAgent_relatedIssues hidden">${relatedIssues}</div></div>`;
1889                    }
1890                    
1891                    return `
1892                        <div class="aiAgent">
1893                            <div class="aiAgent_msg">${marked.parse(msg)}</div>
1894                            ${sourceHtml}
1895                            ${relatedIssuesHtml}
1896                        </div>
1897                    `;
1898                case "internationalEntry":
1899                    if(value == '正在为您转接中...') {
1900                        return `<div class="internationalEntry">${i18n.transfering || value || '正在为您转接中...'}</div>`
1901                    } else {
1902                        return `<div class="internationalEntry">${i18n.humanAgents || value || '目前人工坐席繁忙,请留下您的联系方式,我们将第一时间联系您。'}</div>`
1903                    }
1904                case "confirmDialog":
1905                    let confirmTags = []
1906                    let confirmTextItem = null
1907                    ;(value.input || []).forEach(item => {
1908                        if(item.dataItem && item.dataItem.length){
1909                            confirmTags = confirmTags.concat(item.dataItem)
1910                        }else if(!confirmTextItem){
1911                            confirmTextItem = item
1912                        }
1913                    })
1914                    let confirmTagsHtml = confirmTags.length ? `<div class="confirmDialogTags">${confirmTags.map(opt => `<span class="confirmDialogTag">${opt.name}</span>`).join('')}</div>` : ''
1915                    let confirmInputHtml = confirmTextItem ? `
1916                        <div class="confirmDialogInputRow">
1917                            <input type="text" class="confirmDialogInput" placeholder="${confirmTextItem.placeholder || confirmTextItem.name || ''}" />
1918                            <a href="javascript:;" class="confirmDialogConfirmBtn">${i18n.sms_confirm || '确认'}</a>
1919                        </div>
1920                    ` : ''
1921                    return `<div class="confirmDialogCard">
1922                        ${value.title ? `<div class="confirmDialogTitle">${value.title}</div>` : ''}
1923                        ${confirmTagsHtml}
1924                        ${confirmInputHtml}
1925                    </div>`;
1926                default:
1927                    return ``;
1928            }
1929        }
1930
1931        // 在渲染消息后调用此方法,确保只有最后一个 .sm_msg.ad 的 .aiAgent_relatedIssues 显示
1932        showLastRelatedIssues() {
1933            // 首先隐藏所有 aiAgent_relatedIssues
1934            $('.aiAgent_relatedIssues').addClass('hidden');
1935            
1936            // 显示最后一个 .sm_msg.ad 中的 .aiAgent_relatedIssues
1937            const $lastAdMsg = $('.sm_msg.ad').last();
1938            if ($lastAdMsg.length > 0) {
1939                const $lastRelatedIssues = $lastAdMsg.find('.aiAgent_relatedIssues');
1940                if ($lastRelatedIssues.length > 0) {
1941                    $lastRelatedIssues.removeClass('hidden').show();
1942                }
1943            }
1944        }
1945        //固定表单项
1946        getFixedFormItem(e,k){
1947            let nameObj = {
1948                mobile:i18n.sms_mobil,
1949                email:i18n.sms_email,
1950                nickname:i18n.sms_nickname,
1951                name:i18n.sms_name,
1952                address:i18n.sms_address
1953            }
1954            let label = e.showName || nameObj[e.code] ||e.name
1955            let val = this.escapeAttr(e.value)
1956            let input = `<input class="p_inp" placeholder="${!k&&e.ishide!==undefined?e.tooltip:''}" data-type="${e.dataType}" type="text" name="${e.code}" value="${val}" /><div class="errorMsg"></div>`
1957            if(e.code == 'address'){
1958                input = `<textarea class="p_inp" placeholder="${!k&&e.ishide!==undefined?e.tooltip:''}" data-type="${e.dataType}" name="${e.code}">${val}</textarea><div class="errorMsg"></div>`
1959            }else if(e.code == 'mobile' || e.code == 'custLinkMobile'){
1960                input = this.mobileItem(e,k)
1961            }
1962            return `<div class="formIt" ${e.switchFlag||k?'required':''}>
1963                <label class="formItLabel">${label}</label>
1964                ${input}
1965            </div>`
1966        }
1967        mobileItem(e,k){
1968            let countryCode = ''
1969            let countries = this.arraySort(phoneCode.countries,'iso2')
1970            let defaultCode = countries.find(n=>n.iso2=="CN") || {}
1971            let tmpArr = []
1972            tmpArr.push(`
1973                <li class="p_codeItem p_active">
1974                    <span class="p_enDial">+86</span>
1975                    <span class="p_enCode">CN</span>
1976                </li>
1977            `)
1978            countries.forEach(e=>{
1979                let active = e.iso2=="CN" ? "p_active" : ""
1980                tmpArr.push(`<li class="p_codeItem ${active}"><span class="p_enDial">${e.dialCode}</span><span class="p_enCode">${e.iso2}</span></li>`)
1981            })
1982            countryCode = `<div class="input-group-prepend p_mobilePre">
1983                <div class="p_phoneCode">
1984                    <div class="form-control p_currentCode">
1985                        <span>${defaultCode.dialCode}</span>
1986                        <span class="p_arrow">
1987                        <svg t="1655693452891" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="4805" width="200" height="200"><path d="M297.69350383 346.29910124L512 560.6055974 726.30649617 346.29910124a55.0126984 55.0126984 0 1 1 77.87942242 77.87942241L550.66354348 677.70089876a55.0126984 55.0126984 0 0 1-77.87942242 0L219.26174595 424.17852365c-10.49439069-10.49439069-16.01775312-24.30279805-16.01775442-38.66354347s6.07569919-28.72148955 16.01775442-39.21587894c21.54111683-20.98878007 56.89064234-21.54111683 78.43175788 0z" p-id="4806"></path></svg>
1988                        </span>
1989                    </div>
1990                    <ul class="p_codeList">
1991                        ${tmpArr.join("")}
1992                    </ul>
1993                    <input type="hidden" name="mobilePrefix" class="p_inp" value="${defaultCode.dialCode},${defaultCode.iso2}" />
1994                </div>
1995            </div>` 
1996            return `<div class="input-group p_mobilegroup">
1997                ${countryCode}
1998                <input class="p_inp" placeholder="${!k&&e.ishide!==undefined?e.tooltip:''}" data-type="${e.dataType}" type="text" name="${e.code}" value="${this.escapeAttr(e.value)}">
1999                <div class="errorMsg"></div>
2000            </div>`
2001        }
2002        //表单项
2003        getFormItem(obj){
2004            let input = ``
2005            let val = this.escapeAttr(obj.value)
2006            if(obj.dataType=='txt'){
2007                switch(obj.dataSubType){
2008                    case 'text':
2009                    case 'email':
2010                        input = `<input class="p_inp" placeholder="${obj.tooltip}" data-type="${obj.dataType}" sub-type="${obj.dataSubType}" type="text" name="${obj.code}" value="${val}" /><div class="errorMsg"></div>`
2011                        break;
2012                    case 'numberic':
2013                        input = `<input class="p_inp" placeholder="${obj.tooltip}" data-type="${obj.dataType}" sub-type="${obj.dataSubType}" type="number" name="${obj.code}" value="${val}" /><div class="errorMsg"></div>`
2014                        break;
2015                    case 'mobile':
2016                    case 'phone':
2017                        input = this.mobileItem(obj)
2018                        break;
2019                    case 'simpleDate':
2020                    case 'allDate':
2021                        input = `<div class="j_date"><input class="p_inp" placeholder="${obj.tooltip}" data-type="${obj.dataType}" sub-type="${obj.dataSubType}" type="text" name="${obj.code}" value="${val}" /></div><div class="errorMsg"></div>`
2022                        break;
2023                }
2024            }else if(obj.dataType=='multiTxt'){
2025                input = `<textarea class="p_inp" placeholder="${obj.tooltip}" data-type="${obj.dataType}" name="${obj.code}">${val}</textarea><div class="errorMsg"></div>`
2026            }else if(obj.dataType=='select'){
2027                let arr = []
2028                switch(obj.dataSubType){
2029                    case 'redio':
2030                        obj.dataItem.forEach((e,i)=>{
2031                            let checked = obj.value!==undefined && obj.value!==null && String(e.value)==String(obj.value) ? 'checked' : ''
2032                            arr.push(`<div class="p_radioItem">
2033                                <input type="radio" data-type="${obj.dataType}" sub-type="${obj.dataSubType}" name="${obj.code}" id="${e.key || e.value}" value="${e.value}" ${checked}>
2034                                <label for="${e.key || e.value}">${e.showValue || e.name}</label>
2035                            </div>`)
2036                        })
2037                        input = `<div class="p_inp p_radio" name="${obj.code}">${arr.join('')}</div><div class="errorMsg"></div>`
2038                        break;
2039                    case'checkbox':
2040                    let checkedValues = obj.value!==undefined && obj.value!==null ? String(obj.value).split(',') : []
2041                    obj.dataItem.forEach((e,i)=>{
2042                        let checked = checkedValues.includes(String(e.value)) ? 'checked' : ''
2043                        arr.push(`<div class="p_radioItem">
2044                            <input data-type="${obj.dataType}" sub-type="${obj.dataSubType}" type="checkbox" name="${obj.code}" id="${e.key}" value="${e.value}" ${checked}>
2045                            <label for="${e.key}">${e.showValue}</label>
2046                        </div>`)
2047                    })
2048                    input = `<div class="p_inp p_checkbox" name="${obj.code}">${arr.join('')}</div><div class="errorMsg"></div>`
2049                        break;
2050                    case'selSigle':
2051                    input = `<div class="p_select selSigle">
2052                            <div class="multSelect p_input"></div>
2053                            <div class="invalid-feedback"></div>
2054                            <input type="hidden" name="dataItem" placeholder="${obj.tooltip}" value='${JSON.stringify(obj.dataItem)}'>
2055                            <input class="p_inp" type="hidden" data-type="${obj.dataType}" sub-type="${obj.dataSubType}" name="${obj.code}" value="${val}">
2056                        </div>`
2057                        break;
2058                    case'selMulti':
2059                    input = `<div class="p_select selMulti">
2060                            <div class="multSelect p_input"></div>
2061                            <div class="invalid-feedback"></div>
2062                            <input type="hidden" name="dataItem" placeholder="${obj.tooltip}" value='${JSON.stringify(obj.dataItem)}'>
2063                            <input class="p_inp" type="hidden" data-type="${obj.dataType}" sub-type="${obj.dataSubType}" name="${obj.code}" value="${val}">
2064                        </div>`
2065                        break;
2066                }
2067            }
2068            // 新增 obj.required 客服消息必填标识 0-非必填 1-必填
2069            return `<div class="formIt" ${(obj.switchFlag || obj.required > 0)?'required':''}>
2070                <label class="formItLabel">${obj.showName||obj.name}</label>
2071                ${input}
2072            </div>`
2073        }
2074        getKnowledge(value,type,k){
2075            let content = ``
2076            let change = ``
2077            let reply = ``
2078            if(value.aiReplySurvey && k){
2079                reply = `<div class="reply">
2080                    <a href="javascript:;" class="replyBtn replyY" progressId="${value.progressId}" data-id="1" msg="${encodeURIComponent(value.msg)}">
2080<svg t="1727148138116" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="957" width="200" height="200"><path d="M881.504 356.352l-200.864 0.576c11.2-20.32 66.432-127.488 51.808-242.144-6.144-48.16-37.568-85.376-88.576-104.768-19.936-7.552-117.6-20.928-147.168 6.336-20.512 20.224-18.944 47.552-17.088 79.232 0.864 15.264 1.888 32.576 1.056 50.592-4.992 52.032-11.936 79.744-25.696 102.272-41.6 68.288-112 105.536-127.04 107.968H35.648c-19.68 0-35.648 15.36-35.648 34.336v447.552c0 18.976 15.968 34.336 35.648 34.336l299.776-0.192 0.896 0.736c26.592 21.248 97.28 77.664 214.24 77.664h234.752c65.28 0 117.984-34.496 137.504-90.016l0.64-1.984c2.4-8.576 9.152-27.872 16.96-50.24 31.296-89.6 83.68-239.552 83.68-321.088 0-84.576-50.624-131.168-142.592-131.168zM71.264 804h112.8V425.056H71.264v378.944z m801.6-17.28c-8.48 24.384-14.72 42.24-17.824 52.928-14.048 38.4-53.344 42.56-69.728 42.56h-234.752c-91.296 0-145.6-43.36-168.768-61.888-11.52-9.216-20.672-16.512-35.328-16.512H255.296V425.056h72.64c40.64 0 136.48-56.576 188.48-141.824 22.4-36.736 30.08-77.248 35.296-132.288a534.4 534.4 0 0 0-0.96-59.2c-0.448-7.616-0.96-16.384-0.96-22.976 20.416-1.184 57.28 1.216 67.968 5.12 27.04 10.272 40.992 25.92 43.968 49.28 12.256 96.192-38.176 191.008-43.968 201.504l-1.152 2.176a66.848 66.848 0 0 0 4.864 66.464 72.64 72.64 0 0 0 60.8 31.68h199.232c59.68 0 71.36 22.944 71.36 62.528 0 70.304-52.032 219.2-80 299.2z" p-id="958"></path></svg>${i18n.sms_resolved}</a><a href="javascript:;" class="replyBtn replyN" progressId="${value.progressId}" data-id="0" msg="${encodeURIComponent(value.msg)}"><svg t="1727148138116" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="957" width="200" height="200"><path d="M881.504 356.352l-200.864 0.576c11.2-20.32 66.432-127.488 51.808-242.144-6.144-48.16-37.568-85.376-88.576-104.768-19.936-7.552-117.6-20.928-147.168 6.336-20.512 20.224-18.944 47.552-17.088 79.232 0.864 15.264 1.888 32.576 1.056 50.592-4.992 52.032-11.936 79.744-25.696 102.272-41.6 68.288-112 105.536-127.04 107.968H35.648c-19.68 0-35.648 15.36-35.648 34.336v447.552c0 18.976 15.968 34.336 35.648 34.336l299.776-0.192 0.896 0.736c26.592 21.248 97.28 77.664 214.24 77.664h234.752c65.28 0 117.984-34.496 137.504-90.016l0.64-1.984c2.4-8.576 9.152-27.872 16.96-50.24 31.296-89.6 83.68-239.552 83.68-321.088 0-84.576-50.624-131.168-142.592-131.168zM71.264 804h112.8V425.056H71.264v378.944z m801.6-17.28c-8.48 24.384-14.72 42.24-17.824 52.928-14.048 38.4-53.344 42.56-69.728 42.56h-234.752c-91.296 0-145.6-43.36-168.768-61.888-11.52-9.216-20.672-16.512-35.328-16.512H255.296V425.056h72.64c40.64 0 136.48-56.576 188.48-141.824 22.4-36.736 30.08-77.248 35.296-132.288a534.4 534.4 0 0 0-0.96-59.2c-0.448-7.616-0.96-16.384-0.96-22.976 20.416-1.184 57.28 1.216 67.968 5.12 27.04 10.272 40.992 25.92 43.968 49.28 12.256 96.192-38.176 191.008-43.968 201.504l-1.152 2.176a66.848 66.848 0 0 0 4.864 66.464 72.64 72.64 0 0 0 60.8 31.68h199.232c59.68 0 71.36 22.944 71.36 62.528 0 70.304-52.032 219.2-80 299.2z" p-id="958"></path></svg>${i18n.sms_unresolved}</a>
2081                </div>`
2082            }
2083            if(typeof value.content == 'object'){
2084                if(this.isArray(value.content)){
2085                    let kno = []
2086                    value.content.forEach((e,i)=>{
2087                        let group = Math.floor(i/3)
2088                        kno.push(`<div class="knoa" group="${group}"><a href="javascript:;" biz="${e.bizId}">${e.title}</a></div>`)
2089                    })
2090                    if(value.content.length>3){
2091                        change = `<a href="javascript:;" cg="0" ag="${Math.ceil(value.content.length/3)-1}"><svg t="1727143795984" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="9434" width="200" height="200"><path d="M118.869333 503.096889c1.137778-49.948444 11.406222-98.417778 30.72-144.014222A392.277333 392.277333 0 0 1 233.841778 234.097778a391.111111 391.111111 0 0 1 278.044444-115.2c53.134222 0 104.561778 10.382222 152.917334 30.833778 46.734222 19.740444 89.144889 48.384 124.928 84.366222 11.292444 11.292444 21.902222 23.324444 31.772444 35.868444l-68.835556 53.731556a9.102222 9.102222 0 0 0 3.441778 16.099555l200.817778 49.152c5.688889 1.365333 11.292444-2.986667 11.292444-8.817777l0.910223-206.734223a9.102222 9.102222 0 0 0-14.734223-7.196444l-64.455111 50.403555c-87.893333-112.469333-224.568889-184.576-378.168889-184.576-261.831111 0-474.851556 209.834667-479.772444 470.641778a9.130667 9.130667 0 0 0 9.159111 9.358222h68.551111a9.102222 9.102222 0 0 0 9.159111-8.903111zM982.869333 512h-68.579555a9.102222 9.102222 0 0 0-9.159111 8.903111 390.4 390.4 0 0 1-30.72 144.014222 391.054222 391.054222 0 0 1-84.224 125.013334 391.367111 391.367111 0 0 1-278.072889 115.2 391.139556 391.139556 0 0 1-27
20917.930667-115.2c-11.320889-11.292444-21.959111-23.324444-31.772444-35.868445l68.778666-53.731555a9.130667 9.130667 0 0 0-3.413333-16.099556l-200.817778-49.152a9.187556 9.187556 0 0 0-11.292444 8.817778l-0.796445 206.848c0 7.68 8.789333 12.003556 14.734223 7.196444l64.455111-50.403555c87.893333 112.355556 224.568889 184.462222 378.168889 184.462222 261.973333 0 474.851556-209.92 479.772444-470.641778a9.102222 9.102222 0 0 0-9.130667-9.358222z" p-id="9435"></path></svg>${i18n.sms_change}</a>`
2092                    }
2093                    content = `<p class="ktitle"><span>${i18n.sms_recommend}:</span>${change}</p><div class="faq">${kno.join("")}</div>`
2094                }else{
2095                    let source = []
2096                    let sourceDom = ``
2097                    // value.content.source = ["http://www.baidu.com","http://300.cn","http://asdjdj.3121kasd.cjdad.cchttp://asdjdj.3121kasd.cjdad.cc"]
2098                    if(value.content.source && value.content.source.length>0){
2099                        value.content.source.forEach(e=>{
2100                            if(typeof e == 'string'){
2101                                source.push(`<li class="sourceItem"><a href="${e}" target="_blank">${e}</a></li>`)
2102                            }else if(typeof e == 'object'){
2103                                for(let i in e){
2104                                    if(e[i] && i && i!='null' && e[i]!='null'){
2105                                        source.push(`<li class="sourceItem"><a href="${i}" target="_blank">${e[i]}</a></li>`)
2106                                    }
2107                                }
2108                            }
2109                        })
2110                        if(source.length>0){
2111                            sourceDom = `<div class="source">
2112                                <p>${i18n.sms_resource}:</p>
2113                                <ul>${source.join('')}</ul>
2114                            </div>`
2115                        }
2116                    }
2117                    content = `<div class="markCon">${marked.parse(value.content.answer)}</div>${sourceDom}`
2118                }
2119            }else if(typeof value.content == 'string'){
2120                content = `<div class="markCon">${marked.parse(value.content)}</div>`
2121            }
2122            return `<div class="msgcon msgknowledge">${content}</div>${reply}`;
2123        }
2124        //客户消息
2125        customerHtml(obj){
2126            return `
2127            <div class="sm_msg cus" data-time="${obj.time}">
2128                <div class="msgtitle">
2129                    <span class="time">${$.formatDate(new Date(obj.time),'yyyy-MM-dd hh:mm')}</span>
2130                </div>
2131                <div class="msgcon">
2132                    ${this.escapeHtml(emo.symbolToHtml(obj.text))}
2133                </div>
2134            </div>
2135            `
2136        }
2137        //html属性转义,用于将表单项已有value值安全地渲染进input/textarea等标签属性
2138        escapeAttr(str) {
2139            if(str===undefined || str===null){
2140                return ''
2141            }
2142            return String(str).replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;')
2143        }
2144        //html转义
2145        escapeHtml(str) {
2146            if (!str) return '';
2147            const allowTags = [
2148                'span',
2149                'br'
2150            ];
2151            return str.replace(/<\/?([a-zA-Z][\w-]*)(\s[^<>]*)?>/g, (match, tagName) => {
2152                // 保留允许标签
2153                if (allowTags.includes(tagName.toLowerCase())) {
2154                    return match;
2155                }
2156                // 转义HTML
2157                return match
2158                    .replace(/&/g, '&amp;')
2159                    .replace(/</g, '&lt;')
2160                    .replace(/>/g, '&gt;')
2161                    .replace(/"/g, '&quot;')
2162                    .replace(/'/g, '&#39;');
2163            });
2164        }
2165        //图标
2166        getIcon(){
2167            let prompt = ``
2168            if(this.colorLayout.showFlag!=1 && this.colorLayout.tipText){
2169                prompt = `<span class="smtIconPrompt ${this.colorLayout.windowLocation=='left'?'leftPrompt':''}">${this.colorLayout.tipText}</span>`
2170                if(this.res.enableAgentFlag) {
2171                    prompt = `<span class="smtIconPrompt_"></span>`
2172                }
2173            }
2174            let icons = '';
2175            if(this.res.aiAgentImg) {
2176                icons = `<a href="javascript:;" id="${this.iconId}" smartService class="smartIcon aiAgentImg ${this.colorLayout.windowLocation=='left'?'leftIcon':''}"><img src="${this.res.aiAgentImg}" class="aiAgentImg" /></a>`
2177            }else{
2178                icons = `
2179                    <a href="javascript:;" id="${this.iconId}" smartService class="smartIcon ${this.colorLayout.windowLocation=='left'?'leftIcon':''}">
2180                        <svg t="1691993598192" class="icon" viewB
2180ox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="814" width="200" height="200"><path d="M508.30872719 128.08273435c200.36824869 0 362.83837999 164.57253407 362.83837996 367.57335931 0 203.01910646-162.45184851 367.59164208-362.83837996 367.59164209v-55.13783256c170.33129377 0 308.41353791-139.89213981 308.41353633-312.43552832 0-172.57995248-138.08224413-312.45380951-308.41353633-312.45380952s-308.41353791 139.89213981-308.41353791 312.43552831c0 5.48453223 0.12797313 10.93250049 0.40219903 16.34390634H145.81770106c-0.23766351-5.41140585-0.36563506-10.8593741-0.36563663-16.34390634C145.45206443 292.65526841 307.94047692 128.08273435 508.32700838 128.08273435z" p-id="815"></path><path d="M508.30872719 240.40595711c139.16086813 0 251.95941786 114.27937278 251.95941629 255.25013655 0 140.98904501-112.79854975 255.26841777-251.95941629 255.26841777-36.65495788 0-71.46345612-7.91600767-102.87154529-22.1757924l-65.81438835 34.62568148c-9.89044049 5.19202354-22.06610207 1.27972351-27.18499926-8.72040577a20.65840542 20.65840542 0 0 1-2.01099519-12.76067896l12.10253519-73.76696156a256.18250777 256.18250777 0 0 1-66.18002497-172.47026056c0-140.97076381 112.79854975-255.25013657 251.95941787-255.25013655zM381.28695667 446.66093709c-24.4975775 0-44.33330364 20.10995203-44.33330366 44.91832098 0 24.80836739 19.85400733 44.91831942 44.33330366 44.91831943 24.4975775 0 44.35158484-20.10995203 44.35158486-44.91831943 0-24.80836739-19.85400733-44.91831942-44.35158486-44.91832098z m127.00348775 0c-24.4975775 0-44.35158484 20.10995203-44.35158488 44.91832098 0 24.80836739 19.85400733 44.91831942 44.35158488 44.91831943s44.33330364-20.10995203 44.33330363-44.91831943c0-24.80836739-19.85400733-44.91831942-44.33330363-44.91832098z m126.98520652 0c-24.4975775 0-44.35158484 20.10995203-44.35158484 44.91832098 0 24.80836739 19.85400733 44.91831942 44.35158484 44.91831943s44.35158484-20.10995203 44.35158484-44.91831943c0-24.80836739-19.85400733-44.91831942-44.35158484-44.91832098zM183.47815657 388.70771279l43.82141265 251.79488075a34.91819015 34.91819015 0 0 1-27.33125199 40.36615843l-0.65814374 0.10969033c-62.21287819 11.11531881-121.53723669-30.96932612-132.50630275-93.9866024L56.71233074 529.00205007c-10.96906446-63.03555904 30.5671271-123.12775168 92.79828807-134.24307046l33.96753776-6.06954959zM840.52513489 388.70771279L790.707299 674.89061152l33.98581895 6.06954959c62.21287819 11.11531881 121.53723669-30.96932612 132.50630273-93.98660398l10.09153845-57.97150706c10.96906446-63.03555904-30.5671271-123.12775168-92.7982881-134.24307046l-33.96753614-6.06954959zM464.96263993 808.10990319h86.6738933c23.94912413 0 43.32780605 19.65290783 43.32780446 43.89454063 0 24.25991557-19.37868034 43.91282183-43.32780446 43.91282183h-86.6556121c-23.94912413 0-43.36437003-19.65290783-43.36437003-43.91282183 0-24.2416328 19.41524431-43.89454063 43.34608883-43.89454063z" p-id="816"></path></svg>
2181                    </a>${prompt}`
2182            }
2183            return icons
2184        }  
2185        //对话框
2186        getDialog() {
2187            let c = this.colorLayout
2188            let img = $.handleDataImg(this.kefuHead) || '/npublic/commonjs/smartService/kefu.png'
2189            let className = `smartService ${c.windowLocation=='right'?'rightWindow':'leftWindow'} ${c.windowStyle==1?'bigWindow':'smallWindow'} ${c.entranceLocation!=1?'near':''}`
2190            let sendIcon = `<svg t="1691993635353" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="953" width="200" height="200"><path d="M512 512m-421.875 0a421.875 421.875 0 1 0 843.75 0 421.875 421.875 0 1 0-843.75 0Z" p-id="954"></path><path d="M322.37828973 688.38815811L358.3486846 528.43092136l255.34539404-15.98684272-255.34539404-17.31907864L322.42269702 335.63404636A22.20394702 22.20394702 0 0 1 353.99671026 310.89884851l362.52384934 181.25082285a22.20394702 22.20394702 0 0 1 0 39.70065728L353.97450662 713.12335513A22.20394702 22.20394702 0 0 1 322.37828973 688.38815811z" fill="#ffffff" p-id="955"></path></svg>`
2191            if(this.colorLayout.modelType==2){
2192                sendIcon = i18n.sms_send
2193            }
2194            let title = i18n.sms_title
2195            if(this.settings.titleFlag==1){
2196                title = this.settings.title
2197            }
2198            
2199            // 检查 memberFlag 是否开启会员中心
2200            console.log('是否开启会员中心', this.res.memberFlag);
2201            const isDebugMode = this.res.memberFlag;
2202
2203            // 动态生成快速标签
2204            let quickLabels = '';
2205            
2206            if (this.res.quickLabel && Array.isArray(this.res.quickLabel)) {
2207                quickLabels = this.res.quickLabel
2208                    .filter(label => label.status == true) // 只有status为1时才显示
2209                    .filter(label => label.name == 'AI搜索' ? label.name = i18n.aiSearch : label.name)
2210                    .map((label, index) => 
2211                        `<div class="quick_label_item" data-type="${label.type ? label.type : '0'}" data-index="${index}">${label.svg || ''}${label.name}</div>`
2212                    )
2213                    .join('');
2214            }
2215            
2216            // 快速标签区域
2217            const quickLabelsSection = quickLabels ? `
2218                <div class="quick_labels">
2219                    ${quickLabels}
2220                </div>
2221            ` : '';
2222            
2223            // 只有在调试模式下才显示 tabsNav
2224            const tabsNav = isDebugMode ? `
2225                <div class="sm_tabs_nav">
2226                    <a href="javascript:;" class="sm_tab_link active" data-tab="chat">
2226<svg t="1766115077573" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="1426" width="200" height="200"><path d="M505.6 48a464 464 0 1 1-214.72 875.456c7.104 3.712 2.752 4.096-5.504 6.464l-4.352 1.28c-11.648 3.584-24.576 8.384-52.16 19.2l-1.28 0.448c-34.88 13.632-51.52 19.648-69.824 24.448-36.224 9.408-62.976 9.472-86.144-12.416-36.544-34.56-31.744-63.04 0-164.352l0.512-1.536c14.848-47.36 20.288-73.6 20.864-72.448A464 464 0 0 1 505.6 48z m0 96a368 368 0 0 0-327.296 536.512c17.664 34.24 12.672 58.176-14.592 145.216l-0.512 1.536c-6.976 22.272-11.264 36.672-14.08 48l-0.64 2.56 4.928-1.6c7.808-2.688 17.216-6.208 29.44-10.944l9.856-3.84 1.28-0.448c89.216-34.88 107.776-40.192 141.376-22.656A368 368 0 1 0 505.6 144z" fill="" p-id="1427"></path></svg>${i18n.sms_title || '客服对话'}</a>
2227                    <a href="javascript:;" class="sm_tab_link" data-tab="member"><svg t="1766115111667" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="1571" width="200" height="200"><path d="M0 0h1024v1024H0z" fill="" fill-opacity="0" p-id="1572"></path><path d="M510.912 38.72a464 464 0 1 1 0 928 464 464 0 0 1 0-928z m149.888 736.512h-290.56a16.064 16.064 0 0 0-16 16.384l-0.256 44.16c47.616 22.4 100.8 34.944 156.928 34.944 59.712 0 116.096-14.208 165.952-39.424v-40.064a16 16 0 0 0-16-16zM510.912 134.72a368 368 0 0 0-250.944 637.184 112 112 0 0 1 110.336-92.672h290.56a112 112 0 0 1 108.736 85.12 368 368 0 0 0-258.688-629.632z m1.536 126.528a176 176 0 1 1 0 352 176 176 0 0 1 0-352z m0 96a80 80 0 1 0 0 160 80 80 0 0 0 0-160z" fill="" p-id="1573"></path></svg>${i18n.memberCenter || '会员中心'}</a>
2228                </div>
2229            ` : '';
2230            
2231            // 客服对话内容区域
2232            const chatTabContent = isDebugMode ? `
2233                <div class="sm_tab_content active" id="chat-tab">
2234                    <div class="sm_output clearfix"></div>
2235                    <div class="sm_quickLabel clearfix">${quickLabelsSection}</div>
2236                    <div class="sm_input clearfix">
2237                        <div class="sm_editor"></div>
2238                        <div class="sm_send">
2239                            <div class="erroMsg"></div>
2240                            <a href="javascript:;" class="sm_sendBtn disabled">
2241                                ${sendIcon}
2242                            </a>
2243                        </div>
2244                    </div>
2245                </div>
2246            ` : `
2247                <div class="sm_output clearfix"></div>
2248                <div class="sm_quickLabel clearfix">${quickLabelsSection}</div>
2249                <div class="sm_input clearfix">
2250                    <div class="sm_editor"></div>
2251                    <div class="sm_send">
2252                        <div class="erroMsg"></div>
2253                        <a href="javascript:;" class="sm_sendBtn disabled">
2254                            ${sendIcon}
2255                        </a>
2256                    </div>
2257                </div>
2258            `;
2259
2260            // 会员中心内容区域 - 初始为空,点击时再加载
2261            const memberTabContent = isDebugMode ? `
2262                <div class="sm_tab_content" id="member-tab" style="display:none;">
2263                    <!-- 会员中心内容将在点击tab时动态加载 -->
2264                    <div class="member-loading"></div>
2265                </div>
2266            ` : '';
2267            
2268            // 主对话框结构
2269            const dialogContent = isDebugMode ? `
2270                ${tabsNav}
2271                ${chatTabContent}
2272                ${memberTabContent}
2273            ` : `
2274                ${chatTabContent}
2275            `;
2276            
2277            return `
2278                <div class="${className}" id="${this.conId}">
2279                    <div class="sm_title">
2280                        <span class="sm_mark">
2281                            <svg t="1691993598192" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="814" width="200" height="200"><path d="M508.30872719 128.08273435c200.36824869 0 362.83837999 164.57253407 362.83837996 367.57335931 0 203.01910646-162.45184851 367.59164208-362.83837996 367.59164209v-55.13783256c170.33129377 0 308.41353791-139.89213981 308.41353633-312.43552832 0-172.57995248-138.08224413-312.45380951-308.41353633-312.45380952s-308.41353791 139.89213981-308.41353791 312.43552831c0 5.48453223 0.12797313 10.93250049 0.40219903 
228116.34390634H145.81770106c-0.23766351-5.41140585-0.36563506-10.8593741-0.36563663-16.34390634C145.45206443 292.65526841 307.94047692 128.08273435 508.32700838 128.08273435z" p-id="815"></path><path d="M508.30872719 240.40595711c139.16086813 0 251.95941786 114.27937278 251.95941629 255.25013655 0 140.98904501-112.79854975 255.26841777-251.95941629 255.26841777-36.65495788 0-71.46345612-7.91600767-102.87154529-22.1757924l-65.81438835 34.62568148c-9.89044049 5.19202354-22.06610207 1.27972351-27.18499926-8.72040577a20.65840542 20.65840542 0 0 1-2.01099519-12.76067896l12.10253519-73.76696156a256.18250777 256.18250777 0 0 1-66.18002497-172.47026056c0-140.97076381 112.79854975-255.25013657 251.95941787-255.25013655zM381.28695667 446.66093709c-24.4975775 0-44.33330364 20.10995203-44.33330366 44.91832098 0 24.80836739 19.85400733 44.91831942 44.33330366 44.91831943 24.4975775 0 44.35158484-20.10995203 44.35158486-44.91831943 0-24.80836739-19.85400733-44.91831942-44.35158486-44.91832098z m127.00348775 0c-24.4975775 0-44.35158484 20.10995203-44.35158488 44.91832098 0 24.80836739 19.85400733 44.91831942 44.35158488 44.91831943s44.33330364-20.10995203 44.33330363-44.91831943c0-24.80836739-19.85400733-44.91831942-44.33330363-44.91832098z m126.98520652 0c-24.4975775 0-44.35158484 20.10995203-44.35158484 44.91832098 0 24.80836739 19.85400733 44.91831942 44.35158484 44.91831943s44.35158484-20.10995203 44.35158484-44.91831943c0-24.80836739-19.85400733-44.91831942-44.35158484-44.91832098zM183.47815657 388.70771279l43.82141265 251.79488075a34.91819015 34.91819015 0 0 1-27.33125199 40.36615843l-0.65814374 0.10969033c-62.21287819 11.11531881-121.53723669-30.96932612-132.50630275-93.9866024L56.71233074 529.00205007c-10.96906446-63.03555904 30.5671271-123.12775168 92.79828807-134.24307046l33.96753776-6.06954959zM840.52513489 388.70771279L790.707299 674.89061152l33.98581895 6.06954959c62.21287819 11.11531881 121.53723669-30.96932612 132.50630273-93.98660398l10.09153845-57.97150706c10.96906446-63.03555904-30.5671271-123.12775168-92.7982881-134.24307046l-33.96753614-6.06954959zM464.96263993 808.10990319h86.6738933c23.94912413 0 43.32780605 19.65290783 43.32780446 43.89454063 0 24.25991557-19.37868034 43.91282183-43.32780446 43.91282183h-86.6556121c-23.94912413 0-43.36437003-19.65290783-43.36437003-43.91282183 0-24.2416328 19.41524431-43.89454063 43.34608883-43.89454063z" p-id="816"></path></svg>
2282                        </span>
2283                        <a href="javascript:;" class="sm_close">
2284                            <svg t="1766710772080" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="59118" width="200" height="200"><path d="M512 62c-248.52 0-450 201.48-450 450s201.48 450 450 450 450-201.48 450-450c0-248.52-201.48-450-450-450zM752 542h-480v-60h480v60z" p-id="59119"></path></svg>
2285                        </a>
2286                        <a href="javascript:;" class="sm_expand">
2287                            <span class="sm_expand_txt"><svg t="1783923146259" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10834" width="200" height="200"><path d="M831.89 192l0.11 0.11v639.78l-0.11 0.11H192.11l-0.11-0.11V192.11l0.11-0.11h639.78m0.11-64H192a64.19 64.19 0 0 0-64 64v640a64.19 64.19 0 0 0 64 64h640a64.19 64.19 0 0 0 64-64V192a64.19 64.19 0 0 0-64-64z" p-id="10835"></path><path d="M512 512H224v64h288v-64z" p-id="10836"></path><path d="M512 512h-64v288h64V512z" p-id="10837"></path><path d="M457.37 521.37L224 754.75 269.25 800l233.38-233.37-45.26-45.26zM816 432H528v64h288v-64z" p-id="10838"></path><path d="M592 208h-64v288h64V208z" p-id="10839"></path><path d="M770.75 208L537.37 441.37l45.26 45.26L816 253.25 770.75 208z" p-id="10840"></path></svg>${c.windowLocation=='left' ? (i18n.sms_shrink_left || '还原为左侧助手') : (i18n.sms_shrink || '还原为右侧助手')}</span>
2288                            <svg class="icon sm_expand_icon" t="1783917535858" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9805" width="200" height="200"><path d="M853.333333 0H170.666667C76.8 0 0 76.8 0 170.666667v682.666666c0 93.866667 76.8 170.666667 170.666667 170.666667h682.666666c93.866667 0 170.666667-76.8 170.666667-170.666667V170.666667c0-93.866667-76.8-170.666667-170.666667-170.666667z m85.333334 853.333333c0 46.933333-38.4 85.333333-85.333334 85.333334H170.666667c-46.933333 0-85.333333-38.4-85.333334-85.333334V170.666667c0-46.933333 38.4-85.333333 85.333334-85.333334h682.666666c46.933333 0 85.333333 38.4 85.333334 85.333334v682.666666z" p-id="9806"></path><path d="M128 213.333333c0-46.933333 38.4-85.333333 85.333333-85.333333h128c25.6 0 42.666667 17.066667 42.666667 42.666667s-17.066667 42.666667-42.666667 42.666666H213.333333v128c0 25.6-17.066667 42.666667-42.666666 42.666667s-42.666667-17.066667-42.666667-42.666667V213.333333zM896 213.333333c0-46.933333-38.4-85.333333-85.333333-85.333333h-128c-25.6 0-42.666667 17.066667-42.666667 42.666667s17.066667 42.666667 42.666667 42.666666h128v128c0 25.6 17.066667 42.666667 42.666666 42.666667s42.666667-17.066667 42.666667-42.666667V213.333333zM128 810.666667c0 46.933333 38.4 85.333333 85.333333 85.333333h128c25.6 0 42.666667-17.066667 42.666667-42.666667s-17.066667-42.666667-42.666667-42.666666H213.333333v-128c0-25.6-17.066667-42.666667-42.666666-42.666667s-42.666667 17.066667-42.666667 42.666667v128zM896 810.666667c0 46.933333-38.4 85.333333-85.333333 85.333333h-128c-25.6 0-42.666667-17.066667-42.666667-42.666667s17.066667-42.666667 42.666667-42.666666h128v-128c0-25.6 17.066667-42.666667 42.666666-42.666667s42.666667 17.066667 42.666667 42.666667v128z" p-id="9807"></path></svg>
2289                        </a>
2290                        <div class="sm_admin">
2291                            <img src="${img}" alt="${this.settings.name}" la="la" />
2292                            <p>${title}</p>
2293                        </div>
2294                    </div>
2295                    <div class="sm_dialog">
2296                        ${dialogContent}
2297                    </div>
2298                </div>
2299            `
2300        }
2301        getFormlog(){
2302            let c = this.colorLayout
2303            let className = `smartService ${c.windowLocation=='right'?'rightWindow':'leftWindow'} ${c.windowStyle==1?'bigWindow':'smallWindow'} ${c.entranceLocation!=1?'near':''} smsForm`
2304            let formSet = JSON.parse(this.res.setting.moreSetting)
2305            return `
2306            <div class="${className}" id="${this.conId}-form" >
2307                <div class="sm_title">
2308                    <a href="javascript:;" class="sm_close">
2309                        <svg t="1747379471975" class="icon" viewB
2309ox="0 0 1024 1024" version="1.1" xmlns="https://www.w3.org/2000/svg" p-id="4982" width="128" height="128"><path d="M297.69350383 346.29910124L512 560.6055974 726.30649617 346.29910124a55.0126984 55.0126984 0 1 1 77.87942242 77.87942241L550.66354348 677.70089876a55.0126984 55.0126984 0 0 1-77.87942242 0L219.26174595 424.17852365c-10.49439069-10.49439069-16.01775312-24.30279805-16.01775442-38.66354347s6.07569919-28.72148955 16.01775442-39.21587894c21.54111683-20.98878007 56.89064234-21.54111683 78.43175788 0z" p-id="4983"></path></svg>
2310                    </a>
2311                    <div class="sm_formTitle">${formSet.chatSurveyForm.title}</div>
2312                    <img src="/npublic/commonjs/smartService/formbg.png" alt="form" la="la" />
2313                </div>
2314                ${this.getMsg(formSet.chatSurveyForm,'form')}
2315            </div>
2316            `
2317        }
2318        //显示客服窗口
2319        showFun(){
2320            console.log('是否登录', this.isLoginFlag);
2321            if(this.nim){
2322                this.nim.disconnect();
2323            }
2324            if(this.needForm){
2325                $("#"+this.conId+"-form").addClass("show")
2326                return
2327            }
2328            $("#"+this.conId+"-form").remove()
2329            $("#"+this.conId).addClass("show")
2330            $(".smtIconPrompt").hide()
2331            this.handleReply(false)
2332            //重新打开时视口尺寸可能已变化,重新计算聊天内容区高度
2333            this.calcOutputHeight()
2334
2335            // 在重新打开窗口时,清除未读消息计数和本地存储
2336            this.unreadMessageCount = 0;
2337            this.clearUnreadCountFromStorage();
2338            this.updateUnreadBadge(); // 更新角标显示(实际上会移除角标)
2339            
2340            // 在重新打开窗口时,检查是否需要显示 loading 状态
2341            setTimeout(() => {
2342                const $output = $('.sm_output');
2343                // 检查是否有消息,如果没有则显示 loading
2344                if ($output.find('.sm_msg').length === 0) {
2345                    // 添加 loading 独白
2346                    this.showLoadingMessage();
2347                }
2348                if(this.res.enableAgentFlag) {
2349                    this.manageMessagesDisplay();
2350                }
2351            }, 100);
2352            
2353            this.logNim()
2354
2355            if(window.ZQSensorsObj && !this.res.memberFlag && !this.isWakeUp){
2356                this.isWakeUp = true
2357                console.log("md智慧客服唤起")
2358                let obj = {
2359                    tenantId: tenant.tenantId, 
2360                    iBusinessCode : "01",
2361                    iBusinessName : "智慧客服业务线",
2362                    iBusinessCustId : this.res.account
2363                }
2364                ZQSensorsObj.track('SmartServiceWakeUp',obj);
2365            }
2366            
2367        }
2368        //二维数组排序
2369        arraySort(data, key, order) {
2370            let nData = data
2371            let reg = /^([+]\d+[.]\d+|[-]\d+[.]\d+|\d+[.]\d+|[+]\d+|[-]\d+|\d+)$/
2372            if(order == 'desc'){
2373                nData = data.sort((a, b) => {
2374                    if (reg.test(a[key])) {
2375                        return b[key] - a[key]
2376                    } else {
2377                        return b[key].localeCompare(a[key])
2378                    }
2379                })
2380            }else{
2381                nData = data.sort((a, b) => {
2382                    if (reg.test(a[key])) {
2383                        return a[key] - b[key]
2384                    } else {
2385                        return a[key].localeCompare(b[key])
2386                    }
2387                })
2388            } 
2389            return nData
2390        }
2391        //终端
2392        getTerminal(){
2393            //判断是否mo环境
2394            var isMo = function() {
2395                return Boolean(navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) || $(window).width()<=768 
2396            }
2397            // 渠道:小程序-1、公众号-2、PC-3、H5-4
2398            return this.isWxMini()?1:this.isWechat()?2:isMo()?4:3 
2399        }
2400        //判断微信
2401        isWechat(){
2402            return navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger'
2403        }
2404        //判断小程序
2405        isWxMini(){
2406            return window.__wxjs_environment === 'miniprogram' || navigator.userAgent.toLowerCase().match(/miniprogram/i) =='miniprogram'
2407        }
2408
2409        // 创建打招呼弹窗
2410        createGreetingPopup() {
2411            if (!this.shouldShowGreetingPopup()) {
2412                return; // 如果今天已经关闭过,则不显示
2413            }
2414            // 确保只创建一次
2415            if ($("#greetingPopup").length > 0) return;
2416            let img = $.handleDataImg(this.kefuHead) || '/npublic/commonjs/smartService/kefu.png'
2417            
2418            // 调用接口获取打招呼内容
2419                let title = this.colorLayout.tipTitle || i18n.AICustomerService || '您好!我是AI智能客服';
2420                let content = this.colorLayout.tipText || i18n.AICustomerServiceInfo || '我可以帮您解答问题、推荐产品,随时为您服务!';
2421                let tagsArr = this.colorLayout.tipLabels && this.colorLayout.tipLabels.length ? this.colorLayout.tipLabels : [];
2422                // 创建弹窗DOM
2423                const popupHtml = `
2424                    <div id="greetingPopup" class="greeting-popup ${this.colorLayout.windowLocation=='left'?'greeting-popup-left':''} ${this.colorLayout.entranceLocation==2?'greeting-popup-corner':''}">
2425                        <div class="greeting-content">
2426                            <span class="greeting-close">&times;</span>
2427                            <div class="greeting-info">
2428                                <div class="greeting-img">
2429                                    <img src="${img}" alt="${this.settings.name}" la="la" />
2430                                </div>
2431                                <div class="greeting-infoBox">
2432                                    <div class="greeting-header">
2433                                        <div class="greeting-title"></div>
2434                                    </div>
2435                                    <div class="greeting-body">
2436                                        <div class="greeting-text"></div>
2437                                        <div class="greeting-tags"></div>
2438                                    </div>
2439                                </div>
2440                            </div>
2441                            <div class="greeting-btn-box">
2442                                <button class="greeting-close-btn greeting-btn-close">${i18n.close || '关闭'}</button>
2443                                <button class="greeting-btn">${i18n.quickConsult || '立即咨询'}</button>
2444                            </div>
2445                        </div>
2446                    </div>
2447                `;
2448                
2449                // 添加到页面
2450                $("body").append(popupHtml);
2451
2452                // 绑定事件
2453                const popup = $("#greetingPopup");
2454                popup.find(".greeting-close").on("click", () => {
2455                    // popup.remove();
2456                    this.closeGreetingPopup();
2457                });
2458
2459                popup.find(".greeting-close-btn").on("click", () => {
2460                    this.closeGreetingPopup();
2461                });
2462
2463                popup.find(".greeting-btn").on("click", () => {
2464                    popup.remove();
2465                    $(document).off("click.greetingPopup");
2466                    this.showFun(); // 打开真正的客服窗口
2467                });
2468                
2469                // 设置标题
2470                if (title) {
2471                    popup.find(".greeting-title").text(title);
2472                }
2473                
2474                // 设置内容
2475                if (content) {
2476                    popup.find(".greeting-text").text(content || '打招呼');
2477                }
2478                
2479                // 设置标签
2480                if (tagsArr && Array.isArray(tagsArr)) {
2481                    const colorsClass = ['colors1', 'colors2', 'colors3', 'colors4'];
2482                    const tagsHtml = tagsArr.map((tag, index) => {
2483                        const color = colorsClass[index % colorsClass.length];
2484                        return `<span class="greeting-tag ${color}">${tag}</span>`
2485                    }).join('');
2486                    popup.find(".greeting-tags").html(tagsHtml);
2487                }
2488                
2489                // 1秒后显示弹窗,并注册点击外部关闭
2490                setTimeout(() => {
2491                    popup.addClass("show");
2492                    setTimeout(() => {
2493                        $(document).on("click.greetingPopup", (e) => {
2494                            if (!$(e.target).closest("#greetingPopup .greeting-content").length &&
2495                                !$(e.target).closest(".smartIcon").length) {
2496                                this.closeGreetingPopup();
2497                                $(document).off("click.greetingPopup");
2498                            }
2499                        });
2500                    }, 300);
2501                }, 1000);
2502        }
2503
2504        // 检查是否应该显示问候弹窗
2505        shouldShowGreetingPopup() {
2506            const closedDate = sessionStorage.getItem('greetingPopupClosedDate');
2507            
2508            if (!closedDate) {
2509                return true;
2510            }
2511            
2512            const today = new Date();
2513            const todayKey = `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`;
2514            
2515            return closedDate !== todayKey;
2516        }
2517
2518        // 关闭问候弹窗
2519        closeGreetingPopup() {
2520            const today = new Date();
2521            const dateKey = `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`;
2522
2523            sessionStorage.setItem('greetingPopupClosedDate', dateKey);
2524            $(document).off("click.greetingPopup");
2525
2526            // 隐藏弹窗
2527            $(`#greetingPopup`).fadeOut(300);
2528            
2529            // 如果需要,也可以移除DOM元素
2530            // $(`.greeting-popup`).remove();
2531        }
2532
2533        // 显示跑马灯
2534        showMarquee(msg) {
2535            $("#marqueePopup").remove()
2536            let img = $.handleDataImg(this.kefuHead) || '/npublic/commonjs/smartService/kefu.png'
2537            let isLeft = this.colorLayout.windowLocation === 'left'
2538
2539            // 提取消息纯文本
2540            let text = ''
2541            if (msg.type === 'text') {
2542                text = msg.text || ''
2543            } else if (msg.type === 'custom') {
2544                try {
2545                    let msgObject = JSON.parse(msg.content)
2546                    if (msgObject.aiAgent && msgObject.aiAgent.msg) {
2547                        text = msgObject.aiAgent.msg
2548                    } else {
2549                        for (let key of (msgObject.paramSort || [])) {
2550                            if ((key === 'text' || key === 'title') && msgObject[key]) {
2551                                text = msgObject[key]; break
2552                            }
2553                        }
2554                    }
2555                } catch(e) {}
2556            }
2557            // 去除 markdown 符号,只保留纯文本
2558            text = text.replace(/[#*_`>\[\]!]/g, '').replace(/\n/g, ' ').trim()
2559            if (!text) return
2560
2561            const popupHtml = `
2562                <div id="marqueePopup" class="greeting-popup ${isLeft ? 'greeting-popup-left' : ''}" style="min-width: 382px;">
2563                    <div class="greeting-content">
2564                        <span class="marquee-close greeting-close" style="display: none;">&times;</span>
2565                        <div class="greeting-info">
2566                            <div class="greeting-img" style="display: none;">
2567                                <img src="${img}" alt="${this.settings.name}" la="la" />
2568                            </div>
2569                            <div class="greeting-infoBox">
2570                                <div class="greeting-header" style="display: none;">
2571                                    <div class="greeting-title">${this.settings.name}</div>
2572                                </div>
2573                                <div class="greeting-body">
2574                                    <div class="marquee-text-wrap">
2575                                        <span class="marquee-text">${text}</span>
2576                                    </div>
2577                                </div>
2578                            </div>
2579                        </div>
2580                        <div class="greeting-btn-box">
2581                            <button class="greeting-btn marquee-reply-btn">${i18n.quickConsult || '回复'}</button>
2582                            <button class="greeting-btn-close">${i18n.close || '关闭'}</button>
2583                        </div>
2584                    </div>
2585                </div>
2586            `
2587            if ($("#greetingPopup").length > 0) {
2588                $("#greetingPopup").remove();
2589                this.closeGreetingPopup();
2590            }
2591            $("body").append(popupHtml)
2592            const $popup = $("#marqueePopup")
2593            $popup.find(".marquee-close").on("click", () => { $popup.remove(); $(document).off("click.marqueePopup") })
2594            $popup.find(".marquee-reply-btn").on("click", () => { $popup.remove(); $(document).off("click.marqueePopup"); this.showFun() })
2595            $popup.find(".greeting-btn-close").on("click", () => { $popup.remove(); $(document).off("click.marqueePopup"); $("#greetingPopup").length && $("#greetingPopup").show() })
2596            setTimeout(() => {
2597                $popup.addClass("show");
2598                setTimeout(() => {
2599                    $(document).on("click.marqueePopup", (e) => {
2600                        if (!$(e.target).closest("#marqueePopup .greeting-content").length &&
2601                            !$(e.target).closest(".smartIcon").length) {
2602                            $popup.remove();
2603                            $(document).off("click.marqueePopup");
2604                        }
2605                    });
2606                }, 300);
2607            }, 100)
2608        }
2609
2610        // 隐藏跑马灯
2611        hideMarquee() {
2612            $("#marqueePopup").remove()
2613        }
2614
2615        // 显示 loading 状态
2616        showLoadingMessage() {
2617            const $output = $('.sm_output');
2618            
2619            // 检查是否已经存在 loading 消息
2620            if ($output.find('.loading-message').length === 0) {
2621                // 创建跳动文本效果
2622                const loadingText = "......"; // 你可以自定义这个文本
2623                const bounceText = loadingText.split('').map((char, index) => 
2624                    `<span style="animation-delay: ${index * 0.1}s">${char}</span>`
2625                ).join('');
2626                
2627                $output.append(`
2628                    <div class="loading-message bounce-text" style="min-height:${$('.sm_output').height()}px">${bounceText}</div>
2629                `);
2630                // 确保滚动到底部
2631                $output.scrollTop(99999999);
2632            }
2633        }
2634
2635        // 隐藏 loading 状态
2636        hideLoadingMessage() {
2637            $('.sm_output .loading-message').remove();
2638        }
2639
2640        // 新增:管理消息显示的方法
2641        manageMessagesDisplay() {
2642            const $output = $('.sm_output');
2643            const $messages = $output.find('.sm_msg');
2644            
2645            // 获取今天的日期(时间戳)
2646            const today = new Date();
2647            today.setHours(0, 0, 0, 0);
2648            const todayTimestamp = today.getTime();
2649            
2650            // 筛选出今天之前的消息
2651            const $oldMessages = $messages.filter(function() {
2652                const msgTime = parseInt($(this).attr('data-time')) || 0;
2653                return msgTime < todayTimestamp;
2654            });
2655            
2656            // 筛选出今天及之后的消息
2657            const $todayMessages = $messages.filter(function() {
2658                const msgTime = parseInt($(this).attr('data-time')) || 0;
2659                return msgTime >= todayTimestamp;
2660            });
2661            
2662            // 移除可能存在的"以下是当前会话"提示
2663            $output.find('.current-session-tip').remove();
2664            
2665            // 隐藏今天之前的消息
2666            $oldMessages.hide();
2667            
2668            // 显示今天及之后的消息
2669            $todayMessages.show();
2670            
2671            // 如果有今天之前的旧消息,则添加"查看更多"按钮
2672            if ($oldMessages.length > 0) {
2673                // 如果还没有"查看更多"按钮,则添加一个
2674                if (!$output.find('.load-more-messages').length) {
2675                    const loadMoreButton = $(`
2676                        <div class="load-more-messages">
2677                            <a href="javascript:;">${i18n.viewHistory || '查看历史会话'}</a>
2678                        </div>
2679                    `);
2680                    
2681                    // 将按钮插入到第一条今天的消息之前
2682                    if ($todayMessages.first().length) {
2683                        $todayMessages.first().before(loadMoreButton);
2684                    } else {
2685                        $output.append(loadMoreButton);
2686                    }
2687
2688                    // 绑定点击事件
2689                    loadMoreButton.on('click', () => {
2690                        this.loadMoreMessages();
2691                    });
2692                }
2693            } else {
2694                // 如果没有旧消息,移除"查看更多"按钮
2695                $output.find('.load-more-messages').remove();
2696            }
2697        }
2698
2699        // 加载历史消息
2700        loadMoreMessages() {
2701            const $output = $('.sm_output');
2702            const $messages = $output.find('.sm_msg');
2703            
2704            // 获取今天的日期(时间戳)
2705            const today = new Date();
2706            today.setHours(0, 0, 0, 0);
2707            const todayTimestamp = today.getTime();
2708            
2709            // 筛选出今天之前的消息
2710            const $oldMessages = $messages.filter(function() {
2711                const msgTime = parseInt($(this).attr('data-time')) || 0;
2712                return msgTime < todayTimestamp;
2713            });
2714            
2715            // 筛选出当前隐藏的旧消息
2716            const $hiddenOldMessages = $oldMessages.filter(':hidden');
2717            
2718            // 每次显示最多10条旧消息
2719            const messagesToShow = Math.min(10, $hiddenOldMessages.length);
2720            
2721            // 显示接下来的10条旧消息
2722            if ($hiddenOldMessages.length > 0) {
2723                $hiddenOldMessages.slice(0, messagesToShow).show();
2724            }
2725            
2726            // 获取"查看更多"按钮
2727            const $loadMoreButton = $output.find('.load-more-messages');
2728            
2729            // 将"查看更多"按钮移动到当前显示的最后一条历史消息之后
2730            if ($oldMessages.filter(':visible').length > 0) {
2731                const $lastVisibleOldMessage = $oldMessages.filter(':visible').last();
2732                $lastVisibleOldMessage.after($loadMoreButton);
2733            }
2734            
2735            // 如果没有更多隐藏的旧消息了,移除"查看更多"按钮
2736            if ($hiddenOldMessages.length <= messagesToShow) {
2737                $loadMoreButton.remove();
2738            }
2739        }
2740
2741        // 添加页面对象监听方法(30秒推荐商品<暂时不需要>)
2742        initPageObjListener() {
2743            if(!this.res.enableAgentFlag) return;
2744            // 定时检查 window.pageObj
2745            this.pageObjInterval = setInterval(() => {
2746                this.checkPageObj();
2747            }, 1000); // 每秒检查一次
2748            
2749            // 同时也监听可能的 pageObj 变化
2750            this.checkPageObj();
2751        }
2752
2753        // 检查 pageObj 条件
2754        checkPageObj() {
2755            let stayDuration = Number(this.inviteSet?.behavior?.stayDuration) * 1000 || 30000;
2756            if (window.pageObj && 
2757                window.pageObj.appId === '143150160001' && 
2758                window.pageObj.pageType === '3') {
2759                
2760                // 如果条件满足,设置一个30秒调用接口的定时器
2761                if (!this.pageMatchTimer) {
2762                    this.pageMatchTimer = setTimeout(() => {
2763                        this.callBrowseReportApi();
2764                    }, stayDuration ); // 30秒调用接口
2765                }
2766            } else {
2767                // 如果条件不满足,清除之前的定时器
2768                if (this.pageMatchTimer) {
2769                    clearTimeout(this.pageMatchTimer);
2770                    this.pageMatchTimer = null;
2771                }
2772            }
2773        }
2774
2775        // 调用浏览报告接口
2776        callBrowseReportApi() {
2777            // 检查是否已经调用过,避免重复调用
2778            if (this.hasCalledBrowseReport) {
2779                return;
2780            }
2781            this.behaviorReport('detail');
2782            // const url = `${this.res.domain}/visitormanager/intelligent/front/browseReport?tenantId=${tenant.tenantId}&instance=${tenant.bossProductInstance}`;
2783            
2784            // c.cmsAjax.postJson(url, {
2785            //     appCode: window.pageObj.appId,
2786            //     dsId: 'product',
2787            //     title: document.title,
2788            //     pageType: window.pageObj.pageType,
2789            //     accid: this.res.account,
2790            //     timestamp: Date.now()
2791            // }).then((res) => {
2792            //     this.hasCalledBrowseReport = true; // 标记已调用,避免重复调用
2793            // }).catch((err) => {});
2794        }
2795
2796        // 在类的销毁方法中清理定时器(如果有的话)
2797        // 例如在 closeDialog 或其他适当的位置调用
2798        cleanup() {
2799            if (this.pageObjInterval) {
2800                clearInterval(this.pageObjInterval);
2801                this.pageObjInterval = null;
2802            }
2803            
2804            if (this.pageMatchTimer) {
2805                clearTimeout(this.pageMatchTimer);
2806                this.pageMatchTimer = null;
2807            }
2808        }
2809
2810        // 更新未读消息角标
2811        updateUnreadBadge() {
2812            // 保存计数到本地存储
2813            this.saveUnreadCountToStorage();
2814
2815            // invitationType 3:仅显示跑马灯,不显示未读角标
2816            let invitationType = this.inviteSet && this.inviteSet.invitation && this.inviteSet.invitation.invitationType || 1;
2817            if (invitationType == 3) return
2818
2819            const $icon = $("#" + this.iconId);
2820            const $badge = $icon.find('.unread-badge');
2821            
2822            if (this.unreadMessageCount > 0) {
2823                if ($badge.length > 0) {
2824                    // 如果角标已存在,更新数字
2825                    $badge.text(this.unreadMessageCount);
2826                } else {
2827                    // 如果角标不存在,创建新的角标
2828                    const badgeHtml = `<span class="unread-badge">${this.unreadMessageCount}</span>`;
2829                    $icon.append(badgeHtml);
2830                }
2831            } else {
2832                // 如果没有未读消息,移除角标
2833                $badge.remove();
2834            }
2835        }
2836
2837        // 保存未读消息计数到本地存储
2838        saveUnreadCountToStorage() {
2839            localStorage.setItem(`smartService_unreadCount`, this.unreadMessageCount.toString());
2840        }
2841
2842        // 从本地存储获取未读消息计数
2843        getUnreadCountFromStorage() {
2844            const count = localStorage.getItem(`smartService_unreadCount`);
2845            return count ? parseInt(count) : 0;
2846        }
2847
2848        // 清除本地存储中的未读消息计数
2849        clearUnreadCountFromStorage() {
2850            localStorage.removeItem(`smartService_unreadCount`);
2851        }
2852
2853        // 添加检查登录状态并提交的方法
2854        checkLoginAndSubmit($target, isForm, type) {
2855            // 检查是否已登录
2856            this.isLogin().then(isLoggedIn => {
2857                if (isLoggedIn) {
2858                    // 已登录,直接提交表单
2859                    this.submitForm($target, isForm, type);
2860                } else {
2861                    // 未登录,显示登录弹窗
2862                    this.showLoginPopup(() => {
2863                        // 登录成功后的回调
2864                        this.submitForm($target, isForm, type);
2865                    });
2866                }
2867            });
2868        }
2869
2870        // 显示登录弹窗
2871        showLoginPopup(callback) {
2872            // 检查是否已经存在登录弹窗
2873            if ($("#loginPopup").length > 0) return;
2874            
2875            const loginUrl = '/login.html'; // 根据实际情况调整登录页面路径
2876            
2877            // 创建遮罩层
2878            const overlayHtml = '<div id="loginPopupOverlay" class="login-popup-overlay" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); z-index: 99998;"></div>';
2879            
2880            const popupHtml = `
2881                <div id="loginPopup" class="greeting-popup">
2882                    <div class="greeting-content">
2883                        <div style="padding: 20px;">
2884                            <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;">
2885                                <h3 style="margin: 0;">登录</h3>
2886                                <span id="loginPopupClose" class="greeting-close" style="font-size: 24px; cursor: pointer;">&times;</span>
2887                            </div>
2888                            <div style="height: 600px;">
2889                                <iframe 
2890                                    id="loginFrame" 
2891                                    src="${loginUrl}" 
2892                                    width="100%" 
2893                                    height="100%" 
2894                                    frameborder="0" 
2895                                    style="border-radius: 8px;">
2896                                </iframe>
2897                            </div>
2898                        </div>
2899                    </div>
2900                </div>
2901            `;
2902            
2903            // 添加遮罩层和弹窗到页面
2904            $("body").append(overlayHtml).append(popupHtml);
2905            
2906            const $popup = $("#loginPopup");
2907            const $overlay = $("#loginPopupOverlay");
2908            const $loginPrompt = $('.login-prompt');
2909            
2910            // 绑定关闭事件
2911            $popup.find("#loginPopupClose").on("click", () => {
2912                $popup.remove();
2913                $overlay.remove();
2914                clearInterval(loginCheckTimer);
2915            });
2916            
2917            // 点击遮罩层关闭弹窗
2918            $overlay.on("click", () => {
2919                $popup.remove();
2920                $overlay.remove();
2921            });
2922            
2923            // 绑定iframe的load事件来检测登录状态
2924            const $loginFrame = $popup.find("#loginFrame");
2925            let loginCheckTimer = null;
2926            
2927            $loginFrame.on('load', () => {
2928                // 设置定时器定期检查登录状态
2929                loginCheckTimer = setInterval(() => {
2930                    try {
2931                        // 检查iframe中的登录状态,需要同域才能访问
2932                        const iframeDoc = $loginFrame[0].contentDocument || $loginFrame[0].contentWindow.document;
2933                        const loginStatus = iframeDoc.querySelector('.login-success') || 
2934                                        iframeDoc.querySelector('#loginSuccess') || 
2935                                        iframeDoc.querySelector('.user-logged-in');
2936                                                
2937                        // if (loginStatus) {
2938                            // 检测到登录成功
2939                            this.isLogin().then(isLoggedIn => {
2940                                if (isLoggedIn) {
2941                                    clearInterval(loginCheckTimer);
2942                                    $popup.remove();
2943                                    $overlay.remove();
2944                                    $loginPrompt.remove();
2945                                    if (callback && typeof callback === 'function') {
2946                                        callback();
2947                                    }
2948                                }
2949                            });
2950                        // }
2951                    } catch (e) {
2952                        // 跨域访问时会报错,需要使用其他方式检测登录状态
2953                        console.log('无法直接访问iframe内容,使用其他方式检测登录');
2954                    }
2955                }, 2000); // 每秒检查一次
2956            });
2957            
2958            // 显示弹窗
2959            setTimeout(() => {
2960                $popup.addClass("show");
2961            }, 100);
2962        }
2963
2964        getScrollPercent() {
2965            // 滚动高度
2966            const scrollTop = document.documentElement.scrollTop || window.pageYOffset;
2967            // 页面总高度
2968            const scrollHeight = document.documentElement.scrollHeight;
2969            // 可视窗口高度
2970            const clientHeight = document.documentElement.clientHeight;
2971
2972            // 可滚动的总距离
2973            const totalHeight = scrollHeight - clientHeight;
2974
2975            if (totalHeight <= 0) return 0;
2976
2977            // 计算百分比
2978            const percent = (scrollTop / totalHeight) * 100;
2979
2980            // 保留两位小数(可去掉 toFixed)
2981            return parseInt(percent);
2982        }
2983
2984        // 行为轨迹上报
2985        behaviorReport(pageTypes) {
2986            const url = `/fwebapi/behavior/trace/report?tenantId=${tenant.tenantId}&instance=${tenant.bossProductInstance}`;
2987
2988            const previousPageUrl = sessionStorage.getItem('currentPageUrl') || '';
2989            const previousPageTitle = sessionStorage.getItem('currentPageTitle') || '';
2990            // 滚动深度
2991            const percent = this.getScrollPercent();
2992
2993            let reportData = {};
2994
2995            reportData = {
2996                "visitorId": this.res.account,  //客服  account
2997                "sessionId": sessionStorage.getItem('sdkSessionId') || '',  //sdkSessionId
2998                "jsonData": {
2999                    "source": this.getSensorsdata2015().refferUrl || '直接访问',   //判断latestreffer ,区分百度,谷歌等
3000                    "lp": this.getSensorsdata2015().landUrl || '',  //取latest landpage
3001                    "vp": location.href || '',  //当前页面url
3002                    "vpt": document.title || '',    //当前页title
3003                    "pp": previousPageUrl,  //前一页   手动存一下,进入页面时存sessionstorage,{url,title}
3004                    "ppt": previousPageTitle,    //前一页title
3005                    "pn": window.pageObj ? pageObj.name : '',  // pageObj.name
3006                    "appCode": window.pageObj ? pageObj.appId : "",  // pageObj.appId
3007                    "tid": window.pageObj ? pageObj.contentType : '',    //pageObj.contentType
3008                    "pageType":window.pageObj ? pageObj.pageType : '',   //pageObj.pageType   1,2,3综合,列表,详情
3009                    // "visitorId": this.res.account,  //客服  account
3010                    pageId: window.pageObj ? pageObj.pageId : "",
3011                }
3012            }
3013            if(pageTypes == 'isScroll') {
3014                reportData.jsonData.scrollDepth = percent;
3015            } else {
3016                if(reportData.jsonData.scrollDepth) delete reportData.jsonData.scrollDepth;
3017            }
3018            
3019            c.cmsAjax.postJson(url, reportData).then((res) => {}).catch((e) => {});
3020            if(pageTypes == 'detail') this.hasCalledBrowseReport = true;
3021        }
3022        // 初始化行为轨迹上报 - 首次加载调用一次,60秒后再调用一次,总共调用两次
3023        initBehaviorReport() {
3024            console.log("是否符合上报要求:", this.res.enableAgentFlag)
3025            let totalBrowseTime = Number(this.inviteSet?.behavior?.totalBrowseTime) * 1000 || 60000;
3026            if(this.res.enableAgentFlag) {
3027                // 首次加载立即调用
3028                this.behaviorReport();
3029                
3030                // 设置60秒后调用第二次
3031                this.behaviorReportTimer = setTimeout(() => {
3032                    this.behaviorReport();
3033                    // 调用完成后清理定时器引用
3034                    if (this.behaviorReportTimer) {
3035                        clearTimeout(this.behaviorReportTimer);
3036                        this.behaviorReportTimer = null;
3037                    }
3038                }, totalBrowseTime); // 60秒 = 60000毫秒
3039            }
3040        }
3041        
3042        // 获取神策数据
3043
3044        getSensorsdata2015 (){
3045            let cookie = getCookie('sensorsdata2015jssdkcrossZQSensorsObj');
3046            if(cookie){
3047                cookie = JSON.parse(decodeURIComponent(cookie));
3048                let landUrl = decodeURI(decodeURIComponent(escape(cookie.props.$latest_landing_page)), "UTF-8");
3049                let refferUrl = decodeURI(decodeURIComponent(escape(cookie.props.$latest_referrer)), "UTF-8");
3050                if(refferUrl && refferUrl != 'undefined' && refferUrl != 'null'){
3051                    refferUrl = refferUrl.split("#")[0]
3052                    refferUrl = refferUrl.split("?")[0]
3053                    refferUrl = refferUrl.split("//")[1]
3054                    refferUrl = refferUrl.split("/")[0]
3055                    let relist = [
3056                        {
3057                            name:"baidu",
3058                            key:['m.baidu.com','www.baidu.com','baidu.com']
3059                        },
3060                        {
3061                            name:"google",
3062                            key:["www.google.co.jp","www.google.la","www.google.co.id","www.google.kg","www.google.ae","www.google.com.lb","www.google.com.tr","www.google.az","www.google.no","www.google.ie","www.google.be","www.google.li","www.google.ad","www.google.com.mt","www.google.com.ua","www.google.hr","www.google.me","www.google.dz","www.google.sn","www.google.ci","www.google.tg","www.google.com.ng","www.google.cm","www.google.td","www.google.co.ke","www.google.mg","www.google.co.zm","www.google.nr","www.google.co.ck","www.google.co.ve","www.google.com.br","www.google.hn","www.google.com.ni","www.google.com.jm","www.google.co.kr","www.google.com.vn","www.google.com.kh","www.google.com.sg","www.google.tm","www.google.com.af","www.google.co.in","www.google.com.bd","www.google.am","www.google.se","www.google.fi","www.google.ee","
3062www.google.lv","www.google.lt","www.google.co.uk","www.google.gg","www.google.fr","www.google.de","www.google.cz","www.google.hu","www.google.ba","www.google.mk","www.google.gm","www.google.ml","www.google.com.gh","www.google.ne","www.google.cf","www.google.it.ao","www.google.mu","www.google.com.na","www.google.co.za","www.google.com.nf","www.google.com.sb","www.google.fm","www.google.ws","www.google.gy","www.google.com.pe","www.google.com.ar","www.google.cl","www.google.com","www.google.com.gt","www.google.com.bz","www.google.com.sv","www.google.bs","www.google.com.tw","www.google.com.tj","www.google.com.np","www.google.lk","www.google.com.kw","www.google.com.bh","www.google.com.om","www.google.jo","www.google.co.il","www.google.nl","www.google.at","www.google.ch","www.google.gr","www.google.com.by","www.google.pl","www.google.sk","www.google.rs","www.google.ro","www.google.md","www.google.com.ly","www.google.com.sl","www.google.bj","www.google.sh","www.google.com.et","www.google.dj","www.google.co.ug","www.google.rw","www.google.bi","www.google.mw","www.google.co.mz","www.google.sc","www.google.com.au","www.google.ki","www.google.com.do","www.google.com.mx","www.google.com.pa","www.google.cn","www.google.mn","www.google.co.th","www.google.com.my","www.google.com.bn","www.google.com.ph","www.google.tp","www.google.kz","www.google.co.uz","www.google.com.pk","www.google.mv","www.google.com.sa","www.google.co.ls","www.google.is","www.google.dk","www.google.je","www.google.im","www.google.lu","www.google.pt","www.google.es","www.google.com.gi","www.google.it","www.google.sm","www.google.ru","www.google.si","www.google.bg","www.google.com.eg","www.google.co.ma","www.google.bf","www.google.ga","www.google.cg","www.google.cd","www.google.co.tz","www.google.co.zw","www.google.co.bw","www.google.co.nz","www.google.com.fj","www.google.tk","www.google.as","www.google.to","www.google.nu","www.google.tt","www.google.com.co","www.google.com.ec","www.google.com.bo","www.google.com.py","www.google.com.uy","www.google.gl","www.google.co.cr","www.google.com.cu","www.google.ht","www.google.com.hk"]
3063                        },
3064                        {
3065                            name:"sougou",
3066                            key:["sogou.com","www.sogou.com","m.sogou.com","wap.sogou.com"]
3067                        },
3068                        {
3069                            name:"bing",
3070                            key:["bing.com","cn.bing.com","www.bing.com"]
3071                        },
3072                        {
3073                            name:"360",
3074                            key:["www.so.com","so.com","m.so.com"]
3075                        },
3076                        {
3077                            name:"yandex",
3078                            key:["www.yandex.com","yandex.com","yandex.ru","www.yandex.ru","yandex.ua","yandex.kz","yandex.com.tr","yandex.by","yandex.az","yandex.com.ge","yandex.uz","yandex.md","yandex.ee","yandex.lt","yandex.lv","yandex.ro","yandex.pl","yandex.es","yandex.it","yandex.de","yandex.dk","yandex.no","yandex.pt","yandex.rs","yandex.sk","yandex.tj","www.yandex.ua","www.yandex.kz","www.yandex.com.tr","www.yandex.by","www.yandex.az","www.yandex.com.ge","www.yandex.uz","www.yandex.md","www.yandex.ee","www.yandex.lt","www.yandex.lv","www.yandex.ro","www.yandex.pl","www.yandex.es","www.yandex.it","www.yandex.de","www.yandex.dk","www.yandex.no","www.yandex.pt","www.yandex.rs","www.yandex.sk","www.yandex.tj"]
3079                        },
3080                        {
3081                            name:"other",
3082                            key:['www.aol.com','duckduckgo.com','www.fresheye.com','www.sputtr.com','searcn.yahoo.com','www.search.aol.com','fresheye.com','www.seznam.com','www.duckduckgo.com','search.aol.com','m.ask.com','www.lycos.com','search.naver.com','www.soso.com','www.youdao.com','www.ask.com','www.ceek.jp','www.hotbot.com','www.naver.com','www.search.com','m.sm.cn','www.altavista.com']
3083                        },
3084                    ]
3085                    relist.forEach(e=>{
3086                        let rtmp = e.key.find(n=>refferUrl==n)
3087                        if(rtmp){
3088                            refferUrl = e.name
3089                        }
3090                    })
3091                }
3092                return {
3093                    landUrl,
3094                    refferUrl
3095                }
3096            }else{
3097                return '';
3098            }
3099        }
3100
3101        initScrollListener() {
3102            $(window).on('scroll.scrollListener', () => {
3103                // 获取滚动条当前位置
3104                const scrollTop = $(window).scrollTop();
3105                // 获取页面可滚动总高度
3106                const scrollHeight = $(document).height() - $(window).height();
3107                
3108                // 避免除以 0
3109                if (scrollHeight <= 0) {
3110                    return;
3111                }
3112                
3113                // 计算滚动百分比
3114                const scrollPercent = scrollTop / scrollHeight;
3115                
3116                // 超过 80% 且未弹窗过时触发
3117                let scrollDepth = (this.inviteSet?.behavior?.scrollDepth || 80) / 100
3118                if (scrollPercent >= scrollDepth && !this.hasAlerted) {
3119                    this.hasAlerted = true; // 使用类属性标记
3120                    // alert(123);
3121                    this.behaviorReport('isScroll');
3122                }
3123            });
3124        }
3125
3126        // 会话邀请配置 inviteSet 对象
3127        inviteSetFn() {
3128            // 获取inviteSet对象数据进行配置
3129            // 详情页页数
3130            let totalPageCount = this.inviteSet?.behavior?.pageCount || 3;
3131            // 详情页访问计数:当前页是详情页时累加,达到 pageCount 时上报
3132            let isDetailPage = window.pageObj &&
3133                window.pageObj.appId === '143150160001' &&
3134                window.pageObj.pageType === '3'
3135            if (isDetailPage) {
3136                let visitedCount = parseInt(sessionStorage.getItem('sm_detail_page_count') || '0') + 1
3137                sessionStorage.setItem('sm_detail_page_count', visitedCount)
3138                if (visitedCount === totalPageCount) {
3139                    this.callBrowseReportApi()
3140                }
3141            }
3142            // 指定页面
3143            let currentPages = this.inviteSet?.behavior?.pages;
3144            if (Array.isArray(currentPages) && window.pageObj && window.pageObj.pageId) {
3145                let matched = currentPages.some(page => page.pageId == window.pageObj.pageId)
3146                if (matched) {
3147                    this.behaviorReport()
3148                }
3149            }
3150        }
3151
3152    };
3153    return smartService
3154})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.