index2.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. $(function () {
  2. // 轮播
  3. var banner = new Swiper('.banner', {
  4. autoplay: true,//可选选项,自动滑动
  5. loop: true,
  6. pagination: {
  7. el: '.swiper-pagination',
  8. clickable: true,
  9. },
  10. })
  11. // 轮播
  12. // var banner = new Swiper('.farmsSwiper', {
  13. // autoplay: true,//可选选项,自动滑动
  14. // loop: true,
  15. // pagination: {
  16. // el: '.swiper-pagination',
  17. // clickable: true,
  18. // },
  19. // })
  20. // 新闻资讯滚动
  21. function Roll(ele, time, fun) {
  22. var obj = document.getElementById(ele);
  23. var ul = obj.children;
  24. var li = ul[0].children;
  25. console.log(li)
  26. if (fun) {
  27. var fun = fun;
  28. } else {
  29. var fun = function () { };
  30. }
  31. var t;
  32. if (time) {
  33. var time = time;
  34. } else {
  35. var time = 2500;
  36. }
  37. t = setInterval(function () {
  38. fun()
  39. $(li).eq(0).slideUp(function () {
  40. $(ul).append($(li).eq(0));
  41. });
  42. $(li).show();
  43. }, time);
  44. $(ul).on('mouseenter', 'li', function () {
  45. clearInterval(t)
  46. })
  47. $(ul).on('mouseleave', 'li', function () {
  48. t = setInterval(function () {
  49. fun()
  50. $(li).eq(0).slideUp(function () {
  51. $(ul).append($(li).eq(0));
  52. });
  53. $(li).show();
  54. }, time);
  55. })
  56. }
  57. // Roll('farmBrief', 5000)
  58. // Roll('newsListDiv', 2000)
  59. // Roll('videoListBox', 5000,function(){
  60. // $('#videoListBox .videoListUl >li').removeClass('active');
  61. // $('#videoListBox .videoListUl >li').eq(1).addClass('active');
  62. // })
  63. // Roll('gardenMsg', 2000, function(){
  64. // $('#gardenMsg .gardenUl >li').removeClass('active');
  65. // $('#gardenMsg .gardenUl >li').eq(1).addClass('active');
  66. // $('.gardenImg >img').attr('src',$('#gardenMsg .gardenUl >.active').find('.hide_farm_img').val())
  67. // })
  68. // var stu = new Roll("newsListDiv", 12);
  69. // 视频咨询
  70. // var myPlayer = videojs('my-video');
  71. // videojs("my-video").ready(function () {
  72. // var myPlayer = this;
  73. // myPlayer.play();
  74. // });
  75. // 视频咨询
  76. // $('#videoListBox').on('click', '.date', function () {
  77. // $('#videoListBox .videoListUl >li').removeClass('active');
  78. // $(this).parent().addClass('active');
  79. // var myPlayer = videojs('my-video');
  80. // var videoUrl = $(this).find('.hide_video_url').val();
  81. // videojs("my-video", {}, function () {
  82. // window.myPlayer = this;
  83. // $("#mymoda .video-con #my-video source").attr("src", videoUrl);
  84. // myPlayer.src(videoUrl);
  85. // myPlayer.load(videoUrl);
  86. // myPlayer.play();
  87. // });
  88. // // $('.videoBox').html('');
  89. // $(".video_link").click(function () {
  90. // var myPlayer = videojs('my-video');
  91. // var videoUrl = $(this).find('.hide_video_url').val();
  92. // videojs("my-video", {}, function () {
  93. // window.myPlayer = this;
  94. // $("#mymoda .video-con #my-video source").attr("src", videoUrl);
  95. // myPlayer.src(videoUrl);
  96. // myPlayer.load(videoUrl);
  97. // myPlayer.play();
  98. // });
  99. // $(".click-modal").click();
  100. // });
  101. // // 模态窗消失时,关闭视频    
  102. // $('#mymoda').on('hidden.bs.modal', function () {
  103. // myPlayer.pause();
  104. // });
  105. // })
  106. // 四季采摘
  107. $('#gardenMsg').on('click', '.gardenName', function () {
  108. $('#gardenMsg .gardenUl >li').removeClass('active');
  109. $(this).parent().addClass('active');
  110. // $(this).find('.hide_farm_img').val();
  111. $('.gardenImg >img').attr('src', $(this).find('.hide_farm_img').val())
  112. })
  113. // 导游导览
  114. // var map = new AMap.Map('map', {
  115. // resizeEnable: true, //是否监控地图容器尺寸变化
  116. // zoom: 11, //初始化地图层级
  117. // center: [113.397428, 39.90923] //初始化地图中心点
  118. // });
  119. //绘制初始路径
  120. // var path = [];
  121. // path.push([113.641379, 34.574431]);
  122. // path.push([108.877908, 34.389461]);
  123. // path.push([108.350564, 22.847832]);
  124. // map.plugin("AMap.DragRoute", function () {
  125. // route = new AMap.DragRoute(map, path, AMap.DrivingPolicy.LEAST_FEE); //构造拖拽导航类
  126. // route.search(); //查询导航路径并开启拖拽导航
  127. // });
  128. // 民宿导览
  129. var swiper = new Swiper('.homestay', {
  130. slidesPerView: 3,
  131. spaceBetween: 30,
  132. navigation: {
  133. nextEl: '.swiper-button-next',
  134. prevEl: '.swiper-button-prev',
  135. },
  136. autoplay: {
  137. delay: 3000
  138. },
  139. });
  140. })
  141. var map = new AMap.Map('map', {
  142. resizeEnable: true, //是否监控地图容器尺寸变化
  143. zoom: 11, //初始化地图层级
  144. center: [113.397428, 39.90923] //初始化地图中心点
  145. });
  146. // var geoc = new AMap.Geocoder();
  147. function searchWay() {
  148. clearWay()
  149. var startPath = $("#startPath").val();
  150. var endPath = $("#endPath").val();
  151. if (!startPath) {
  152. $("#startPath").focus();
  153. return;
  154. }
  155. if (!endPath) {
  156. $("#endPath").focus();
  157. return;
  158. }
  159. $('.guideMap').append('<div class="loadDiv"><img src="../static/imgs/timg.gif" /></div>')
  160. //构造路线导航类
  161. var driving = new AMap.Driving({
  162. map: map,
  163. panel: "panel"
  164. });
  165. // 根据起终点名称规划驾车导航路线
  166. driving.search([
  167. { keyword: startPath, city: '' },
  168. { keyword: endPath, city: '' }
  169. ], function (status, result) {
  170. if (status === 'complete') {
  171. // log.success('绘制驾车路线完成');
  172. $('.loadDiv').remove();
  173. } else {
  174. alert('获取驾车数据失败:' + result)
  175. $('.loadDiv').remove();
  176. }
  177. });
  178. }
  179. function clearWay() {
  180. // 清除地图上所有添加的覆盖物
  181. map.clearMap();
  182. $('#panel').html('');
  183. }
  184. // 登录
  185. function login() {
  186. var username = $("#username").val();
  187. var password = $("#password").val();
  188. if (!username) {
  189. $("#username").focus();
  190. return;
  191. }
  192. if (!password) {
  193. $("#password").focus();
  194. return;
  195. }
  196. // $('.notLogin').toggle();
  197. // $('.isLogin').toggle();
  198. // window.open("back_manage");
  199. $.ajax({
  200. url: 'user_land',
  201. data: {
  202. username: username,
  203. password: password
  204. },
  205. type: 'post',
  206. dataType:'json',
  207. success: function (data) {
  208. if (data.code) {
  209. var hrefstr = 'person_farm?name=' + data.username;
  210. window.location.reload();
  211. // $('.isLogin').toggle();
  212. // $('#person_farm').attr('href', hrefstr)
  213. // $('.userPhoto').attr('src', data.user_img)
  214. // $('.notLogin').hide();
  215. // $('.isLogin').show();
  216. } else if (data.code == 0) {
  217. $('body').append('<div class="hint">用户不存在</div>')
  218. setTimeout(function () {
  219. $('.hint').remove();
  220. }, 1000)
  221. } else if (data.code == 2) {
  222. $('body').append('<div class="hint">用户名错误</div>')
  223. setTimeout(function () {
  224. $('.hint').remove();
  225. }, 1000)
  226. } else if (data.code == 3) {
  227. $('body').append('<div class="hint">密码错误</div>')
  228. setTimeout(function () {
  229. $('.hint').remove();
  230. }, 1000)
  231. } else {
  232. $('body').append('<div class="hint">登录失败</div>')
  233. setTimeout(function () {
  234. $('.hint').remove();
  235. }, 1000)
  236. }
  237. },
  238. error: function (type) {
  239. }
  240. })
  241. }
  242. // 返回顶部
  243. function goUp() {
  244. $('body,html').animate({ scrollTop: 0 }, 300)
  245. }
  246. function show() {
  247. $(window).scroll(function () {
  248. if ($(window).scrollTop() > 100) {
  249. $("#back2top").fadeIn(100);
  250. } else {
  251. $("#back2top").fadeOut(100);
  252. }
  253. });
  254. }
  255. show();