var zmoney=0; var sum=0; var vipD=0; var appointPrice=0; $('.couponsList').html('
优惠券
暂无优惠券

'); $('.payPoints').html('
积分
不可用

'); $('.vipCard').hide(); $('.zmoney').html('0'); $('.appointPrice').html(''); $('.tomoney1').html(sum); $('#exid').val('0'); function getDateStr(today, addDayCount) { var dd; if (today) { dd = new Date(today); } else { dd = new Date(); } dd.setDate(dd.getDate() + addDayCount); //获取AddDayCount天后的日期 var y = dd.getFullYear(); var m = dd.getMonth() + 1; //获取当前月份的日期 var d = dd.getDate(); if (m < 10) { //格式化小于10的月份 m = "0" + m; }; if (d < 10) { //格式化小于10的日期 d = "0" + d; }; return y + "-" + m + "-" + d; } function changeTimeSegments(data){ let timeList = data; let timeSegmentHtml =''; timeList.forEach(function(item,index) { timeSegmentHtml += `
${item.showname}
`; }); $(".timeshows").html(timeSegmentHtml); } function setBookPrice(data){ console.log("data:", data); console.log("addhtml:", data.addhtml); changeTimeSegments(data.addhtml); console.log('not changetime::'); sum=data.sumPrice; if($("#usescore").val()==1){//积分判断 if (0>0) {//that.data.score.reduceMoney var scoreMoney = parseFloat("0").toFixed(2);//that.data.score.reduceMoney sum-=scoreMoney; } } if(0!=0){//优惠劵 var couponsList=$("coupons").children('option:selected').val(); if(couponsList!=0){ var discountPrice = parseFloat($('.coupons').children('option:selected').attr("data-price")).toFixed(2);//that.data.couponsList[that.data.couponsKey] sum-=discountPrice; } } if ( == 2) { appointPrice = sum; $('.appointPrice').html(appointPrice); } sum=parseFloat(sum-appointPrice).toFixed(2); zmoney=parseFloat(data.price).toFixed(2); vipD=parseFloat(data.score.discountPrice).toFixed(2); $(".zmoney").html(zmoney); $(".tomoney1").html(sum); $(".tomoney2").html(data.price); $(".vipDiscount").html(data.score.discountPrice); if(data.showspec==1) $(".timeshow").show(); else $(".timeshow").hide(); if (data.isHide == true) { $(".themoney .money").hide(); $(".themoney .money_1").hide(); $(".yuyue .btnSet").attr("disabled","disabled"); $(".yuyue .btnSet").attr("style","background:#ccc !important;"); } else { $(".themoney .money").show(); $(".themoney .money_1").show(); $(".yuyue .btnSet").removeAttr("disabled"); $(".yuyue .btnSet").removeAttr("style"); } showmoney(); } function ajaxPrice(type){ var pid = $("#pid").val(); var idweb = 3423; var employ_id = $('#eid').val(); var startdate = $(".startdate").val(); var enddate = $(".enddate").val(); var curday = $(".curday").val(); var attachID = {}; var time = {'0':$("input[name='time']:checked").data('btime'),'1':$("input[name='time']:checked").data('etime')}; var nowtime = this.getDateStr('', 0); //获取当前日期 var systime = this.getDateStr(nowtime, 1); //获取明天日期 $(".choose_prod").each(function(i,val){ if($(this).is(':checked')){ attachID[i] = $(this).val(); } }) if(typeof(startdate)=='undefined') startdate = nowtime; if(typeof(enddate)=='undefined') enddate = systime; if(typeof(curday)=='undefined') curday = nowtime; if(curday == ''){ curday =$(".formBtn").attr("year")+"-"+$(".formBtn").attr("date")+' '+$(".formBtn").attr("time"); } var data = '&pid='+pid+'&startdate='+startdate+'&startdate='+startdate+'&enddate='+enddate+'&curday='+curday+'&attachID='+attachID+'&uid='+0+'&time='+time+'&employ_id='+employ_id+'&'; $.ajax({ crossDomain: true, xhrFields:{withCredentials:true}, url: "/webapp.php?mod=api&name=book&ctrl=ajaxPrice&idweb=3423"+data, success: function(res){ sum=res.sumPrice; if($("#usescore").val()==1){//积分判断 if (0>0) {//that.res.score.reduceMoney var scoreMoney = parseFloat("0").toFixed(2);//that.res.score.reduceMoney sum-=scoreMoney; } } if(0!=0){//优惠劵 var couponsList=$("coupons").children('option:selected').val(); if(couponsList!=0){ var discountPrice = parseFloat($('.coupons').children('option:selected').attr("data-price")).toFixed(2);//that.res.couponsList[that.res.couponsKey] sum-=discountPrice; } } sum=parseFloat(sum-appointPrice).toFixed(2); zmoney=parseFloat(res.price).toFixed(2); vipD=parseFloat(res.score.discountPrice).toFixed(2); $(".zmoney").html(zmoney); $(".tomoney1").html(sum); $(".tomoney2").html(res.price); $(".timeshows").html(res.addhtml); $(".vipDiscount").html(res.score.discountPrice); if(res.showspec==1) $(".timeshow").show(); else $(".timeshow").hide(); showmoney(); }, }); } //优惠券选项 $('.coupons').change(function(){ $(".tomoney1").html(couposn()); }) //积分的js function payPoints(obj){//积分的js if($(obj).children("img").css("left")=="0px"){ $(obj).children("img").animate({left:"40px"},300); $(obj).attr("class", "payPointsYes"); //$(obj).children("img").css("background",skinBackColor); $(obj).children("input").val("1"); $("#usescore").val("1"); $(".tomoney1").html(couposn()); }else { $(obj).children("img").animate({left:"0px"},300); $(obj).attr("class", "payPointsNO"); $(obj).children("img").css("background","#999999"); $(obj).children("input").val("0"); $("#usescore").val("0"); $(".tomoney1").html(couposn()); } } function couposn(){ var goodsPrice = zmoney;//商品价格 var appointPrice = 0;//预定价格 var sumPrice = goodsPrice; //积分 if ($("#usescore").val()==1) {//that.data.useScore == 1 if (0!=0) {//that.data.score.reduceMoney var scoreMoney = parseFloat("0");//that.data.score.reduceMoney sumPrice -= scoreMoney; } } //优惠券 if (0!=0) {//that.data.couponsList.length > 0 var couponsList=$("#selectCoupons").children('option:selected').val(); if(couponsList!=0){ var discountPrice = parseFloat($('.coupons').children('option:selected').attr("data-price")).toFixed(2);//that.data.couponsList[that.data.couponsKey] }else{ var discountPrice =0; } sumPrice -= parseFloat(discountPrice); } else { discountPrice = 0; } //会员卡折扣 if (vipD>0) {//that.data.score.discount > 0 var mdiscountPrice = parseFloat(vipD).toFixed(2);//that.data.score.discountPrice sumPrice -= mdiscountPrice; } if (appointPrice > 0){ sumPrice -= appointPrice; } if (''=='1') {//that.data.Info.proInfo.paytype == 1 var paytype = 1; } else if ('' == 2) { var paytype = 2; } else { var paytype = 3; } sumPrice= parseFloat(sumPrice).toFixed(2); return sumPrice; }