//---------------------------------------工具方法 start-------------------------------------------
//克隆添加多段
function cloneMoreDiv(divClass){
var cloneDiv = $("."+divClass).eq(0).clone();
emptyContentByObj(cloneDiv);
$("."+divClass).last().after(cloneDiv);
initDateTimePicker($("."+divClass));
}
//删除多段
function deleteMoreDiv(divClass){
if($("."+divClass).length>1){
$("."+divClass+":last").remove();
}
}
//克隆时,查看当前div下是否有DateTimePicker,如果有则进行初始化
function initDateTimePicker(obj){
obj.find("input[type='text'][class='datetimepickercss']").each(function() {
$(this).datetimepicker({
format: 'dd/mm/yyyy',
autoclose: true,//选中日期后 自动关闭
pickerPosition:"top-left",//显示位置
minView: "month"//只显示年月日
});
});
}
initDateTimePicker($(document));
//勾选checkbox("不知道"),设置前一个兄弟级元素disable和no edit
function editEleBeforeCheckbox(obj){
/*
//适合单个
obj.change(function(){
var beforeEle = obj.prev();
beforeEle.val("");
if(obj.is(':checked')){
beforeEle.prop("disabled",true);
}else{
beforeEle.prop("disabled",false);
}
});*/
//适合多段
$(document).click(function (e) {
var obj = $(e.target);
if(obj.attr("type")=="checkbox"){
obj.change(function(){
var beforeEle = obj.prev();
beforeEle.val("");
if(obj.is(':checked')){
beforeEle.prop("disabled",true);
}else{
beforeEle.prop("disabled",false);
}
});
}
});
}
//---------------------------------------工具方法 end-------------------------------------------
/* -------------------------日期格式转换 start---------------------------- */
//将分钟数量转换为小时和分钟字符串
toHourMinute = function(minutes){
var m = parseInt(minutes);
return (Math.floor(m/60) + "h" + (m%60) + "m" );
}
/*获取某一天是周几*/
getWeekByDay = function(i){
var today = new Array("周日","周一","周二","周三","周四","周五","周六"); //创建星期数组
return today[i]; //返一个星期中的某一天,其中0为星期日
}
/*格式化日期为年月*/
getNowFormatDate = function (changeDate){
var seperator1 = "-";
var seperator2 = " ";
var year = changeDate.getFullYear();
var month = changeDate.getMonth() + 1;
var strDate = changeDate.getDate();
var weekday = changeDate.getDay();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var outdate = month +seperator1+ strDate +seperator2+ getWeekByDay(weekday);
return outdate;
}
/*------------------------日期加减天数 默认返程日期是出发日期的15天---------------------*/
function addDate(dd,count){
var a = new Date(dd)
a = a.valueOf()
a = a + count * 24 * 60 * 60 * 1000
a = new Date(a)
return a;
}
defaultDate = function(){
defaultReturnDate = addDate($("#outDatepicker").val(),15);
years = defaultReturnDate.getFullYear();
months = defaultReturnDate.getMonth()+1;
days = defaultReturnDate.getDate();
if (months >= 1 && months <= 9) {
months = "0" + months;
}
if (days >= 0 && days <= 9) {
days = "0" + days;
}
var returnDateStr = years +'-'+ months +'-'+days;
return returnDateStr;
}
function selectSingle(){
$("#searchSingleTicketsBtn").click();
}
/* -------------------------日期格式转换 end---------------------------- */