|
-
-
- //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('<span>只有在发车前一天的18:30之前才可以修改订单车次</span>');
- 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 = '<option value="-1" selected="selected" style="font-size: 12px;">请选择</option>';
- for (var i = 0, m = start_station.length; i < m; i++) {
- var dict = start_station[i];
- var tempHTML = '<option value="0" style="font-size: 12px;">请选择</option>';
- 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 = '<option value="-1" selected="selected" style="font-size: 12px;">请选择</option>';
- for (var i = 0, m = end_station.length; i < m; i++) {
- var dict = end_station[i];
- var tempHTML = '<option value="0" style="font-size: 12px;">请选择</option>';
- 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<m;i++) {
- var dict=order_list[i];
- var tempHTML=table_order_html_str;
- tempHTML=tempHTML.replace('[ace_order_id]',dict['parent_order_id']);
- tempHTML=tempHTML.replace('[people-count]',dict['passenger_num']);
- tempHTML=tempHTML.replace('[data-id]',i);
- tempHTML=tempHTML.replace('[order_id]',dict['parent_order_id']);
- tempHTML=tempHTML.replace('[订单编号]',dict['parent_order_id']);
- tempHTML=tempHTML.replace('[订单来源]',dict['org_name']);
- tempHTML=tempHTML.replace('[下单时间]',dict['create_time']);
- tempHTML=tempHTML.replace('[渠道订单号]',dict['outside_order_no']);
- // tempHTML=tempHTML.replace('[line]',dict['line']);
- tempHTML=tempHTML.replace('[line]',dict['parent_prod_name']);
- tempHTML=tempHTML.replace('[预订产品]',"("+dict['start_station']+")-("+dict['end_station']+")");
- tempHTML=tempHTML.replace('<div>[普通成人票]</div>',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<m;i++) {
- var dict=carList[i];
- var tempHTML='<span class="un_select" data-car-no="[car_no]" onclick="select_car_no(this)">[文本]</span>';
- tempHTML=tempHTML.replace('[car_no]',dict['bus_order_id']);
- var str_text="车号"+dict['bus_order_id']+" "+dict['seat_count']+" 库存"+dict['stock'];
- tempHTML=tempHTML.replace('[文本]',str_text);
- sumHTML+=tempHTML;
- }
- if(sumHTML){
- $('#car_no_list').html(sumHTML);
- }else{
- $('#car_no_list').html('');
- }
- })
-
- }
- function update_f(btn_type){
- //先拿到order_id
- var arr_order_ids = new Array();
- $('.ace').each(function(index, item) {
- if (this.checked && index != 0) {
- arr_order_ids.push($(this).attr('data-order-id'));
- }
- });
- if (arr_order_ids.length <= 0) {
- alert('请勾选!!!');
- return;
- }
- var order_id_str=arr_order_ids.join(',');
- if(btn_type=="reset"){ //重置
- var run_id=getPar('run_id');
- var url=base_url+"/st-xm/Api/update_car_no.php?method=reset&run_id="+run_id+"&order_ids="+order_id_str;
- ZZlog(url);
- $.getJSON(url,function(res_data){
- ZZlog(res_data);
- if(res_data['code']!="0"){alert(res_data['info']);return;}
- alert('重置成功!!!');
- location.reload();
- })
- }else if(btn_type=="update"){ //修改弹出弹框
- if(temp_car_no_obj!=null){
- $(temp_car_no_obj).removeClass('select');
- $(temp_car_no_obj).addClass('un_select' );
- }
- center_show($('.choose_car_no'));
- }else{
- ZZlog('非重置,非修改');
- }
- }
- var cur_car_no=-1; //当前选中的车号
- function click_btn_save(){
- $('.choose_info').text('');
- if(cur_car_no==-1){
- $('.choose_info').text('请选择车号!!!');
- }else{
- $('.choose_info').text('');
- hide_all();
- }
- var run_id=getPar('run_id');
-
- //先拿到order_id
- var arr_order_ids = new Array();
- $('.ace').each(function(index, item) {
- if (this.checked && index != 0) {
- arr_order_ids.push($(this).attr('data-order-id'));
- }
- });
- if (arr_order_ids.length <= 0) {
- alert('请勾选!!!');
- return;
- }
- var order_ids_str=arr_order_ids.join(',');
-
- ZZlog('车号:'+cur_car_no);
- ZZlog('run_id:'+run_id);
- ZZlog('order_ids='+order_ids_str);
- var url=base_url+"/st-xm/Api/update_car_no.php?method=updateCar&run_id="+run_id+"&order_ids="+order_ids_str+"&bus_order_id="+cur_car_no;
- ZZlog(url);
- $.getJSON(url,function(res_data){
- ZZlog(res_data);
- if(res_data['code']!="0"){alert(res_data['info']);return;}
- alert('修改成功!!!');
- location.reload();
- })
-
-
-
- }
- var peop_count=0;
- function select_checked(index,self_obj) {
- if(index=='0'){
- peop_count=0;
- }else{
- var _temp_=parseInt($(self_obj).attr('data-people-count'));
- if(self_obj.checked){
- peop_count+=_temp_;
- }else{
- peop_count-=_temp_;
- }
- }
- //index=0最上面的全选 index=1表示的是下面所有的
- var cur_check = $('.ace')[0];
- var checkList = $('.ace');
- var checkCount = checkList.length - 1;
- var true_count = 0;
-
- for (var i = 1; i < checkList.length; i++) {
- if (index == '0') {
- checkList[i].checked = cur_check.checked;
- if(cur_check.checked){
- var __temp_=parseInt($(checkList[i]).attr('data-people-count'));
- peop_count+=__temp_;
- }
-
- } else {
- if (checkList[i].checked == false) {
- cur_check.checked = false
- } else {
- true_count = true_count + 1;
- }
- }
- }
- $('#people_count').html('已选择'+peop_count+'人');
- $('#car_info').html('已选择'+peop_count+'人');
- //判断下面是否选中完
- if (checkCount == true_count) {
- cur_check.checked = true;
- }
- temp_index=index;
- }
- //居中显示
- var tempDiv = null;
-
- function center_show(show_div) {
- tempDiv = show_div;
- //显示蒙板
- show_div.css('display', 'block');
- show_div.css('z-index', 30);
- show_div.css('background-color', 'white');
- show_div.css('position', 'fixed');
-
- var w = show_div.css('width');
- var h = show_div.css('height');
- w = w.substr(0, w.length - 2);
- h = h.substr(0, h.length - 2);
-
- // var s_left=(window.screen.availWidth-w)/2 +"px";
- // var s_top=(window.screen.availHeight-h)/2 +'px';
- var s_left = (window.innerWidth - w) / 2 + 'px';
- var s_top = (window.innerHeight - h) / 2 + 'px';
- show_div.css('left', s_left);
- show_div.css('top', s_top);
- $('.mask').css('display', 'block');
-
- }
- //点击蒙板
- function hide_all() {
- $('.mask').css('display', 'none');
- tempDiv.css('display', 'none');
- }
- //点击了关闭
- function click_cancel(father_name, self_name) {
- if (father_name) {
- var father = $(father_name);
- center_show(father);
- } else {
- $('.mask').css('display', 'none');
- }
- $(self_name).css('display', 'none');
- }
-
- var temp_car_no_obj=null;
- function select_car_no(self_obj){
- $('.choose_info').text('');
- if(temp_car_no_obj!=self_obj){
- $(temp_car_no_obj).removeClass('select');
- $(temp_car_no_obj).addClass('un_select' );
- temp_car_no_obj=self_obj;
- }
- $(self_obj).addClass('select');
- $(self_obj).removeClass('un_select' );
- cur_car_no=$(self_obj).attr('data-car-no');
- }
- // 根据订单状态值得到str
- function get_status_by_no(num) {
- switch(num) {
- case "145":
- return "待支付";
- break;
- case "146":
- return "已出票";
- break;
- case "147":
- return "已完成";
- break;
- case "148":
- return "已取消";
- break;
- default:
-
- break;
- }
- }
-
- 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 "";
- }
- //截取字符串
- 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;
- case 8: //得到上一个月的今天
- 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 == 0) {
- year2 = parseInt(year2) - 1;
- month2 = 12;
- }
- var day2 = day;
- var days2 = new Date(year2, month2, 0);
- days2 = days2.getDate();
- if(day2 > 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;
- }
|