$(function () { // 轮播 var banner = new Swiper('.banner', { autoplay: true,//可选选项,自动滑动 loop: true, pagination: { el: '.swiper-pagination', clickable: true, }, }) // 新闻资讯滚动 function Roll(ele, time, fun) { var obj = document.getElementById(ele); var ul = obj.children; var li = ul[0].children; console.log(li) if (fun) { var fun = fun; } else { var fun = function () { }; } var t; if (time) { var time = time; } else { var time = 2500; } t = setInterval(function () { fun() $(li).eq(0).slideUp(function () { $(ul).append($(li).eq(0)); }); $(li).show(); }, time); $(ul).on('mouseenter', 'li', function () { clearInterval(t) }) $(ul).on('mouseleave', 'li', function () { t = setInterval(function () { fun() $(li).eq(0).slideUp(function () { $(ul).append($(li).eq(0)); }); $(li).show(); }, time); }) } // Roll('farmBrief', 5000) // Roll('newsListDiv', 2000) // Roll('videoListBox', 5000,function(){ // $('#videoListBox .videoListUl >li').removeClass('active'); // $('#videoListBox .videoListUl >li').eq(1).addClass('active'); // }) // Roll('gardenMsg', 2000, function(){ // $('#gardenMsg .gardenUl >li').removeClass('active'); // $('#gardenMsg .gardenUl >li').eq(1).addClass('active'); // $('.gardenImg >img').attr('src',$('#gardenMsg .gardenUl >.active').find('.hide_farm_img').val()) // }) // var stu = new Roll("newsListDiv", 12); // 视频咨询 var myPlayer = videojs('my-video'); videojs("my-video").ready(function () { var myPlayer = this; myPlayer.play(); }); // 视频咨询 $('#videoListBox').on('click', '.date', function () { $('#videoListBox .videoListUl >li').removeClass('active'); $(this).parent().addClass('active'); var myPlayer = videojs('my-video'); var videoUrl = $(this).find('.hide_video_url').val(); videojs("my-video", {}, function () { window.myPlayer = this; $("#mymoda .video-con #my-video source").attr("src", videoUrl); myPlayer.src(videoUrl); myPlayer.load(videoUrl); myPlayer.play(); }); // $('.videoBox').html(''); $(".video_link").click(function () { var myPlayer = videojs('my-video'); var videoUrl = $(this).find('.hide_video_url').val(); videojs("my-video", {}, function () { window.myPlayer = this; $("#mymoda .video-con #my-video source").attr("src", videoUrl); myPlayer.src(videoUrl); myPlayer.load(videoUrl); myPlayer.play(); }); $(".click-modal").click(); }); // 模态窗消失时,关闭视频     $('#mymoda').on('hidden.bs.modal', function () { myPlayer.pause(); }); }) // 四季采摘 $('#gardenMsg').on('click', '.gardenName', function () { $('#gardenMsg .gardenUl >li').removeClass('active'); $(this).parent().addClass('active'); // $(this).find('.hide_farm_img').val(); $('.gardenImg >img').attr('src', $(this).find('.hide_farm_img').val()) }) // 导游导览 // var map = new AMap.Map('map', { // resizeEnable: true, //是否监控地图容器尺寸变化 // zoom: 11, //初始化地图层级 // center: [113.397428, 39.90923] //初始化地图中心点 // }); //绘制初始路径 // var path = []; // path.push([113.641379, 34.574431]); // path.push([108.877908, 34.389461]); // path.push([108.350564, 22.847832]); // map.plugin("AMap.DragRoute", function () { // route = new AMap.DragRoute(map, path, AMap.DrivingPolicy.LEAST_FEE); //构造拖拽导航类 // route.search(); //查询导航路径并开启拖拽导航 // }); // 民宿导览 var swiper = new Swiper('.homestay', { slidesPerView: 3, spaceBetween: 30, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, autoplay: { delay: 3000 }, }); }) var map = new AMap.Map('map', { resizeEnable: true, //是否监控地图容器尺寸变化 zoom: 11, //初始化地图层级 center: [113.397428, 39.90923] //初始化地图中心点 }); // var geoc = new AMap.Geocoder(); function searchWay() { clearWay() var startPath = $("#startPath").val(); var endPath = $("#endPath").val(); if (!startPath) { $("#startPath").focus(); return; } if (!endPath) { $("#endPath").focus(); return; } $('.guideMap').append('
') //构造路线导航类 var driving = new AMap.Driving({ map: map, panel: "panel" }); // 根据起终点名称规划驾车导航路线 driving.search([ { keyword: startPath, city: '' }, { keyword: endPath, city: '' } ], function (status, result) { if (status === 'complete') { // log.success('绘制驾车路线完成'); $('.loadDiv').remove(); } else { alert('获取驾车数据失败:' + result) $('.loadDiv').remove(); } }); } function clearWay() { // 清除地图上所有添加的覆盖物 map.clearMap(); $('#panel').html(''); } // 登录 function login() { var username = $("#username").val(); var password = $("#password").val(); if (!username) { $("#username").focus(); return; } if (!password) { $("#password").focus(); return; } // $('.notLogin').toggle(); // $('.isLogin').toggle(); // window.open("back_manage"); $.ajax({ url: 'user_land', data: { username: username, password: password }, type: 'post', dataType:'json', success: function (data) { if (data.code) { var hrefstr = 'person_farm?name=' + data.username; window.location.reload(); // $('.isLogin').toggle(); // $('#person_farm').attr('href', hrefstr) // $('.userPhoto').attr('src', data.user_img) // $('.notLogin').hide(); // $('.isLogin').show(); } else if (data.code == 0) { $('body').append('
用户不存在
') setTimeout(function () { $('.hint').remove(); }, 1000) } else if (data.code == 2) { $('body').append('
用户名错误
') setTimeout(function () { $('.hint').remove(); }, 1000) } else if (data.code == 3) { $('body').append('
密码错误
') setTimeout(function () { $('.hint').remove(); }, 1000) } else { $('body').append('
登录失败
') setTimeout(function () { $('.hint').remove(); }, 1000) } }, error: function (type) { } }) } // 返回顶部 function goUp() { $('body,html').animate({ scrollTop: 0 }, 300) } function show() { $(window).scroll(function () { if ($(window).scrollTop() > 100) { $("#back2top").fadeIn(100); } else { $("#back2top").fadeOut(100); } }); } show();