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.
 
 
 
 
 
 

130 lines
4.2 KiB

  1. // body onload
  2. var area1="";
  3. var area2="";
  4. var endspan="";
  5. function init_page(){
  6. area1 = getPar('area1');
  7. area2 = getPar('area2');
  8. endspan = getPar('endspan');
  9. // 默认有城市
  10. // click_xshuaxin();
  11. var c_address1 = document.getElementById("c_address1");
  12. var c_address2 = document.getElementById("c_address2");
  13. var city_listHTML = '';
  14. var cstr1 = '';
  15. var myArray = new Array();
  16. myArray[0] = '上海';
  17. myArray[1] = '苏州';
  18. myArray[2] = '杭州';
  19. myArray[3] = '常州';
  20. myArray[4] = '嘉兴';
  21. myArray[5] = '湖州';
  22. myArray[6] = '扬州';
  23. for (var i=0;i<myArray.length;i++) {
  24. cstr1 = myArray[i];
  25. if (cstr1 == area1){
  26. city_listHTML +='<li id="li'+(i+1)+'" class="c_button" style="background:#00cc9c;color:#ffffff;border-color:#00cc9c;" onclick="c_get_target_area('+'\''+myArray[i]+'\''+')">'+myArray[i]+'</li>';
  27. }else{
  28. city_listHTML +='<li id="li'+(i+1)+'" class="c_button" onclick="c_get_target_area('+'\''+myArray[i]+'\''+')">'+myArray[i]+'</li>';
  29. }
  30. }
  31. c_address1.innerHTML = city_listHTML;
  32. if(area1=="false"){
  33. document.getElementById("li1").style.color="#FFFFFF";
  34. document.getElementById("li1").style.background="#00cc9c";
  35. document.getElementById("li1").style.border="2px solid #00cc9c";
  36. }
  37. var sightspot_listHTML = '';
  38. var cstr2 = '';
  39. var myArray2 = new Array();
  40. myArray2[0] = '千岛湖';
  41. myArray2[1] = '安吉';
  42. myArray2[2] = '天目湖';
  43. myArray2[3] = '南山竹海';
  44. myArray2[4] = '乌镇';
  45. myArray2[5] = '同里';
  46. myArray2[6] = '留园';
  47. myArray2[7] = '灵山大佛';
  48. myArray2[8] = '甪直';
  49. myArray2[9] = '锦溪';
  50. myArray2[10] = '周庄';
  51. myArray2[11] = '萧山机场';
  52. myArray2[12] = '恐龙园';
  53. myArray2[13] = '嬉戏谷';
  54. myArray2[14] = '大明山';
  55. myArray2[15] = '青山湖';
  56. myArray2[16] = '西塘';
  57. myArray2[17] = '南浔';
  58. myArray2[18] = '桐庐';
  59. myArray2[19] = '莫干山';
  60. for (var i=0;i<myArray2.length;i++) {
  61. cstr2 = myArray2[i];
  62. if(area1==cstr2){
  63. sightspot_listHTML +='<li id="li'+(i+6)+'" class="c_button" style="background:#00cc9c;color:#ffffff;border-color:#00cc9c;" onclick="c_get_target_area('+'\''+myArray2[i]+'\''+')">'+myArray2[i]+'</li>';
  64. }else{
  65. sightspot_listHTML +='<li id="li'+(i+6)+'" class="c_button" onclick="c_get_target_area('+'\''+myArray2[i]+'\''+')">'+myArray2[i]+'</li>';
  66. }
  67. }
  68. c_address2.innerHTML = sightspot_listHTML;
  69. }
  70. // 选中一个城市
  71. function c_get_target_area(area){
  72. area1=area;
  73. // 用一个新的页面打开
  74. var listURL = "../index.html?area1="+area1+"&area2="+area2+'&endspan='+endspan;
  75. // 跳转前将URL编码
  76. listURL = encodeURI(listURL);
  77. window.location.href = listURL;
  78. }
  79. // 刷新坐标位置
  80. function click_xshuaxin(){
  81. var c_address = document.getElementById("c_address");
  82. var addHTML = '';
  83. addHTML +='<li id="c_currentLocation" class="c_choose sh xc_choose" onclick="c_get_target_area('+'\''+"上海"+'\''+')">上海</li>';
  84. c_address.innerHTML = addHTML;
  85. // 将景区改为热门城市
  86. var c_hotpush = document.getElementById("c_hotpush");
  87. var pushHTML = '';
  88. pushHTML+='<p>热门城市</p>';
  89. pushHTML+='<div class="xxian3"></div>';
  90. pushHTML+='<ul class="c_address">';
  91. pushHTML+='<li class="c_button"><span id="c_btn-sh" onclick="c_get_target_area('+'\''+"上海"+'\''+')">上海</span></li>';
  92. // pushHTML+='<li class="c_button"><span id="c_btn-hz" onclick="c_get_target_area('+'\''+"北京"+'\''+')">北京</span></li>';
  93. // pushHTML+='<li class="c_button"><span id="c_btn-nj" onclick="c_get_target_area('+'\''+"厦门"+'\''+')">厦门</span></li>';
  94. // pushHTML+='<li class="c_button"><span id="c_btn-zs" onclick="c_get_target_area('+'\''+"福州"+'\''+')">福州</span></li>';
  95. c_hotpush.innerHTML = pushHTML;
  96. }
  97. // 从上一页的链接上获取参数
  98. function getPar(par){
  99. //获取当前URL
  100. var local_url = document.location.href;
  101. // 接收的时候将URL 解码
  102. local_url = decodeURI(local_url);
  103. //获取要取得的get参数位置
  104. var get = local_url.indexOf(par +"=");
  105. if(get == -1){
  106. return false;
  107. }
  108. //截取字符串
  109. var get_par = local_url.slice(par.length + get + 1);
  110. //判断截取后的字符串是否还有其他get参数
  111. var nextPar = get_par.indexOf("&");
  112. if(nextPar != -1){
  113. get_par = get_par.slice(0, nextPar);
  114. }
  115. return get_par;
  116. }