farmList.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. {% load staticfiles %}
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8. <title>农场列表页</title>
  9. <link rel="stylesheet" href="{% static '/lib/font/fontIcon/iconfont.css' %}">
  10. <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css">
  11. <link rel="stylesheet" href="{% static '/lib/css/reset.css' %}">
  12. <link rel="stylesheet" href="{% static '/lib/layui/css/layui.css' %}">
  13. <link rel="stylesheet" href="{% static '/css/common.css' %}">
  14. <link rel="stylesheet" href="{% static '/css/module.css' %}">
  15. <!-- <link rel="stylesheet" href="{% static '/css/hotelList.css' %}"> -->
  16. <style>
  17. .advImg {
  18. background: url(../static/imgs/farmAdv.jpg) no-repeat center;
  19. background-size: cover;
  20. }
  21. /* 内容模块 */
  22. .hacienda .haciendaList {
  23. display: flex;
  24. flex-flow: wrap;
  25. }
  26. .hacienda .haciendaList {
  27. padding: 20px 20px 0 20px;
  28. }
  29. .hacienda .haciendaItem {
  30. display: flex;
  31. margin-bottom: 20px;
  32. }
  33. .hacienda .haciendaImg {
  34. width: 195px;
  35. height: 165px;
  36. position: relative;
  37. }
  38. .hacienda .haciendaImg .haciendaImg1 {
  39. width: 100%;
  40. height: 100%;
  41. }
  42. .hacienda .haciendaImg .haciendaImg2 {
  43. position: absolute;
  44. top: 0;
  45. left: 10px;
  46. }
  47. .hacienda .haciendaItem .haciendaTxt {
  48. width: 147px;
  49. padding: 10px 10px;
  50. }
  51. .hacienda .haciendaItem .haciendaTxt h2 {
  52. font-size: 14px;
  53. font-weight: bold;
  54. line-height: 33px;
  55. white-space: nowrap;
  56. overflow: hidden;
  57. text-overflow: ellipsis;
  58. }
  59. .hacienda .haciendaItem .haciendaTxt .desc {
  60. letter-spacing: 2px;
  61. height: 100px;
  62. overflow: hidden;
  63. }
  64. .hacienda .haciendaItem .haciendaTxt button {
  65. color: #fff;
  66. padding: 5px 6px;
  67. border-radius: 5px;
  68. }
  69. .hacienda .haciendaItem .haciendaTxt button.btn1 {
  70. background-color: #00aeed;
  71. }
  72. .hacienda .haciendaItem .haciendaTxt button.btn2 {
  73. background-color: #3bb852;
  74. }
  75. /* 弹出观光样式 */
  76. .tourismShow {
  77. position: relative;
  78. z-index: 999;
  79. opacity: 0;
  80. display: none;
  81. position: fixed;
  82. top: 25%;
  83. left: 50%;
  84. margin-left: -300px;
  85. width: 600px;
  86. min-height: 400px;
  87. background-color: #fff;
  88. border: 1px solid #f1f1f1;
  89. -webkit-box-shadow: 2px 4px 10px rgba(0, 0, 0, .15);
  90. -moz-box-shadow: 2px 4px 10px rgba(0, 0, 0, .15);
  91. -o-box-shadow: 2px 4px 10px rgba(0, 0, 0, .15);
  92. box-shadow: 2px 4px 10px rgba(0, 0, 0, .15);
  93. padding: 20px;
  94. border-radius: 12px;
  95. z-index: 9;
  96. border-top-left-radius: 0;
  97. cursor: default;
  98. border-top-right-radius: 0;
  99. transition: all .5s;
  100. }
  101. .tourismShow .title {
  102. border-left: 3px solid #ff6a28;
  103. padding-left: 8px;
  104. font-size: 16px;
  105. }
  106. .tourismShow .line {
  107. border-bottom: 1px solid #ddd;
  108. margin-top: 10px;
  109. }
  110. .tourismShow .content {
  111. height: 430px;
  112. padding-top: 20px;
  113. }
  114. .tourismShow .tourismShowCloseBtn {
  115. position: absolute;
  116. right: 15px;
  117. top: 11px;
  118. border-radius: 50%;
  119. border: 2px solid #ddd;
  120. width: 25px;
  121. height: 25px;
  122. line-height: 25px;
  123. text-align: center;
  124. cursor: pointer;
  125. }
  126. .tourismShow .content .guideForm>input {
  127. width: 40%;
  128. }
  129. .tourismShow .content .guideForm>button {
  130. color: #fff;
  131. padding: 5px 6px;
  132. border-radius: 5px;
  133. vertical-align: middle;
  134. margin-left: 10px;
  135. background: #1eaeed;
  136. }
  137. .tourismShow .content .guideForm>button {
  138. color: #fff;
  139. padding: 5px 6px;
  140. border-radius: 5px;
  141. vertical-align: middle;
  142. margin-left: 10px;
  143. background: #1eaeed;
  144. }
  145. .tourismShow .content #map {
  146. height: 373px;
  147. margin-top: 10px;
  148. }
  149. .tourismShow .loadDiv {
  150. position: absolute;
  151. left: 45%;
  152. top: 45%;
  153. }
  154. </style>
  155. </head>
  156. <body>
  157. <div class="header">
  158. <div class="headerTxt">
  159. <div class="wrapper">
  160. <p class="logoNameCn">休闲农业旅游网</p>
  161. <p class="logoNameEn">Leisure agricultural tourism network</p>
  162. </div>
  163. </div>
  164. <!-- 广告 -->
  165. <div class="bjColor advImg"></div>
  166. </div>
  167. <!-- 主体部分 -->
  168. <div class="content">
  169. <div class="wrapper">
  170. <div class="newsDiv">
  171. <!-- 面包屑导航 -->
  172. <div class="breadcrumb">
  173. <span class="layui-breadcrumb">
  174. <a href="home">首页</a>
  175. <a>
  176. <cite>农场导览</cite>
  177. </a>
  178. </span>
  179. <div class="searchDiv">
  180. <input type="text" id="searchTitlt" value="{{con|default:''}}" placeholder="请输入标题"
  181. autocomplete="off" class="layui-input">
  182. <button type="button" onclick="searchCon()" class="layui-btn layui-btn-ms"><i
  183. class="layui-icon">&#xe615;</i></button>
  184. </div>
  185. </div>
  186. <!-- 新闻列表 -->
  187. <div class="innerDiv">
  188. <div class="hacienda">
  189. <ul class="haciendaList">
  190. {% if garden_list|length %} {% for gardenItem in garden_list %}
  191. <li class="haciendaItem">
  192. <div class="haciendaImg">
  193. <img class="haciendaImg1" src="http://112.49.38.63:8011/{{gardenItem.img_1}}" alt="">
  194. </div>
  195. <div class="haciendaTxt">
  196. <h2>{{gardenItem.name}}</h2>
  197. <div class="desc">{{gardenItem.desc|default:''}}</div>
  198. <div>
  199. <button class="btn1">
  200. <input type="hidden" name="" value="{{gardenItem.guide_img}}" id="">
  201. 观光路线
  202. </button>
  203. <button class="btn2">
  204. <input type="hidden" name="" value="{{gardenItem.location}}" id="">
  205. 导游导览
  206. </button>
  207. </div>
  208. </div>
  209. </li>
  210. {% endfor %} {% else %}
  211. <li class="videoItem" style=" width: 100%;">
  212. <div style="text-align:center;line-height:200px;font-size:18px">暂无数据</div>
  213. </li>
  214. {% endif %}
  215. </ul>
  216. </div>
  217. {% if garden_list|length %}
  218. <div id="page"></div>
  219. <input type="hidden" value="{{nums}}" id="nums">
  220. <input type="hidden" value="{{page}}" id="currPage">
  221. {% else %}
  222. {% endif %}
  223. </div>
  224. </div>
  225. </div>
  226. </div>
  227. <!-- 底部版权 -->
  228. <div class="footer bjColor">
  229. <div class="wrapper">
  230. <div class="floatDiv">
  231. <div class="copyrightTxt">
  232. <div>休闲农业旅游网</div>
  233. <div>联系人:李四  联系电话:13811111111</div>
  234. <div>地址:河南省郑州市XXXXXXXXXXXXXXXXXXXXXXXXXX</div>
  235. </div>
  236. <div class="WeChatCode">
  237. <img src="{% static '/imgs/WeChatCode.jpg' %}" alt="">
  238. <p>关注公众号</p>
  239. </div>
  240. </div>
  241. <div class="copyright">
  242. 版权所有XXXXXXXXXXXXXXXXXXXXXX
  243. </div>
  244. </div>
  245. </div>
  246. <div class="tourismShow">
  247. <div class="title">
  248. <span>观光路线</span>
  249. <div class="tourismShowCloseBtn"><i class="layui-icon layui-icon-close"></i></div>
  250. </div>
  251. <div class="line"></div>
  252. <div class="content"></div>
  253. </div>
  254. <script src="{% static '/lib/js/jquery-2.1.4.min.js'%}"></script>
  255. <script src="https://webapi.amap.com/maps?v=1.4.15&key=3939967b919a8003377dd113fc445a3d&plugin=AMap.Driving&plugin=AMap.Geocoder"></script>
  256. <script src="{% static '/lib/layui/layui.js'%}"></script>
  257. <script>
  258. //注意:导航 依赖 element 模块,否则无法进行功能性操作
  259. layui.use(['element', 'laypage'], function () {
  260. var element = layui.element;
  261. //…
  262. var laypage = layui.laypage;
  263. var currPage = $('#currPage').val();
  264. //执行一个laypage实例
  265. laypage.render({
  266. elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
  267. , count: $('#nums').val() //数据总数,从服务端得到
  268. // , limit: 5
  269. , curr: currPage
  270. , jump: function (obj, first) {
  271. //obj包含了当前分页的所有参数,比如:
  272. console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
  273. console.log(obj.limit); //得到每页显示的条数
  274. var searchTitlt = $('#searchTitlt').val();
  275. //首次不执行
  276. if (!first) {
  277. window.location.href = 'farm_list?page=' + obj.curr + '&condition=' + searchTitlt;
  278. }
  279. }
  280. });
  281. });
  282. $('#searchTitlt').on('keypress', function (e) {
  283. if (e && e.keyCode == 13) { // 按 Esc
  284. searchCon()
  285. }
  286. })
  287. function searchCon() {
  288. var searchTitlt = $('#searchTitlt').val();
  289. window.location.href = 'farm_list?page=1' + '&condition=' + searchTitlt;
  290. }
  291. $('.haciendaTxt .btn1').on('click', function () {
  292. $('.tourismShow .title span').html('观光路线')
  293. var img = $(this).find('input').val();
  294. $('.tourismShow .content').html('<div style="text-align:center;width:100%;height:100%"><img style="width:100%;height:100%" src="' + img + '">')
  295. $('.tourismShow').show();
  296. $('.tourismShow').css('opacity', 1)
  297. })
  298. $('.tourismShowCloseBtn').on('click', function () {
  299. $('.tourismShow .content').html('')
  300. $('.tourismShow').css('opacity', 0)
  301. setTimeout(function () {
  302. $('.tourismShow').hide();
  303. }, 500)
  304. })
  305. var map;
  306. $('.haciendaTxt .btn2').on('click', function () {
  307. $('.tourismShow .title span').html('导游导览');
  308. var lng = $(this).find('input').val().split(',')[0];
  309. var lat = $(this).find('input').val().split(',')[1];
  310. var html = '<div class="">' +
  311. '<div class="guideForm">起始地点:<input type="text" id="startPath"><button onclick="searchWay(\'' + lng + '\',\'' + lat + '\')">确定</button></div>' +
  312. '<div id="map">地图</div>' +
  313. '</div>'
  314. $('.tourismShow .content').html(html);
  315. map = new AMap.Map('map', {
  316. resizeEnable: true, //是否监控地图容器尺寸变化
  317. zoom: 11, //初始化地图层级
  318. center: [lng, lat] //初始化地图中心点
  319. });
  320. geocoder = new AMap.Geocoder({
  321. city: "010", //城市设为北京,默认:“全国”
  322. radius: 1000 //范围,默认:500
  323. });
  324. var startIcon = new AMap.Icon({
  325. // 图标尺寸
  326. size: new AMap.Size(25, 34),
  327. // 图标的取图地址
  328. image: '//a.amap.com/jsapi_demos/static/demo-center/icons/dir-marker.png',
  329. // 图标所用图片大小
  330. imageSize: new AMap.Size(135, 40),
  331. // 图标取图偏移量
  332. imageOffset: new AMap.Pixel(-9, -3)
  333. });
  334. var endIcon = new AMap.Icon({
  335. size: new AMap.Size(25, 34),
  336. image: '//a.amap.com/jsapi_demos/static/demo-center/icons/dir-marker.png',
  337. imageSize: new AMap.Size(135, 40),
  338. imageOffset: new AMap.Pixel(-95, -3)
  339. });
  340. var marker = new AMap.Marker({
  341. icon: endIcon,
  342. position: new AMap.LngLat(lng, lat), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
  343. });
  344. map.add(marker);
  345. $('.tourismShow').show();
  346. $('.tourismShow').css('opacity', 1);
  347. geocoder = new AMap.Geocoder({
  348. city: "010", //城市设为北京,默认:“全国”
  349. radius: 1000 //范围,默认:500
  350. });
  351. })
  352. function searchWay(lng,lat) {
  353. map.clearMap();
  354. var startPath = $("#startPath").val();
  355. var endPath = '北京';
  356. if (!startPath) {
  357. $("#startPath").focus();
  358. return;
  359. }
  360. $('.tourismShow .content').append('<div class="loadDiv"><img src="../static/imgs/timg.gif" /></div>')
  361. //构造路线导航类
  362. var driving = new AMap.Driving({
  363. map: map,
  364. // panel: "panel"
  365. });
  366. geocoder.getAddress([lng,lat], function(status, result) {
  367. if (status === 'complete'&&result.regeocode) {
  368. var address = result.regeocode.formattedAddress;
  369. // 根据起终点名称规划驾车导航路线
  370. driving.search([
  371. { keyword: startPath, city: '' },
  372. { keyword: address, city: '' }
  373. ], function (status, result) {
  374. if (status === 'complete') {
  375. // log.success('绘制驾车路线完成');
  376. $('.loadDiv').remove();
  377. } else {
  378. alert('获取驾车数据失败:' + result)
  379. $('.loadDiv').remove();
  380. }
  381. });
  382. }else{
  383. log.error('根据经纬度查询地址失败')
  384. }
  385. });
  386. }
  387. </script>
  388. </body>
  389. </html>