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.
 
 
 
 
 

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