index.js 7.9 KB

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