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.
 
 
 
 
 
 

329 lines
10 KiB

  1. //========================列表页的主页=============================//
  2. function init_page(){
  3. var area1=getPar('area1');
  4. var area2=getPar('area2');
  5. if(area1!=false){
  6. var url = "http://wx.zhizhuchuxing.com/core/query.asp?area1="+area1+"&area2="+area2;
  7. get_virtual_user_list(url);
  8. }
  9. }
  10. // 刷新表格
  11. var temp_httpData;
  12. function reload_cell(httpData){
  13. temp_httpData = httpData;
  14. // 判断是否有搜索的结果
  15. if(httpData.code!="0"){
  16. alert(httpData.info);
  17. var footer_center = document.getElementById("footer-center");
  18. footer_center.style.display='none';
  19. return;
  20. }
  21. // 得到center对象
  22. var center = document.getElementById("center");
  23. // 得到数据中的数据
  24. var product_list = httpData.product_list;
  25. var htmlStr="";
  26. for (var i=0;i<product_list.length;i++) {
  27. // if(i==0){
  28. // htmlStr+='<div class="title">';
  29. // htmlStr+='<p class="z">热门推荐</p>';
  30. // htmlStr+='</div>';
  31. // }
  32. if (i==product_list.length-1) {
  33. htmlStr+='<div class="cell-start-last cell-start zh" onclick="click_cell('+'\''+product_list[i].prod_code+'\''+')">';
  34. }else{
  35. htmlStr+='<div class="cell-start zh" onclick="click_cell('+'\''+product_list[i].prod_code+'\''+')">';
  36. }
  37. htmlStr+='<div class="smallbox">';
  38. htmlStr+='<img class="smalllogo" src="../img/smalllogo.png">';
  39. htmlStr+='<div class="smallboxleft z">';
  40. htmlStr+='<div class="smallareainput z">';
  41. htmlStr+='<div class="areastart">';
  42. htmlStr+='<span class="area">'+product_list[i].start_area+'</span>';
  43. htmlStr+='<span class="arearight y">'+product_list[i].run_info+'</span>';
  44. htmlStr+='</div>';
  45. htmlStr+='<div class="areaend">';
  46. htmlStr+='<span class="area">'+product_list[i].end_area+'</span>';
  47. htmlStr+='<span class="arearight y">'+product_list[i].run_count+'个班次</span>';
  48. htmlStr+='</div>';
  49. htmlStr+='</div>';
  50. htmlStr+='<div class="tickettitle z">'+product_list[i].prod_name+'</div>';
  51. htmlStr+='</div>';
  52. // 判断往返程信息
  53. if(product_list[i].direction=="1"){
  54. htmlStr+='<img class="exchangelogo" src="../img/single_arrow.png">';
  55. }else if(product_list[i].direction=="2"){
  56. htmlStr+='<img class="exchangelogo" src="../img/go_back.png">';
  57. }
  58. htmlStr+='<div class="smallboxright y">';
  59. htmlStr+='<div class="ticketprice">';
  60. htmlStr+='<span>¥</span>';
  61. htmlStr+='<span>'+product_list[i].price+'</span>';
  62. htmlStr+='</div>';
  63. htmlStr+='<div class="tickettypeimage">';
  64. // 是否包含景点
  65. var sightspot = product_list[i].if_sightspot;
  66. if (sightspot=="1") {
  67. htmlStr+='<img class="img y" style="width:16px" src="../img/ticket.png" alt="">';
  68. }
  69. // 是否包含宾馆
  70. var hotel = product_list[i].if_hotel;
  71. if (hotel=="1"){
  72. htmlStr+='<img class="img y" src="../img/hotel.png" alt="">';
  73. }
  74. // 是否包含车子
  75. var car = product_list[i].if_bus;
  76. if(car=="1"){
  77. htmlStr+='<img class="img y" src="../img/car.png" alt="">';
  78. }
  79. htmlStr+='</div>';
  80. htmlStr+='</div>';
  81. htmlStr+='</div>';
  82. htmlStr+='</div>';
  83. }
  84. // 执行
  85. center.innerHTML = htmlStr;
  86. }
  87. // 点击单元格
  88. function click_cell(prod_code){
  89. // var listURL = "details.html?prod_code="+prod_code;
  90. var listURL = "/core/prod_detail.asp?prod_code="+prod_code;
  91. // 跳转前将URL编码
  92. listURL = encodeURI(listURL);
  93. window.location.href = listURL;
  94. }
  95. // 从上一页的链接上获取参数
  96. function getPar(par){
  97. //获取当前URL
  98. var local_url = document.location.href;
  99. // 接收的时候将URL 解码
  100. local_url = decodeURI(local_url);
  101. //获取要取得的get参数位置
  102. var get = local_url.indexOf(par +"=");
  103. if(get == -1){
  104. return false;
  105. }
  106. //截取字符串
  107. var get_par = local_url.slice(par.length + get + 1);
  108. //判断截取后的字符串是否还有其他get参数
  109. var nextPar = get_par.indexOf("&");
  110. if(nextPar != -1){
  111. get_par = get_par.slice(0, nextPar);
  112. }
  113. return get_par;
  114. }
  115. //========================列表页的两个层=============================//
  116. // 点击了目的地
  117. function clickMudidi(){
  118. load_mudidi_citys_sightspot(); // 动态加载目的地的城市和景点
  119. hide_mask_type(); // 隐藏蒙板和出发、目的地层
  120. // 得到蒙板层
  121. var mask = document.getElementById("mask");
  122. // 目的地
  123. var mudidi = document.getElementById("m_mudidi");
  124. // 得到目的地按钮
  125. var toaddess = document.getElementById("toaddess");
  126. mask.style.display = 'block';
  127. mudidi.style.display = 'block';
  128. toaddess.style.color='#00CC9C';
  129. }
  130. // 动态加载目的地的城市和景点
  131. function load_mudidi_citys_sightspot(){
  132. var m_city = document.getElementById("m_city");
  133. var m_scenery = document.getElementById("m_scenery");
  134. var city_list = temp_httpData.city_list;
  135. var city_listHTML = '';
  136. for (var i=0;i<city_list.length;i++) {
  137. city_listHTML +='<li class="m_button" onclick="m_get_target_area('+'\''+city_list[i].city+'\''+')">'+city_list[i].city+'</li>';
  138. }
  139. // 执行
  140. m_city.innerHTML = city_listHTML;
  141. var sightspot_list = temp_httpData.sightspot_list;
  142. var sightspot_listHTML = '';
  143. for (var i=0;i<sightspot_list.length;i++) {
  144. sightspot_listHTML +='<li class="m_button"><a id="m_dsn" onclick="m_get_target_area('+'\''+sightspot_list[i].sightspot+'\''+')">'+sightspot_list[i].sightspot+'</a></li>';
  145. }
  146. // 执行
  147. m_scenery.innerHTML = sightspot_listHTML;
  148. }
  149. // 选中目的地层上的地点
  150. function m_get_target_area(area){
  151. alert("你选择的地点是="+area);
  152. // 选择了地点之后,将蒙板去掉、将该层隐藏
  153. hide_mask_type();
  154. }
  155. // 点击了出发类型
  156. function clickType(){
  157. load_type_data(); // 动态加载出发类型的数据
  158. hide_mask_type();
  159. // 得到蒙板层
  160. var mask = document.getElementById("mask");
  161. // 出发类型
  162. var c_type = document.getElementById("c_type");
  163. // 得到出发类型按钮
  164. var type = document.getElementById("type");
  165. mask.style.display = 'block';
  166. c_type.style.display = 'block';
  167. type.style.color = "#00CC9C";
  168. }
  169. // 动态加载出发类型上的数据
  170. function load_type_data(){
  171. // 全部
  172. var c_header_all = document.getElementById("c_header_all");
  173. var c_header_allHTML ='';
  174. c_header_allHTML +='<span class="type_title z">全部</span>';
  175. c_header_allHTML+='<span class="type_count y">'+temp_httpData.total_count+'条</span>';
  176. //
  177. c_header_all.innerHTML=c_header_allHTML;
  178. // 单程票
  179. var c_header_all_single = document.getElementById("c_header_all_single");
  180. var singleHTML = '';
  181. singleHTML +='<span class="type_title z">单程票</span>';
  182. singleHTML +='<span class="type_count y">'+temp_httpData.single_count+'条</span>';
  183. //
  184. c_header_all_single.innerHTML = singleHTML;
  185. // 往返票
  186. var c_header_all_goback = document.getElementById("c_header_all_goback");
  187. var gobackHTML = '';
  188. gobackHTML +='<span class="type_title z">往返票</span>';
  189. gobackHTML +='<span class="type_count y">'+temp_httpData.goback_count+'条</span>';
  190. //
  191. c_header_all_goback.innerHTML = gobackHTML;
  192. // 往返票+景点
  193. var c_header_all_gobacksight = document.getElementById("c_header_all_gobacksight");
  194. var gobacksightHTML = '';
  195. gobacksightHTML +='<span class="type_title z">往返票+景点</span>';
  196. gobacksightHTML +='<span class="type_count y">'+temp_httpData.gobacksight_count+'条</span>';
  197. //
  198. c_header_all_gobacksight.innerHTML = gobackHTML;
  199. // 单程票+景点
  200. var c_header_all_singlehotel = document.getElementById("c_header_all_singlehotel");
  201. var singlehotelHTML = '';
  202. singlehotelHTML +='<span class="type_title z">单程票+景点</span>';
  203. singlehotelHTML +='<span class="type_count y">'+temp_httpData.singlehotel_count+'条</span>';
  204. c_header_all_singlehotel.innerHTML = singlehotelHTML;
  205. }
  206. // 选中出发类型上的类型
  207. function c_get_type(type){
  208. hide_mask_type();
  209. }
  210. // 隐藏蒙板和出发、目的地层
  211. function hide_mask_type(){
  212. // 蒙板
  213. var mask = document.getElementById("mask");
  214. // 出发类型层
  215. var c_type = document.getElementById("c_type");
  216. mask.style.display = 'none';
  217. c_type.style.display = 'none';
  218. // 目的地层
  219. var m_mudidi = document.getElementById("m_mudidi");
  220. m_mudidi.style.display = 'none';
  221. // 目的地按钮
  222. var toaddess = document.getElementById("toaddess");
  223. toaddess.style.color='black';
  224. // 出发类型按钮
  225. var type = document.getElementById("type");
  226. type.style.color='black';
  227. }
  228. /*======================网络请求的Ajax的代码=======================*/
  229. // 创建一个Ajax对象
  230. if (window.ActiveXObject){
  231. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  232. }else{
  233. var myreq = new XMLHttpRequest();
  234. }
  235. // 请求方法,传入URL
  236. function get_virtual_user_list(myURL)
  237. {
  238. var tnowtime = getDateTime(4);
  239. // m_url = 接口
  240. // var myURL = m_url + 'op=userlink&vuser=' + cvuserid + '&tt=' + tnowtime;
  241. // var myURL = "http://wx.zhizhuchuxing.com/core/area_target.asp?keyword=";
  242. myreq.open("get",myURL,true);
  243. // 接收的数据交给哪个函数处理
  244. myreq.onreadystatechange = show_user_list;
  245. myreq.send();
  246. }
  247. function show_user_list()
  248. {
  249. if (myreq.readyState == 4)
  250. {
  251. // newstr 就是接收到的数据
  252. var newstr = myreq.responseText;
  253. var httpData=JSON.parse(newstr);
  254. //
  255. reload_cell(httpData);
  256. }
  257. }
  258. function getDateTime(nTypeFlag)
  259. {
  260. var tNowTime = new Date();
  261. var myYear = ';' + tNowTime.getFullYear() + ';';
  262. var myMonth = ';' + (tNowTime.getMonth()+1-0) + ';';
  263. var myDay = ';' + tNowTime.getDate()+ ';';
  264. var myHour = ';' + tNowTime.getHours()+ ';';
  265. var myMinu = ';' + tNowTime.getMinutes()+ ';';
  266. var mySecond = ';' + tNowTime.getSeconds()+ ';';
  267. if (myMonth.length < 4) myMonth = '0' + myMonth;
  268. if (myDay.length < 4) myDay = '0' + myDay;
  269. if (myHour.length < 4) myHour = '0' + myHour;
  270. if (myMinu.length < 4) myMinu = '0' + myMinu;
  271. if (mySecond.length < 4) mySecond = '0' + mySecond;
  272. var cNewTimeStr;
  273. //alert(tNowTime);
  274. switch (nTypeFlag+1-1)
  275. {
  276. case 0:
  277. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  278. break;
  279. case 1:
  280. cNewTimeStr = myYear + myMonth + myDay;
  281. break;
  282. case 2:
  283. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  284. break;
  285. case 3:
  286. cNewTimeStr = myHour + myMinu + mySecond;
  287. break;
  288. case 4:
  289. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  290. break;
  291. case 5:
  292. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  293. break;
  294. case 6:
  295. cNewTimeStr = myYear;
  296. break;
  297. case 7:
  298. cNewTimeStr = myYear + '-' + myMonth;
  299. break;
  300. default:
  301. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  302. break;
  303. }
  304. cNewTimeStr = cNewTimeStr.replace(/;/g,"");
  305. return cNewTimeStr;
  306. }