|
-
-
- //========================列表页的主页=============================//
- function init_page(){
-
- var area1=getPar('area1');
- var area2=getPar('area2');
- if(area1!=false){
- var url = "http://wx.zhizhuchuxing.com/core/query.asp?area1="+area1+"&area2="+area2;
- get_virtual_user_list(url);
- }
- }
-
- // 刷新表格
- var temp_httpData;
- function reload_cell(httpData){
- temp_httpData = httpData;
- // 判断是否有搜索的结果
- if(httpData.code!="0"){
- alert(httpData.info);
- var footer_center = document.getElementById("footer-center");
- footer_center.style.display='none';
- return;
- }
-
- // 得到center对象
- var center = document.getElementById("center");
- // 得到数据中的数据
- var product_list = httpData.product_list;
- var htmlStr="";
- for (var i=0;i<product_list.length;i++) {
- // if(i==0){
- // htmlStr+='<div class="title">';
- // htmlStr+='<p class="z">热门推荐</p>';
- // htmlStr+='</div>';
- // }
- if (i==product_list.length-1) {
- htmlStr+='<div class="cell-start-last cell-start zh" onclick="click_cell('+'\''+product_list[i].prod_code+'\''+')">';
- }else{
- htmlStr+='<div class="cell-start zh" onclick="click_cell('+'\''+product_list[i].prod_code+'\''+')">';
- }
-
- htmlStr+='<div class="smallbox">';
- htmlStr+='<img class="smalllogo" src="../img/smalllogo.png">';
- htmlStr+='<div class="smallboxleft z">';
- htmlStr+='<div class="smallareainput z">';
- htmlStr+='<div class="areastart">';
- htmlStr+='<span class="area">'+product_list[i].start_area+'</span>';
- htmlStr+='<span class="arearight y">'+product_list[i].run_info+'</span>';
- htmlStr+='</div>';
- htmlStr+='<div class="areaend">';
- htmlStr+='<span class="area">'+product_list[i].end_area+'</span>';
- htmlStr+='<span class="arearight y">'+product_list[i].run_count+'个班次</span>';
- htmlStr+='</div>';
- htmlStr+='</div>';
- htmlStr+='<div class="tickettitle z">'+product_list[i].prod_name+'</div>';
- htmlStr+='</div>';
- // 判断往返程信息
- if(product_list[i].direction=="1"){
- htmlStr+='<img class="exchangelogo" src="../img/single_arrow.png">';
- }else if(product_list[i].direction=="2"){
- htmlStr+='<img class="exchangelogo" src="../img/go_back.png">';
- }
- htmlStr+='<div class="smallboxright y">';
- htmlStr+='<div class="ticketprice">';
- htmlStr+='<span>¥</span>';
- htmlStr+='<span>'+product_list[i].price+'</span>';
- htmlStr+='</div>';
- htmlStr+='<div class="tickettypeimage">';
-
- // 是否包含景点
- var sightspot = product_list[i].if_sightspot;
- if (sightspot=="1") {
- htmlStr+='<img class="img y" style="width:16px" src="../img/ticket.png" alt="">';
- }
- // 是否包含宾馆
- var hotel = product_list[i].if_hotel;
- if (hotel=="1"){
- htmlStr+='<img class="img y" src="../img/hotel.png" alt="">';
- }
- // 是否包含车子
- var car = product_list[i].if_bus;
- if(car=="1"){
- htmlStr+='<img class="img y" src="../img/car.png" alt="">';
- }
- htmlStr+='</div>';
- htmlStr+='</div>';
- htmlStr+='</div>';
- htmlStr+='</div>';
- }
- // 执行
- center.innerHTML = htmlStr;
- }
- // 点击单元格
- function click_cell(prod_code){
- // var listURL = "details.html?prod_code="+prod_code;
- var listURL = "/core/prod_detail.asp?prod_code="+prod_code;
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- }
-
- // 从上一页的链接上获取参数
- 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 clickMudidi(){
- load_mudidi_citys_sightspot(); // 动态加载目的地的城市和景点
- hide_mask_type(); // 隐藏蒙板和出发、目的地层
- // 得到蒙板层
- var mask = document.getElementById("mask");
- // 目的地
- var mudidi = document.getElementById("m_mudidi");
- // 得到目的地按钮
- var toaddess = document.getElementById("toaddess");
- mask.style.display = 'block';
- mudidi.style.display = 'block';
- toaddess.style.color='#00CC9C';
- }
- // 动态加载目的地的城市和景点
- function load_mudidi_citys_sightspot(){
- var m_city = document.getElementById("m_city");
- var m_scenery = document.getElementById("m_scenery");
-
- var city_list = temp_httpData.city_list;
- var city_listHTML = '';
- for (var i=0;i<city_list.length;i++) {
- city_listHTML +='<li class="m_button" onclick="m_get_target_area('+'\''+city_list[i].city+'\''+')">'+city_list[i].city+'</li>';
- }
- // 执行
- m_city.innerHTML = city_listHTML;
- var sightspot_list = temp_httpData.sightspot_list;
- var sightspot_listHTML = '';
- for (var i=0;i<sightspot_list.length;i++) {
- 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>';
- }
- // 执行
- m_scenery.innerHTML = sightspot_listHTML;
- }
- // 选中目的地层上的地点
- function m_get_target_area(area){
- alert("你选择的地点是="+area);
- // 选择了地点之后,将蒙板去掉、将该层隐藏
- hide_mask_type();
- }
-
- // 点击了出发类型
- function clickType(){
- load_type_data(); // 动态加载出发类型的数据
- hide_mask_type();
- // 得到蒙板层
- var mask = document.getElementById("mask");
- // 出发类型
- var c_type = document.getElementById("c_type");
- // 得到出发类型按钮
- var type = document.getElementById("type");
- mask.style.display = 'block';
- c_type.style.display = 'block';
- type.style.color = "#00CC9C";
- }
- // 动态加载出发类型上的数据
- function load_type_data(){
- // 全部
- var c_header_all = document.getElementById("c_header_all");
- var c_header_allHTML ='';
- c_header_allHTML +='<span class="type_title z">全部</span>';
- c_header_allHTML+='<span class="type_count y">'+temp_httpData.total_count+'条</span>';
- //
- c_header_all.innerHTML=c_header_allHTML;
- // 单程票
- var c_header_all_single = document.getElementById("c_header_all_single");
- var singleHTML = '';
- singleHTML +='<span class="type_title z">单程票</span>';
- singleHTML +='<span class="type_count y">'+temp_httpData.single_count+'条</span>';
- //
- c_header_all_single.innerHTML = singleHTML;
- // 往返票
- var c_header_all_goback = document.getElementById("c_header_all_goback");
- var gobackHTML = '';
- gobackHTML +='<span class="type_title z">往返票</span>';
- gobackHTML +='<span class="type_count y">'+temp_httpData.goback_count+'条</span>';
- //
- c_header_all_goback.innerHTML = gobackHTML;
- // 往返票+景点
- var c_header_all_gobacksight = document.getElementById("c_header_all_gobacksight");
- var gobacksightHTML = '';
- gobacksightHTML +='<span class="type_title z">往返票+景点</span>';
- gobacksightHTML +='<span class="type_count y">'+temp_httpData.gobacksight_count+'条</span>';
- //
- c_header_all_gobacksight.innerHTML = gobackHTML;
- // 单程票+景点
- var c_header_all_singlehotel = document.getElementById("c_header_all_singlehotel");
- var singlehotelHTML = '';
- singlehotelHTML +='<span class="type_title z">单程票+景点</span>';
- singlehotelHTML +='<span class="type_count y">'+temp_httpData.singlehotel_count+'条</span>';
- c_header_all_singlehotel.innerHTML = singlehotelHTML;
- }
- // 选中出发类型上的类型
- function c_get_type(type){
-
- hide_mask_type();
- }
- // 隐藏蒙板和出发、目的地层
- function hide_mask_type(){
- // 蒙板
- var mask = document.getElementById("mask");
- // 出发类型层
- var c_type = document.getElementById("c_type");
- mask.style.display = 'none';
- c_type.style.display = 'none';
- // 目的地层
- var m_mudidi = document.getElementById("m_mudidi");
- m_mudidi.style.display = 'none';
-
- // 目的地按钮
- var toaddess = document.getElementById("toaddess");
- toaddess.style.color='black';
- // 出发类型按钮
- var type = document.getElementById("type");
- type.style.color='black';
- }
- /*======================网络请求的Ajax的代码=======================*/
-
- // 创建一个Ajax对象
- if (window.ActiveXObject){
- var myreq = new ActiveXObject("Microsoft.XMLHTTP");
- }else{
- var myreq = new XMLHttpRequest();
- }
-
- // 请求方法,传入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://wx.zhizhuchuxing.com/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);
- //
- reload_cell(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;
-
- }
|