|
- /*======================网络请求的Ajax的代码=======================*/
-
- // 创建一个Ajax对象
- if (window.ActiveXObject){
- var myreq = new ActiveXObject("Microsoft.XMLHTTP");
- }else{
- var myreq = new XMLHttpRequest();
- }
- var isHot = true;
- // 请求方法,传入URL
- function get_virtual_user_list(myURL)
- {
- var tnowtime = getDateTime(4);
- // m_url = 接口
-
- // var myURL = m_url + 'op=userlink&vuser=' + cvuserid + '&tt=' + tnowtime;
- // var myURL = "http://xmwx.zhizhuchuxing.cn/core/area_target.asp?keyword=";
- myreq.open("get",myURL,true);
- // 接收的数据交给哪个函数处理
- myreq.onreadystatechange = show_user_list;
- myreq.send();
- }
- function show_user_list()
- {
- if (myreq.readyState == 4)
- {
- // newstr 就是接收到的数据
- var newstr = myreq.responseText;
- var httpData=JSON.parse(newstr);
- if(isHot){
- reload_cell(httpData);
- }else{
- reload_sy_input(httpData);
-
- }
- }
- }
- function getDateTime(nTypeFlag)
- {
- var tNowTime = new Date();
- var myYear = ';' + tNowTime.getFullYear() + ';';
- var myMonth = ';' + (tNowTime.getMonth()+1-0) + ';';
- var myDay = ';' + tNowTime.getDate()+ ';';
- var myHour = ';' + tNowTime.getHours()+ ';';
- var myMinu = ';' + tNowTime.getMinutes()+ ';';
- var mySecond = ';' + tNowTime.getSeconds()+ ';';
-
- if (myMonth.length < 4) myMonth = '0' + myMonth;
- if (myDay.length < 4) myDay = '0' + myDay;
- if (myHour.length < 4) myHour = '0' + myHour;
- if (myMinu.length < 4) myMinu = '0' + myMinu;
- if (mySecond.length < 4) mySecond = '0' + mySecond;
-
- var cNewTimeStr;
- //alert(tNowTime);
- switch (nTypeFlag+1-1)
- {
- case 0:
- cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
- break;
- case 1:
- cNewTimeStr = myYear + myMonth + myDay;
- break;
- case 2:
- cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
- break;
- case 3:
- cNewTimeStr = myHour + myMinu + mySecond;
- break;
- case 4:
- cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
- break;
- case 5:
- cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
- break;
- case 6:
- cNewTimeStr = myYear;
- break;
- case 7:
- cNewTimeStr = myYear + '-' + myMonth;
- break;
- default:
- cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
- break;
- }
-
- cNewTimeStr = cNewTimeStr.replace(/;/g,"");
-
- return cNewTimeStr;
-
- }
-
- /*===========index.html的JS========================*/
- // 点击搜索
- function click_sy_button() {
- // 得到出发地的文本框
- var start = document.getElementById("startAddress");
- // 得到目的地的文本框
- var end = document.getElementById("endAddress");
- var sy_button = document.getElementById("sy-button");
- var endValue = end.innerHTML;
- if(endValue=="选择目的地"){
- endValue="";
- }
- if (endValue=='ZZWF') {
- end.innerHTML='周庄迪士尼';
- }
- var listURL = "bookingHomePage/list.html?area1="+start.innerHTML+"&area2="+endValue+"&endspan="+endspan;
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- }
- // 点击精选路线的三个目的地
- function click_route(area){
- // 得到目的地的文本框
- var end = document.getElementById("endAddress");
- end.innerHTML = area;
- // 调用点击搜索
- click_sy_button();
- }
- //在body onload 调用
- var area1="";
- var area2="";
- var endspan=""; // 判断在目的地选择的哪个地点 那个span的id名称
- function init_page()
- {
- area1 = getPar('area1');
- area2 = getPar('area2');
- endspan = getPar('endspan');
- if(area1!="false" && area1!=""){
- var startAddress = document.getElementById("startAddress");
- startAddress.innerHTML=area1;
- }
- if(area2!="false" && area1!=""){
- var endAddress = document.getElementById("endAddress");
- endAddress.style.color='#000000';
- endAddress.innerHTML=area2;
- }
- var url = "/core/hot_list.asp";
- get_virtual_user_list(url);
- }
- // 从上一页的链接上获取参数
- function getPar(par){
- //获取当前URL
- var local_url = document.location.href;
- // 接收的时候将URL 解码
- local_url = decodeURI(local_url);
- //获取要取得的get参数位置
- var get = local_url.indexOf(par +"=");
- if(get == -1){
- return false;
- }
- //截取字符串
- var get_par = local_url.slice(par.length + get + 1);
- //判断截取后的字符串是否还有其他get参数
- var nextPar = get_par.indexOf("&");
- if(nextPar != -1){
- get_par = get_par.slice(0, nextPar);
- }
- return get_par;
- }
- //点击出发地
- function click_startAddress(){
- var listURL = "bookingHomePage/startArea.html?area1="+area1+"&area2="+area2+'&endspan='+endspan;
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- }
- // 点击目的地
- function click_endAddress(){
- var listURL = "bookingHomePage/endArea.html?area1="+area1+"&area2="+area2+'&endspan='+endspan;
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- }
- // 点击单元格
- function click_cell(prod_code){
- // var listURL = "bookingHomePage/details.html?prod_code="+prod_code;
- var listURL = "/core/prod_detail.asp?prod_code="+prod_code;
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- }
- // 热门推荐的cell
- // 刷新表格
- function reload_cell(httpData){
- if(httpData.code!="0"){
- alert(httpData.info);return;
- }
- // 得到center对象
- var hot = document.getElementById("hotRecommend");
- // 得到数据中的数据
- var product_list = httpData.product_list;
- var htmlStr="";
- var disp_count = 0;
- for (var i=0;i<product_list.length;i++) {
- if(disp_count>=3) break;
- //if(i>=5)break;
- if(i==0){
- htmlStr+='<div class="title">';
- htmlStr+='<p class="z">精选路线</p>';
- htmlStr+='</div>';
- }
- if(product_list[i].prod_code!="QC1"&&product_list[i].prod_code!="QC02"&&product_list[i].prod_code!="SHXT1"){continue;}
- htmlStr+='<div class="cell-start zh" onclick="click_cell('+'\''+product_list[i].prod_code+'\''+')">';
- htmlStr+='<div class="smallbox">';
- htmlStr+='<img style="position:absolute;top:23px;left:4%;width:9px;height: 39px;" class="smalllogo" src="img/smalllogo.png">';
- htmlStr+='<div class="smallboxleft z">';
- htmlStr+='<div class="smallareainput z" style="margin-top:10px;">';
- htmlStr+='<div style="height:32px; line-height: 32px; width:100%; border-bottom:1px solid #ECEBEE;">';
- htmlStr+='<span id="start_area" style="font-size:16px;color:#343434;">'+product_list[i].start_area+'</span>';
- htmlStr+='<span id="go_info" style="float:right;color:#808080;font-size:14px;">'+product_list[i].run_info+'</span>';
- htmlStr+='</div>';
- htmlStr+='<div style="height:32px;width:100%; line-height: 32px;">';
- htmlStr+='<span id="end_area" style="font-size:16px;color:#343434;">'+product_list[i].end_area+'</span>';
- htmlStr+='<span id="back_info" style="float:right;color:#808080;font-size:14px;">'+product_list[i].run_count+' 班 / 天</span>';
- htmlStr+='</div>';
- htmlStr+='</div>';
- var width = window.screen.width ;
- var name = product_list[i].prod_name;
- if (width>320){
- if(name.length>19){
- name = name.substr(0,18)+'...';
- }else{
- name = name.substr(0,20);
- }
- }else if(width==320){
- if(name.length>17){
- name = name.substr(0,15)+'...';
- }else{
- name = name.substr(0,17);
- }
- }else if(width>=300 && width<320){
- if(name.length>15){
- name = name.substr(0,13)+'...';
- }else{
- name = name.substr(0,15);
- }
- }
- htmlStr+='<div class="tickettitle z" style="float:left;color:#808080;font-size:13px;margin-left:4.89%;margin-top:14px;">'+name+'</div>';
- htmlStr+='</div>';
- // 判断往返程信息
- if(product_list[i].direction=="1"){
- htmlStr+='<img class="exchangelogo" style="position:absolute;top:36px;right:6.8%;width:13px; height: 13px;" src="img/single_arrow.png">';
- }else if(product_list[i].direction=="2"){
- htmlStr+='<img class="exchangelogo" style="position:absolute;top:36px;right:6.8%;width:13px; height: 13px;" src="img/go_back.png">';
- }
- htmlStr+='<div class="smallboxright y" style="margin-right:-3px; text-align: center;">';
- htmlStr+='<div class="ticketprice" style="margin-right:0px;">';
- htmlStr+='<span style="margin-right:-2px;">¥ </span>';
- htmlStr+='<span>'+product_list[i].price+'</span>';
- htmlStr+='</div>';
- htmlStr+='<div class="tickettypeimage" style="width:100%;margin-top:29px;float:left;">';
- var bus = product_list[i].if_bus;
- if(bus=="1"){
- htmlStr+='<img class="img car" style="" src="img/car.png" alt="">';
- }
- var hotel = product_list[i].if_hotel;
- if(hotel=="1"){
- htmlStr+='<img class="img ticket" style="width: 15px;" src="img/hotel.png" alt="">';
- }
- var sight = product_list[i].if_sightspot;
- if(sight=="1"){
- htmlStr+='<img class="img hotel" style="width:16px;margin-right:0px;" src="img/ticket.png" alt="">';
- }
- htmlStr+='</div>';
- htmlStr+='</div>';
- htmlStr+='</div>';
- htmlStr+='</div>';
- }
- // 执行
- hot.innerHTML = htmlStr;
- }
- // 点击加载更多
- function click_load_more(){
- // 得到目的地的文本框
- var listURL = "bookingHomePage/list.html?area1=&area2=&endspan=";
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- }
-
-
-
|