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.
 
 
 
 
 

283 lines
8.8 KiB

  1. /*======================网络请求的Ajax的代码=======================*/
  2. // 创建一个Ajax对象
  3. if (window.ActiveXObject){
  4. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  5. }else{
  6. var myreq = new XMLHttpRequest();
  7. }
  8. var isHot = true;
  9. // 请求方法,传入URL
  10. function get_virtual_user_list(myURL)
  11. {
  12. var tnowtime = getDateTime(4);
  13. // m_url = 接口
  14. // var myURL = m_url + 'op=userlink&vuser=' + cvuserid + '&tt=' + tnowtime;
  15. // var myURL = "http://xmwxc.zhizhuchuxing.cn/core/area_target.asp?keyword=";
  16. myreq.open("get",myURL,true);
  17. // 接收的数据交给哪个函数处理
  18. myreq.onreadystatechange = show_user_list;
  19. myreq.send();
  20. }
  21. function show_user_list()
  22. {
  23. if (myreq.readyState == 4)
  24. {
  25. // newstr 就是接收到的数据
  26. var newstr = myreq.responseText;
  27. var httpData=JSON.parse(newstr);
  28. if(isHot){
  29. reload_cell(httpData);
  30. }else{
  31. reload_sy_input(httpData);
  32. }
  33. }
  34. }
  35. function getDateTime(nTypeFlag)
  36. {
  37. var tNowTime = new Date();
  38. var myYear = ';' + tNowTime.getFullYear() + ';';
  39. var myMonth = ';' + (tNowTime.getMonth()+1-0) + ';';
  40. var myDay = ';' + tNowTime.getDate()+ ';';
  41. var myHour = ';' + tNowTime.getHours()+ ';';
  42. var myMinu = ';' + tNowTime.getMinutes()+ ';';
  43. var mySecond = ';' + tNowTime.getSeconds()+ ';';
  44. if (myMonth.length < 4) myMonth = '0' + myMonth;
  45. if (myDay.length < 4) myDay = '0' + myDay;
  46. if (myHour.length < 4) myHour = '0' + myHour;
  47. if (myMinu.length < 4) myMinu = '0' + myMinu;
  48. if (mySecond.length < 4) mySecond = '0' + mySecond;
  49. var cNewTimeStr;
  50. //alert(tNowTime);
  51. switch (nTypeFlag+1-1)
  52. {
  53. case 0:
  54. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  55. break;
  56. case 1:
  57. cNewTimeStr = myYear + myMonth + myDay;
  58. break;
  59. case 2:
  60. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  61. break;
  62. case 3:
  63. cNewTimeStr = myHour + myMinu + mySecond;
  64. break;
  65. case 4:
  66. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  67. break;
  68. case 5:
  69. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  70. break;
  71. case 6:
  72. cNewTimeStr = myYear;
  73. break;
  74. case 7:
  75. cNewTimeStr = myYear + '-' + myMonth;
  76. break;
  77. default:
  78. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  79. break;
  80. }
  81. cNewTimeStr = cNewTimeStr.replace(/;/g,"");
  82. return cNewTimeStr;
  83. }
  84. /*===========index.html的JS========================*/
  85. // 点击搜索
  86. function click_sy_button() {
  87. // 得到出发地的文本框
  88. var start = document.getElementById("startAddress");
  89. // 得到目的地的文本框
  90. var end = document.getElementById("endAddress");
  91. var sy_button = document.getElementById("sy-button");
  92. var endValue = end.innerHTML;
  93. if(endValue=="选择目的地"){
  94. endValue="";
  95. }
  96. if (endValue=='ZZWF') {
  97. end.innerHTML='周庄迪士尼';
  98. }
  99. var listURL = "bookingHomePage/list.html?area1="+start.innerHTML+"&area2="+endValue+"&endspan="+endspan;
  100. // 跳转前将URL编码
  101. listURL = encodeURI(listURL);
  102. window.location.href = listURL;
  103. }
  104. // 点击精选路线的三个目的地
  105. function click_route(area){
  106. // 得到目的地的文本框
  107. var end = document.getElementById("endAddress");
  108. end.innerHTML = area;
  109. // 调用点击搜索
  110. click_sy_button();
  111. }
  112. //在body onload 调用
  113. var area1="";
  114. var area2="";
  115. var endspan=""; // 判断在目的地选择的哪个地点 那个span的id名称
  116. function init_page()
  117. {
  118. area1 = getPar('area1');
  119. area2 = getPar('area2');
  120. endspan = getPar('endspan');
  121. if(area1!="false" && area1!=""){
  122. var startAddress = document.getElementById("startAddress");
  123. startAddress.innerHTML=area1;
  124. }
  125. if(area2!="false" && area1!=""){
  126. var endAddress = document.getElementById("endAddress");
  127. endAddress.style.color='#000000';
  128. endAddress.innerHTML=area2;
  129. }
  130. var url = "/core/hot_list.asp";
  131. get_virtual_user_list(url);
  132. }
  133. // 从上一页的链接上获取参数
  134. function getPar(par){
  135. //获取当前URL
  136. var local_url = document.location.href;
  137. // 接收的时候将URL 解码
  138. local_url = decodeURI(local_url);
  139. //获取要取得的get参数位置
  140. var get = local_url.indexOf(par +"=");
  141. if(get == -1){
  142. return false;
  143. }
  144. //截取字符串
  145. var get_par = local_url.slice(par.length + get + 1);
  146. //判断截取后的字符串是否还有其他get参数
  147. var nextPar = get_par.indexOf("&");
  148. if(nextPar != -1){
  149. get_par = get_par.slice(0, nextPar);
  150. }
  151. return get_par;
  152. }
  153. //点击出发地
  154. function click_startAddress(){
  155. var listURL = "bookingHomePage/startArea.html?area1="+area1+"&area2="+area2+'&endspan='+endspan;
  156. // 跳转前将URL编码
  157. listURL = encodeURI(listURL);
  158. window.location.href = listURL;
  159. }
  160. // 点击目的地
  161. function click_endAddress(){
  162. var listURL = "bookingHomePage/endArea.html?area1="+area1+"&area2="+area2+'&endspan='+endspan;
  163. // 跳转前将URL编码
  164. listURL = encodeURI(listURL);
  165. window.location.href = listURL;
  166. }
  167. // 点击单元格
  168. function click_cell(prod_code){
  169. // var listURL = "bookingHomePage/details.html?prod_code="+prod_code;
  170. var listURL = "/core/prod_detail.asp?prod_code="+prod_code;
  171. // 跳转前将URL编码
  172. listURL = encodeURI(listURL);
  173. window.location.href = listURL;
  174. }
  175. // 热门推荐的cell
  176. // 刷新表格
  177. function reload_cell(httpData){
  178. if(httpData.code!="0"){
  179. alert(httpData.info);return;
  180. }
  181. // 得到center对象
  182. var hot = document.getElementById("hotRecommend");
  183. // 得到数据中的数据
  184. var product_list = httpData.product_list;
  185. var htmlStr="";
  186. for (var i=0;i<product_list.length;i++) {
  187. if(i>=5)break;
  188. if(i==0){
  189. htmlStr+='<div class="title">';
  190. htmlStr+='<p class="z">精选路线</p>';
  191. htmlStr+='</div>';
  192. }
  193. htmlStr+='<div class="cell-start zh" onclick="click_cell('+'\''+product_list[i].prod_code+'\''+')">';
  194. htmlStr+='<div class="smallbox">';
  195. htmlStr+='<img style="position:absolute;top:23px;left:4%;width:9px;height: 39px;" class="smalllogo" src="img/smalllogo.png">';
  196. htmlStr+='<div class="smallboxleft z">';
  197. htmlStr+='<div class="smallareainput z" style="margin-top:10px;">';
  198. htmlStr+='<div style="height:32px; line-height: 32px; width:100%; border-bottom:1px solid #ECEBEE;">';
  199. htmlStr+='<span id="start_area" style="font-size:16px;color:#343434;">'+product_list[i].start_area+'</span>';
  200. htmlStr+='<span id="go_info" style="float:right;color:#808080;font-size:14px;">'+product_list[i].run_info+'</span>';
  201. htmlStr+='</div>';
  202. htmlStr+='<div style="height:32px;width:100%; line-height: 32px;">';
  203. htmlStr+='<span id="end_area" style="font-size:16px;color:#343434;">'+product_list[i].end_area+'</span>';
  204. htmlStr+='<span id="back_info" style="float:right;color:#808080;font-size:14px;">'+product_list[i].run_count+'&nbsp;班&nbsp;/&nbsp;天</span>';
  205. htmlStr+='</div>';
  206. htmlStr+='</div>';
  207. var width = window.screen.width ;
  208. var name = product_list[i].prod_name;
  209. if (width>320){
  210. if(name.length>19){
  211. name = name.substr(0,18)+'...';
  212. }else{
  213. name = name.substr(0,20);
  214. }
  215. }else if(width==320){
  216. if(name.length>17){
  217. name = name.substr(0,15)+'...';
  218. }else{
  219. name = name.substr(0,17);
  220. }
  221. }else if(width>=300 && width<320){
  222. if(name.length>15){
  223. name = name.substr(0,13)+'...';
  224. }else{
  225. name = name.substr(0,15);
  226. }
  227. }
  228. htmlStr+='<div class="tickettitle z" style="float:left;color:#808080;font-size:13px;margin-left:4.89%;margin-top:14px;">'+name+'</div>';
  229. htmlStr+='</div>';
  230. // 判断往返程信息
  231. if(product_list[i].direction=="1"){
  232. htmlStr+='<img class="exchangelogo" style="position:absolute;top:36px;right:6.8%;width:13px; height: 13px;" src="img/single_arrow.png">';
  233. }else if(product_list[i].direction=="2"){
  234. htmlStr+='<img class="exchangelogo" style="position:absolute;top:36px;right:6.8%;width:13px; height: 13px;" src="img/go_back.png">';
  235. }
  236. htmlStr+='<div class="smallboxright y" style="margin-right:-3px; text-align: center;">';
  237. htmlStr+='<div class="ticketprice" style="margin-right:0px;">';
  238. htmlStr+='<span style="margin-right:-2px;">¥&nbsp;</span>';
  239. htmlStr+='<span>'+product_list[i].price+'</span>';
  240. htmlStr+='</div>';
  241. htmlStr+='<div class="tickettypeimage" style="width:100%;margin-top:29px;float:left;">';
  242. var bus = product_list[i].if_bus;
  243. if(bus=="1"){
  244. htmlStr+='<img class="img car" style="" src="img/car.png" alt="">';
  245. }
  246. var hotel = product_list[i].if_hotel;
  247. if(hotel=="1"){
  248. htmlStr+='<img class="img ticket" style="width: 15px;" src="img/hotel.png" alt="">';
  249. }
  250. var sight = product_list[i].if_sightspot;
  251. if(sight=="1"){
  252. htmlStr+='<img class="img hotel" style="width:16px;margin-right:0px;" src="img/ticket.png" alt="">';
  253. }
  254. htmlStr+='</div>';
  255. htmlStr+='</div>';
  256. htmlStr+='</div>';
  257. htmlStr+='</div>';
  258. }
  259. // 执行
  260. hot.innerHTML = htmlStr;
  261. }
  262. // 点击加载更多
  263. function click_load_more(){
  264. // 得到目的地的文本框
  265. var listURL = "bookingHomePage/list.html?area1=&area2=&endspan=";
  266. // 跳转前将URL编码
  267. listURL = encodeURI(listURL);
  268. window.location.href = listURL;
  269. }