Browse Source

feat: 新增百度统计

zhangyuhan 4 years ago
parent
commit
0b6a391ff0

+ 1 - 0
src/web/staticres/common-module/public/fotter.js

@@ -0,0 +1 @@
+console.log('footer.js')

+ 17 - 0
src/web/staticres/common-module/public/head.js

@@ -0,0 +1,17 @@
+;(function() {
+  var host = location.host
+  var hm = document.createElement("script");
+  var patterns = {
+    ip: /((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/g,
+    testServer: /jianyu360\.cn$/g
+  }
+  if (patterns.ip.test(host) || patterns.testServer.test(host)) {
+    hm.src = "https://hm.baidu.com/hm.js?52c42de35032567eb9d7a24a43c84bda";
+  } else {
+    hm.src = "https://hm.baidu.com/hm.js?72331746d85dcac3dac65202d103e5d9";
+  }
+  setTimeout(function(){
+    var s = document.getElementsByTagName("script")[0];
+    s.parentNode.insertBefore(hm, s);
+  }, 300);
+})();

+ 23 - 13
src/web/staticres/js/pcindex.js

@@ -72,11 +72,11 @@ var fourScreenFlag = 0;
 var i_avg = 0;
 var i_govsite = 0;
 var i_entsite = 0;
-function GetRandomNum(Min,Max){   
-	var Range = Max - Min;   
-	var Rand = Math.random();   
-	return(Min + Math.round(Rand * Range));   
-}   
+function GetRandomNum(Min,Max){
+	var Range = Max - Min;
+	var Rand = Math.random();
+	return(Min + Math.round(Rand * Range));
+}
 function initFoutScreen(className,value,numIncSpace){
 	setTimeout(function(){
 		var numInc = 0;
@@ -338,7 +338,7 @@ $(function(){
 	$(window).scroll(function(){
 		afterScroll();
 	});
-	
+
 	//重新计算最新信息的发布时间
 	$("#lastBidNews .com-time").each(function(){
 		var diff = timeDiff(new Date(Number($(this).attr("data-value")+"000")));
@@ -347,10 +347,20 @@ $(function(){
 		}
 	});
 });
-var _hmt = _hmt || [];
-(function(){
-	var hm = document.createElement("script");
-	hm.src = "//hm.baidu.com/hm.js?d7bc90fd54f45f37f12967f13c4ba19a";
-	var s = document.getElementsByTagName("script")[0]; 
-	s.parentNode.insertBefore(hm, s);
-})();
+;(function() {
+  var host = location.host
+  var hm = document.createElement("script");
+  var patterns = {
+    ip: /((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/g,
+    testServer: /jianyu360\.cn$/g
+  }
+  if (patterns.ip.test(host) || patterns.testServer.test(host)) {
+    hm.src = "https://hm.baidu.com/hm.js?52c42de35032567eb9d7a24a43c84bda";
+  } else {
+    hm.src = "https://hm.baidu.com/hm.js?72331746d85dcac3dac65202d103e5d9";
+  }
+  setTimeout(function(){
+    var s = document.getElementsByTagName("script")[0];
+    s.parentNode.insertBefore(hm, s);
+  }, 300);
+})();