$(document).ready(function () {
erpproduct.PageInit();
})
function bindimgclick() {
$(".cpdetail_list_img").each(function () {
$(this).find("a").touchTouch();
});
}
var erpproduct = {
domain: "http://"+document.domain,
nowyear: $("#h_year").val(),
nowmonth: $("#h_month").val(),
productId: $("#h_productid").val(),
productType: $("#h_type").val(),
individualUnit: $("#h_individualUnit").val(),
confirmtype: $("#h_stockconfirmtype").val(),
selectdate: "",
selectenddate: "",
selectpriceid: 0,
selectendpriceid: 0,
baseprice: 0,
subbind: false,
maxnum: 999,
PageInit: function () {
this.PageFunction();
this.LoadPriceCalendar($("#detail_calendar_warp"), this.nowyear, this.nowmonth, true);
this.LoadProductPreference();
erpproduct.BindSelectEvent();
erpproduct.LoadAddOnProducts();
erpproduct.LoadRecommendProducts();
this.DateChange();
this.ImageShuffling();
this.WindowScroll();
},
PageFunction: function () {
$("#i_qijiashuoming").mouseover(function () {
$("#div_qijiashuoming").show();
}).mouseout(function () {
$("#div_qijiashuoming").hide();
});
$(".productInfoBox-price-aoyou").find("i").click(function () {
$(".productInfoBox-price-aoyou-info").slideToggle(1000);
});
var featurelist = $('.featureshow .icon-sarrowdown').parent().prev('.features-list');
if (featurelist.length > 0) {
var features_height = $(featurelist).height();
if (features_height > 233) {
$(featurelist).height(233);
$('.featureshow .icon-sarrowdown').click(function () {
var stat = $(this).attr('stat');
var t = $(this);
if (stat == 'close') {
t.addClass('up');
$(this).parent().prev('.features-list').css('height', 'auto')
t.attr('stat', 'open');
} else {
t.removeClass('up');
$(this).parent().prev('.features-list').css('height', '230px')
t.attr('stat', 'close');
}
});
} else {
$('.featureshow .icon-sarrowdown').hide();
}
}
//优惠显示详情
$('.features-list .span-tips').hover(function () {
if ($(this).parents('.features-list li').find('.tips-con').attr("right") == "1") {
$(this).parents('.features-list li').css('z-index', '1').find('.tips-con').attr("style", "left:auto;right:" + (230 - parseInt($(this).children("em").width())) + "px;").show();
} else {
$(this).parents('.features-list li').css('z-index', '1').find('.tips-con').show();
}
}, function () {
$(this).parents('.features-list li').css('z-index', '0').find('.tips-con').hide();
});
//乘车地点显示详情
$('.productInfoBox-desBox .productInfoBox-desBoxCont').hover(function () {
$(this).siblings('div').css('z-index', '1').find('.tips-con2').show();
});
$(".row_item", $("#middle")).click(function () {
if (!$(this).hasClass("selected")) {
var checkpeople = $(this).attr("data-people");
if (erpproduct.individualUnit == "人" && checkpeople != "0") {
$("#maxCheckPeople").html(checkpeople);
$("#maxCheckPeople").parent().removeClass("hidden");
erpproduct.maxnum = parseInt(checkpeople, 10)
}
else {
$("#maxCheckPeople").parent().addClass("hidden");
erpproduct.maxnum = 999;
}
$(this).siblings(".row_item").removeClass("selected");
$(this).addClass("selected");
var weaveId = $(this).attr("data-role");
$(".info_travel_choose_con", $("#middle")).addClass("hidden");
var thisTxt = $("#text_" + weaveId);
if (thisTxt) {
$(thisTxt).removeClass("hidden");
}
erpproduct.LoadPriceCalendar($("#detail_calendar_warp"), erpproduct.nowyear, 0, true, 0);
}
});
},
DateChange: function () {
$("#input_data_span").on("click", function (e) {
if ($("#detail_calendar_warp").is(":hidden") && $("#detail_calendar_warp").children().length > 0) {
$("#detail_calendar_warp2").hide();
$("#detail_calendar_warp").show();
} else {
$("#detail_calendar_warp").hide();
alert("抱歉,本套餐已售罄,请选择其他套餐");
}
if (e && e.stopPropagation)
e.stopPropagation();
else
window.event.cancelBubble = true;
});
if (this.individualUnit != "份") {
$("#input_data_span2").on("click", function (e) {
if ($("#detail_calendar_warp2").is(":hidden") && $("#detail_calendar_warp2").children().length > 0) {
$("#detail_calendar_warp").hide();
$("#detail_calendar_warp2").show();
} else {
$("#detail_calendar_warp2").hide();
alert("请选择入住日期");
}
if (e && e.stopPropagation)
e.stopPropagation();
else
window.event.cancelBubble = true;
});
}
$("#calendar_ico").on("click", function (e) {
if ($(".detail_calendar_warp").is(":hidden")) {
$(".detail_calendar_warp").show();
} else {
$(".detail_calendar_warp").hide();
}
if (e && e.stopPropagation)
e.stopPropagation();
else
window.event.cancelBubble = true;
});
},
BindCalendarEvent: function (detail_calendar_warp) {
// 日期选择
detail_calendar_warp.find(".detail_calendar_table .on").on("click", function () {
var d = $(this);
var showdate = erpproduct.CalendarSelectDay(d);
detail_calendar_warp.siblings(".input_data_span").text(showdate);
detail_calendar_warp.hide();
});
// 年份选择
$('[name="nice_select"]').click(function (e) {
$('[name="nice_select"]').find('ul').hide();
$(this).find('ul').show();
e.stopPropagation();
});
$('[name="nice_select"] li').click(function (e) {
var val = $(this).text();
$(this).parents('[name="nice_select"]').find('input').val(val);
// 添加刷新日期列表代码
$('[name="nice_select"] ul').hide();
e.stopPropagation();
});
detail_calendar_warp.find(".month_right").on("click", function (e) {
//设置当前年份和月份
var $nice_select = detail_calendar_warp.find(".nice_select");
var nowyear = parseInt($nice_select.children("input").attr("src"), 10);
var nowmonth = parseInt($nice_select.children("input").attr("src2"), 10);
erpproduct.LoadPriceCalendar(detail_calendar_warp, nowyear, nowmonth + 1, false, 1);
e.stopPropagation();
});
detail_calendar_warp.find(".month_left").on("click", function (e) {
//设置当前年份和月份
var $nice_select = detail_calendar_warp.find(".nice_select");
var nowyear = parseInt($nice_select.children("input").attr("src"), 10);
var nowmonth = parseInt($nice_select.children("input").attr("src2"), 10);
erpproduct.LoadPriceCalendar(detail_calendar_warp, nowyear, nowmonth - 1, false, 2);
e.stopPropagation();
});
$(document).bind("mousedown", function (e) {
var pannel = $("#addonservice").find(".use-date");
var input = jQuery(e.target).closest(".use-date", pannel);
var calendarpannel = $(".detail_calendar_warp");
var calendar = jQuery(e.target).closest(".detail_calendar_warp", calendarpannel);
if (input.length > 0 && !input.hasClass("info_wifi_days_disable")) {
$("#addonservice").find("li").removeClass("z-index");
$(".detail_calendar_warp").hide();
return;
}
if (calendar.length > 0) {
return;
}
$(".detail_calendar_warp").hide();
});
},
LoadPriceCalendar: function (detail_calendar_warp, nowyear, nowmonth, page_load, event) {
var code = "";
var minday = 0, maxday = 0;
var weaveCur = $(".selected", $(".row_choose"));
if (weaveCur) {
if (erpproduct.individualUnit == "份") {
minday = 0;
}
else {
minday = $("#h_minday").val();
}
code = weaveCur.attr("data-theme");
var checkpeople = weaveCur.attr("data-people");
if (erpproduct.individualUnit == "人" && checkpeople != "0") {
erpproduct.maxnum = parseInt(checkpeople, 10);
}
}
if (detail_calendar_warp.attr("id") == "detail_calendar_warp") {
page_load = page_load || false;
$.ajax({
url: erpproduct.domain + "/HotelProduct/GetPriceCalendar",
data: { productid: this.productId, producttype: this.productType, year: nowyear, month: nowmonth, minday: minday, code: code },
type: 'GET',
cache: false,
async: true,
success: function (data) {
if (data != null && data.isSuccess) {
$(detail_calendar_warp).html(data.calendarStr);
if ($("#input_data_span").html() == "") {
$("#input_data_span").html($("#h_fpdt").val());
}
var firstpid = $("#h_fpd").val();
if (page_load && (firstpid == undefined || firstpid == 0)) {
$("#input_data_span").html("选择入住日期");
erpproduct.selectdate = "";
erpproduct.selectenddate = "";
erpproduct.baseprice = 0;
$("#detail_calendar_warp2").html("");
alert("抱歉,本套餐已售罄,请选择其他套餐");
}
else {
erpproduct.BindCalendarEvent(detail_calendar_warp);
$firstpriceid = "#" + firstpid;
var daytd = $("#detail_calendar_warp").find(".detail_calendar_table").find($firstpriceid).parent("td");
var firstDate = erpproduct.CalendarSelectDay(daytd);
if (event == 0) {
$("#input_data_span").text(firstDate);
$(detail_calendar_warp).find(".month_left").hide();
}
}
}
else {
if (event == 1) {
$(detail_calendar_warp).find(".month_right").hide();
}
else if (event == 2) {
$(detail_calendar_warp).find(".month_left").hide();
}
else {
$("#input_data_span").html("选择入住日期");
erpproduct.selectdate = "";
erpproduct.selectenddate = "";
erpproduct.baseprice = 0;
$("#detail_calendar_warp").html("");
$("#detail_calendar_warp2").html("");
alert("抱歉,本套餐已售罄,请选择其他套餐");
}
}
},
error: function () {
alert("发生错误");
}
});
}
else {
erpproduct.LoadPriceCalendarLate(this.productId, this.selectdate, nowmonth, code, minday, 0, event);
}
},
LoadProductPreference: function () {
$.ajax({
url: erpproduct.domain + "/Common/GetPreference",
data: { productId: $("#h_productid").val(), productType: $("#h_producttype").val(), subType: $("#h_type").val() },
type: 'GET',
cache: false,
async: true,
success: function (data) {
if (data != null) {
if (data.preference != "") {
$("#divPreferential").html(data.preference);
if ($("li.preinfolist").length <= 2)
{
$(".morepreinfo").css("top", "0");
}
$("#divPreferential").show();
erpproduct.showPreference();
}
if (data.hasMobilePreference && $("#erweima_li").length > 0) {
$("#erweimaImg").attr("src", $("#hidErWeiMa").val());
$("#erweimaInfo").html(data.mobilePreName);
$("#erweima_li").show();
}
if (data.couponMoney > 0) {
$("#couponinfo").find("em").html(data.couponMoney);
$("#couponinfo").removeClass("hidden");
}
}
}
});
},
CalendarSelectDay: function (day) {
var c = day.attr("class");
if (typeof (c) == "undefined") {
//清除价格
alert("没有可选日期");
erpproduct.baseprice = 0;
}
var baseparent = day.parents(".detail_calendar_warp_sub");
var curMonth = $(".nice_select", baseparent).children("input");
var curDay = $($firstpriceid, baseparent);
var year = erpproduct.nowyear;
var month = erpproduct.nowmonth;
var data = day.children("a").children(".date").text();
var week = day.children("a").attr("data_num");
if (curMonth.length > 0) {
year = curMonth.attr("src");
month = curMonth.attr("src2");
erpproduct.baseprice = day.children("a").attr("baseprice");//基础价
erpproduct.selectpriceid = day.children("a").attr("data_priceid");
}
var showdata = year + "-" + month;
if (data == "") {
} else {
showdata += "-" + data + " " + "(星期" + week + ")";
}
if ($(baseparent).parents(".detail_calendar_warp").attr("id") == "detail_calendar_warp2") {
if (data == "") {
showdata = "选择退房日期";
}
this.selectenddate = year + "/" + month + "/" + data;
}
else {
if (data == "") {
showdata = "选择入住日期";
}
this.selectdate = year + "/" + month + "/" + data;
}
baseparent.find(".detail_calendar_table .on").children("a").removeClass("select");
day.children("a").addClass("select");
var beforeday = day.children("a").attr("data_bd");
if (beforeday > 0) {
$("#beforedayinfo").text("需提前" + beforeday + "天预订");
} else {
$("#beforedayinfo").remove();
}
var code = "";
var minday = 0, maxday = 0;
var weaveCur = $(".selected", $(".row_choose"));
if (weaveCur) {
code = weaveCur.attr("data-theme");
if (erpproduct.individualUnit == "份") {
minday = weaveCur.attr("data-night");
}
else {
minday = $("#h_minday").val();
}
}
if (baseparent.parent().attr("id") == "detail_calendar_warp") {
//加载截止日
erpproduct.LoadPriceCalendarLate(erpproduct.productId, erpproduct.selectdate, 0, code, minday, maxday, 1);
if (erpproduct.individualUnit != "份") {
$("#rentday").find("font").text(0);
erpproduct.baseprice = 0;
$(".ft_calculate").find("font").text(0);
$("#CheckInNum").val(1);
$(".num_reduce").addClass("disable");
$(".num_add").removeClass("disable");
erpproduct.selectenddate = "";
$("#input_data_span2").html("选择退房日期");
erpproduct.CalTotalPrice();
}
else {
erpproduct.GetProductPriceStock(code);
}
} else {
erpproduct.GetProductPriceStock(code);
}
return showdata;
},
GetProductPriceStock: function (code) {
var date1 = new Date(erpproduct.selectdate);
var date2 = new Date(erpproduct.selectenddate);
var dates = (date2 - date1) / (1000 * 60 * 60 * 24);
if (dates >= 0) {
$("#rentday").find("font").text(dates);
$.ajax({
type: "POST",
url: erpproduct.domain + "/HotelProduct/SynGetHotelDatePrice",
data: { productid: erpproduct.productId, startdate: erpproduct.selectdate, enddate: erpproduct.selectenddate, code: code, type: erpproduct.individualUnit },
success: function (data) {
if (data.isSuccess) {
erpproduct.baseprice = data.totalPrice;
$(".ft_calculate").attr("value", data.totalPrice);
$(".ft_calculate").find("font").html(data.totalPrice);
erpproduct.CalTotalPrice();
}
}
});
}
},
BindSelectEvent: function () {
// 加减运算
$(".num_add").on("click", function (e) {
var t = $(this);
t.siblings(".num_reduce").removeClass("disable");
var myval = t.siblings(".num_lable").val();
if (myval < erpproduct.maxnum) {
if (myval == erpproduct.maxnum - 1) {
t.addClass("disable");
}
t.siblings(".num_lable").val(++myval);
erpproduct.CalTotalPrice();
}
else {
t.addClass("disable");
}
e.stopPropagation();
});
$(".num_reduce").on("click", function (e) {
var t = $(this);
t.siblings(".num_add").removeClass("disable");
var myval = t.siblings(".num_lable").val();
var tm = myval - 1;
if (myval <= 1) {
tm = 1;
t.addClass("disable");
return false;
}
t.siblings(".num_lable").val(tm);
if (tm <= 1) {
t.addClass("disable");
}
erpproduct.CalTotalPrice();
e.stopPropagation();
});
$("#numbertype").find("input.num_lable").each(function () {
var nl = $(this);
var tempnum = /^[0-9]\d*$/;
nl.bind("keyup", function () {
nl.val(nl.val().replace(/\D/g, ""));
if (tempnum.test(nl.val())) {
if (nl.val() > erpproduct.maxnum) {
nl.val(erpproduct.maxnum);
nl.siblings(".num_add").addClass("disable");
}
else {
nl.siblings(".num_add").removeClass("disable");
}
erpproduct.CalTotalPrice();
if (nl.val() > 0) {
nl.parent().children("a.num_reduce").removeClass("disable");
} else {
nl.parent().children("a.num_reduce").addClass("disable");
}
}
else {
nl.val(1);
}
});
});
},
CalTotalPrice: function () {
addproduct.SetFreeServiceNum();
var marktotal = parseInt($("#totalFee_b").html(), 10);
var orderTotal = parseInt($("#totalOrderFee").html(), 10);
var totalnum = $("#numbertype").find("input.num_lable").val();
var newmarktotal = totalnum * this.baseprice;
$("#adultNum_b").html(totalnum);
$("#totalFee_b").html(newmarktotal);
var newOrderFee = orderTotal - marktotal + newmarktotal;
$("#totalOrderFee").html(newOrderFee);
if (totalnum == 0 || newmarktotal == 0) {
erpproduct.DeBindSubmit();
} else {
erpproduct.BindSubmitEvent();
}
},
BindSubmitEvent: function () {
if (!this.subbind) {
$(".btn-big").css("background-color", "#FF6600");
$(".btn-big").on("click", function () {
var numlable = $(".num_lable").val();
if (numlable > 0) {
var subxml = "" + code + "
";
subxml += "" + obj.code + "
";
addproducts += "";
subxml += addproducts;
subxml += "
";
}
}
subxml += "