/*邮轮*/ var Cruise = new function () { var nowDate = new Date(); var now = new Date(); /*当前时间*/ var nowObj = null; var obj = this; var num = 1; var datepriceflyobj = null; /*弹出层*/ obj.BSortID = "33"; /*************************************************邮轮*********************************************************/ /*显示日期和价格*/ obj.ShowDatePrice = function () { datepriceflyobj = $("#datepricefly"); /*弹出层*/ var url = location.pathname + "?action=dataprice&month=" + nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1); $.getJSON(url, ShowDatePrice_CallBack); }; var lineDate = ""; /*显示日期下的航线基本信息*/ obj.ShowLineInfo = function (lineids, mdate) { var url = location.pathname + "?action=showline&lineids=" + lineids; lineDate = mdate; $.getJSON(url, ShowLineInfo_CallBack); }; /*显示日期下的航线基本信息_回调函数*/ var ShowLineInfo_CallBack = function (json) { var str = "
"; str += "
" + lineDate.split('-')[1] + "月" + lineDate.split('-')[2] + "
"; str += "
"; str += "
"; str += "
" + lineDate.split('-')[1] + "月" + lineDate.split('-')[2] + "日" + "航次
"; str += "
"; for (var i = 0; i < json.length; i++) { str += "
"; str += "
"; str += "\"\""; str += "
"; str += "
"; str += "
"; str += "
"; str += "<" + json[i].cruisename + ">" + json[i].linename + ""; str += "
" + json[i].sales + "
"; str += "
"; str += "\"""; str += "
"; str += "
"; str += "
"; str += "
    "; str += "
  • 编  号:" + json[i].lineid + "
  • " str += "
  • 行程天数:" + json[i].days + "天
  • "; str += "
  • 出发城市:" + json[i].cityname + "
  • "; str += "
  • 航行区域:" + json[i].areaname + "
  • "; str += "
"; str += "
" + json[i].defaultprice + "
查看详情"; str += "
"; str += "
"; str += "
"; str += "
"; str += "
"; str += "
"; } str += "
"; str += "
"; str += "
"; $("#cruise_voyage_date_vlist").html(str); $("#cruise_voyage_date_vlist").stop().animate({ left: "0px" }, "slow"); }; /*隐藏日期下和航线基本信息*/ obj.HideLineInfo = function () { $("#cruise_voyage_date_vlist").stop().animate({ left: "-1190px" }, "slow"); }; var postNum = 1; /*回调函数*/ var ShowDatePrice_CallBack = function (json) { /*没有团期显示下一个月 if (json.length == 0 && postNum == 1) { postNum++; nowDate = new Date(nowDate.getFullYear(), (nowDate.getMonth() + 1), 1); obj.ShowDatePrice(); return false; } else if (json.length == 0 && postNum == 2) { postNum++; nowDate = new Date(nowDate.getFullYear(), (nowDate.getMonth() - 1), 1); obj.ShowDatePrice(); return false; }*/ for (var i = 0; i < json.length; i++) { var temDateArray = json[i].gooffdate.split('-'); json[i].gooffdate = new Date(temDateArray[0], temDateArray[1] - 1, temDateArray[2].split(' ')[0]); } var htmlStr = ShowDatePriceMonth(nowDate, json, "one"); $("#Calendar").html(htmlStr); }; /*显示月份日期价格*/ var ShowDatePriceMonth = function (m, json, cal) { /*最多多少天(下一个月)*/ var maxDay = (new Date(m.getFullYear(), (m.getMonth() + 1), 0)).getDate(); /*获取当前日(1-31)*/ var nowDay = m.getDate(); /*获取当前星期X(0-6,0代表星期天)*/ var xq = (new Date(m.getFullYear(), (m.getMonth()), 1)).getDay(); var str = "
"; str += "
" + m.getFullYear() + "

" + (m.getMonth() + 1) + "
"; str += "
"; str += "
"; str += "
"; str += "
"; str += ""; str += ""; str += "
"; return str; }; /*下一月*/ obj.NextMonth = function () { nowDate = new Date(nowDate.getFullYear(), (nowDate.getMonth() + 1), 1); obj.ShowDatePrice(); }; /*上一月*/ obj.UpMonth = function () { nowDate = new Date(nowDate.getFullYear(), (nowDate.getMonth() - 1), 1); obj.ShowDatePrice(); }; /*显示月份标题*/ var ShowMonthTitle = function () { }; /*显示指定邮轮日期和价格*/ obj.ShowDatePriceByDate = function (year, month, _now) { nowDate = new Date(year, (month - 1), 1); now = _now; obj.ShowDatePrice(); }; /*************************************************邮轮品牌下邮轮*********************************************************/ /*显示指定邮轮品牌下邮轮的日期和价格*/ obj.ShowCruiseBrandDatePriceByDate = function (year, month, _now) { nowDate = new Date(year, (month - 1), 1); now = _now; obj.ShowCruiseBrandDatePrice(); }; /*显示日期和价格*/ obj.ShowCruiseBrandDatePrice = function () { datepriceflyobj = $("#datepricefly"); /*弹出层*/ var url = location.pathname + "?action=dataprice&month=" + nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1); $.getJSON(url, ShowDatePrice_CallBack); }; /*************************************************邮轮航线*********************************************************/ /*显示指定邮轮航线的日期和价格*/ obj.ShowCruiseRouteByDate = function (year, month, _now) { nowDate = new Date(year, (month - 1), 1); now = _now; obj.GetCruiseRouteDatePrice(); }; /*获取指定邮轮航线的日期和价格*/ obj.GetCruiseRouteDatePrice = function () { var url = location.pathname + "?action=dateroomprice"; $.getJSON(url, ShowRouteDatePrice_CallBack); }; /*航线的日期和价格回调函数*/ var ShowRouteDatePrice_CallBack = function (json) { for (var i = 0; i < json.length; i++) { var temDateArray = json[i].gooffdate.split('-'); json[i].date = json[i].gooffdate.split(' ')[0]; json[i].gooffdate = new Date(temDateArray[0], temDateArray[1] - 1, temDateArray[2].split(' ')[0]); } var htmlStr = ShowRouteGoOffDateList(nowDate, json); $("#GoOffDateList").html(htmlStr); $("#GoOffDateList").css("width", parseInt($("#GoOffDateList .p_tab_item").length) * 271); $("#GoOffDateList").attr("maxleft", parseInt($("#GoOffDateList .p_tab_item").length) * 271); /*注册事件*/ $("#GoOffDateList .p_tab_item").click(function () { $("#GoOffDateList .p_tab_item").removeClass("active"); $(this).addClass("active"); GetRoomPriceList($(this).attr("gooffdate")); }); /*显示第一个团期的房型信息*/ if ($("#GoOffDateList .p_tab_item").length > 0) { $("#GoOffDateList .p_tab_item").eq(0).click(); } }; /*显示航线的团期列表*/ var ShowRouteGoOffDateList = function (nowDate, json) { var str = ""; var gooffdate = ""; for (var i = 0; i < json.length; i++) { if (json[i].date != gooffdate) { var temPrice = 0; /*起始价格*/ for (var jIndex = 0; jIndex < json.length; jIndex++) { if (json[jIndex].date == json[i].date) { if (temPrice == 0) { temPrice = json[jIndex].price * 1; } else if (temPrice > json[jIndex].price * 1) { if (json[jIndex].price * 1 > 0) { temPrice = json[jIndex].price * 1; } } } } str += "
"; str += "
" + json[i].gooffdate.getFullYear() + "-" + (json[i].gooffdate.getMonth() + 1) + "-" + json[i].gooffdate.getDate() + " 登船
航线区域:" + json[i].areaname + "      行程天数:" + json[i].days + "
"; if (temPrice > 0) { str += "
" + temPrice + "
"; } else { str += "
请电询
"; } str += "
"; } gooffdate = json[i].date; } str += "
"; return str; }; /*获取航线的房型列表******************************************************************/ var GetRoomPriceList = function (gooffdate) { var url = location.pathname + "?action=dateroomprice&gooffdate=" + gooffdate; $.getJSON(url, ShowRoomDatePrice_CallBack); /*设置URL*/ $("#book_btn_main").attr("href", ($("#book_btn_main").attr("data") + "?date=" + gooffdate)); $("#book_btn_main").attr("gooffdate", gooffdate); }; /*航线房型回调函数*/ var ShowRoomDatePrice_CallBack = function (json) { for (var i = 0; i < json.length; i++) { var temDateArray = json[i].gooffdate.split('-'); json[i].date = json[i].gooffdate.split(' ')[0]; json[i].gooffdate = new Date(temDateArray[0], temDateArray[1] - 1, temDateArray[2].split(' ')[0]); } var htmlStr = ShowRoomPriceList(json); $("#roomsList").html(htmlStr); SumPriceNum(); /*求和*/ /*减*/ $(".znum_subtract").click(function () { var $input = $(this).parent().find(".znum_input"); if (parseInt($input.val()) > 0) { $input.val(parseInt($input.val()) - 1); } SumPriceNum(); }); /*加*/ $(".znum_add").click(function () { var $input = $(this).parent().find(".znum_input"); $input.val(parseInt($input.val()) + 1); SumPriceNum(); }); }; /*显示房型列表*/ var ShowRoomPriceList = function (json) { var str = "房型名称甲板层(层)面积(m2)可住人数(人)价格入住人数"; str += ""; for (var i = 0; i < json.length; i++) { str += ""; str += "" + json[i].roomname + ""; str += "" + json[i].floor + ""; str += "" + json[i].cabinsize + ""; str += "" + json[i].peoplenum + ""; str += "" + json[i].price + ""; str += ""; str += "
"; str += ""; str += "
"; str += ""; str += "" } str += ""; return str; }; /*求和*/ var SumPriceNum = function () { var sumPerson = 0; var sumPrice = 0; var roomStr = ""; $("#roomsList td .znum_input").each(function () { var roomid = parseInt($(this).attr("roomid")); var price = parseInt($(this).attr("price")); var v = parseInt($(this).val()); sumPerson += v; sumPrice += (price * v); if (v > 0) { roomStr += ("," + roomid + "|" + v); } }); $("#total_personNum").html(sumPerson); $("#statistics_price").html(sumPrice); /*设置URL*/ if (roomStr != "") { roomStr = roomStr.substr(1); var url = $("#book_btn_main").attr("data"); url += "?date=" + $("#book_btn_main").attr("gooffdate") url += "&RoomNum=" + roomStr; $("#book_btn_main").attr("href", url); } }; };