123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- var iscroll,mciscroll,swiper;
- $(function () {
- /**
- * 初始化滚动条
- * */
- iscroll = new IScroll(".iscroll",{
- scrollbars: true,
- fadeScrollbars:true,
- scrollbars: 'custom',
- shrinkScrollbars:'clip',
- click:true
- });
- setTimeout(function(){
- iscroll.refresh();
- },100);
- /**
- * 选择的牧场名称滚动条
- * */
- var mcsize = $("#size").attr("value");
- if(mcsize>1){
- mciscroll = new IScroll(".mcIscroll",{
- scrollbars: true,
- fadeScrollbars:true,
- scrollbars: 'custom',
- shrinkScrollbars:'clip'
- });
- $(".middle button").on("tap",function(){
- setTimeout(function(){
- mciscroll.refresh();
- },100);
- });
- }
- /**
- * 轮播图
- * */
- swiper = new Swiper('.swiper-container',{
- pagination:'.swiper-pagination',
- prevButton:'.swiper-button-prev',//点击箭头
- nextButton:'.swiper-button-next',//点击箭头
- paginationClickable: true,//点击分页器
- touchMoveStopPropagation : false,
- followFinger: false,
- autoplay : 3000,//每3秒自动轮播
- autoplayDisableOnInteraction : false,
- loop : true,//环路
- //ajax动态循环生成当到第二页的时候始终滑动不起来的方法
- //分页器消失解决方法
- observer:true,//修改swiper自己或子元素时,自动初始化swiper
- observeParents:true,//修改swiper的父元素时,自动初始化swiper
- onSlideChangeEnd: function(swiper){
- swiper.update(); //swiper滑动的时候滑动到第3屏就滑动不了的解决办法
- }
- });
- /**
- * 每点击li初始化滚动条
- */
- $('#selectUl div').on("tap",function(){
- iscroll.refresh();
- });
- /**
- * 列表切换
- * */
- $(".sectionBtm .nav-pills li").click(function(){
- $(this).addClass("liborderBottom").siblings().removeClass("liborderBottom");
- $(this).children().addClass("liborderBottomColor").parent().siblings().children().removeClass("liborderBottomColor");
- $(".sectionBtm div ul").hide().eq($('.sectionBtm .nav-pills li').index(this)).show();
- if($('.sectionBtm .nav-pills li').index(this)==0){
- takeMcgk(0,iscroll);
- }else if($('.sectionBtm .nav-pills li').index(this)==1){
- takeMcgk(1,iscroll);
- }else if($('.sectionBtm .nav-pills li').index(this)==2){
- takeMcgk(2,iscroll);
- }
- iscroll.scrollTo(0, 0);
- iscroll.refresh();
- });
- //默认初始进入显示预警提示
- takeMcgk(1,iscroll);
- });
- /**
- * footer图标
- * */
- function pig(e) {
- $('.syfo .nav li').eq(0).find('span').css({'background-image':'url(views/haifmv/img/bai.png)'});
- $('.syfo .nav li').eq(1).find('span').css({'background-image':'url(views/haifmv/img/bai.png)'});
- $('.syfo .nav li').eq(2).find('span').css({'background-image':'url(views/haifmv/img/bai.png)'});
- $(".cbkz").css({'background-image':'url(views/haifmv/img/cbkz_an.jpg)'});
- $(".scxx").css({'background-image':'url(views/haifmv/img/scxx_an.jpg)'});
- $('.syfo .nav li a').eq(0).removeClass('textColor');
- $('.syfo .nav li a').eq(1).removeClass('textColor');
- $('.syfo .nav li a').eq(2).removeClass('textColor');
- $('.syfo .nav li a').eq(3).removeClass('textColor');
- $('.syfo .nav li a').eq(4).removeClass('textColor');
- switch(e) {
- case 0://牧场首页
- $(".mcsy").css({'background-image':'url(views/haifmv/img/ding.png)'});
- $(".mcsy").next().addClass('textColor');
- break;
- case 1:
- $(".sjlr").css({'background-image':'url(views/haifmv/img/ding.png)'});
- $(".sjlr").next().addClass('textColor');
- break;
- case 2:
- $(".jrmc").css({'background-image':'url(views/haifmv/img/ding.png)'});
- $(".jrmc").next().addClass('textColor');
- break;
- case 3:
- $(".cbkz").css({'background-image':'url(views/haifmv/img/cbkz_liang.jpg)'});
- $(".cbkz").next().addClass('textColor');
- break;
- case 4:
- $(".scxx").css({'background-image':'url(views/haifmv/img/scxx_liang.jpg)'});
- $(".scxx").next().addClass('textColor');
- break;
- }
-
- };
- //异步加载消息通知 默认打开牧场概况
- function takeMcgk(type,iscroll) {
- var li,curIndex;
- var jsonLength = 0;
- var val = 0;
- var url = "";
- curIndex = $(".liborderBottom").index();
- if (type == 0) {
- url = "syMcgk.htm";
- }else if(type == 1){
- url = "syYjts.htm";
- }
- else if(type == 2){
- url = "syScxx.htm";
- }
- $(".refinsh").show();
- jQuery.ajax({
- type : "get",
- url : url,
- data : {"mcid" : $("#mcid").val(),
- "type" : type,
- },
- dataType : "json",
- async : true,
- success : function(data) {
- //获得data长度
- for (var j in data) {
- jsonLength++;
- }
- setTimeout(function() {
- $(".refinsh").hide();
- $(".iscroll ul li").remove();
- if (jsonLength > 6) {
- jsonLength = 6;
- val = 7;
- }
- for (var i = 0 ; i < jsonLength ; i++) {
- li = document.createElement("li");
- if(curIndex == 0){
- li = $("<li id='"+data[i].id+"' style='justify-content:flex-start !important;text-align: left;padding-left:0.5rem;padding-right:0.5rem;' onclick = viewXxtsxx('"+data[i].id+"','sy')>" + data[i].title +"</li>");
- }else if(curIndex == 1){
- li = $("<li id='"+data[i].id+"' style='justify-content:flex-start !important;text-align: left;padding-left:0.5rem;padding-right:0.5rem;' onclick = viewXxtsxx('"+data[i].id+"','sy')>" + data[i].title +"</li>");
- }else if(curIndex == 2){
- li = $("<li id='"+data[i].id+"' style='justify-content:flex-start !important;text-align: left;padding-left:0.5rem;padding-right:0.5rem;' onclick = viewXxtsxx('"+data[i].id+"','sy')>" + data[i].title +"</li>");
- }
- $(".sectionBtm div ul").eq($(".liborderBottom").index()).append(li);
- }
- if (jsonLength==0 && curIndex == 0) {
- li = $("<li>暂无数据</li>");
- } else if (jsonLength==0 && curIndex == 1){
- li = $("<li>暂无数据</li>");
- } else if (jsonLength==0 && curIndex == 2){
- li = $("<li>暂无数据</li>");
- }
- if (val == 7 || jsonLength >0 ) {
- //var wdCount = data[6].context;
- var text = "点击查看详细信息";
- if (curIndex == 0) {
- li = $("<li onclick= viewXxlist('mcgk')>" + text +"</li>");
- } else if (curIndex == 1) {
- li = $("<li onclick= viewXxlist('sbxx')>" + text +"</li>");
- } else if (curIndex == 2) {
- li = $("<li onclick= viewXxlist('scxx')>" + text +"</li>");
- }
- }
- $(".sectionBtm div ul").eq($(".liborderBottom").index()).append(li);
- iscroll.refresh();
- },200);
- }
- });
- }
- /*//异步加载 更新未读信息
- function updateWdCount() {
- jQuery.ajax({
- type : "get",
- url : "updateWdCount.htm",
- data : {"mcid" : $("#mcid").val()},
- dataType : "json",
- success : function(data) {
- if (data[0] != 0) {
- $("#countMcgk").html(data[0]);
- }
- if (data[1] != 0) {
- $("#countMcgk").html(data[1]);
- }
- if (data[2] != 0) {
- $("#countMcgk").html(data[2]);
- }
- }
- });
- }*/
- function viewXxtsxx(id, from) {
- haifm.loadMobilePage("haifm", "viewHaifmvGtxxtsxx.htm?xxid=" + id + "&from=" + from );
- //window.location.href = "viewHaifmvGtxxtsxx.htm?xxid=" + id + "&from=" + from;
- }
- function viewXxlist(from) {
- haifm.loadMobilePage("haifm", "viewHaifmvXxlist.htm?from=" + from +"&mcid=" + $("#mcid").val());
- }
|