You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

160 lines
4.4 KiB

  1. //Author:fuhc
  2. //Date:20160825
  3. //Description:热门城市
  4. var key_word ="";
  5. var area_type = "all";
  6. var type_null = "";
  7. //页面加载
  8. window.onload=function(){
  9. var url=base_api+"./zz_wxsct/control.php";
  10. var parm={
  11. type:"bus_area_list",
  12. area:key_word,
  13. area_type:area_type
  14. }
  15. ZZLog(url+JSON.stringify(parm));
  16. $.post(url,parm,function(res_data){
  17. res_data=JSON.parse(res_data);
  18. ZZLog(res_data);
  19. if(res_data["code"]!="0"){
  20. alert(res_data["info"]);
  21. return;
  22. }
  23. //将下拉列表展示出来
  24. $(".select_content").css('z-index','5');
  25. var list=res_data['list'];
  26. var HTML="";
  27. for (var i=0,m=list.length;i<m;i++) {
  28. var dict=list[i];
  29. HTML += '<div class="sort_list" onclick="click_select_area('+dict['area_id']+')" id='+dict['area_id']+' type="'+dict['type']+'" area_id="'+dict['area_id']+'" area_name="'+dict['area_name']+'">'
  30. + '<div class="num_name">'+dict['area_name']+'</div>'
  31. + '</div>'
  32. }
  33. $(".select_content").html(HTML);
  34. $.getScript("js/sort.js");
  35. });
  36. // eg:打字太快 如黄
  37. // 黄的数据先出来,拼音的后出来就没有显示
  38. //将选中的地点设置为选中状态
  39. var his_area_id=getPar('his_area_id');
  40. if(his_area_id!="" && his_area_id!="791" && his_area_id!="850"){
  41. $('#'+his_area_id).addClass('city_info_selected');
  42. }
  43. $(".selected").click(function(){
  44. area_type = $(this).attr("select_type");
  45. console.log(area_type);
  46. $("#shaixuan").children().removeClass("select_color");
  47. $(this).addClass("select_color");
  48. if(area_type=="all"){
  49. $("#hot1").show();
  50. $("#hot2").show();
  51. }else{
  52. $("#hot1").hide();
  53. $("#hot2").hide();
  54. }
  55. var url=base_api+"./zz_wxsct/control.php";
  56. var parm={
  57. type:"bus_area_list",
  58. area:key_word,
  59. area_type:area_type
  60. }
  61. ZZLog(url+JSON.stringify(parm));
  62. $.post(url,parm,function(res_data){
  63. res_data=JSON.parse(res_data);
  64. ZZLog(res_data);
  65. if(res_data["code"]!="0"){
  66. alert(res_data["info"]);
  67. return;
  68. }
  69. //将下拉列表展示出来
  70. $(".select_content").css('z-index','5');
  71. var list=res_data['list'];
  72. var HTML="";
  73. for (var i=0,m=list.length;i<m;i++) {
  74. var dict=list[i];
  75. HTML += '<div class="sort_list" onclick="click_select_area('+dict['area_id']+')" id='+dict['area_id']+' type="'+dict['type']+'" area_id="'+dict['area_id']+'" area_name="'+dict['area_name']+'">'
  76. + '<div class="num_name">'+dict['area_name']+'</div>'
  77. + '</div>'
  78. }
  79. $(".select_content").html(HTML);
  80. $.getScript("js/sort.js")
  81. });
  82. })
  83. $('#key_word').on('input',function(e){
  84. $("#btn_cancel").css("color","#0076ff");
  85. key_word=$(this).val();
  86. var url=base_api+"./zz_wxsct/control.php";
  87. var parm={
  88. type:"bus_area_list",
  89. area:key_word,
  90. area_type:type_null
  91. }
  92. ZZLog(url+JSON.stringify(parm));
  93. $.post(url,parm,function(res_data){
  94. res_data=JSON.parse(res_data);
  95. ZZLog(res_data);
  96. if(res_data["code"]!="0"){
  97. alert(res_data["info"]);
  98. return;
  99. }
  100. //将下拉列表展示出来
  101. $(".select_xiala").css('z-index','999');
  102. var list=res_data['list'];
  103. var HTML="";
  104. for (var i=0,m=list.length;i<m;i++) {
  105. var dict=list[i];
  106. HTML += '<div style="margin-left: 0.38rem;color: #999;font-size: 0.16rem;margin-right: 0rem;" class="content_xiala ui_p_t15 ui_p_b15 ui_m_l15 ui_m_r15 ui_line_b line_color_b bc-border" onclick="click_select_area('+dict['area_id']+')" id='+dict['area_id']+' type="'+dict['type']+'" area_id="'+dict['area_id']+'" area_name="'+dict['area_name']+'">'+dict['area_name']+'</div>'
  107. }
  108. $(".select_xiala").html(HTML);
  109. });
  110. });
  111. //取消
  112. $('#btn_cancel').on('click',function(e){
  113. $('#key_word').val('');
  114. $(".select_xiala").css('z-index','-1');
  115. $(".select_xiala").html('');
  116. $("#btn_cancel").css("color","#FFF");
  117. });
  118. }
  119. function click_select_area(self_id){
  120. var self_obj=$('#'+self_id);
  121. var area_name=self_obj.attr('area_name');
  122. var area_id=self_obj.attr('area_id');
  123. var type=self_obj.attr('type');
  124. var op_type=getPar('op_type'); //判断是选择出发地-还是目的地
  125. var data={
  126. op_type:op_type,
  127. area_id:area_id,
  128. area_name:area_name,
  129. area_type:type
  130. };
  131. if(op_type=="start"){
  132. setStorJson('f_wx_start_hot_city20160826',data);
  133. }
  134. if(op_type=="end"){
  135. setStorJson('f_wx_end_hot_city20160826',data);
  136. }
  137. var tt=getDateTime(4);
  138. var listURL='travel_book.html?tt='+tt;
  139. window.location.href=listURL;
  140. }