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.
 
 
 
 
 

351 lines
11 KiB

  1. // 当前网页加载的时候
  2. var current_prod_code;
  3. function init_page(){
  4. // 获得上一页面的参数
  5. var prod_code = getPar('prod_code');
  6. current_prod_code = prod_code;
  7. // 根据prod_code 查询详情
  8. if(prod_code!=false){
  9. var url = 'http://xmwx.zhizhuchuxing.cn/core/detail.asp?prodcode='+prod_code;
  10. get_virtual_user_list(url);
  11. }
  12. }
  13. // 刷新
  14. var temp_httpData;
  15. function reload_Info(httpData){
  16. temp_httpData = httpData;
  17. // 得到arr
  18. console.log(temp_httpData)
  19. var bus_list = httpData.bus_list;
  20. var recommand_list = httpData.recommand_list;
  21. var container = document.getElementById("container");
  22. var header = document.getElementById("header");
  23. var center = document.getElementById("center");
  24. // 单元格HTML
  25. var wrapper_HTML = '';
  26. wrapper_HTML += '<div style="margin-top:10px; border-top:1px solid #dadada; position:relative; width:100%;background:#fff;overflow:hidden;">';
  27. wrapper_HTML += '<img style="position:absolute;top:24px;left:4%;width:9px;height: 39px;" src="../img/smalllogo.png" alt="">';
  28. wrapper_HTML +='<div style="float:left;width:100%;">';
  29. wrapper_HTML +='<div style="float:left;width:75%;margin-top:11px;margin-left:10.5%;">';
  30. wrapper_HTML +='<div style="height:32px; line-height: 32px; width:100%; border-bottom:1px solid #ECEBEE;">';
  31. wrapper_HTML +='<span id="start_area" style="font-size:16px;color:#343434;">上海</span>';
  32. wrapper_HTML +='<span id="go_info" style="float:right;color:#808080;font-size:14px;">04.15 07:30 出发</span>';
  33. wrapper_HTML +='</div>';
  34. wrapper_HTML +='<div style="height:32px;width:100%; line-height: 32px;">';
  35. wrapper_HTML +='<span id="end_area" style="font-size:16px;color:#343434;">舟山</span>';
  36. wrapper_HTML +='<span id="back_info" style="float:right;color:#808080;font-size:14px;">04.15 07:30 返回</span>';
  37. wrapper_HTML +='</div>';
  38. wrapper_HTML +='</div>';
  39. wrapper_HTML +='<div style="float:left;overflow:hidden;margin-top: 10px; padding-bottom:12px; border-bottom:1px solid #ECEBEE;width:98.7%;margin-left:2.89%;">';
  40. wrapper_HTML +='<div id="prod_name" style="float:left;color:#808080;font-size:13px;">豪华大巴陆地航空式顶级商务座</div>';
  41. wrapper_HTML +='<div style="float:left;margin-left:1.5%;">';
  42. // 是否包含车子
  43. var car = httpData.if_bus;
  44. if(car=="1"){
  45. wrapper_HTML += '<img id="if_bus" style="width:14px; height:15px;" src="../img/car2.png" alt="">';
  46. }
  47. // 是否包含宾馆
  48. var hotel = httpData.if_hotel;
  49. if (hotel=="1"){
  50. wrapper_HTML += '<img id="if_hotel" style="width:15px; height:15px;" src="../img/hotel2.png" alt="">';
  51. }
  52. // 是否包含景点
  53. var sightspot = httpData.if_sightspot;
  54. if (sightspot=="1") {
  55. wrapper_HTML += '<img id="if_sightspot" style="width:15px; height:15px;" src="../img/ticket.png" alt="">';
  56. }
  57. // 单元格结束
  58. // 单元格下面补充
  59. wrapper_HTML +='<div class="boxpricediv">';
  60. wrapper_HTML +='<div class="ticketprice">';
  61. wrapper_HTML +='<span>¥</span>';
  62. wrapper_HTML +='<span>'+httpData.price+'</span>';
  63. wrapper_HTML +='<img class="y" src="../img/right_arrow_orange.png" />';
  64. wrapper_HTML +='<a href="spend.html"><span class="y>费用说明</span></a>';
  65. wrapper_HTML +='</div>';
  66. wrapper_HTML +='</div>';
  67. // 补充结束
  68. // header执行cell
  69. header.innerHTML=wrapper_HTML;
  70. // 线路介绍
  71. var intro = httpData.circuitry_intro;
  72. var xcontent = document.getElementById("xcontent");
  73. // alert(s.replace(/\LOVE/g, "爱"));
  74. //var text= "javascript 非常强大 !JAVASCRIPT 是我最喜欢的一门语言 !";
  75. //17 text.replace(/javascript/ig, "JavaScript");18 // 返回:JavaScript 非常强大 !JavaScript 是我最喜欢的一门语言 !
  76. var xcHTML='';
  77. xcHTML+='<div style="overflow:hidden;margin-bottom:16px;">';
  78. xcHTML+='<img style="width:21px;height:24px;float:left;" src="../img/getin.jpg" alt="">';
  79. xcHTML+='</div>';
  80. xcHTML+='<div>';
  81. xcHTML+='<img style="width:8px;height:12px;margin-left:2.05%;float:left;" src="../img/xarive.jpg" alt="">';
  82. xcHTML+='';
  83. xcHTML+='';
  84. xcHTML+='';
  85. xcHTML+='';
  86. var t ='<span style="float:left;margin-left:6.4%;margin-top:1px;margin-bottom:8px;margin-top:-2px;">';
  87. var t2 ='</span><br>';
  88. intro=intro.replace(/[T]/g,t);
  89. intro=intro.replace(/[/T]/g,t2);
  90. var s = '<div style="float:left;margin-left:10.4%;margin-bottom:19px;">';
  91. var s2=' </div>';
  92. intro=intro.replace(/[S]/g,s);
  93. intro=intro.replace(/[/S]/g,s2);
  94. // var a ='';
  95. // var a2 ='';
  96. // introl=introl.replace(/[A]/g,a);
  97. // introl=introl.replace(/[/A]/g,a2);
  98. var sc = '<span style="font-size:17px;color:#030303;float:left;margin-left:3.4%;margin-top:1px;">';
  99. var sc2 ='</span>';
  100. intro=intro.replace(/[SC]/g,sc);
  101. intro=intro.replace(/[/SC]/g,sc2);
  102. // alert(intro);
  103. }
  104. // 将出行介绍、上下班点、费用说明三个按钮颜色清空
  105. function clear_type_title_color(){
  106. var chuxingjs = document.getElementById("chuxingjs");
  107. var shangxiazd = document.getElementById("shangxiazd");
  108. var feiyongsm = document.getElementById("feiyongsm");
  109. chuxingjs.style.color = "black";
  110. chuxingjs.style.borderBottomWidth="0px";
  111. shangxiazd.style.color = "black";
  112. shangxiazd.style.borderBottomWidth="0px";
  113. feiyongsm.style.color = "black";
  114. feiyongsm.style.borderBottomWidth="0px";
  115. }
  116. // 点击出行介绍
  117. function click_chuxingjs(intro){
  118. clear_type_title_color();
  119. var chuxingjs = document.getElementById("chuxingjs");
  120. change_css_type(chuxingjs);
  121. var type_info = document.getElementById("type-info");
  122. type_info.innerHTML=intro;
  123. }
  124. // 点击上下站点
  125. function click_shangxiazd(intro){
  126. clear_type_title_color();
  127. var shangxiazd = document.getElementById("shangxiazd");
  128. change_css_type(shangxiazd);
  129. var type_info = document.getElementById("type-info");
  130. type_info.innerHTML=intro;
  131. }
  132. // 点击费用说明
  133. function click_feiyongsm(intro){
  134. clear_type_title_color();
  135. var feiyongsm = document.getElementById("feiyongsm");
  136. change_css_type(feiyongsm);
  137. var type_info = document.getElementById("type-info");
  138. type_info.innerHTML=intro;
  139. }
  140. // 改变三个type的样式
  141. function change_css_type(type){
  142. type.style.color="#00CC9C";
  143. type.style.borderBottomWidth="2px";
  144. type.style.borderBottomStyle="solid";
  145. type.style.borderBottomColor="#00CC9C";
  146. }
  147. // 点击更多
  148. function click_more_more(type_id){
  149. var listURL = "mdidiProduct.html?type_id="+type_id;
  150. // 跳转前将URL编码
  151. listURL = encodeURI(listURL);
  152. window.location.href = listURL;
  153. }
  154. // 点击单元格
  155. function click_cell_box(prod_code){
  156. var listURL = "mdidiDetail.html?prod_code="+prod_code;
  157. // 跳转前将URL编码
  158. listURL = encodeURI(listURL);
  159. window.location.href = listURL;
  160. }
  161. // 点击立即预订
  162. function click_booking(){
  163. var listURL = "../reserve.html?prodcode="+current_prod_code;
  164. // 跳转前将URL编码
  165. listURL = encodeURI(listURL);
  166. window.location.href = listURL;
  167. }
  168. // 从内容中截取图片名称
  169. function subStrFormContext(context){
  170. var imgName="";
  171. var i = context.indexOf("[img]");
  172. var j = context.indexOf("[/img]");
  173. imgName=context.substring(i+5,j);
  174. // 去掉[img][/img]的文本内容
  175. var str1 = context.substring(0,i);
  176. var str2 = context.substring(j+6,context.length);
  177. var str = str1+str2;
  178. var img_str = new Array();
  179. img_str.push(imgName); //0
  180. img_str.push(str); //1
  181. img_str.push(str1); //2
  182. img_str.push(str2); //3
  183. return img_str;
  184. }
  185. // 从上一页的链接上获取参数
  186. function getPar(par){
  187. //获取当前URL
  188. var local_url = document.location.href;
  189. // 接收的时候将URL 解码
  190. local_url = decodeURI(local_url);
  191. //获取要取得的get参数位置
  192. var get = local_url.indexOf(par +"=");
  193. if(get == -1){
  194. return false;
  195. }
  196. //截取字符串
  197. var get_par = local_url.slice(par.length + get + 1);
  198. //判断截取后的字符串是否还有其他get参数
  199. var nextPar = get_par.indexOf("&");
  200. if(nextPar != -1){
  201. get_par = get_par.slice(0, nextPar);
  202. }
  203. return get_par;
  204. }
  205. //目的地 三个type
  206. // 点击三个票种
  207. function click_ticket_type(type_id){
  208. var ship_ticket = document.getElementById("ship_ticket");
  209. clear_three_ticket_type(ship_ticket);
  210. var hotel_ticket = document.getElementById("hotel_ticket");
  211. clear_three_ticket_type(hotel_ticket);
  212. var door_ticket = document.getElementById("door_ticket");
  213. clear_three_ticket_type(door_ticket);
  214. if(type_id=="1"){
  215. ship_ticket.style.color = '#00CC9C';
  216. ship_ticket.style.borderBottomWidth = "2px";
  217. ship_ticket.style.borderBottomStyle = "solid";
  218. ship_ticket.style.borderBottomColor = "#00CC9C";
  219. }else if(type_id=="2"){
  220. hotel_ticket.style.color = '#00CC9C';
  221. hotel_ticket.style.borderBottomWidth = "2px";
  222. hotel_ticket.style.borderBottomStyle = "solid";
  223. hotel_ticket.style.borderBottomColor = "#00CC9C";
  224. }else{
  225. door_ticket.style.color = '#00CC9C';
  226. door_ticket.style.borderBottomWidth = "2px";
  227. door_ticket.style.borderBottomStyle = "solid";
  228. door_ticket.style.borderBottomColor = "#00CC9C";
  229. }
  230. }
  231. // 清空三个票种的选中效果
  232. function clear_three_ticket_type(type){
  233. type.style.color = "black";
  234. type.style.backgroundColor = "white";
  235. type.style.borderBottomWidth = "0px";
  236. }
  237. /*======================网络请求的Ajax的代码=======================*/
  238. // 创建一个Ajax对象
  239. if (window.ActiveXObject){
  240. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  241. }else{
  242. var myreq = new XMLHttpRequest();
  243. }
  244. // 请求方法,传入URL
  245. function get_virtual_user_list(myURL)
  246. {
  247. var tnowtime = getDateTime(4);
  248. // m_url = 接口
  249. // var myURL = m_url + 'op=userlink&vuser=' + cvuserid + '&tt=' + tnowtime;
  250. // var myURL = "http://xmwx.zhizhuchuxing.cn/core/area_target.asp?keyword=";
  251. myreq.open("get",myURL,true);
  252. // 接收的数据交给哪个函数处理
  253. myreq.onreadystatechange = show_user_list;
  254. myreq.send();
  255. }
  256. function show_user_list()
  257. {
  258. if (myreq.readyState == 4)
  259. {
  260. // newstr 就是接收到的数据
  261. var newstr = myreq.responseText;
  262. var httpData=JSON.parse(newstr);
  263. //
  264. reload_Info(httpData);
  265. }
  266. }
  267. function getDateTime(nTypeFlag)
  268. {
  269. var tNowTime = new Date();
  270. var myYear = ';' + tNowTime.getFullYear() + ';';
  271. var myMonth = ';' + (tNowTime.getMonth()+1-0) + ';';
  272. var myDay = ';' + tNowTime.getDate()+ ';';
  273. var myHour = ';' + tNowTime.getHours()+ ';';
  274. var myMinu = ';' + tNowTime.getMinutes()+ ';';
  275. var mySecond = ';' + tNowTime.getSeconds()+ ';';
  276. if (myMonth.length < 4) myMonth = '0' + myMonth;
  277. if (myDay.length < 4) myDay = '0' + myDay;
  278. if (myHour.length < 4) myHour = '0' + myHour;
  279. if (myMinu.length < 4) myMinu = '0' + myMinu;
  280. if (mySecond.length < 4) mySecond = '0' + mySecond;
  281. var cNewTimeStr;
  282. //alert(tNowTime);
  283. switch (nTypeFlag+1-1)
  284. {
  285. case 0:
  286. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  287. break;
  288. case 1:
  289. cNewTimeStr = myYear + myMonth + myDay;
  290. break;
  291. case 2:
  292. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  293. break;
  294. case 3:
  295. cNewTimeStr = myHour + myMinu + mySecond;
  296. break;
  297. case 4:
  298. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  299. break;
  300. case 5:
  301. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  302. break;
  303. case 6:
  304. cNewTimeStr = myYear;
  305. break;
  306. case 7:
  307. cNewTimeStr = myYear + '-' + myMonth;
  308. break;
  309. default:
  310. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  311. break;
  312. }
  313. cNewTimeStr = cNewTimeStr.replace(/;/g,"");
  314. return cNewTimeStr;
  315. }