var smsFlag=false; var smsShowFun=null; var hasScroll=false; var isWeixin = function(){ var ua = navigator.userAgent.toLowerCase(); return ua.match(/MicroMessenger/i) == "micromessenger" } $(function(){ //yabo2021网页版执行,灰色主题 if(window.pageObj && window.pageObj.isHomePage==1){ gray() } if(tenant.unittype!='portal-saas-mall'){ //节日挂件 festival() //智慧客服 smartServiceInit() } //防钓鱼 if(tenant.tenantId!=268516 && tenant.unittype!='portal-saas-mall'){ preventFish() } if(isWeixin() && tenant.unittype!='portal-saas-mall'){ wxShare() } //微信小程序 if(window.__wxjs_environment === 'miniprogram'){ $require(['/npublic/commonjs/jweixin/jweixin.js','pl_util'],function(){ wx.miniProgram.postMessage({ data: { shareTitle:encodeURIComponent(document.title), shareDesc:getmeta("description"), shareUrl:encodeURIComponent(location.href) } }) }) } }) //通过name获取对应meta的content值 function getmeta(name) { var _metas = document.getElementsByTagName("meta") for (var i = 0, _item; (_item = _metas[i++]); ) { if (_item.getAttribute("name") && _item.getAttribute("name").toLowerCase() === name) { return encodeURIComponent(_item.content) } } } //灰色主题 function gray(){ $require(['cmsAjax'],function(c){ let url = window.location.origin + "/ndesigner/api/gray" c.cmsAjax.postJson(url).then(function(res){ if(res.code == 200){ $("html")[0].style="filter:progid:DXImageTransform.Microsoft.Basiclmage\(grayscale=1\);-webkit-filter\:grayscale\(100%\)\;" } }) }) } //节日挂件 function festival(){ if(!isFrontEnv()){ return } $require(['cmsAjax'],function(c){ let url = "/fwebapi/cms/lowcode/festivalPendant/getSettings" c.cmsAjax.get(url).then(function(resp){ if(resp.data && resp.data.code == 200 && resp.data.settings){ let res = resp.data.settings if(res.location==1 && window.pageObj && window.pageObj.isHomePage!=1){ return } let canTime = (res.showTime && res.showTime.length==2 && res.nowTime>=res.showTime[0] && res.nowTime<=res.showTime[1]) || !res.showTime || res.showTime.length==0 if(res.isOpen && canTime){ $require(['/npublic/commonjs/restival.js'],function(r){ r.init(res) }) } } }) }) } //智慧客服 function smartServiceInit(){ if(!isFrontEnv()){ return } // if(tenant.ningkerDomain && tenant.ningkerDomain == "FOREIGN_TRADE" && tenant.language != "zh_CN"){//外贸,自动弹出 $(window).on('mousemove scroll touchmove tap click keydown',function(){ if(!hasScroll){ hasScroll = true getSmSvs(function(resp){ $require([`css!/npublic/commonjs/smartService/t.css`],function(r){ let set = {} try{ set = JSON.parse(resp.setting.colorLayout) }catch(e){} if(set.entranceLocation==1){ let dom = ` ` $("body").append(dom) $(".smartIcon").hover(function(){ $(this).css({ "background-color": set.windowColor, "color": "#fff" }) },function(){ $(this).css({ "background-color": "#fff", "color": set.windowColor }) }) } smSvsFunc(true,resp) }) }) } }) // }else{ // smSvsFunc() // } function smSvsFunc(foriegn,resp){ let set = {} try{ set = JSON.parse(resp.setting.colorLayout) }catch(e){} $(document).on("click","[smartService]",showAndInit) if(set.showFlag==1 && resp){ showAndInit() } function showAndInit(){ if(smsShowFun){ if(smsFlag){ smsShowFun.showFun() }else{ smsShowFun() } return } if(foriegn && resp){ if(resp.account){ localStorage.setItem(`account_${tenant.tenantId}`,resp.account) } $require(['/npublic/commonjs/smartService.js'],function(smartService){ smsFlag = true smsShowFun = new smartService(resp) if(window.ZQSensorsObj){ let obj = { tenantId: tenant.tenantId, iBusinessCode : "01", iBusinessName : "智慧客服业务线", iBusinessCustId : localStorage.getItem(`account_${tenant.tenantId}`) } ZQSensorsObj.track('SmartServiceWakeUp',obj); } }) return } } } function getSmSvs(callback){ $require(['cmsAjax'],function(c){ let domain = __ce.smartServiceUrl || 'https://web-visitor.yun300.cn' let url = `${domain}/visitormanager/intelligent/front/checkAndRegister?tenantId=${tenant.tenantId}&instance=${tenant.bossProductInstance}` let data = { account:localStorage.getItem(`account_${tenant.tenantId}`) } c.cmsAjax.postJson(url,data).then(function(res){ if(res.status==200 && res.data){ callback(res.data) } }) }) function smsFail(){ if(tenant.ningkerDomain && tenant.ningkerDomain == "FOREIGN_TRADE" && tenant.language != "zh_CN"){ return } $require(['pl_toast'],function(){ $.pl_toast({msg:i18n.sms_no}) }) smsFlag = false smsShowFun = function(){ $.pl_toast({msg:i18n.sms_no}) } } } } //防钓鱼 function preventFish(){ var req = location.hostname var rel = getCookie('realhost') || "" if(rel && rel != req){ var url = "/repository/cheat?req="+req+"&rel="+rel $.ajax({ url:url }) } } //自定义微信分享 function wxShare(){ $require(['cmsAjax','/npublic/commonjs/jweixin/jweixin.js','pl_util'],function(c){ let url = "/fwebapi/cms/api/tdk/getWxShareInfo" let data = { pageUrl:location.href, appCode:pageObj.appId, tid:pageObj.contentType, pageType:pageObj.pageType, isHomePage:pageObj.isHomePage, pageId:pageObj.pageId, contentId:pageObj._detailId, pageName:pageObj.name } function imgxaf(src,v){ var imgParam = src.indexOf('?')>-1 ? src.split('?')[1] : ""; var imgSrc = src.split('?')[0] var paramStr = imgParam ? "?" + imgParam : ""; return imgSrc + "_" + v + "xaf" + imgSrc.substr(imgSrc.lastIndexOf('.')) + paramStr } c.cmsAjax.postJson(url,data).then(function(resp){ let data = resp.data if(data.data){ data = data.data } if(data.wxJsConfig){ let obj = data.wxJsConfig let content = data.wxShareContent let sharObj = { title: content.title, // 分享标题 desc: content.desc, // 分享描述 link: location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: imgxaf($.handleDataImg(content.imgUrl),104) } console.log("分享数据:",sharObj) wx.config({ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: obj.appId, // 必填,公众号的唯一标识 timestamp: obj.timestamp, // 必填,生成签名的时间戳 nonceStr: obj.nonceStr, // 必填,生成签名的随机串 signature: obj.signature,// 必填,签名 jsApiList: ['updateAppMessageShareData','updateTimelineShareData'] // 必填,需要使用的JS接口列表 }); wx.ready(function () { //需在用户可能点击分享按钮前就先调用 wx.updateAppMessageShareData(sharObj) wx.updateTimelineShareData(sharObj) }); } }) }) }