var smsFlag=false; var smsShowFun=null; var hasScroll=false; var isWeixin = function(){ var ua = navigator.userAgent.toLowerCase(); return ua.match(/MicroMessenger/i) == "micromessenger" } $(function(){ //棣栭〉鎵ц锛岀伆鑹蹭富棰 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鐨刢ontent鍊 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 } $(window).on('mousemove scroll touchmove tap click keydown',function(){ if(!hasScroll){ hasScroll = true getSmSvs(function(resp){ $require([`css!/npublic/commonjs/smartService/t.css`,'/npublic/commonjs/smartService.js'],function(r,smartService){ 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 }) }) } $(document).on("click","[smartService]",showAndInit) //涓诲姩鍏抽棴鏍囪瘑 let smartServiceClose = sessionStorage.getItem('smartServiceClose') if(set.showFlag==1 && resp && smartServiceClose!='true'){ showAndInit() } function showAndInit(){ if(smsShowFun){ if($(".smartService.show").length>0){ smsShowFun.closeDialog() return } if(smsFlag){ smsShowFun.showFun() }else{ smsShowFun() } return } 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); } } }) }) } }) //璇锋眰鎺ュ彛鏁版嵁 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){ localStorage.setItem(`account_${tenant.tenantId}`,res.data.account) callback(res.data) } }) }) } } //闃查挀楸 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, // 寮€鍚皟璇曟ā寮?璋冪敤鐨勬墍鏈塧pi鐨勮繑鍥炲€间細鍦ㄥ鎴风alert鍑烘潵锛岃嫢瑕佹煡鐪嬩紶鍏ョ殑鍙傛暟锛屽彲浠ュ湪pc绔墦寮€锛屽弬鏁颁俊鎭細閫氳繃log鎵撳嚭锛屼粎鍦╬c绔椂鎵嶄細鎵撳嵃銆 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) }); } }) }) }