|
- /*======================网络请求的Ajax的代码=======================*/
- var carTicketInfo = null;
- var ticket_info_str='';
- // 创建一个Ajax对象
- if (window.ActiveXObject) {
- var myreq = new ActiveXObject("Microsoft.XMLHTTP");
- } else {
- var myreq = new XMLHttpRequest();
- }
- //======================基本信息结束
- window.onload = function() {
- var run_id = getPar('run_id');
- if (run_id) {} else {
- run_id = '1';
- }
- ticket_info_str=$("#ticketList").html();
- // get_virtual_user_list('http://192.168.6.245:8080/st-xm/Api/runInfoControll.php?method=getRunInfo&run_id=' + run_id);
- get_virtual_user_list('./st-xm/Api/runInfoControll.php?method=getRunInfo&user_id=1&run_id=' + run_id);
-
- }
- // 请求方法,传入URL
-
- function get_virtual_user_list(myURL) {
- var tnowtime = getDateTime(4);
- if (myURL.indexOf('?') >= 0) {
- myURL += '&tt=' + tnowtime;
- } else {
- myURL += '?tt=' + tnowtime;
- }
- $.getJSON(myURL, function(httpData) {
- // newstr 就是接收到的数据
- //
- if (httpData['code'] != '0') {
- alert(httpData['info']);
- return;
- }
- //基本信息
- $("#startarea").text(httpData['property'] + ' (' + httpData['prod_name'] + ')');
- $("#starttime").text(httpData['run_date'] + ' ' + httpData['run_time']);
- //途径站点
- if(httpData['station_list']){
- waytosite(httpData['station_list']);
- }else{
- $('#tujingstation').css('display','none');
- }
-
- //班次状态
- $('#bancistatus').text((function(data) {
- return data == "137" ? "待审核" : data == "138" ? "待调派" : data == "139" ? "已调派" : data == "140" ? "已发车" : data == "141" ? "已完成" : data == "142" ? "已停用" : "其他"
- })(httpData['run_status']));
-
- //收客状态
- // $('#shoukestatus').text(httpData['receiving']);
- //承运信息
- if(httpData['bus_info']){
- chenyunInfo(httpData['bus_info']);
- }else{
- $('#chenyun').css('display','none');
- }
-
- //可售票种
- if(httpData['ticket_type']){
- keshouTicket(httpData['ticket_type']);
- }else{
- $('#keshouTicket').css('display','none');
- }
- $('.control-show').css('display','block');
- //预售天数
- // $('#yushoudays').text(httpData['pre_sale_day'] + '天');
- //车票信息
- if(httpData['order_ticket_info_list']){
- carTicketInfo = httpData['order_ticket_info_list'];
- }
- // }
- });
-
- // $.ajax({
- // url:myURL,
- // success:function(data){
- // var httpData = JSON.parse(data);
- // console.log(httpData);
- // // newstr 就是接收到的数据
- // var newstr = myreq.responseText;
- // console.log(eval("("+newstr+")"))
- // var httpData = JSON.parse(newstr);
- // //
- // if (httpData['code'] != '0') {
- // alert(httpData['info']);
- // return;
- // }
- // //基本信息
- // $("#startarea").text(httpData['property'] + ' (' + httpData['prod_name'] + ')');
- // $("#starttime").text(httpData['run_date'] + ' ' + httpData['run_time']);
- // //途径站点
- // waytosite(httpData['station_list']);
- // //班次状态
- // $('#bancistatus').text(httpData['run_status']);
- // //收客状态
- // $('#shoukestatus').text(httpData['receiving']);
- // //承运信息
- // chenyunInfo(httpData['bus_info']);
-
- // //可售票种
- // keshouTicket(httpData['ticket_type']);
-
- // //预售天数
- // $('#yushoudays').text(httpData['pre_sale_day'] + '天');
- // //车票信息
- // var carTicketInfo = httpData['order_ticket_info_list'];
- // var newHTML = ''
- // for (var i = 0; i < carTicketInfo.length; i++) {
- // var tempDict = carTicketInfo[i];
- // var tempHTML = $("#ticketList").html();
- // tempHTML = tempHTML.replace('[出发地]', tempDict['start_area']);
- // tempHTML = tempHTML.replace('[目的地]', tempDict['end_area']);
- // tempHTML = tempHTML.replace('[上]', tempDict['start_station']);
- // tempHTML = tempHTML.replace('[下]', tempDict['end_station']);
- // tempHTML = tempHTML.replace('[出行时间]', tempDict['start_time'] + ' - ' + tempDict['end_time']);
- // tempHTML = tempHTML.replace('[车号]', tempDict['bus_order_id']);
- // tempHTML = tempHTML.replace('[座位]', tempDict['seat_type']);
- // tempHTML = tempHTML.replace('[人群]', tempDict['crowd']);
- // tempHTML = tempHTML.replace('[座号]', tempDict['seat_name']);
- // tempHTML = tempHTML.replace('[售价]', tempDict['order_price']);
- // tempHTML = tempHTML.replace('[出票]', tempDict['if_ticket']);
- // tempHTML = tempHTML.replace('[打印]', tempDict['if_print']);
- // tempHTML = tempHTML.replace('[操作]', '<a target="_Blank" href="detailTicket.html?order_id='+tempDict['order_id']+'">查看</a>');
- // newHTML += tempHTML;
- // }
- // //车票信息下面
- // var carTicketInfo_Down = httpData['not_in_order_ticket_info_list'];
- // for (var i = 0; i < carTicketInfo_Down.length; i++) {
- // var tempDict = carTicketInfo_Down[i];
- // var tempHTML = $("#ticketList").html();
- // tempHTML = tempHTML.replace('[出发地]', tempDict['start_area']);
- // tempHTML = tempHTML.replace('[目的地]', tempDict['end_area']);
- // tempHTML = tempHTML.replace('[上]', '');
- // tempHTML = tempHTML.replace('[下]', '');
- // tempHTML = tempHTML.replace('[出行时间]', '');
- // tempHTML = tempHTML.replace('[车号]', '');
- // tempHTML = tempHTML.replace('[座位]', tempDict['seat']);
- // tempHTML = tempHTML.replace('[人群]', tempDict['crowd']);
- // tempHTML = tempHTML.replace('[座号]', '-');
- // tempHTML = tempHTML.replace('[售价]', '-');
- // tempHTML = tempHTML.replace('[出票]', tempDict['sale']);
- // tempHTML = tempHTML.replace('[打印]', '');
- // tempHTML = tempHTML.replace('[操作]', '');
- // newHTML += tempHTML;
- // }
- // $("#ticketList").html(newHTML);
- // $('.control-show').css('display','block');
-
- // }
- // })
-
- }
-
- //途径站点
- function waytosite(waytosite) {
- var tujingHTML = ''
- for (var i = 0; i < waytosite.length; i++) {
- var tempDict = waytosite[i];
- var tempHTML = $("#tujingstation").html();
- tempHTML = tempHTML.replace('[时间]', tempDict['start_time']);
- tempHTML = tempHTML.replace('[站点]', tempDict['station_name']);
- tempHTML = tempHTML.replace('[上下类型]', tempDict['type_name']);
- tempHTML = tempHTML.replace('[检票口]', function() {
- return !tempDict['res_name'] ? "-" : tempDict['res_name']
- });
- //tempDict['res_name']
- tujingHTML += tempHTML;
- }
- $("#tujingstation").html(tujingHTML);
-
- }
- //承运信息
- function chenyunInfo(chenyunInfo) {
- var chenHTML = '';
- var cyHTML = $('#chenyun').html();
- for (var i = 0; i < chenyunInfo.length; i++) {
- var tempDict = chenyunInfo[i];
- var tempHTML=cyHTML;
- var carNo = tempDict['bus_order_id'];
- carNo=(Array(2).join(0)+carNo).slice(-2);
- tempHTML = tempHTML.replace('[车次]', carNo);
- tempHTML = tempHTML.replace('[品牌]', tempDict['bus_brand']);
- tempHTML = tempHTML.replace('[座位]', tempDict['property']);
- tempHTML = tempHTML.replace('[选座支持]', tempDict['allow_select_seat']);
- tempHTML = tempHTML.replace('[车辆]', tempDict['send_bus_res_id']);
- tempHTML = tempHTML.replace('[司机]', tempDict['send_bus_driver_res_id']);
- chenHTML += tempHTML;
- }
- $("#chenyun").html(chenHTML);
- }
- //可售票种
- function keshouTicket(keshouTicket) {
- var keshouHTML = '';
- for (var i = 0; i < keshouTicket.length; i++) {
- var tempDict = keshouTicket[i];
- var tempHTML = $('#keshouTicket').html();
-
- tempHTML = tempHTML.replace('[出发地]', tempDict['start_area']);
- tempHTML = tempHTML.replace('[目的地]', tempDict['end_area']);
- tempHTML = tempHTML.replace('[座位]', tempDict['seat']);
- // tempHTML = tempHTML.replace('[人群]', tempDict['croed']);
- tempHTML = tempHTML.replace('[零售价]', tempDict['price']);
- if (tempDict['max_count']=="0") {
- tempDict['max_count']="Freesale";
- };
- tempHTML = tempHTML.replace('[最大可售]', tempDict['max_count']);
- // tempHTML = tempHTML.replace('[已售]', tempDict['sale_count']);
- keshouHTML += tempHTML;
- }
- $('#keshouTicket').html(keshouHTML);
- }
-
- function type_choose(typeName) {
- var basic = $("#carBasicInfo");
- var carInfo = $("#carTicketInfo");
- var li_basic = $("#li_basic a");
- var li_carInfo = $("#li_carInfo a");
- if (typeName == "基本信息") {
- basic.css("display", "block");
- carInfo.css("display", "none");
- li_carInfo.css("background", "#f9f9f9");
- li_basic.css("background", "#DDDDDD");
- } else {
- basic.css("display", "none");
- carInfo.css("display", "block");
- li_carInfo.css("background", "#DDDDDD");
- li_basic.css("background", "#f9f9f9");
- if(carTicketInfo.length<=0){
- $("#ticketList").html('');
- alert('目前已售车票数量为0');
-
- return;
- }
- $("#ticketList").html('');
- var newHTML = ''
- for (var i = 0; i < carTicketInfo.length; i++) {
- var tempDict = carTicketInfo[i];
- var tempHTML = ticket_info_str;
- var carNo = tempDict['bus_order_id'];
- carNo=(Array(2).join(0)+carNo).slice(-2);
- tempHTML = tempHTML.replace('[出发地]', tempDict['start_area']);
- tempHTML = tempHTML.replace('[目的地]', tempDict['end_area']);
- tempHTML = tempHTML.replace('[上]', tempDict['start_station']);
- tempHTML = tempHTML.replace('[下]', tempDict['end_station']);
- tempHTML = tempHTML.replace('[出行时间]', tempDict['start_time'] + ' - ' + tempDict['end_time']);
- tempHTML = tempHTML.replace('[车次]', carNo);
- tempHTML = tempHTML.replace('[座位]', tempDict['seat_type']);
- // tempHTML = tempHTML.replace('[人群]', tempDict['crowd']);
- tempHTML = tempHTML.replace('[座号]', tempDict['seat_name']);
- tempHTML = tempHTML.replace('[售价]', tempDict['order_price']);
- tempHTML = tempHTML.replace('[出票]', tempDict['if_ticket']);
- tempHTML = tempHTML.replace('[打印]', tempDict['if_print']);
- tempHTML = tempHTML.replace('[操作]', '<a target="_Blank" onclick="open_new_path(this)" go_path="detailTicket.html?order_id=' + tempDict['order_id'] + '">查看</a>');
- newHTML += tempHTML;
- }
- $("#ticketList").html(newHTML);
-
- }
- }
-
- function getPar(par) {
- //获取当前URL
- var local_url = document.location.href;
- 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 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;
-
- }
|