$(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 = "" + erpproduct.productId + ""; var pid = erpproduct.selectpriceid; var code = ""; var weaveCur = $(".selected", $(".row_choose")); if (weaveCur) { code = weaveCur.attr("data-theme"); if (code == "") { alert("请选择套餐"); return; } } if (pid > 0) { subxml += "" + pid + ""; subxml += "" + erpproduct.productType + ""; subxml += "" + erpproduct.selectdate + ""; subxml += "" + erpproduct.selectenddate + ""; subxml += "" + code + ""; subxml += "" + numlable + ""; var addproducts = ""; if ($("#addonservice").find("input.input-number").length > 0) { $.each($("#addonservice").find("input.input-number"), function () { var datastr = $(this).closest("li").attr("data-role"); var obj = JSON.parse(datastr); var tag = obj.id + "_" + obj.index; var bdate = $("#selectDate_" + tag).val(), edate = ""; var num = $(this).val(); var flag = false; if (obj.type == 3 || obj.type == 6) { edate = $("#selectEndDate_" + tag).val(); if (bdate != "" && edate != "" && num > 0) { flag = true; } } else { if (bdate != "" && num > 0) { flag = true; } } if (flag) { addproducts += ""; addproducts += "" + obj.id + ""; addproducts += "" + obj.type + ""; addproducts += "" + obj.code + ""; addproducts += "" + bdate + ""; addproducts += "" + edate + ""; addproducts += "" + num + ""; addproducts += ""; } }); if (addproducts != "") { subxml += ""; subxml += addproducts; subxml += ""; } } subxml += ""; //神策监测代码 - 点击_产品详情页 sensor.track('ProductDetaiPageClick', { start_city: '无', destination_city: $("#h_destination").val(), click_content: '立即预订', product_id: parseInt($("#h_productid").val()), product_name: $("#h_maintitle").val(), product_type: "当地玩乐" }); $("#BookingInfo").val(escape(subxml)); $(".submite").submit(); } else { alert("请选择数量"); } } else { alert("请选择正确的日期"); } }); this.subbind = true; } }, DeBindSubmit: function () { $(".btn-big").unbind("click"); $(".btn-big").css("background-color", "#E5E5E5"); this.subbind = false; }, LoadPriceCalendarLate: function (productid, startdate, month, code, minday, maxday, event) { if (this.individualUnit == "份") { var bdate = new Date(erpproduct.selectdate); var edate = new Date(bdate.setDate(bdate.getDate() + parseInt(minday, 10))); erpproduct.selectenddate = edate.getFullYear() + "/" + (edate.getMonth() + 1) + "/" + edate.getDate(); var week = edate.getDay(); var weekstr = "星期"; switch (week) { case 0: weekstr += "日"; break; case 1: weekstr += "一"; break; case 2: weekstr += "二"; break; case 3: weekstr += "三"; break; case 4: weekstr += "四"; break; case 5: weekstr += "五"; break; case 6: weekstr += "六"; break; } $("#input_data_span2").text(edate.getFullYear() + "-" + (edate.getMonth() + 1) + "-" + edate.getDate() + "(" + weekstr + ")"); } else { $.ajax({ url: erpproduct.domain + "/HotelProduct/GetHotelEndPriceCalendar", data: { productid: productid, startdate: startdate, month: month, iday: minday, aday: maxday, code: code }, type: 'GET', cache: false, async: true, success: function (data) { if (data != null && data.isSuccess) { $("#detail_calendar_warp2").html(data.calendarStr); erpproduct.BindCalendarEvent($("#detail_calendar_warp2")); } else { if (event == 1) { $("#detail_calendar_warp2").find(".month_right").hide(); } else { $("#detail_calendar_warp2").find(".month_left").hide(); } } } }); } }, LoadAddOnProducts: function () { $.ajax({ url: erpproduct.domain + "/Common/GetAddService", data: { productId: erpproduct.productId }, type: 'GET', cache: false, async: true, success: function (data) { if (data != null && data.isSuccess) { if (data.products != "") { $("#addonservice").html(data.products); if (data.feeStr != "") { $("#FeeDetailContent").append(data.feeStr); } $("#addonservice").removeClass("hidden"); addproduct.DateInputClick(); addproduct.SetFreeServiceNum(); } } else { $(".panel-body-hotel").removeClass("bor-3x"); $(".box-section").removeClass("bor-1x"); } } }); }, LoadRecommendProducts: function () { $.ajax({ url: erpproduct.domain + "/Common/SynGetRecommendProducts", data: { productId: erpproduct.productId, showType: $("#h_showtype").val(), price: $("#h_baseprice").val() }, type: 'GET', cache: false, async: true, success: function (data) { if (data != null && data.isSuccess) { if (data.products != "") { $("#divNewRecommend").html(data.products); $("#divNewRecommend").show(); $("#productrecnav").removeClass("hidden"); } } } }); }, WindowScroll: function () { $('a[href*=#]').click(function (e) { var $this = $(this); if ($this.hasClass("productInfoBox-picGetReady-up") || $this.hasClass("productInfoBox-picGetReady-down")) { return false; } e.preventDefault(); if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']'); if ($target.length) { var targetOffset = $target.offset().top; $('html,body').animate({ scrollTop: targetOffset - 48 }, 500); return false; } } }); var offsetval = 100; var right_info = $(".info_detail_right").length > 0 ? $(".info_detail_right").offset().top : 0; var wrapper_nav = $(".wrapper_nav").length > 0 ? $(".wrapper_nav").offset().top : 999999; var nav_feature = $("#feature").length > 0 ? $("#feature").offset().top - offsetval : 999999; var nav_experience = $("#experience").length > 0 ? $("#experience").offset().top - offsetval : 999999; var nav_service = $("#service").length > 0 ? $("#service").offset().top - offsetval : 999999; var nav_fysm = $("#fysm").length > 0 ? $("#fysm").offset().top - offsetval : 999999; var nav_method = $("#method").length > 0 ? $("#method").offset().top - offsetval : 999999; var nav_attention = $("#attention").length > 0 ? $("#attention").offset().top - offsetval : 999999; var nav_follow = $("#follow").length > 0 ? $("#follow").offset().top - offsetval : 999999; var nav_refund = $("#refund").length > 0 ? $("#refund").offset().top - offsetval : 999999; //var nav_khdp = $("#khdp").length > 0 ? $("#khdp").offset().top - offsetval : 999999; var nav_boarding = $("#boardingaddress").length > 0 ? $("#boardingaddress").offset().top - offsetval : 999999; $(window).scroll(function () { var addheight = $("#addonservice").height(); var scrolls = $(this).scrollTop(); if (scrolls < right_info || scrolls >= wrapper_nav + addheight) { $(".info_detail_right").removeClass("sidefixed"); } else { $(".info_detail_right").addClass("sidefixed"); } if (scrolls >= wrapper_nav + addheight) { $(".wrapper_nav").addClass("wrapper_nav_top"); $(".wrapper_nav_ydBtn").show(); $(".wrapper_nav_list li a").css("width", "75px"); } else { $(".wrapper_nav").removeClass("wrapper_nav_top"); $(".wrapper_nav_list li a").css("width", "85px"); $(".wrapper_nav_ydBtn").hide(); } if (scrolls >= nav_feature + addheight) { $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").removeClass("now"); $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").each(function () { if ($(this).find("a").attr("href").indexOf("#feature") != -1) { $(this).addClass("now"); } }); } if (scrolls >= nav_experience + addheight) { $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").removeClass("now"); $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").each(function () { if ($(this).find("a").attr("href").indexOf("#experience") != -1) { $(this).addClass("now"); } }); } if (scrolls >= nav_service + addheight) { $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").removeClass("now"); $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").each(function () { if ($(this).find("a").attr("href").indexOf("#service") != -1) { $(this).addClass("now"); } }); } if (scrolls >= nav_fysm + addheight) { $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").removeClass("now"); $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").each(function () { if ($(this).find("a").attr("href").indexOf("#fysm") != -1) { $(this).addClass("now"); } }); } if (scrolls >= nav_method + addheight) { $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").removeClass("now"); $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").each(function () { if ($(this).find("a").attr("href").indexOf("#method") != -1) { $(this).addClass("now"); } }); } if (scrolls >= nav_attention + addheight) { $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").removeClass("now"); $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").each(function () { if ($(this).find("a").attr("href").indexOf("#attention") != -1) { $(this).addClass("now"); } }); } if (scrolls >= nav_follow + addheight) { $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").removeClass("now"); $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").each(function () { if ($(this).find("a").attr("href").indexOf("#follow") != -1) { $(this).addClass("now"); } }); } if (scrolls >= nav_refund + addheight) { $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").removeClass("now"); $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").each(function () { if ($(this).find("a").attr("href").indexOf("#refund") != -1) { $(this).addClass("now"); } }); } if (scrolls >= nav_boarding + addheight) { $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").removeClass("now"); $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").each(function () { if ($(this).find("a").attr("href").indexOf("#boardingaddress") != -1) { $(this).addClass("now"); } }); } var nav_khdp = $("#khdpcontent").length > 0 ? $("#khdpcontent").offset().top - offsetval : 999999; if ($("#khdpcontent").css('display') == "none") { nav_khdp = 999999; } if (scrolls >= nav_khdp + addheight) { $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").removeClass("now"); $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").each(function () { if ($(this).find("a").attr("href").indexOf("#khdp") != -1) { $(this).addClass("now"); } }); } var nav_tuijian = $("#tuijian").length > 0 ? $("#tuijian").offset().top - offsetval : 999999; if (scrolls >= nav_tuijian) { $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").removeClass("now"); $(".wrapper_nav .wrapper_nav_list .wrapper_nav_list_li").each(function () { if ($(this).find("a").attr("href").indexOf("#tuijian") != -1) { $(this).addClass("now"); } }); } }) }, ImageShuffling: function () { var si; si = setInterval(this.fetchData, 3000); //启动 $(".productInfoBox-picGetReadyPic").on("click", function () { clearInterval(si); $this = $(this); var imgcount = $(".productInfoBox-picGetReady").find("ul").children().length; $(".productInfoBox-picGetReady .productInfoBox-picGetReadyPic").removeClass("pic-on"); $this.addClass("pic-on"); $(".productInfoBox-picShow").children("img").hide(); $(".productInfoBox-picShow").children("img").eq($this.index()).show(); window.INDEX = $this.index(); if (window.INDEX == 0) { $(".productInfoBox-picGetReady-up").removeClass("productInfoBox-picGetReady-up-current"); } if (window.INDEX > 0) { $(".productInfoBox-picGetReady-up").addClass("productInfoBox-picGetReady-up-current"); $(".productInfoBox-picGetReady-down").addClass("productInfoBox-picGetReady-down-current"); } if (window.INDEX >= imgcount - 2) { $(".productInfoBox-picGetReady-down").removeClass("productInfoBox-picGetReady-down-current"); } }); $(".productInfoBox-picGetReady-up").on("click", function () { clearInterval(si); window.INDEX = $('.pic-on').index(); if (window.INDEX - 1 >= 0) { window.INDEX = window.INDEX - 1; $(".productInfoBox-picGetReady-down").addClass("productInfoBox-picGetReady-down-current"); $(".productInfoBox-picGetReady ul li").removeClass("pic-on"); $(".productInfoBox-picGetReady ul li").eq(window.INDEX).addClass("pic-on"); if (window.INDEX == 0) { $(".productInfoBox-picGetReady-up").removeClass("productInfoBox-picGetReady-up-current"); } $(".productInfoBox-picShow").children("img").hide(); $(".productInfoBox-picShow").children("img").eq(window.INDEX).show(); } else { return false; } }); $(".productInfoBox-picGetReady-down").on("click", function () { clearInterval(si); window.INDEX = $('.pic-on').index(); var imgcount = $(".productInfoBox-picGetReady").find("ul").children().length; if (window.INDEX + 1 < imgcount - 1) { window.INDEX = window.INDEX + 1; $(".productInfoBox-picGetReady-up").addClass("productInfoBox-picGetReady-up-current"); $(".productInfoBox-picGetReady ul li").removeClass("pic-on"); $(".productInfoBox-picGetReady ul li").eq(window.INDEX).addClass("pic-on"); if (window.INDEX == imgcount - 2) { $(".productInfoBox-picGetReady-down").removeClass("productInfoBox-picGetReady-down-current"); } $(".productInfoBox-picShow").children("img").hide(); $(".productInfoBox-picShow").children("img").eq(window.INDEX).show(); } else { return false; } }); $(".productInfoBox-picGetReady ul").mouseleave(function () { clearInterval(si); si = setInterval(erpproduct.fetchData, 3000); }); }, fetchData: function () { window.INDEX = $('.pic-on').index(); var imgcount = $(".productInfoBox-picGetReady").find("ul").children().length; if (window.INDEX + 1 < imgcount - 1) { window.INDEX = window.INDEX + 1; $(".productInfoBox-picGetReady-up").addClass("productInfoBox-picGetReady-up-current"); $(".productInfoBox-picGetReady ul li").removeClass("pic-on"); $(".productInfoBox-picGetReady ul li").eq(window.INDEX).addClass("pic-on"); $("") if (window.INDEX == imgcount - 2) { $(".productInfoBox-picGetReady-down").removeClass("productInfoBox-picGetReady-down-current"); } } else { window.INDEX = 0; $(".productInfoBox-picGetReady-up").removeClass("productInfoBox-picGetReady-up-current"); $(".productInfoBox-picGetReady ul li").removeClass("pic-on"); $(".productInfoBox-picGetReady ul li").eq(window.INDEX).addClass("pic-on"); $(".productInfoBox-picGetReady-down").addClass("productInfoBox-picGetReady-down-current"); } $(".productInfoBox-picShow").children("img").hide(); $(".productInfoBox-picShow").children("img").eq(window.INDEX).show(); }, showPreference: function () { if ($("#MorePrefenence").length > 0) { $("#MorePrefenence").live("click", function () { $("#preInfoDiv").width($(document).width()); $("#preInfoDiv").height($(document).height()); $('#preinner_pop').css("left", ($(document).width() - $('#preinner_pop').width()) / 2); if (window.screen.availHeight < 768) { $('#preinner_pop').css("height", 580); $('#preStyle').css("height", 499); $('#preinner_pop').css("top", 20); } $("#preInfoDiv").removeClass("hidden"); }); $("#close_preferencepop").live("click", function () { $("#preInfoDiv").addClass("hidden"); }); $(".youhuianniu").live('click', function () { if (!$(this).parent("p").hasClass("youhuipup")) { $("#preInfoDiv").find(".youhuianniu").html("展开"); $("#preInfoDiv").find(".youhuiimgzk").removeClass("youhuiimgsq"); $("#preInfoDiv").find(".youhuip").removeAttr("style"); $("#preInfoDiv").find(".youhuipshow").removeClass("youhuipup"); $(this).html("收起"); $(this).next(".youhuiimgzk").addClass("youhuiimgsq"); $(this).parent("p").prev(".youhuip").css("height", "auto"); $(this).parent("p").addClass("youhuipup"); } else { $(this).html("展开"); $(this).next(".youhuiimgzk").removeClass("youhuiimgsq"); $(this).parent("p").prev(".youhuip").removeAttr("style"); $(this).parent("p").removeClass("youhuipup"); } }); $(".youhuiimgzk").live('click', function () { $(this).prev("span").click(); }); } } } var addproduct = { DateInputClick: function () { $("#addonservice").find(".panel-hide").bind('click', function () { var state = $(this).attr("stat"); var datastr = $(this).closest("li").attr("data-role"); var obj = JSON.parse(datastr); var tag = obj.id + "_" + obj.index; if (state == "close") { $(this).attr("stat", "open"); $(this).find(".arrowDown-blue").addClass("up"); var weave = $(this).closest("li").attr("data-weave"); if ($("#addproductdesc_" + tag).find(".subtitle").length == 0) { $.ajax({ url: erpproduct.domain + "/Common/GetAddProductDetail", data: { productid: obj.id }, type: 'GET', cache: false, async: true, success: function (data) { if (data != null && data.isSuccess) { $("#addproductdesc_" + tag).html(data.products); $("#addproductdesc_" + tag).find(".subtitle").html(weave); $("#addproductdesc_" + tag).show(); addproduct.CloseAddProductDesc(); } } }); } else { $("#addproductdesc_" + tag).show(); } } else { $(this).attr("stat", "close"); $(this).find(".arrowDown-blue").removeClass("up"); $("#addproductdesc_" + tag).hide(); } }); $("#addonservice").find(".use-date").bind('click', function () { if ($(this).hasClass("info_wifi_days_disable")) { return; } var datastr = $(this).closest("li").attr("data-role"); var obj = JSON.parse(datastr); var box = $(this).next(".detail_calendar_warp"); var nowyear = $("#h_year").val(), nowmonth = $("#h_month").val(); if ($("#selectDate_" + obj.id + "_" + obj.index).val() != "") { var selectedDate = new Date($("#selectDate_" + obj.id + "_" + obj.index).val()); nowyear = selectedDate.getFullYear(); nowmonth = selectedDate.getMonth() + 1; } $(this).closest("li").addClass("z-index"); if ($(this).next(".detail_calendar_warp").children().length == 0) { addproduct.LoadPriceCalendar(box, obj, nowyear, nowmonth, 0); } else { $(this).next(".detail_calendar_warp").show(); } }); $("#addonservice").find(".arrowUp").bind('click', function (e) { var datastr = $(this).closest("li").attr("data-role"); var obj = JSON.parse(datastr); var tag = obj.id + "_" + obj.index; var maxnum = parseInt($("#totalNum_" + tag).attr("data-maxnum"), 10); var nowval = parseInt($("#totalNum_" + tag).val(), 10); if (obj.type == 6 && obj.unit == "人" && obj.people > 0) { if (obj.people < maxnum) { maxnum = obj.people; } } if (nowval < maxnum) { $("#totalNum_" + tag).val(++nowval); addproduct.AddFeeDetail(obj); } e.stopPropagation(); }); $("#addonservice").find(".arrowDown").bind('click', function (e) { var datastr = $(this).closest("li").attr("data-role"); var obj = JSON.parse(datastr); var tag = obj.id + "_" + obj.index; var maxnum = parseInt($("#totalNum_" + tag).attr("data-maxnum"), 10); var nowval = parseInt($("#totalNum_" + tag).val(), 10); var newval = nowval - 1; if (newval < 0) { newval = 0; } $("#totalNum_" + tag).val(newval); addproduct.AddFeeDetail(obj); e.stopPropagation(); }); $("#addonservice").find("input.input-number").each(function () { var datastr = $(this).closest("li").attr("data-role"); var obj = JSON.parse(datastr); var tag = obj.id + "_" + obj.index; var nl = $(this); var tempnum = /^[1-9]{1}[0-9]{0,}$/ nl.bind("focus", function () { $(this).select(); return this; }).bind("keyup", function () { var maxnum = parseInt($("#totalNum_" + tag).attr("data-maxnum"), 10); nl.val(nl.val().replace(/\D/g, "")); if (tempnum.test(nl.val())) { if (obj.type == 6 && obj.unit == "人" && obj.people > 0) { if (obj.people < maxnum) { maxnum = obj.people; } } if (nl.val() > maxnum) { nl.val(maxnum); } } else { nl.val(0); $(this).focus(); } addproduct.AddFeeDetail(obj); }); }); }, SetFreeServiceNum: function () { var num = $("#CheckInNum").val(); if ($("#freeaddservice").length > 0) { $("#freeaddservice").find(".productNum").html(num); } if ($("#freeservice_box").length > 0) { var fee = parseInt($("#freeTotal").attr("data-total"), 10); var newfee = fee * num; $("#freeTotal").html(newfee); $("#FeeDetailContent").find(".productNum").html(num); } }, CloseAddProductDesc: function () { $("#addonservice").find(".btn-hide").bind('click', function () { var datastr = $(this).closest("li").attr("data-role"); var obj = JSON.parse(datastr); var tag = obj.id + "_" + obj.index; $("#addproduct_" + tag).attr("stat", "close"); $("#addproduct_" + tag).find(".arrowDown-blue").removeClass("up"); $('html,body').animate({ scrollTop: $(window).scrollTop() - $("#addproductdesc_" + tag).height() }, 100); $("#addproductdesc_" + tag).hide(); }); }, CalendarClick: function (box, obj) { //设置当前年份和月份 var $nice_select = box.find(".nice_select"); if ($nice_select) { var nowyear = parseInt($nice_select.children("input").attr("src"), 10); var nowmonth = parseInt($nice_select.children("input").attr("src2"), 10); box.find(".month_right").on("click", function (e) { addproduct.LoadPriceCalendar(box, obj, nowyear, nowmonth + 1, 1); if (e && e.stopPropagation) e.stopPropagation(); else window.event.cancelBubble = true; }); box.find(".month_left").on("click", function (e) { addproduct.LoadPriceCalendar(box, obj, nowyear, nowmonth - 1, 2); if (e && e.stopPropagation) e.stopPropagation(); else window.event.cancelBubble = true; }); box.find(".detail_calendar_table .on").on("click", function () { var tddate = $(this); var showdate = addproduct.CalendarSelectDay(box, tddate, obj); box.siblings(".use-date").val(showdate); box.hide(); if (e && e.stopPropagation) e.stopPropagation(); else window.event.cancelBubble = true; }); } }, LoadPriceCalendar: function (box, obj, nowyear, nowmonth, event) { var tag = obj.id + "_" + obj.index; if (box.attr("id") == "firstDate_" + tag) { var minday = obj.wifiminday; if (obj.type == 6 && obj.unit != "份") { minday = obj.night; } $.ajax({ url: erpproduct.domain + "/Common/GetPriceCalendar", data: { productid: obj.id, producttype: obj.type, year: nowyear, month: nowmonth, minday: minday, code: obj.code }, type: 'GET', cache: false, async: true, success: function (data) { if (data != null && data.isSuccess) { $(box).html(data.calendarStr); $(box).show(); addproduct.CalendarClick(box, obj); } else { if (event == 1) { box.find(".month_right").hide(); } else if (event == 2) { box.find(".month_left").hide(); } else { $(box).html(""); $("#totalPrice_" + tag).html("已售罄"); alert("抱歉,本产品已售罄,请选择其他产品"); } } } }); } else { addproduct.LoadSecondDateCalendar(box, obj, nowmonth, event); } }, LoadSecondDateCalendar: function (box, obj, month, event) { var tag = obj.id + "_" + obj.index; if (obj.type == 6 && obj.unit == "份") { var bdate = new Date(erpproduct.selectdate); var edate = new Date(bdate.setDate(bdate.getDate() + obj.night)); $("selectEndDate_" + tag).val(edate.getFullYear() + "/" + (edate.getMonth() + 1) + "/" + edate.getDate()); box.siblings(".use-date").html(edate.getFullYear() + "-" + (edate.getMonth() + 1) + "-" + edate.getDate()); addproduct.CalendarClick(box, obj); } else { var minday = obj.wifiminday; if (obj.type == 6) { minday = obj.night; } var bdate = $("#selectDate_" + tag).val(); if (bdate != "") { $.ajax({ url: erpproduct.domain + "/Common/GetSecondPriceCalendar", data: { productid: obj.id, ptype: obj.type, startdate: bdate, month: month, iday: minday, aday: obj.wifimaxday, code: obj.code }, type: 'GET', cache: false, async: true, success: function (data) { if (data != null && data.isSuccess) { $(box).html(data.calendarStr); $(box).show(); addproduct.CalendarClick(box, obj); } else { if (event == 1) { box.find(".month_right").hide(); } else { box.find(".month_left").hide(); } } } }); } else { alert("请先选择开始日期"); } } }, CalendarSelectDay: function (box, day, obj) { var tag = obj.id + "_" + obj.index; var c = day.attr("class"); if (typeof (c) == "undefined") { $("#totalPrice_" + tag).html("0"); $("#totalNum_" + tag).val(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"); $("#totalPrice_" + tag).find("font").html(day.children("a").attr("baseprice"));//基础价 } var showdata = year + "-" + month; if (data == "") { } else { showdata += "-" + data; } box.find(".detail_calendar_table .on").children("a").removeClass("select"); day.children("a").addClass("select"); if (box.attr("id") == "secondDate_" + tag) { if (obj.type == 3 || obj.type == 6) { if (data == "") { showdata = "结束日期"; $("#selectEndDate_" + tag).val(""); } else { $("#selectEndDate_" + tag).val(year + "/" + month + "/" + data); } } } else { $("#selectDate_" + tag).val(year + "/" + month + "/" + data); $("#secondDate_" + tag).prev(".use-date").val("结束日期"); $("#selectEndDate_" + tag).val(""); addproduct.AddFeeDetail(obj); addproduct.LoadSecondDateCalendar($("#secondDate_" + tag), obj, 0, 0); } addproduct.GetProductPriceStock(box, obj); return showdata; }, GetProductPriceStock: function (box, obj) { var tag = obj.id + "_" + obj.index; var date1 = $("#selectDate_" + tag).val(); var date2 = ""; if (obj.type == 3 || obj.type == 6) { if (obj.type == 6 && obj.unit == "份") { var tag = obj.id + "_" + obj.index; var bdate = new Date(date1); var edate = new Date(bdate.setDate(bdate.getDate() + obj.night)); $("#selectEndDate_" + tag).val(edate.getFullYear() + "/" + (edate.getMonth() + 1) + "/" + edate.getDate()); $("#secondDate_" + tag).siblings(".use-date").html(edate.getFullYear() + "-" + (edate.getMonth() + 1) + "-" + edate.getDate()); } date2 = $("#selectEndDate_" + tag).val(); if (date2 == "") { return; } } else { date2 = date1; } $.ajax({ type: "POST", url: erpproduct.domain + "/common/SynGetDatePrice", data: { productid: obj.id, startdate: date1, enddate: date2, code: obj.code, type: obj.type, unit: obj.unit }, success: function (data) { if (data.isSuccess) { $("#totalPrice_" + tag).find("font").html(data.totalPrice); addproduct.AddFeeDetail(obj); } } }); }, AddFeeDetail: function (obj) { var tag = obj.id + "_" + obj.index; var bdate = $("#selectDate_" + tag).val(), edate = ""; var num = $("#totalNum_" + tag).val(); var flag = false; if (obj.type == 3 || obj.type == 6) { edate = $("#selectEndDate_" + tag).val(); if (bdate != "" && edate != "" && num > 0) { flag = true; } } else { if (bdate != "" && num > 0) { flag = true; } } if (flag) { $("#selectproduct_" + tag).removeClass("hidden"); var totalOrderFee = parseInt($("#totalOrderFee").html(), 10); var typeBox = $("#categorydt_box"); var price = parseInt($("#totalPrice_" + tag).find("font").html(), 10); if (typeBox.length > 0) { var totalFee = parseInt($("#feeTotal_box").html(), 10); if ($("#addProductFee_" + tag).length > 0) {//该产品已选 var beforePrice = parseInt($("#addprice_b" + tag).html(), 10); var beforeNum = parseInt($("#addnum_b" + tag).html(), 10); var newTotalFee = totalFee - beforeNum * beforePrice + price * num; var newTotalOrderFee = totalOrderFee - beforeNum * beforePrice + price * num; $("#addprice_b" + tag).html(price); $("#addnum_b" + tag).html(num); $("#feeTotal_box").html(newTotalFee); $("#totalOrderFee").html(newTotalOrderFee); } else { var newTotalOrderFee = totalOrderFee + price * num; $("#feeTotal_box").html(totalFee + price * num); $("#totalOrderFee").html(newTotalOrderFee); $("#categoryDetail_box").append("
(" + obj.text + ")" + obj.name + "" + price + " × " + num + "
"); } } else { var totalFee = price * num; $("#FeeDetailContent").append("
目的地服务" + totalFee + "
"); var feeDetailStr = "
"; feeDetailStr += "
(" + obj.text + ")" + obj.name + "" + price + " × " + num + "
"; feeDetailStr += "
"; $("#FeeDetailContent").append(feeDetailStr); var newTotalOrderFee = totalOrderFee + totalFee; $("#totalOrderFee").html(newTotalOrderFee); } } else { $("#selectproduct_" + tag).addClass("hidden"); if ($("#addProductFee_" + tag).length > 0) { var beforePrice = parseInt($("#addprice_b" + tag).html(), 10); var beforeNum = parseInt($("#addnum_b" + tag).html(), 10); var totalFee = parseInt($("#feeTotal_box").html(), 10); var newTotalFee = totalFee - beforeNum * beforePrice; var totalOrderFee = parseInt($("#totalOrderFee").html(), 10); var newTotalOrderFee = totalOrderFee - beforeNum * beforePrice; if (newTotalFee == 0) { $("#categorydt_box").remove(); $("#categoryDetail_box").remove(); } else { $("#feeTotal_box").html(newTotalFee); $("#addProductFeediv_" + tag).remove(); } $("#totalOrderFee").html(newTotalOrderFee); } } } }