| | |
| | | }); |
| | | |
| | | /** |
| | | * 下一步:跳转到价格配置 |
| | | * 下一步:切换到价格配置 |
| | | */ |
| | | TSite.nextStep = function() { |
| | | // 验证基本信息是否填写完整 |
| | | var storeName = $("#name").val(); |
| | | if (!storeName) { |
| | | Feng.error("请先填写场地名称!"); |
| | | var siteName = $("#name").val(); |
| | | |
| | | // 验证场地名称 |
| | | if (!siteName) { |
| | | Feng.error("请输入场地名称!"); |
| | | return; |
| | | } |
| | | |
| | | var insuranceEndTime = $("#insuranceEndTime").val(); |
| | | if (!insuranceEndTime) { |
| | | Feng.error("请先填写场地责任险有效期!"); |
| | | // 这些将在步骤二中配置 |
| | | var isHalf = 2; // 默认不可预定半场 |
| | | var nextNames = []; |
| | | var halfNames = []; |
| | | |
| | | // 保存信息到全局变量 |
| | | TSite.priceConfig = { |
| | | siteName: siteName, |
| | | isHalf: isHalf, |
| | | nextNames: nextNames, |
| | | halfNames: halfNames, |
| | | timeSlots: [], |
| | | priceData: {} |
| | | }; |
| | | |
| | | // 显示场地信息 |
| | | $("#display_site_name").text(siteName); |
| | | $("#display_next_names").html(""); // 清空 |
| | | $("#display_half_names").html(""); // 清空 |
| | | |
| | | // 切换步骤,仅依赖CSS的active class |
| | | $("#step1_basic_info").removeClass('active'); |
| | | $("#step2_price_config").addClass('active'); |
| | | |
| | | // 初始化价格配置 |
| | | TSite.initPriceConfig(); |
| | | |
| | | // 滚动到顶部 |
| | | $('html, body').animate({scrollTop: 0}, 300); |
| | | } |
| | | |
| | | /** |
| | | * 上一步:返回基本信息 |
| | | */ |
| | | TSite.previousStep = function() { |
| | | // 切换步骤,仅依赖CSS的active class |
| | | $("#step2_price_config").removeClass('active'); |
| | | $("#step1_basic_info").addClass('active'); |
| | | |
| | | // 滚动到顶部 |
| | | $('html, body').animate({scrollTop: 0}, 300); |
| | | } |
| | | |
| | | /** |
| | | * 初始化价格配置 |
| | | */ |
| | | TSite.initPriceConfig = function() { |
| | | // 初始化计数器 |
| | | TSite.bookingRowIndex = 0; |
| | | TSite.walkinRowIndex = 0; |
| | | |
| | | // 清空价格表 |
| | | $("#booking_price_tbody").empty(); |
| | | $("#walkin_price_tbody").empty(); |
| | | |
| | | // 隐藏价格表区域 |
| | | $("#booking_section").hide(); |
| | | $("#walkin_section").hide(); |
| | | |
| | | // 标记价格表未生成 |
| | | TSite.priceTablesGenerated = false; |
| | | |
| | | // 初始化是否可预定半场状态 |
| | | var isHalf = TSite.priceConfig ? TSite.priceConfig.isHalf : 2; |
| | | |
| | | if (isHalf == 1) { |
| | | $("input[name='ishalf_step2'][value='1']").prop('checked', true); |
| | | $("#halfCode_step2").show(); |
| | | } else { |
| | | $("input[name='ishalf_step2'][value='2']").prop('checked', true); |
| | | $("#halfCode_step2").hide(); |
| | | } |
| | | |
| | | // 监听人群选择变化 |
| | | $("#audience_booking, #audience_walkin").off('change').on('change', function() { |
| | | TSite.updateAudienceUI(); |
| | | // 如果价格表已生成,提示需要重新生成 |
| | | if (TSite.priceTablesGenerated) { |
| | | TSite.clearPriceTables(); |
| | | } |
| | | }); |
| | | |
| | | // 更新界面(但不显示价格表) |
| | | TSite.updateAudienceUI(); |
| | | } |
| | | |
| | | /** |
| | | * 生成价格表 |
| | | */ |
| | | TSite.generatePriceTables = function() { |
| | | // 验证人群选择 |
| | | var bookingChecked = $("#audience_booking").is(':checked'); |
| | | var walkinChecked = $("#audience_walkin").is(':checked'); |
| | | |
| | | if (!bookingChecked && !walkinChecked) { |
| | | Feng.error("请至少选择一种面向人群!"); |
| | | return; |
| | | } |
| | | |
| | | // 提示:需要先保存基本信息 |
| | | Feng.info("请先点击【提交】按钮保存场地基本信息,保存成功后在编辑页面进行价格配置!"); |
| | | }; |
| | | // 验证容纳散客数 |
| | | if (walkinChecked) { |
| | | var walkinCapacity = $("#walkin_capacity").val(); |
| | | if (!walkinCapacity || parseInt(walkinCapacity) <= 0) { |
| | | Feng.error("请输入有效的容纳散客数!"); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | // 清除现有价格表 |
| | | TSite.clearPriceTables(); |
| | | |
| | | // 生成表头 |
| | | TSite.buildTableHeaders(); |
| | | |
| | | // 显示对应的价格表区域 |
| | | if (bookingChecked) { |
| | | $("#booking_section").show(); |
| | | } |
| | | if (walkinChecked) { |
| | | $("#walkin_section").show(); |
| | | } |
| | | |
| | | // 标记价格表已生成 |
| | | TSite.priceTablesGenerated = true; |
| | | |
| | | Feng.success("价格表已生成,请添加时段并填写价格!"); |
| | | } |
| | | |
| | | /** |
| | | * 清除价格表 |
| | | */ |
| | | TSite.clearPriceTables = function() { |
| | | // 清空价格表内容 |
| | | $("#booking_price_tbody").empty(); |
| | | $("#walkin_price_tbody").empty(); |
| | | |
| | | // 隐藏价格表区域 |
| | | $("#booking_section").hide(); |
| | | $("#walkin_section").hide(); |
| | | |
| | | // 重置计数器 |
| | | TSite.bookingRowIndex = 0; |
| | | TSite.walkinRowIndex = 0; |
| | | |
| | | // 标记价格表未生成 |
| | | TSite.priceTablesGenerated = false; |
| | | |
| | | Feng.info("价格配置已清除,请重新生成价格表!"); |
| | | } |
| | | |
| | | /** |
| | | * 添加场地名 |
| | | */ |
| | | TSite.addFieldBox = function() { |
| | | var html = '<div class="field-item">' + |
| | | '<label>*单个场地名</label>' + |
| | | '<input type="text" name="name1_step2" class="form-control" style="flex:1;margin-right:10px;" placeholder="请输入场地名"/>' + |
| | | '<i class="fa fa-remove btn-remove" onclick="TSite.removeFieldBox(this)"></i>' + |
| | | '</div>'; |
| | | $("#field_container").append(html); |
| | | } |
| | | |
| | | /** |
| | | * 删除场地名 |
| | | */ |
| | | TSite.removeFieldBox = function(btn) { |
| | | $(btn).closest('.field-item').remove(); |
| | | } |
| | | |
| | | /** |
| | | * 添加半场名称 |
| | | */ |
| | | TSite.addHalfFieldBox = function() { |
| | | var html = '<div class="field-item">' + |
| | | '<label>*半场名称</label>' + |
| | | '<input type="text" name="name2_step2" class="form-control" style="flex:1;margin-right:10px;" placeholder="请输入半场名称"/>' + |
| | | '<i class="fa fa-remove btn-remove" onclick="TSite.removeHalfFieldBox(this)"></i>' + |
| | | '</div>'; |
| | | $("#half_field_container").append(html); |
| | | } |
| | | |
| | | /** |
| | | * 删除半场名称 |
| | | */ |
| | | TSite.removeHalfFieldBox = function(btn) { |
| | | $(btn).closest('.field-item').remove(); |
| | | } |
| | | |
| | | /** |
| | | * 更新半场字段显示 |
| | | */ |
| | | TSite.updateHalfField = function(value) { |
| | | if (value == 1) { |
| | | $("#halfCode_step2").show(); |
| | | // 更新isHalf |
| | | TSite.priceConfig.isHalf = 1; |
| | | } else { |
| | | $("#halfCode_step2").hide(); |
| | | TSite.priceConfig.isHalf = 2; |
| | | } |
| | | |
| | | // 如果价格表已生成,清除价格表 |
| | | if (TSite.priceTablesGenerated) { |
| | | TSite.clearPriceTables(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新人群相关UI |
| | | */ |
| | | TSite.updateAudienceUI = function() { |
| | | var walkinChecked = $("#audience_walkin").is(':checked'); |
| | | |
| | | // 只控制容纳散客数字段的显示/隐藏 |
| | | // 价格表的显示由生成按钮控制 |
| | | if (walkinChecked) { |
| | | $("#walkin_capacity_group").show(); |
| | | } else { |
| | | $("#walkin_capacity_group").hide(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 构建表头 |
| | | */ |
| | | TSite.buildTableHeaders = function() { |
| | | var isHalf = TSite.priceConfig ? TSite.priceConfig.isHalf : 2; |
| | | |
| | | var headerHtml = '<tr>' + |
| | | '<th rowspan="3" width="120">时段开始</th>' + |
| | | '<th rowspan="3" width="120">时段结束</th>'; |
| | | |
| | | // 周一到周日的表头 |
| | | var weekDays = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']; |
| | | |
| | | if (isHalf == 1) { |
| | | // 如果可预订半场,每天有4列(全场×2 + 半场×2) |
| | | for (var i = 0; i < weekDays.length; i++) { |
| | | headerHtml += '<th colspan="4">' + weekDays[i] + '</th>'; |
| | | } |
| | | headerHtml += '<th rowspan="3" width="80">操作</th>' + |
| | | '</tr>' + |
| | | '<tr>'; |
| | | |
| | | // 第二行:全场/半场 |
| | | for (var i = 0; i < weekDays.length; i++) { |
| | | headerHtml += '<th colspan="2">全场</th>' + |
| | | '<th colspan="2">半场</th>'; |
| | | } |
| | | headerHtml += '</tr>' + |
| | | '<tr>'; |
| | | |
| | | // 第三行:现金/玩湃币 |
| | | for (var i = 0; i < weekDays.length; i++) { |
| | | headerHtml += '<th width="80">现金</th>' + |
| | | '<th width="80">玩湃币</th>' + |
| | | '<th width="80">现金</th>' + |
| | | '<th width="80">玩湃币</th>'; |
| | | } |
| | | } else { |
| | | // 如果不可预订半场,每天有2列(全场×2) |
| | | for (var i = 0; i < weekDays.length; i++) { |
| | | headerHtml += '<th colspan="2">' + weekDays[i] + '</th>'; |
| | | } |
| | | headerHtml += '<th rowspan="3" width="80">操作</th>' + |
| | | '</tr>' + |
| | | '<tr>'; |
| | | |
| | | // 第二行:全场 |
| | | for (var i = 0; i < weekDays.length; i++) { |
| | | headerHtml += '<th colspan="2">全场</th>'; |
| | | } |
| | | headerHtml += '</tr>' + |
| | | '<tr>'; |
| | | |
| | | // 第三行:现金/玩湃币 |
| | | for (var i = 0; i < weekDays.length; i++) { |
| | | headerHtml += '<th width="80">现金</th>' + |
| | | '<th width="80">玩湃币</th>'; |
| | | } |
| | | } |
| | | |
| | | headerHtml += '</tr>'; |
| | | |
| | | // 设置表头 |
| | | $("#booking_thead").html(headerHtml); |
| | | $("#walkin_thead").html(headerHtml); |
| | | } |
| | | |
| | | /** |
| | | * 添加订场时段 |
| | | */ |
| | | TSite.addBookingTimeSlot = function() { |
| | | var isHalf = TSite.priceConfig ? TSite.priceConfig.isHalf : 2; |
| | | var index = TSite.bookingRowIndex++; |
| | | |
| | | var html = '<tr data-index="' + index + '">' + |
| | | '<td><input type="time" class="form-control" id="booking_start_' + index + '" value="09:00"></td>' + |
| | | '<td><input type="time" class="form-control" id="booking_end_' + index + '" value="10:00"></td>'; |
| | | |
| | | // 周一到周日,每天的价格输入框 |
| | | for (var day = 1; day <= 7; day++) { |
| | | if (isHalf == 1) { |
| | | // 全场现金、全场玩湃币、半场现金、半场玩湃币 |
| | | html += '<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_full_cash" min="0" step="0.01" placeholder="0"></td>' + |
| | | '<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_full_coin" min="0" step="0.01" placeholder="0"></td>' + |
| | | '<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_half_cash" min="0" step="0.01" placeholder="0"></td>' + |
| | | '<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_half_coin" min="0" step="0.01" placeholder="0"></td>'; |
| | | } else { |
| | | // 全场现金、全场玩湃币 |
| | | html += '<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_full_cash" min="0" step="0.01" placeholder="0"></td>' + |
| | | '<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_full_coin" min="0" step="0.01" placeholder="0"></td>'; |
| | | } |
| | | } |
| | | |
| | | html += '<td><button type="button" class="btn btn-sm btn-danger" onclick="TSite.removeTimeSlot(this)"><i class="fa fa-trash"></i></button></td>' + |
| | | '</tr>'; |
| | | |
| | | $("#booking_price_tbody").append(html); |
| | | } |
| | | |
| | | /** |
| | | * 添加散客时段 |
| | | */ |
| | | TSite.addWalkinTimeSlot = function() { |
| | | var isHalf = TSite.priceConfig ? TSite.priceConfig.isHalf : 2; |
| | | var index = TSite.walkinRowIndex++; |
| | | |
| | | var html = '<tr data-index="' + index + '">' + |
| | | '<td><input type="time" class="form-control" id="walkin_start_' + index + '" value="09:00"></td>' + |
| | | '<td><input type="time" class="form-control" id="walkin_end_' + index + '" value="10:00"></td>'; |
| | | |
| | | // 周一到周日,每天的价格输入框 |
| | | for (var day = 1; day <= 7; day++) { |
| | | if (isHalf == 1) { |
| | | // 全场现金、全场玩湃币、半场现金、半场玩湃币 |
| | | html += '<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_full_cash" min="0" step="0.01" placeholder="0"></td>' + |
| | | '<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_full_coin" min="0" step="0.01" placeholder="0"></td>' + |
| | | '<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_half_cash" min="0" step="0.01" placeholder="0"></td>' + |
| | | '<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_half_coin" min="0" step="0.01" placeholder="0"></td>'; |
| | | } else { |
| | | // 全场现金、全场玩湃币 |
| | | html += '<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_full_cash" min="0" step="0.01" placeholder="0"></td>' + |
| | | '<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_full_coin" min="0" step="0.01" placeholder="0"></td>'; |
| | | } |
| | | } |
| | | |
| | | html += '<td><button type="button" class="btn btn-sm btn-danger" onclick="TSite.removeTimeSlot(this)"><i class="fa fa-trash"></i></button></td>' + |
| | | '</tr>'; |
| | | |
| | | $("#walkin_price_tbody").append(html); |
| | | } |
| | | |
| | | /** |
| | | * 删除时段 |
| | | */ |
| | | TSite.removeTimeSlot = function(btn) { |
| | | $(btn).closest('tr').remove(); |
| | | } |
| | | |
| | | /** |
| | | * 保存所有数据(基本信息+价格配置) |
| | | */ |
| | | TSite.saveAllData = function() { |
| | | // 验证价格表是否已生成 |
| | | if (!TSite.priceTablesGenerated) { |
| | | Feng.error("请先点击【生成价格表】按钮生成价格配置表!"); |
| | | return; |
| | | } |
| | | |
| | | // 验证人群选择 |
| | | var bookingChecked = $("#audience_booking").is(':checked'); |
| | | var walkinChecked = $("#audience_walkin").is(':checked'); |
| | | |
| | | if (!bookingChecked && !walkinChecked) { |
| | | Feng.error("请至少选择一种面向人群!"); |
| | | return; |
| | | } |
| | | |
| | | // 验证容纳散客数 |
| | | if (walkinChecked) { |
| | | var walkinCapacity = parseInt($("#walkin_capacity").val()); |
| | | if (!walkinCapacity || walkinCapacity <= 0) { |
| | | Feng.error("请输入有效的容纳散客数!"); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | // 收集价格数据 |
| | | var priceDetails = TSite.collectPriceData(); |
| | | |
| | | if (priceDetails.length === 0) { |
| | | Feng.error("请至少添加一个时段并填写价格!"); |
| | | return; |
| | | } |
| | | |
| | | // 收集基本信息数据 |
| | | var basicData = TSite.collectBasicData(); |
| | | if (!basicData) { |
| | | return; // 基本信息验证失败 |
| | | } |
| | | |
| | | // 收集场地配置 |
| | | var nextNames = []; |
| | | $("input[name='name1_step2']").each(function() { |
| | | var val = $(this).val(); |
| | | if (val) { |
| | | nextNames.push(val); |
| | | } |
| | | }); |
| | | |
| | | var halfNames = []; |
| | | $("input[name='name2_step2']").each(function() { |
| | | var val = $(this).val(); |
| | | if (val) { |
| | | halfNames.push(val); |
| | | } |
| | | }); |
| | | |
| | | var isHalf = $("input[name='ishalf_step2']:checked").val(); |
| | | |
| | | // 构建提交数据 |
| | | var targetAudience = []; |
| | | if (bookingChecked) targetAudience.push('1'); |
| | | if (walkinChecked) targetAudience.push('2'); |
| | | |
| | | // 合并基本信息和价格配置 |
| | | basicData.targetAudience = targetAudience.join(','); |
| | | basicData.walkinCapacity = walkinChecked ? parseInt($("#walkin_capacity").val()) : 0; |
| | | basicData.nextName = nextNames.join(','); |
| | | basicData.halfName = halfNames.join(','); |
| | | basicData.isHalf = parseInt(isHalf); |
| | | basicData.priceDetails = priceDetails; |
| | | |
| | | // 确认提交 |
| | | layer.confirm('确定要保存场地信息吗?', { |
| | | btn: ['确定', '取消'] |
| | | }, function(index) { |
| | | layer.close(index); |
| | | |
| | | // 提交到后端 |
| | | $.ajax({ |
| | | url: Feng.ctxPath + "/tSite/addSite", |
| | | type: "POST", |
| | | data: JSON.stringify(basicData), |
| | | contentType: "application/json", |
| | | success: function(response) { |
| | | Feng.success("场地信息保存成功!"); |
| | | // 刷新列表 |
| | | if (window.parent.TSite && window.parent.TSite.table) { |
| | | window.parent.TSite.table.refresh(); |
| | | } |
| | | // 关闭页面 |
| | | setTimeout(function() { |
| | | TSite.close(); |
| | | }, 1500); |
| | | }, |
| | | error: function(xhr, status, error) { |
| | | var errorMsg = "保存失败"; |
| | | if (xhr.responseJSON && xhr.responseJSON.message) { |
| | | errorMsg = xhr.responseJSON.message; |
| | | } |
| | | Feng.error(errorMsg); |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 收集基本信息数据 |
| | | */ |
| | | TSite.collectBasicData = function() { |
| | | var data = { |
| | | province:"", |
| | | city:"", |
| | | cityManagerId:"", |
| | | storeId:"", |
| | | siteTypeId:null, |
| | | appointmentStartTime:"", |
| | | appointmentEndTime:"", |
| | | cashPrice:null, |
| | | playPaiCoin:null, |
| | | insuranceEndTime:"", |
| | | name:"", |
| | | insuranceImg:"", |
| | | managementPlan:"", |
| | | operatorId:"", |
| | | typeName:"", |
| | | nextName:"", |
| | | ishalf:"", |
| | | cashPriceOne:"", |
| | | playPaiCoinOne:"", |
| | | halfName:"", |
| | | introduce:"", |
| | | imgs:"", |
| | | reservation:"", |
| | | isCanBeBooked:"", |
| | | type:"", |
| | | }; |
| | | |
| | | data.province = $("#pCode").val() |
| | | data.city = $("#cCode").val() |
| | | data.cityManagerId = $("#account").val() |
| | | data.storeId = $("#store").val() |
| | | data.siteTypeId = $("#siteTypeId").val() |
| | | data.appointmentStartTime= $("#start-time").val() |
| | | data.appointmentEndTime = $("#end-time").val() |
| | | data.cashPrice = $("#cashPrice").val() |
| | | data.playPaiCoin = $("#playPaiCoin").val() |
| | | data.insuranceEndTime = $("#insuranceEndTime").val() |
| | | data.name = $("#name").val() |
| | | data.insuranceImg = $("#img").val() |
| | | data.managementPlan = $('#courseVideo').val() |
| | | data.typeName = $('#siteTypeOne').val() |
| | | |
| | | var reservation= $("input[name='reservation']:checked").val(); |
| | | data.reservation= reservation; |
| | | data.isCanBeBooked= reservation; |
| | | |
| | | var checkbox = document.querySelector('input[name="pt"]'); |
| | | if (checkbox!=null){ |
| | | if (checkbox.checked) { |
| | | data.type = 1 |
| | | data.operatorId = 0; |
| | | } else { |
| | | data.type = 2; |
| | | } |
| | | } |
| | | |
| | | var SelectValue=""; |
| | | var getSelectValueMenbers = $("input[name='pt']:checked").each(function(j) { |
| | | if (j >= 0) { |
| | | SelectValue += $(this).val() |
| | | } |
| | | }); |
| | | if(SelectValue==''){ |
| | | let yys = $("#yys").val() |
| | | if(yys==""){ |
| | | Feng.info("请选择运营商") |
| | | return null; |
| | | } |
| | | SelectValue= yys |
| | | } |
| | | data.operatorId= SelectValue; |
| | | |
| | | let introduce = ""; |
| | | var objectType = $("#objectType").val(); |
| | | if (objectType==1){ |
| | | introduce = TSite.editor.getContent(); |
| | | if(introduce==""){ |
| | | Feng.info("请输入公告内容") |
| | | return null; |
| | | } |
| | | } |
| | | data.introduce= introduce; |
| | | |
| | | var goodImgs = this.goodsPicArray; |
| | | if(objectType==1){ |
| | | if(goodImgs.length==0){ |
| | | Feng.info("请上传实景图") |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | var imgOne =""; |
| | | for (let i = 0; i <goodImgs.length; i++) { |
| | | if(i==goodImgs.length-1){ |
| | | imgOne += (goodImgs[i].response) |
| | | }else { |
| | | imgOne+=(goodImgs[i].response+",") |
| | | } |
| | | } |
| | | data.imgs = imgOne |
| | | |
| | | // 基本验证 |
| | | if($("#store").val()=='' ){ |
| | | Feng.info("请选择门店") |
| | | return null; |
| | | } |
| | | if($("#siteTypeId").val()=='' ){ |
| | | Feng.info("请选择场地分类") |
| | | return null; |
| | | } |
| | | if($("#name").val()==''){ |
| | | Feng.info("请输入场地名称") |
| | | return null; |
| | | } |
| | | if($("#insuranceEndTime").val()==''){ |
| | | Feng.info("请输入场地责任险有效期") |
| | | return null; |
| | | } |
| | | if($("#img").val()==''){ |
| | | Feng.info("请上传场地责任有效期图片") |
| | | return null; |
| | | } |
| | | if($('#courseVideo').val()==''){ |
| | | Feng.info("请上传消防及应急管理方案") |
| | | return null; |
| | | } |
| | | |
| | | return data; |
| | | } |
| | | |
| | | /** |
| | | * 收集价格数据 |
| | | */ |
| | | TSite.collectPriceData = function() { |
| | | var priceDetails = []; |
| | | var isHalf = TSite.priceConfig ? TSite.priceConfig.isHalf : 2; |
| | | var bookingChecked = $("#audience_booking").is(':checked'); |
| | | var walkinChecked = $("#audience_walkin").is(':checked'); |
| | | |
| | | // 收集订场价格 |
| | | if (bookingChecked) { |
| | | $("#booking_price_tbody tr").each(function() { |
| | | var index = $(this).data('index'); |
| | | var startTime = $("#booking_start_" + index).val(); |
| | | var endTime = $("#booking_end_" + index).val(); |
| | | |
| | | // 验证时段 |
| | | if (!startTime || !endTime) { |
| | | Feng.error("订场价格配置中存在空的时段!"); |
| | | return false; |
| | | } |
| | | |
| | | if (startTime >= endTime) { |
| | | Feng.error("订场价格配置中,结束时间必须大于开始时间!"); |
| | | return false; |
| | | } |
| | | |
| | | // 遍历周一到周日 |
| | | for (var day = 1; day <= 7; day++) { |
| | | var fullCash = parseFloat($("#booking_" + index + "_" + day + "_full_cash").val() || 0); |
| | | var fullCoin = parseFloat($("#booking_" + index + "_" + day + "_full_coin").val() || 0); |
| | | |
| | | // 全场价格 |
| | | if (fullCash > 0 || fullCoin > 0) { |
| | | priceDetails.push({ |
| | | startTime: startTime, |
| | | endTime: endTime, |
| | | dayOfWeek: day, |
| | | targetAudience: 1, |
| | | fieldType: 'full', |
| | | cashPrice: fullCash, |
| | | coinPrice: fullCoin |
| | | }); |
| | | } |
| | | |
| | | // 半场价格(如果可预订半场) |
| | | if (isHalf == 1) { |
| | | var halfCash = parseFloat($("#booking_" + index + "_" + day + "_half_cash").val() || 0); |
| | | var halfCoin = parseFloat($("#booking_" + index + "_" + day + "_half_coin").val() || 0); |
| | | |
| | | if (halfCash > 0 || halfCoin > 0) { |
| | | priceDetails.push({ |
| | | startTime: startTime, |
| | | endTime: endTime, |
| | | dayOfWeek: day, |
| | | targetAudience: 1, |
| | | fieldType: 'half', |
| | | cashPrice: halfCash, |
| | | coinPrice: halfCoin |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 收集散客价格 |
| | | if (walkinChecked) { |
| | | $("#walkin_price_tbody tr").each(function() { |
| | | var index = $(this).data('index'); |
| | | var startTime = $("#walkin_start_" + index).val(); |
| | | var endTime = $("#walkin_end_" + index).val(); |
| | | |
| | | // 验证时段 |
| | | if (!startTime || !endTime) { |
| | | Feng.error("散客价格配置中存在空的时段!"); |
| | | return false; |
| | | } |
| | | |
| | | if (startTime >= endTime) { |
| | | Feng.error("散客价格配置中,结束时间必须大于开始时间!"); |
| | | return false; |
| | | } |
| | | |
| | | // 遍历周一到周日 |
| | | for (var day = 1; day <= 7; day++) { |
| | | var fullCash = parseFloat($("#walkin_" + index + "_" + day + "_full_cash").val() || 0); |
| | | var fullCoin = parseFloat($("#walkin_" + index + "_" + day + "_full_coin").val() || 0); |
| | | |
| | | // 全场价格 |
| | | if (fullCash > 0 || fullCoin > 0) { |
| | | priceDetails.push({ |
| | | startTime: startTime, |
| | | endTime: endTime, |
| | | dayOfWeek: day, |
| | | targetAudience: 2, |
| | | fieldType: 'full', |
| | | cashPrice: fullCash, |
| | | coinPrice: fullCoin |
| | | }); |
| | | } |
| | | |
| | | // 半场价格(如果可预订半场) |
| | | if (isHalf == 1) { |
| | | var halfCash = parseFloat($("#walkin_" + index + "_" + day + "_half_cash").val() || 0); |
| | | var halfCoin = parseFloat($("#walkin_" + index + "_" + day + "_half_coin").val() || 0); |
| | | |
| | | if (halfCash > 0 || halfCoin > 0) { |
| | | priceDetails.push({ |
| | | startTime: startTime, |
| | | endTime: endTime, |
| | | dayOfWeek: day, |
| | | targetAudience: 2, |
| | | fieldType: 'half', |
| | | cashPrice: halfCash, |
| | | coinPrice: halfCoin |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | return priceDetails; |
| | | }; |