//var val =null; $(document).ready(function(){ var ticket1 = $(".adult").html(); var ticket2 = $(".noble").html(); // var hour = $(".hour").html(), // minute = $(".minute").html(), // place = $(".place").html(), // entry = $(".entry").html(), // mouth = $(".mouth").html(); //console.log(hour) //$(".replace-lineinfo").hide() $('.add-line').on('keyup',function(ev){ var val = this.value; if(/[a-zA-Z]+/.test(val)){ //console.log(1) $.getJSON("json/"+val+".html?rand="+Math.random(),function(data){ //console.log(2); //console.log(data); var html = []; $.each(data,function(i,v){ html.push('
  • '+v.name+'
  • ') }); //console.log(this) $(".line-item").html(html.join("")); $(".line-item>li").on("click",function(){ var val = $(this).html().replace(/[^a-zA-Z]+/,''); $('.add-line').val($(this).html()).attr("dataid",$(this).attr("dataid")); $(".line-item").html(""); $.getJSON('json/'+val+'.html?rand='+Math.random(),function(data){ var linehtml = []; //console.log(1); //console.log(lineInfoFormat); var tickethtml = []; $.each(data,function(i,v){ // console.log(v.lineId); if(typeof v.lineId=="undefined"){ var td1= addTd(addTime(v.time)); var td2= addTd(v.site); if(i==0){var td3= addTd('')} else{var td3=addTd(addUpdownType(v.type))}; var td4 = addTd(addMouth(v.maxcheck,v.check)); linehtml.push(addItem("tr","aline",td1.concat(td2,td3,td4))) }else{ var line = v.line.split("-"), ticket11= ticket1.replace("出发地",line[0]).replace("目的地",line[1]), ticket22 = ticket2, arr = [], ticket=null, judge=false; $.each(v,function(key,value){ if(key=="child"){ var child=["child","","儿童"]; Array.prototype.push.apply(child,value.split(",")); arr.push(child); }; if(key=="noble"){ var noble=["noble","贵宾","成人"]; Array.prototype.push.apply(noble,value.split(",")); arr.push(noble); }; if(key=="adult"){ var adult=["adult","普通","成人"]; Array.prototype.push.apply(adult,value.split(",")); arr.push(adult); }; }); //var myticket1 = ticket1.replace("出发地",line[0]).replace("目的地",line[1]); for(var i = 0;i23){addvalue-=24}{ $(".hour").eq(t).find("option").removeAttr("selected");$(".hour").eq(t).find("option").eq(addvalue).attr("selected","true") hourinfo[t][1]=addvalue; } } } } } hourinfo[index][1]=dangvalue; }) $(".minute").on("change",function(){ var index = $(this).parent().parent().index(); var max = $(".minute").length; var dangvalue = parseInt($(this).val()); for(var i = 0;i=60){addvalue-=60; var addhour = parseInt(hourinfo[t][1])+1;} if(typeof addhour=="undefined"){ $(".minute").eq(t).find("option").removeAttr("selected");$(".minute").eq(t).find("option").eq(addvalue).attr("selected","true") minuteinfo[t][1]=addvalue; }else{ $(".minute").eq(t).find("option").removeAttr("selected");$(".minute").eq(t).find("option").eq(addvalue).attr("selected","true") minuteinfo[t][1]=addvalue; $(".hour").eq(t).find("option").removeAttr("selected");$(".hour").eq(t).find("option").eq(addhour).attr("selected","true"); hourinfo[t][1]=addhour; } } } } } minuteinfo[index][1]=dangvalue; }) }) }) }) } }); $(".add-cartype").on("click",function(){ $.getJSON("json/cartype.html?rand="+Math.random(),function(data){ var car = []; $.each(data,function(i,v){ car.push(''); }); car = addItem('select','car-item',car.join("")); var carnumoption = []; for(var i = 1;i<=data[0].count;i++){ carnumoption.push('') } var carnum = addItem('select','car-num',carnumoption.join("")); var ifseat = []; if(data[0].ifSeat==0){ ifseat.push(''); }else if(data[0].ifSeat==1){ ifseat.push(''); }else if(data[0].ifSeat==2){ ifseat.push(''); } ifseat=addItem("select","ifseat",ifseat.join("")) var del = addItem('span','del','删除') var all = car.concat(carnum,ifseat,del); var div = addItem('div','car-select',all); $(".car-type").append(div); $(".del").on("click",function(){ $(this).parent().remove(); }) $(".car-item").on("change",function(){ var count = null; var ifseat = null; var val = this.value; $.each(data,function(i,v){ if(val==v.id){ count=v.count; ifseat=v.ifSeat } }); var selnum = []; for(var i = 1;i<=count;i++){ selnum.push('') } $(this).parent().find(".car-num").html(selnum.join("")).removeAttr("disabled"); if(ifseat==0){ $(this).parent().find(".if-seat").html('').removeAttr("disabled"); } else if(ifseat==1){ $(this).parent().find(".if-seat").html('').removeAttr("disabled"); } else if(ifseat==1){ $(this).parent().find(".if-seat").html('').removeAttr("disabled"); } }) }) }) $('.date-picker').datepicker({autoclose:true}).next().on('click', function(){ $(this).prev().focus(); }); $('.allweek').on('change',function(){ if($(this).is(":checked")){ for(var i=0;i<$(".week").length;i++){ $(".week").eq(i).click() } }else{ for(var i=0;i<$(".week").length;i++){ $(".week").eq(i).removeAttr("checked"); } } }) $(".storage").on("click",function(){ var lineid = 'lineid='+$(".add-line").attr('dataid'); var time = 'time='+$("#id-date-picker-1").val()+'-'+$("#id-date-picker-2").val(); var pass = []; (function(){ var line =[]; for(var i = 0;i<$(".aline").length;i++){ var aline = []; aline.push("time="+$(".aline").eq(i).find(".hour").val()+":"+$(".aline").eq(i).find(".minute").val()); aline.push("site="+$(".aline").find("td").eq(1).html()); aline.push("updown="+$(".aline").find(".updown").val()); aline.push("mouth="+$(".aline").find(".mouth").val()); line.push(aline.join("")); } })() url = 'lineid='+$(".add-line").attr('dataid')+'time='+$("#id-date-picker-1").val()+'-'+$("#id-date-picker-2").val() }) }) function addItem(label,classname,cent){ var html = ['<'+label+' class='+classname+'>']; html.push(cent); html.push(''); return html.join("") } function addLi(html){ var li = ['
  • ']; li.push(html); li.push('
  • '); li = li.join(""); return li } function addTime(time){ var time = time.split(":"); var newHour = parseInt(time[0]), newMinute = parseInt(time[1]); var html = [':'); html = html.join("") return html } function addUpdownType(type){ var html = [''); html = html.join("") return html } function addMouth(maxNum,num){ var html = ['"); html = html.join("") return html; } function addTd(html){ var td = ['']; td.push(html); td.push(''); td = td.join("") return td; } function addTr(html){ var tr = ['']; tr.push(html) tr.push(''); tr = tr.join("") return tr; }