$("#loading_html").show();
//当前时间
var tmonth = new Date();
var year = tmonth.getFullYear();
var month = tmonth.getMonth();
var dom = $('.month');
//中间变量 记录
var tttmonth = '';
var tyear = '';
window.onload = function() {
!dom.hasClass("amonth") && dom.addClass("amonth");
//当前日期
var date1 = new Date(year, month);
//当前月份
var tomonth = new Date().getMonth();
//
var today = new Date().getDate();
var dayhtml = [];
var week = ["日", "一", "二", "三", "四", "五", "六"];
for(var t = 1; t <= 3; t++) {
dayhtml.push('
');
var date = date1;
month = date.getMonth() + t - 1;
if(month >= 11) {
tyear = year + 1;
tttmonth = month - 12;
// month = 0;
} else {
tyear = year;
tttmonth = month;
}
if(tttmonth == -1) {
tttmonth = 11;
tyear = year;
}
dayhtml.push('
' + (tttmonth + 1) + '月' + '' + tyear + '
')
// dayhtml.push();
// $.each(week,function(i,v){
// dayhtml.push('
'+week[i]+'
')
// });
var str = '';
$.each(week, function(i, v) {
str += '
' + week[i] + '
';
});
dayhtml.push('
' + str + '
')
var nextdate = new Date(year, month)
var firstweek = nextdate.getDay();
// var firstweek = month.getDay();
// var first = month.getDay();
var allday = new Date(parseInt(year), (parseInt(month) + 1), 0).getDate();
var daystr = '
';
for(var i = 0; i < firstweek; i++) {
daystr += '
'
};
var data_cur_str = ''; //日期str
var data_cur = ''; //日期-
// 得到去程日期
var go_run_date = getPar('go_date');
// var date1 = new Date(go_run_date.replace(/\-/g, '/'));
// // 判断日期是否合理
// var date1 = new Date(start_date.replace(/\-/g, '/'));
// var date2 = new Date(end_date.replace(/\-/g, '/'));
// if (date1>date2 || end_date=="") {
// $('#id-date-picker-2').val(start_date);
// }
if(month == tomonth) {
for(i = 1; i <= allday; i++) {
var t_m = (tttmonth + 1);
var t_m_str = t_m;
var t_d_str = i;
if(t_m <= 9) {
t_m_str = "0" + t_m;
}
if(i <= 9) {
t_d_str = "0" + i;
}
data_cur_str = t_m_str + "月" + t_d_str + '日';
data_cur = tyear + "-" + (Array(2).join(0) + (tttmonth + 1)).slice(-2) + "-" + (Array(2).join(0) + i).slice(-2);
var run_day = go_run_date.substring(8);
if(i < parseInt(run_day)) {
daystr += '
' + i + '
';
} else {
if(i == today) {
// if(getPar('from')=="fill_order"){
// daystr+='
'+i+'
';
// }else{
daystr += '
今天
';
// }
} else if(i < today) {
daystr += '
' + i + '
';
} else {
daystr += '
' + i + '
';
}
}
}
} else if(month < tomonth) {
for(i = 1; i <= allday; i++) {
daystr += '
' + i + '
'
}
} else {
for(i = 1; i <= allday; i++) {
var t_m = (tttmonth + 1);
var t_m_str = t_m;
var t_d_str = i;
if(t_m <= 9) {
t_m_str = "0" + t_m;
}
if(i <= 9) {
t_d_str = "0" + i;
}
data_cur_str = t_m_str + "月" + t_d_str + '日';
data_cur = tyear + "-" + (Array(2).join(0) + (tttmonth + 1)).slice(-2) + "-" + (Array(2).join(0) + i).slice(-2);
daystr += '
' + i + '
'
}
}
daystr += "
";
dayhtml.push(daystr);
dayhtml.push('
');
}
dom.html(dayhtml.join(""))
//选中去程的日期
$(".canday").each(function(index, domE) {
if($(this).attr('data-cur') == getPar('go_run_date')) {
$(this).removeClass('select_day');
$(this).removeClass('select_go_day');
$(this).addClass('select_go_day');
};
})
$(".canday").on("click", function() {
$(".canday").removeClass('select_day');
$(this).addClass('select_day');
//判断从哪个页面跳转过来
var from = getPar('from');
//出行预订
if(from == "travel_book") {
var data_cur = $(this).attr('data-cur');
var data_cur_str = $(this).attr('data-cur-str');
var tt = getDateTime(4);
var listURL = 'travel_book.html?run_date=' + data_cur + "&run_date_str=" + data_cur_str + "&tt=" + tt ;
listURL = encodeURI(listURL);
window.location.href = listURL;
}
//订单详情
if(from == "fill_order") {
// go_ticket_id='+go_ticket_id+'&go_date='+go_date+'&back=back'+'&from=fill_order';
var start_area_id = getPar("start_area_id");
var end_area_id = getPar("end_area_id");
var data_cur_str = $(this).attr('data-cur-str');
var data_cur = $(this).attr('data-cur');
var tt = getDateTime(4);
var listURL = "search_results.html?start_area_id=" + start_area_id + "&end_area_id=" + end_area_id + "&run_date=" + data_cur + "&if_go=back" +"&go_run_date=" + getPar('go_run_date');
listURL = encodeURI(listURL);
window.location.href = listURL;
// 测试返程列表接口。。。
// var url=base_api+"./zz_wxsct/control.php";
// var parm={
// type:"bus_reservation_list_back",
// date:go_date,
// ticket_id:go_ticket_id
// }
// ZZLog(url+JSON.stringify(parm));
// $.post(url,parm,function(res_data){
// ZZLog(res_data);
// res_data=JSON.parse(res_data);
// ZZLog(res_data);
// });
}
if(from == "search_results"){
var data_cur_str = $(this).attr('data-cur-str');
var data_cur = $(this).attr('data-cur');
var start_area_id = getPar('start_area_id');
var end_area_id = getPar('end_area_id');
var ticket_id = getPar('go_ticket_id');
var listURL = '';
if(ticket_id != '') {
listURL = "./search_results.html?run_date=" + data_cur + "&data_cur_str=" + data_cur_str + "&start_area_id=" + start_area_id + "&end_area_id=" + end_area_id + "&from=search_results" + "&go_run_date=" + getPar('go_run_date');
} else {
listURL = "./search_results.html?run_date=" + data_cur + "&data_cur_str=" + data_cur_str + "&start_area_id=" + start_area_id + "&end_area_id=" + end_area_id + "&from=search_results" + "&go_run_date=" + getPar('go_run_date');
}
listURL = encodeURI(listURL);
window.location.href = listURL;
}
if(from == "pick_drop") {
var data_cur_str = $(this).attr('data-cur-str');
var data_cur = $(this).attr('data-cur');
var temp=data_cur.replace('-','/');
var week_day = getWeekDay(temp);
window.location.href = "pick_drop_person.html?data_cur=" + data_cur + "&data_cur_str=" + data_cur_str+"&week_day=" + week_day + "&go_run_date=" + getPar('go_run_date') ;
}
if(from == "disney_tranship") {
var data_cur_str = $(this).attr('data-cur-str');
var data_cur = $(this).attr('data-cur');
var temp=data_cur.replace(/-/g,"/");
var week_day = getWeekDay(temp);
window.location.href = "disney_tranship.html?data_cur=" + data_cur + "&data_cur_str=" + data_cur_str+"&week_day=" + week_day ;
}
// $(".canday").removeClass('thisday');
// $(this).next().addClass("placesel");
// $(this).addClass("thisday");
})
}