Browse Source

整理代码

李雪梅 2 years ago
parent
commit
26263345e6
1 changed files with 77 additions and 226 deletions
  1. 77 226
      nngkxxdp/src/main/resources/static/district/js/sy.js

+ 77 - 226
nngkxxdp/src/main/resources/static/district/js/sy.js

@@ -1083,10 +1083,6 @@ $(function() {
 								sContnet += "<p title='"+res.data[j].itemName+"'>"+res.data[j].itemName+"</p></a></li>"
 							});
 							sContnet += "</ul></div></div></li></ul>"
-							if (tempAdd == arraddre) {
-								addMarker(arrIndex,address,new BMap.InfoWindow(sContnet,arraddre),arrdep,typepage);
-								map.setCenter(addFirst);
-							}
 						}else{
 							sContnet += "<ul class='text-tab-title'>"
 							sContnet += "<li class='text-this'>个人办事</li><li>法人办事</li>"
@@ -1102,10 +1098,10 @@ $(function() {
 							});
 							sContnet += "</ul><ul class='text-tab-item'></ul></div>"
 							sContnet += "</div><div id='demo'></div></li></ul>"
-							if (tempAdd == arraddre) {
-								addMarker(arrIndex,address,new BMap.InfoWindow(sContnet, arraddre),arrdep,typepage);
-								map.setCenter(addFirst);
-							}
+						}
+						if (tempAdd == arraddre) {
+							addMarker(arrIndex,address,new BMap.InfoWindow(sContnet, arraddre),arrdep,typepage);
+							map.setCenter(addFirst);
 						}
 						document.querySelectorAll(".two_img").onload = function() {
 							infoWindow.redraw();
@@ -1476,6 +1472,8 @@ $(function() {
 	};
 
 	function addMarker(getIndex,point,infoWindow,dep,typepage) {
+		// 存放总数的值
+		var count;
 		var myIcon = new BMap.Icon("./img/location.png", new BMap.Size(40, 40));
 		var marker = new BMap.Marker(point, {
 			icon: myIcon
@@ -1506,10 +1504,9 @@ $(function() {
 			layui.use(['laypage', 'layer'], function(){
 				var laypage = layui.laypage;
 				if(typepage==0){
-					var count;
-					var firstpage = 1;
-					var pagetype = 0;
-					page(firstpage,pagetype)
+					var firstpage=1,pagetype=0;
+					page(firstpage,pagetype);
+					jumplaypage()
 					laypage.render({
 						elem: 'demo'
 						,count: count
@@ -1522,30 +1519,6 @@ $(function() {
 							page(obj.curr,pagetype)
 						}
 					});
-					function page(page,pagetype) {
-						$.ajax({
-							type: 'GET',
-							url: PATH + '/mapdata/getHandMatterPage',
-							// url: "http://192.168.1.253:7777/mapdata/getHandMatterPage",
-							async: false,
-							dataType: 'json',
-							data: {
-								page: page,
-								limit: 4,
-								type: pagetype,
-								matterDept: dep
-							},
-							success: function(res){
-								count = res.count;
-								var html = '';
-								$.each(res.data,function(j){
-									html += "<li><a href='"+res.data[j].matterUrl+"' target='_blank'><h6></h6>"
-									html += "<p title='"+res.data[j].itemName+"'>"+res.data[j].itemName+"</p></a></li>"
-								})
-								$('.text-tab-item').empty().append(html)
-							}
-						});
-					}
 				}
 			});
 			$('.text-tab-title li').click(function(){
@@ -1554,39 +1527,9 @@ $(function() {
 				if(tabtex == '个人办事'){
 					$('.text-tab-content .text-tab-item:nth-child(1)').addClass('text-show').siblings().removeClass('text-show')
 					layui.use(['laypage', 'layer'], function(){
-						var laypage = layui.laypage,layer = layui.layer;
-						var count;
-						var firstpage = 1;
-						var pagetype = 0;
-						page(firstpage,pagetype)
-						function page(page,pagetype) {
-							$.ajax({
-								type: 'GET',
-								url: PATH + '/mapdata/getHandMatterPage',
-								// url: "http://192.168.1.253:7777/mapdata/getHandMatterPage",
-								async: false,
-								dataType: 'json',
-								data: {
-									page: page,
-									limit: 4,
-									type: pagetype,
-									matterDept: dep
-								},
-								success: function(res){
-									count = res.count;
-									var html = '';
-									$.each(res.data,function(j){
-										html += "<li>"
-										html += "<a href='"+res.data[j].matterUrl+"' target='_blank'>"
-										html += "<h6></h6>"
-										html += "<p title='"+res.data[j].itemName+"'>"+res.data[j].itemName+"</p>"
-										html += "</a>"
-										html += "</li>"
-									})
-									$('.text-tab-item').empty().append(html)
-								}
-							});
-						}
+						var laypage = layui.laypage;
+						var firstpage = 1,pagetype = 0;
+						page(firstpage,pagetype);
 						laypage.render({
 							elem: 'demo'
 							,count: count
@@ -1594,50 +1537,18 @@ $(function() {
 							,layout: ['prev', 'next']
 							,prev: '<i class="layui-icon layui-icon-left"></i><span>上一页</span>'
 							,next: '<span>下一页</span><i class="layui-icon layui-icon-right"></i>'
-							,jump: function(obj,first){
-								// if(!first){
-									pagetype = 0
-									page(obj.curr,pagetype)
-								// }
+							,jump: function(obj){
+								pagetype = 0
+								page(obj.curr,pagetype)
 							}
 						});
 					});
 				} else {
 					$('.text-tab-content .text-tab-item:nth-child(2)').addClass('text-show').siblings().removeClass('text-show');
 					layui.use(['laypage', 'layer'], function(){
-						var laypage = layui.laypage,layer = layui.layer;
-						var count;
-						var firstpage = 1;
-						var pagetype = 1;
-						page(firstpage,pagetype)
-						function page(page,pagetype) {
-							$.ajax({
-								type: 'GET',
-								url: PATH + '/mapdata/getHandMatterPage',
-								// url: "http://192.168.1.253:7777/mapdata/getHandMatterPage",
-								async: false,
-								dataType: 'json',
-								data: {
-									page: page,
-									limit: 4,
-									type: pagetype,
-									matterDept: dep
-								},
-								success: function(res){
-									count = res.count;
-									var html = '';
-									$.each(res.data,function(j){
-										html += "<li>"
-										html += "<a href='"+res.data[j].matterUrl+"' target='_blank'>"
-										html += "<h6></h6>"
-										html += "<p title='"+res.data[j].itemName+"'>"+res.data[j].itemName+"</p>"
-										html += "</a>"
-										html += "</li>"
-									})
-									$('.text-tab-item').empty().append(html)
-								}
-							});
-						}
+						var laypage = layui.laypage;
+						var firstpage=1,pagetype=1;
+						page(firstpage,pagetype);
 						laypage.render({
 							elem: 'demo'
 							,count: count
@@ -1645,11 +1556,9 @@ $(function() {
 							,layout: ['prev', 'next']
 							,prev: '<i class="layui-icon layui-icon-left"></i><span>上一页</span>'
 							,next: '<span>下一页</span><i class="layui-icon layui-icon-right"></i>'
-							,jump: function(obj,first){
-								// if(!first){
-									pagetype = 1
-									page(obj.curr,pagetype)
-								// }
+							,jump: function(obj){
+								pagetype = 1
+								page(obj.curr,pagetype)
 							}
 						});
 					});
@@ -1681,39 +1590,9 @@ $(function() {
 				$(this).attr('href','correct.html');
 			});
 			layui.use(['laypage', 'layer'], function(){
-				var laypage = layui.laypage,layer = layui.layer;
-				var count;
-				var firstpage = 1;
-				var pagetype = 0;
-				page(firstpage,pagetype)
-				function page(page,pagetype) {
-					$.ajax({
-						type: 'GET',
-						url: PATH + '/mapdata/getHandMatterPage',
-						// url: "http://192.168.0.40:7777/mapdata/getHandMatterPage",
-						async: false,
-						dataType: 'json',
-						data: {
-							page: page,
-							limit: 4,
-							type: pagetype,
-							matterDept: dep
-						},
-						success: function(res){
-							count = res.count;
-							var html = '';
-							$.each(res.data,function(j){
-								html += "<li>"
-								html += "<a href='"+res.data[j].matterUrl+"' target='_blank'>"
-								html += "<h6></h6>"
-								html += "<p title='"+res.data[j].itemName+"'>"+res.data[j].itemName+"</p>"
-								html += "</a>"
-								html += "</li>"
-							})
-							$('.text-tab-item').empty().append(html)
-						}
-					});
-				}
+				var laypage = layui.laypage;
+				var firstpage = 1,pagetype = 0;
+				page(firstpage,pagetype);
 				laypage.render({
 					elem: 'demo'
 					,count: count
@@ -1721,11 +1600,9 @@ $(function() {
 					,layout: ['prev', 'next']
 					,prev: '<i class="layui-icon layui-icon-left"></i><span>上一页</span>'
 					,next: '<span>下一页</span><i class="layui-icon layui-icon-right"></i>'
-					,jump: function(obj,first){
-						// if(!first){
-							pagetype = 0
-							page(obj.curr,pagetype)
-						// }
+					,jump: function(obj){
+						pagetype = 0
+						page(obj.curr,pagetype);
 					}
 				});
 			});
@@ -1735,39 +1612,9 @@ $(function() {
 				if(tabtex == '个人办事'){
 					$('.text-tab-content .text-tab-item:nth-child(1)').addClass('text-show').siblings().removeClass('text-show')
 					layui.use(['laypage', 'layer'], function(){
-						var laypage = layui.laypage,layer = layui.layer;
-						var count;
-						var firstpage = 1;
-						var pagetype = 0;
-						page(firstpage,pagetype)
-						function page(page,pagetype) {
-							$.ajax({
-								type: 'GET',
-								url: PATH + '/mapdata/getHandMatterPage',
-								// url: "http://192.168.0.40:7777/mapdata/getHandMatterPage",
-								async: false,
-								dataType: 'json',
-								data: {
-									page: page,
-									limit: 4,
-									type: pagetype,
-									matterDept: dep
-								},
-								success: function(res){
-									count = res.count;
-									var html = '';
-									$.each(res.data,function(j){
-										html += "<li>"
-										html += "<a href='"+res.data[j].matterUrl+"' target='_blank'>"
-										html += "<h6></h6>"
-										html += "<p title='"+res.data[j].itemName+"'>"+res.data[j].itemName+"</p>"
-										html += "</a>"
-										html += "</li>"
-									})
-									$('.text-tab-item').empty().append(html)
-								}
-							});
-						}
+						var laypage = layui.laypage;
+						var firstpage = 1,pagetype = 0;
+						page(firstpage,pagetype);
 						laypage.render({
 							elem: 'demo'
 							,count: count
@@ -1775,50 +1622,18 @@ $(function() {
 							,layout: ['prev', 'next']
 							,prev: '<i class="layui-icon layui-icon-left"></i><span>上一页</span>'
 							,next: '<span>下一页</span><i class="layui-icon layui-icon-right"></i>'
-							,jump: function(obj,first){
-								// if(!first){
-									pagetype = 0
-									page(obj.curr,pagetype)
-								// }
+							,jump: function(obj){
+								pagetype = 0
+								page(obj.curr,pagetype)
 							}
 						});
 					});
 				} else {
 					$('.text-tab-content .text-tab-item:nth-child(2)').addClass('text-show').siblings().removeClass('text-show');
 					layui.use(['laypage', 'layer'], function(){
-						var laypage = layui.laypage,layer = layui.layer;
-						var count;
-						var firstpage = 1;
-						var pagetype = 1;
-						page(firstpage,pagetype)
-						function page(page,pagetype) {
-							$.ajax({
-								type: 'GET',
-								url: PATH + '/mapdata/getHandMatterPage',
-								// url: "http://192.168.0.40:7777/mapdata/getHandMatterPage",
-								async: false,
-								dataType: 'json',
-								data: {
-									page: page,
-									limit: 4,
-									type: pagetype,
-									matterDept: dep
-								},
-								success: function(res){
-									count = res.count;
-									var html = '';
-									$.each(res.data,function(j){
-										html += "<li>"
-										html += "<a href='"+res.data[j].matterUrl+"' target='_blank'>"
-										html += "<h6></h6>"
-										html += "<p title='"+res.data[j].itemName+"'>"+res.data[j].itemName+"</p>"
-										html += "</a>"
-										html += "</li>"
-									})
-									$('.text-tab-item').empty().append(html)
-								}
-							});
-						}
+						var laypage = layui.laypage;
+						var firstpage = 1,pagetype = 1;
+						page(firstpage,pagetype);
 						laypage.render({
 							elem: 'demo'
 							,count: count
@@ -1826,17 +1641,53 @@ $(function() {
 							,layout: ['prev', 'next']
 							,prev: '<i class="layui-icon layui-icon-left"></i><span>上一页</span>'
 							,next: '<span>下一页</span><i class="layui-icon layui-icon-right"></i>'
-							,jump: function(obj,first){
-								// if(!first){
-									pagetype = 1
-									page(obj.curr,pagetype)
-								// }
+							,jump: function(obj){
+								pagetype = 1
+								page(obj.curr,pagetype);
 							}
 						});
 					});
 				}
 			})
 		});
+		function page(page,pagetype) {
+			$.ajax({
+				type: 'GET',
+				url: PATH + '/mapdata/getHandMatterPage',
+				// url: "http://192.168.1.253:7777/mapdata/getHandMatterPage",
+				async: false,
+				dataType: 'json',
+				data: {
+					page: page,
+					limit: 4,
+					type: pagetype,
+					matterDept: dep
+				},
+				success: function(res){
+					count = res.count;
+					var html = '';
+					$.each(res.data,function(j){
+						html += "<li><a href='"+res.data[j].matterUrl+"' target='_blank'><h6></h6>"
+						html += "<p title='"+res.data[j].itemName+"'>"+res.data[j].itemName+"</p></a></li>"
+					})
+					$('.text-tab-item').empty().append(html)
+				}
+			});
+		}
+		function jumplaypage(){
+			laypage.render({
+				elem: 'demo'
+				,count: count
+				,limit: 4
+				,layout: ['prev', 'next']
+				,prev: '<i class="layui-icon layui-icon-left"></i><span>上一页</span>'
+				,next: '<span>下一页</span><i class="layui-icon layui-icon-right"></i>'
+				,jump: function(obj){
+					pagetype = 0
+					page(obj.curr,pagetype)
+				}
+			});
+		}
 	}
 
 	// 封装点击公交点击获取的值的部分