//var base_url="http://cs.zhizhuchuxing.com:8080";
//var base_url="http://temp.zhizhuchuxing.com";
var base_url="";
var table_order_html_str='';
// 打印日志
var is_log=true; //是否打印日志
function ZZlog(value){
if(is_log==true){
console.log(value);
}
}
window.onload=function(){
table_order_html_str=$('#tableOrder').html();
var line=getPar('line');
var start_date=getPar('start_date');
var run_id=getPar('run_id');
if(start_date==""){start_date=getDateTime(0);}
$('#line').text(line);
$('#start_date').text(start_date);
var station_url=base_url+"/st-xm/Api/update_car_no.php?method=getStations&run_id="+run_id;
get_station(station_url);
var car_list_url=base_url+"/st-xm/Api/update_car_no.php?method=getCarList&run_id="+run_id;
car_no_list(car_list_url);
}
function get_station(url) {
ZZlog(url);
$.getJSON(url, function (res_data) {
ZZlog(res_data);
//这里加一个对该班次时间的判断,只有在发车前一天的18:30之前才可以修改订单车次
/*
if (res_data['code'] == "666") {
//alert(res_data['info']);
$('.btn').hide();
$('#rep').html('只有在发车前一天的18:30之前才可以修改订单车次');
return;
}
*/
if (res_data['code'] != "0") {
alert(res_data['info']);
return;
}
var start_station = res_data['start_station'];
var end_station = res_data['end_station'];
var start_sumHTML = '';
for (var i = 0, m = start_station.length; i < m; i++) {
var dict = start_station[i];
var tempHTML = '';
tempHTML = tempHTML.replace('0', dict['start_station_id']);
tempHTML = tempHTML.replace('请选择', dict['start_station']);
start_sumHTML += tempHTML;
}
if (start_sumHTML) {
$('#startArea').html(start_sumHTML);
}
var end_sumHTML = '';
for (var i = 0, m = end_station.length; i < m; i++) {
var dict = end_station[i];
var tempHTML = '';
tempHTML = tempHTML.replace('0', dict['end_station_id']);
tempHTML = tempHTML.replace('请选择', dict['end_station']);
end_sumHTML += tempHTML;
}
if (start_sumHTML) {
$('#endArea').html(end_sumHTML);
btn_select();
}
});
}
// 点击查询
function btn_select(){
var run_id=getPar('run_id');
var start_station_id=$('#startArea').val();
var end_station_id=$('#endArea').val();
if(run_id==""){
alert('缺少run_id!!!');return;
}
//默认传<=0的值
// if(start_station_id==""){
// alert('请选择出发站!!!');return;
// }
// if(end_station_id==""){
// alert('请选择目的地站!!!');return;
// }
// var url="http://temp.zhizhuchuxing.com/st-xm/Api/order_list.php?tt=20160803131257&timelimit=%E4%B8%8B%E5%8D%95%E6%97%B6%E9%97%B4&starttime=&endtime=&ordersource=-1&orderstatus=0&paystatus=-1&billingstatus=&mealbounce=&refund=&moresearch=&start_area=&end_area=&line=&currpage=4&pagesize=30";
var url=base_url+"/st-xm/Api/update_car_no.php?method=getOrderList&run_id="+run_id+"&start_station_id="+start_station_id+"&end_station_id="+end_station_id;
get_order_list(url);
}
function get_order_list(url){
ZZlog(url);
$('#tableOrder').html('');
$.getJSON(url,function(res_data){
ZZlog(res_data);
if(res_data['code']!="0"){alert(res_data['info']);return;}
var order_list=res_data['orderList'];
var sumHTML='';
for (var i=0,m=order_list.length;i[普通成人票]',dict['prod_name'] + '×' + dict['passenger_num'] );
tempHTML=tempHTML.replace('[出发时间]',dict['travel_time']);
tempHTML=tempHTML.replace('[name]',dict['customer_name']);
tempHTML=tempHTML.replace('[phone]',dict['customer_mobile']);
tempHTML=tempHTML.replace('[车号]',dict['run_bus_order_id']);
var state=dict['order_status'];
tempHTML=tempHTML.replace('[状态]',get_status_by_no(state));
sumHTML+=tempHTML;
}
if(tempHTML){
$('#tableOrder').html(sumHTML);
var currpage = getPar("currpage");
if(currpage) {} else {
currpage = 1;
}
$('#page').html('');
var sum = res_data['totalTickets'];
var tag = "page";
// getPager(myURL2, sum, currpage, pagesize, tag, 'currpage');
// document.getElementById("sum").innerHTML = "共"+sum+"条数据";
}else{
$('#tableOrder').html('');
$('#page').html('');
// document.getElementById("sum").innerHTML = "共0条数据";
}
})
}
//得到车座-库存
function car_no_list(url){
ZZlog(url);
$.getJSON(url,function(res_data){
ZZlog(res_data);
if(res_data['code']!="0"){alert(res_data['info']);return;}
var carList=res_data['carList'];
var sumHTML='';
for (var i=0,m=carList.length;i days2) {
day2 = days2;
}
if(month2 < 10) {
month2 = '0' + month2;
}
cNewTimeStr = year2 + '-' + month2 + '-' + day2;
break;
case 9: //得到下一个月的今天
var date = getDateTime(0);
var arr = date.split('-');
var year = arr[0]; //获取当前日期的年份
var month = arr[1]; //获取当前日期的月份
var day = arr[2]; //获取当前日期的日
var days = new Date(year, month, 0);
days = days.getDate(); //获取当前日期中的月的天数
var year2 = year;
var month2 = parseInt(month) + 1;
if(month2 == 13) {
year2 = parseInt(year2) + 1;
month2 = 1;
}
var day2 = day;
var days2 = new Date(year2, month2, 0);
days2 = days2.getDate();
if(day2 > days2) {
day2 = days2;
}
if(month2 < 10) {
month2 = '0' + month2;
}
var t2 = year2 + '-' + month2 + '-' + day2;
return t2;
break;
case 10: //昨日日期
var dateStr=getDateTime(0);
var t_temp_sdate = dateStr.split('-');
var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]);
now.setDate(now.getDate() - 0 - 1);
var year = ";" + now.getFullYear() + ";";
var month = ";" + now.getMonth() + ";";
var day = ";" + now.getDate() + ";";
if(year.length < 4) {
year = "0" + year;
}
if(month.length < 4) {
month = "0" + month;
}
if(day.length < 4) {
day = "0" + day;
}
var datestr = year + "-" + month + "-" + day;
datestr = datestr.replace(/;/g, "");
return datestr;
break;
case 11: //明日日期
var dateStr=getDateTime(0);
var t_temp_sdate = dateStr.split('-');
var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]);
now.setDate(now.getDate() - 0 + 1);
var year = ";" + now.getFullYear() + ";";
var month = ";" + now.getMonth() + ";";
var day = ";" + now.getDate() + ";";
if(year.length < 4) {
year = "0" + year;
}
if(month.length < 4) {
month = "0" + month;
}
if(day.length < 4) {
day = "0" + day;
}
var datestr = year + "-" + month + "-" + day;
datestr = datestr.replace(/;/g, "");
return datestr;
break;
default:
cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
break;
}
cNewTimeStr = cNewTimeStr.replace(/;/g, "");
return cNewTimeStr;
}
//设置字符串类型的本地缓存
function setStorage(objName, objValue) {
var sto = window.localStorage;
if(sto)
sto.setItem(objName, objValue);
}
//读取字符串类型的本地缓存
function getStorage(objName) {
var ret = '';
var sto = window.localStorage;
if(sto)
ret = sto.getItem(objName);
return ret;
}
//清除本地缓存,如没指定名称则为清空所有缓存
function clearStorage(objName) {
var sto = window.localStorage;
if(sto) {
if(objName)
sto.removeItem(objName);
else
sto.clear();
}
}
//设置Json类型的本地缓存
function setStorJson(objName, json) {
if(json)
setStorage(objName, JSON.stringify(json));
}
//读取Json类型的本地缓存
function getStorJson(objName) {
var ret = null;
var str = getStorage(objName);
if(str)
ret = JSON.parse(str);
return ret;
}