$(document).ready(function(){
$(".fancybox").fancybox({
helpers : {
overlay : {
css : {'background':'rgba(000,000,000,0.3)'}
}
},
openEffect:'elastic',
openSpeed : 150,
closeEffect:'elastic',
transitionIn:'elastic',
transitionOut:'elastic'
});
// $(".fancybox").click(function(){
// })
if($(".timeinfo").hasClass("disney")){
$(".pay").on("click",function(){
var judge = false ;
$.each($(".aticket"),function(){
if($(this).val()>0){judge=true;}
});
var num = 0;
$.each($(".aticket"),function(){
num+=parseInt($(this).val());
});
if(judge!=true){
// $("#inline").html("请选择票种");
// $(".fancybox").click();
alert("请选择票种")
return
}else if(num>5){
// $("#inline").html("单次购买不能超过5张");
// $(".fancybox").click();
alert("单次购买不能超过5张")
return
}else if( $(".hide").length!=0 ){
// $("#inline").html("请选择日期");
// $(".fancybox").click();
alert("请选择日期");
return
}else if( $(".hidestation").length!=0 ){
// $("#inline").html("请选择日期");
// $(".fancybox").click();
alert("请选择上下站点");
return
}else if($(".name").val()==""){
// $("#inline").html("请填写姓名")
// $(".fancybox").click();
alert("请填写姓名")
return
}else if($(".phone").val()==""||$(".phone").val().length!=11){
// $("#inline").html("请填写正确的手机号码")
// $(".fancybox").click();
alert("请填写正确的手机号码")
return
}else if($(".idcard").val()==""){
// $("#inline").html("请填写身份证号码")
// $(".fancybox").click();
alert("请填写身份证号码")
return
}
document.pay_form.submit();
})
}else{
$(".pay").on("click",function(){
var judge = false ;
$.each($(".aticket"),function(){
if($(this).val()>0){judge=true;}
});
if(judge!=true){
// $("#inline").html("请选择票种");
// $(".fancybox").click();
alert("请选择票种")
return
}else if( $(".hide").length!=0 ){
// $("#inline").html("日期");
// $(".fancybox").click();
alert("请选择日期")
return
}else if( $(".hidestation").length!=0 ){
// $("#inline").html("请选择日期");
// $(".fancybox").click();
alert("请选择上下站点");
return
}else if($(".name").val()==""){
// $("#inline").html("请填写姓名")
// $(".fancybox").click();
alert("请填写姓名")
return
}else if($(".phone").val()==""||$(".phone").val().length!=11){
// $("#inline").html("请填写正确的手机号码")
// $(".fancybox").click();
alert("请填写正确的手机号码")
return
}else if($("idcard").val()==""){
// $("#inline").html("请填写身份证号码")
// $(".fancybox").click();
alert("请填写身份证号码")
return
}
document.pay_form.submit();
})
}
// $(".packagelist").on("touchstart",function(){
// var index = $(this).index();
// $(".packagelist").removeClass("on");
// $(this).addClass("on");
// $(".disneylistgrid").hide();
// $(".disneylistgrid").eq(index).fadeIn();
// })
var tomonth = new Date();
atimehtml = $(".atime").outerHTML();
$(".atime").remove();
atimehtml2 = $(".atime2").outerHTML();
$(".atime2").remove();
atimehtml3 = $(".atime3").outerHTML();
$(".atime3").remove();
atimehtml4 = $(".atime4").outerHTML();
$(".atime4").remove();
astationhtml = $(".astation").outerHTML();
$(".astation").remove();
console.log(atimehtml)
var timeinfo = $(".timeinfo").outerHTML();
//addmouth($(".month"),tomonth.getFullYear(),13);
$(".sel_goback").on("click",function(){
addmouth($(".month"),tomonth.getFullYear(),tomonth.getMonth());
$(".month").show();
$(".asell_list").hide();
disney()
});
$(".sel_station").on("click",function(){
$(".station").show();
$(".asell_list").hide();
});
$(".station").find("li").click(function(){
var astation = [];
$(this).siblings("li").removeClass("selects");
$(this).addClass("selects");
$.each($(".station").find(".selects"),function(){
astation.push($(this).html());
})
if(astation.length==2){
var html = astationhtml.replace(/star_station|end_station/g,function(match){
switch(match){
case "star_station":
return astation[0];
case "end_station":
return astation[1];
}
})
// $(".cartime li").removeClass("selects")
$(".sel_station").html(html);
$(".station").hide();
$(".asell_list").show();
}
})
$(".add").on("click",function(){
if($(".timeinfo").hasClass("disney")){
var num =0;
$.each($(".aticket"),function(){
num += parseInt($(this).val());
})
if(num==5){}else{
var num = $(this).siblings("input").val();
$(this).siblings("input").val(++num);
}
}else{
var num = parseInt($(this).siblings("input").val());
$(this).siblings("input").val(++num);
}
//var price = parseInt($(this).parent().siblings(".ticket_price").html().replace("¥",""))*num
var allprice = 0;
for(var i = 0 ;i<$(".aticket").length;i++){
var thisone = $(".aticket").eq(i).val();
var price = parseInt($(".aticket").eq(i).parent().siblings(".ticket_price").html().replace("¥",""))
var aprice = thisone*price;
allprice+=aprice
}
$(".buyprice").html("¥"+allprice)
})
$(".cut").on("click",function(){
var num = parseInt($(this).siblings("input").val());
if(num==0){
}else{
$(this).siblings("input").val(--num);
var allprice = 0;
for(var i = 0 ;i<$(".aticket").length;i++){
var thisone = $(".aticket").eq(i).val();
var price = parseInt($(".aticket").eq(i).parent().siblings(".ticket_price").html().replace("¥",""))
var aprice = thisone*price;
allprice+=aprice
}
$(".buyprice").html("¥"+allprice)
}
})
$(".aticket").on("change",function(){
$(".buyprice").html();
var price = parseInt($(this).parent().siblings(".ticket_price").html().replace("¥",""))*$(this).val();
})
var doubletime = [];
var atime = [];
});
function addmouth(dom,year,month){
//console.log(atimehtml)
!dom.hasClass("amonth")&&dom.addClass("amonth");
var date = new Date(year,month);
var tomonth = new Date().getMonth();
var today = new Date().getDate();
var tomorrow = today+1;
var todayhours = new Date().getHours();
// window.localStorage.setItem("carTodayhours",carTodayhours);
// window.localStorage.setItem("carTodayMin",carTodayMin);
var ticketType = window.localStorage.getItem("ticketType");
var dayhtml = [];
var week = ["一","二","三","四","五","六","日"];
dayhtml.push('
<'+date.getFullYear()+'年'+(date.getMonth()+1)+'月>
')
$.each(week,function(i,v){
dayhtml.push(''+week[i]+'
')
});
var firstweek = date.getDay();
console.log(date)
var first = date.getDate();
var allday = new Date(parseInt(year),(parseInt(month)+1),0).getDate();
//console.log(allday)
//console.log(parseInt(year)+","+(parseInt(month)+1))
// console.log(new Date(year,month+1,0))
for(var i = 0;i')
};
if (month==tomonth){
for(i=1;i<=allday;i++){
if(i==today){
if($(".timeinfo").hasClass("oneday")||$(".timeinfo").hasClass("twoday")){
dayhtml.push('今天
')
}else if($(".timeinfo").hasClass("oneway")){
if(todayhours<17){
dayhtml.push('今天
')
}else{
dayhtml.push('今天
')
}
}else if($(".timeinfo").hasClass("lion")||$(".timeinfo").hasClass("disney")){
alert(1)
if((type_id==16)||(type_id==18)){
if(todayhours<14){
alert(2)
dayhtml.push('今天
')
}else{
alert(3)
dayhtml.push('今天
')
}
}else{
if(todayhours>8&&todayhours<22){
dayhtml.push('今天
')
}else{
dayhtml.push('今天
')
}
}
}
}else if(i==tomorrow){
if($(".timeinfo").hasClass("oneday")||$(".timeinfo").hasClass("twoday")){
if(todayhours<22){
dayhtml.push(''+i+'
')
}else{
dayhtml.push(''+i+'
')
}
}else if($(".timeinfo").hasClass("oneway")){
dayhtml.push(''+i+'
')
}else if($(".timeinfo").hasClass("lion")||$(".timeinfo").hasClass("disney")){
if((type_id==16)||(type_id==18)){
dayhtml.push(''+i+'
')
}else{
if(todayhours>21){
dayhtml.push(''+i+'
')
}else{
dayhtml.push(''+i+'
')
}
}
}
}else if(i'+i+'')
}else{
dayhtml.push(''+i+'
')
}
}
}else if(month'+i+'')
}
}else{
for(i=1;i<=allday;i++){
dayhtml.push(''+i+'
')
}
}
dom.html(dayhtml.join(""))
$(".monthleft").unbind();
$(".monthright").unbind();
$(".monthleft").on("click",function(){
var currentdate = $(".currentdate").html();
currentdate = currentdate.split("年");
addmouth($(".month"),currentdate[0],(currentdate[1]-2));
$(".cartime").removeClass("sel")
$(".aweekday").hide();
disney()
//console.log(new Date(currentdate[0],(currentdate[1]-2)))
})
$(".monthright").on("click",function(){
var currentdate = $(".currentdate").html();
currentdate = currentdate.split("年");
//console.log(currentdate);
addmouth($(".month"),currentdate[0],(currentdate[1]));
$(".cartime li").removeClass("sel")
$(".aweekday").hide();
disney()
//console.log(new Date(currentdate[0],(currentdate[1])))
})
}
function disney(){
//$(".canday").unbind();
if($(".timeinfo").hasClass("disney")){
$(".canday").on("click",function(){
if($(this).html()=="今天"){
var seldate = new Date().getDate();
}else{
var seldate =$(this).html();
}
var yearmonth = $(".currentdate").html().split("年")
var thisdata = yearmonth[0]+"年"+addzero(yearmonth[1])+"月"+addzero(seldate)+"日";
var html = atimehtml4.replace(/mydata|star_time|time_val/g,function(match){
switch(match){
case "star_time":
return "star_time";
case "time_val":
return thisdata;
case "mydata":
return thisdata;
}
})
$(this).addClass("thisday");
$(".sel_goback").html(html);
$(".month").hide();
$(".asell_list").show();
})
}
else if($(".timeinfo").hasClass("oneday")){
$(".canday").on("click",function(){
$(".canday").removeClass("thisday");
$(this).addClass("thisday");
$(".timeinfo").find("li").removeClass("sel")
atime = [];
var thisdate = $(".currentdate").html().split("年");
var thisday = $(this).html();
console.log(thisday);
if($(this).html()=="今天"){
var selday = new Date().getDay();
var seldate = new Date().getDate();
}else{
var seldate = $(this).html();
var selday = new Date(parseInt(thisdate[0]),(parseInt(thisdate[1])-1),parseInt(thisday)).getDay();
console.log(selday)
}
var index = null;
if(selday==0){
$(".aweekday").hide();
$(".aweekday").eq(0).show();
}
else{
$(".aweekday").hide();
$(".aweekday").eq(selday).show();
}
$(".timeinfo").show();
$(".timeinfo").find("li").unbind();
$(".timeinfo").find("li").on("click",function(){
atime = [];
console.log(atime)
if(!($(this).hasClass("disable"))){
$(this).siblings("li").removeClass("sel");
$(this).addClass("sel");
$.each($(".timeinfo").find(".sel"),function(){
atime.push($(this).children(".time").html());
})
if(atime.length==2){
var yearmonth = $(".currentdate").html().split("年")
var thisdata = yearmonth[0]+"年"+addzero(yearmonth[1])+"月"+addzero(seldate)+"日";
var html = atimehtml.replace(/mydata|mytime1|mytime2|star_time|time_val/g,function(match){
switch(match){
case "star_time":
return "star_time";
case "time_val":
return thisdata+atime[0]+"-"+thisdata+atime[1];
case "mydata":
return thisdata;
case "mytime1":
return atime[0];
case "mytime2":
return atime[1];
}
})
$(".cartime li").removeClass("sel")
$(".sel_goback").html(html);
$(".month").hide();
$(".timeinfo").hide();
$(".asell_list").show();
}
}
})
//判断车票开车4小时内不能买票
if($(".thisday").html()=="今天"){
var carTodayhours = new Date().getHours()+4;
var carTodayMin = new Date().getMinutes();
if(carTodayMin<10){
carTodayMin="0"+carTodayMin;
}else{
carTodayMin=carTodayMin;
}
var NowTime = carTodayhours.toString()+carTodayMin.toString();
var objGo = $("input[name=check_go_time]").val();
var objBack = $("input[name=check_back_time]").val()
var objGoArr = objGo.split(",");
var objBackArr = objBack.split(",");
for(var i=0;iobjGoArr[i]){
$(".carticketGo"+i).unbind("click");//去掉事件
$(".carticketGo"+i).css("background-color","#bbb");
}
}
for(var i=0;iobjBackArr[i]){
$(".carticketBack"+i).unbind("click");//去掉事件
$(".carticketBack"+i).css("background-color","#bbb");
}
}
}else{
var objGo = $("input[name=check_go_time]").val();
var objBack = $("input[name=check_back_time]").val()
var objGoArr = objGo.split(",");
var objBackArr = objBack.split(",");
for(var i=0;i60){
carTodayMin = carTodayMin%60;
if(carTodayMin<11){
NowTime = (carTodayhours+1).toString()+("0"+carTodayMin).toString();
}else{
NowTime = (carTodayhours+1).toString()+carTodayMin.toString();
}
}else{
NowTime = carTodayhours.toString()+carTodayMin.toString();
}
var objGo = $("input[name=check_go_time]").val();
var objGoArr = objGo.split(",");
for(var i=0;iobjGoArr[i]){
$(".carticketGo"+i).unbind("click");//去掉事件
$(".carticketGo"+i).css("background-color","#bbb");
}
}
}else{
var objGo = $("input[name=check_go_time]").val();
var objGoArr = objGo.split(",");
for(var i=0;iobjGoArr[i]){
$(".carticketGo"+i).unbind("click");//去掉事件
$(".carticketGo"+i).css("background-color","#bbb");
}
}
for(var i=0;iobjBackArr[i]){
$(".carticketBack"+i).unbind("click");//去掉事件
$(".carticketBack"+i).css("background-color","#bbb");
}
}
}else{
var objGo = $("input[name=check_go_time]").val();
var objBack = $("input[name=check_back_time]").val()
var objGoArr = objGo.split(",");
var objBackArr = objBack.split(",");
for(var i=0;i
var ahtml = atimehtml.replace(/mydata|mytime1|mytime2|time_val|star_time/g,function(match){
switch(match){
case "star_time":
return "star_time";
case "time_val":
return week1.go[0]+"年"+ addzero(week1.go[1])+"月"+ addzero(week1.go[2])+"日"+week1.go[3]+"-"+week1.go[0]+"年"+ addzero(week1.go[1])+"月"+ addzero(week1.go[2])+"日"+week1.back[3];
case "mydata":
return week1.go[0]+"年"+ addzero(week1.go[1])+"月"+ addzero(week1.go[2])+"日";
case "mytime1":
return week1.go[3];
case "mytime2":
return week1.back[3]
}
});
// console.log(week1.go[0]+"."+ week1.go[1]+"."+ week1.go[2]);
// console.log(".aaaa");
// $(".aaaa").val(week1.go[0]+"."+ week1.go[1]+"."+ week1.go[2]);
//console.log($(".aaaa").val());
// console.log($(".aaaa"));
html.push(ahtml);
var ahtml = atimehtml.replace(/mydata|mytime1|mytime2|time_val|star_time/g,function(match){
switch(match){
case "star_time":
return "end_time";
case "time_val":
return week2.go[0]+"年"+addzero(week2.go[1])+"月"+ addzero(week2.go[2])+"日"+week2.go[3]+"-"+week2.go[0]+"年"+ addzero(week2.go[1])+"月"+ addzero(week2.go[2])+"日"+week2.back[3];
case "time_val":
return week2.go[0]+"年"+ addzero(week2.go[1])+"月"+ addzero(week2.go[2])+"日"+week2.back[3];
case "mydata":
return week2.go[0]+"年"+ addzero(week2.go[1])+"月"+ addzero(week2.go[2])+"日";
case "mytime1":
return week2.go[3];
case "mytime2":
return week2.back[3]
}
});
html.push(ahtml);
// console.log($(".aaaa").val());
$(".cartime li").removeClass("sel");
$(".sel_goback").html(html);
//console.log($(".aaaa").val())
$(".month").hide();
$(".timeinfo").hide();
$(".asell_list").show();
week1={};
week2={};
}
}
})
})
}
function judge(week,time,goback){
console.log(goback);
if(week==1){
week1[goback]=time;
}else{
week2[goback]=time;
};
console.log(week1)
console.log(week2)
if(typeof week1.go!="undefined"&&typeof week2.back!="undefined"){
return true
}
}
function disney2(){
}
function leftright(){
}
//得到url上的参数,并反映线路名称
function getPar(par){
var local_url = document.location.href;
local_url = decodeURI(local_url);
var get = local_url.indexOf(par +"=");
if(get == -1){
return false;
}
var get_par = local_url.slice(par.length + get + 1);
var nextPar = get_par.indexOf("&");
if(nextPar != -1){
get_par = get_par.slice(0, nextPar);
}
return get_par;
}
var type_id = getPar("id");
function addzero(num){
if(num.length<2){
return "0"+num;
}else{
return num;
}
}
jQuery.fn.outerHTML = function(s) {
return (s) ? this.before(s).remove() : $("").append(this.eq(0).clone()).html();
}