/** * 用户详情对话框(可用于添加和修改对话框) */ var CoursePackageInfo = { goodsPicArray1:[], userInfoData: {}, goodsPicArray: [], }; /** * 关闭此对话框 */ CoursePackageInfo.close = function () { parent.layer.close(window.parent.CoursePackage.layerIndex); }; CoursePackageInfo.openDia = function (i) { let index = layer.open({ type: 2, title: '编辑', area: ['80%', '80%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/coursePackage/conpun/'+i }); this.layerIndex = index; }; CoursePackageInfo.openDia1 = function (i) { var ids = $("#counpons"+i).val() console.log($("#counpons"+i).val()) let index = layer.open({ type: 2, title: '编辑', area: ['80%', '80%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/coursePackage/conpun1'+'/'+i+'?conpunids='+ids }); this.layerIndex = index; }; /** * 提交添加用户 */ CoursePackageInfo.addSubmit = function () { let objectType= $('#objectType').val(); console.log("看看角色类型") console.log(objectType) let province = $('#provinceCode option:checked').text(); let provinceCode = $('#provinceCode').val(); let city = $('#cityCode option:checked').text(); let cityCode = $('#cityCode').val(); let storeId = $('#storeId').val(); let coursePackageTypeId = $('#coursePackageTypeId').val(); let name = $('#name').val(); let siteId = $('#siteId').val(); let coachId = $('#coachId').val(); let maxSubscribeNumber = $('#maxSubscribeNumber').val(); let codeTime = $('#codeTime').val(); let type = $('#type').val(); let holitime = $('#holitime').val(); console.log("=======这是type======"+type) var goodImgs = CoursePackageInfo.goodsPicArray1; if(goodImgs.length==0){ Feng.info("请上传详情图片") return; } var imgOne =""; for (let i = 0; i .form-group').each(function (i, e) { let classHours = $($(e).find(".classNumber_span input[class='classNumber']")[0]).val(); let cash = $($(e).find(".cash_span input[class='cash']")[0]).val(); if (typeof cash == "undefined"){ console.log("========进入===") } let paiCoin = $($(e).find(".paiCoin_span input[class='paiCoin']")[0]).val(); let counpons = $($(e).find(".counpons")).val(); price.push({ classHours: classHours, cashPayment: typeof cash == "undefined" ? 0 : cash, playPaiCoin: typeof paiCoin == "undefined" ? 0 : paiCoin, couponIds: typeof counpons == "undefined" ? 0 : counpons }); }); if (objectType==1){ if(null == provinceCode || '' == provinceCode){ Feng.error("所在省不能为空"); return } if(null == cityCode || '' == cityCode){ Feng.error("所在市不能为空"); return } } if(null == storeId || '' == storeId){ Feng.error("所属门店不能为空"); return } if(null == coursePackageTypeId || '' == coursePackageTypeId){ Feng.error("课程类型不能为空"); return } if(null == name || '' == name){ Feng.error("课包名称不能为空"); return } if(null == siteId || '' == siteId){ Feng.error("上课场地不能为空"); return } if(null == coachId || '' == coachId){ Feng.error("授课教师不能为空"); return } var checkboxes1 = document.getElementsByName('payType'); var isChecked1 = false; for (var i = 0; i < checkboxes1.length; i++) { if (checkboxes1[i].checked) { isChecked1 = true; break; } } console.log("看看选中") console.log(isChecked1) if (isChecked1) { console.log("At least one checkbox is selected."); } else { Feng.error("请选择支付方式") return; } var checkboxes = document.getElementsByName('payType'); var isChecked = false; var isChecked1 = false; for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked && checkboxes[i].value === '1') { isChecked = true; break; } } for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked && checkboxes[i].value === '2') { isChecked1 = true; break; } } if (isChecked1) { var elements3 = document.getElementsByClassName('paiCoin'); for (var i = 0; i < elements3.length; i++) { var value = elements3[i].value.trim(); if (value === '') { Feng.error("请输入玩湃币价格") return; // Value is empty // Perform your desired action } else { // Value is not empty // Perform other actions } } } if (isChecked) { var elements2 = document.getElementsByClassName('cash'); for (var i = 0; i < elements2.length; i++) { var value = elements2[i].value.trim(); if (value === '') { Feng.error("请输入现金价格") return; // Value is empty // Perform your desired action } else { // Value is not empty // Perform other actions } } } if (type == 1 ) { var elements1 = document.getElementsByClassName('classNumber'); for (var i = 0; i < elements1.length; i++) { var value = elements1[i].value.trim(); if (value === '') { Feng.error("请输入课时数") return; // Value is empty // Perform your desired action } else { // Value is not empty // Perform other actions } } var elements = document.querySelectorAll('[name="classStartTime"]'); var isEmpty = false; for (var i = 0; i < elements.length; i++) { if (elements[i].value.trim() === '') { isEmpty = true; break; } } if (isEmpty) { Feng.error("请输入上课时间") return; console.log("At least one element with the name 'yourName' is empty."); } else { console.log("All elements with the name 'yourName' are filled."); } if (null == maxSubscribeNumber || '' == maxSubscribeNumber) { Feng.error("最多预约人数不能为空"); return } if (null == codeTime || '' == codeTime) { Feng.error("扣除课时数不能为空"); return } if (null == classStartTime || '' == classStartTime) { Feng.error("上课时间不能为空"); return } if (null == classWeeks || '' == classWeeks) { Feng.error("上课时间不能为空"); return } if (null == validDays || '' == validDays) { Feng.error("课时有效期不能为空"); return } } classWeeks = classWeeks.substring(0, classWeeks.length - 1); if(null == coverDrawing || '' == coverDrawing){ Feng.error("课包封面不能为空"); return } if(null == introduceDrawing || '' == introduceDrawing){ Feng.error("课包介绍不能为空"); return } let obj = { province: province, provinceCode: provinceCode, city: city, cityCode: cityCode, storeId: storeId, coursePackageTypeId: coursePackageTypeId, name: name, siteId: siteId, coachId: coachId, maxSubscribeNumber: maxSubscribeNumber, classStartTime: classStartTime, codeTime:codeTime, // classStartTime: classStartTime.split(" - ")[0], // classEndTime: classStartTime.split(" - ")[1], classWeeks: classWeeks, coverDrawing: coverDrawing, detailDrawing: imgOne, introduceDrawing: introduceDrawing, sort: sort, validDays: validDays, coursePackagePaymentConfig: JSON.stringify(price), type:type, holitime:holitime } //提交信息 var ajax = new $ax(Feng.ctxPath + "/coursePackage/addCoursePackage", function (data) { if(data.code == 200){ Feng.success("添加成功!"); CoursePackageInfo.close(); window.parent.CoursePackage.table.refresh(); }else{ Feng.error(data.msg); } }, function (data) { Feng.error("添加失败!" + data.responseJSON.message + "!"); }); ajax.set(obj); ajax.start(); }; /** * 提交修改 */ CoursePackageInfo.editSubmit = function () { let id = $('#id').val(); let province = $('#provinceCode option:checked').text(); let provinceCode = $('#provinceCode').val(); let city = $('#cityCode option:checked').text(); let cityCode = $('#cityCode').val(); let storeId = $('#storeId').val(); let coursePackageTypeId = $('#coursePackageTypeId').val(); let name = $('#name').val(); let siteId = $('#siteId').val(); let coachId = $('#coachId').val(); let maxSubscribeNumber = $('#maxSubscribeNumber').val(); let codeTime = $('#codeTime').val(); let type = $('#type').val(); var goodImgs = CoursePackageInfo.goodsPicArray1; // if(goodImgs.length==0){ // Feng.info("请上传赛事活动图片") // return; // } var imgOne =""; for (let i = 0; i .form-group').each(function (i, e) { let classHours = $($(e).find(".classNumber_span input[class='classNumber']")[0]).val(); let cash = $($(e).find(".cash_span input[class='cash']")[0]).val(); let paiCoin = $($(e).find(".paiCoin_span input[class='paiCoin']")[0]).val(); let counpons = $($(e).find(".counpons")).val(); price.push({ classHours: classHours, cashPayment: typeof cash == "undefined" ? 0 : cash, playPaiCoin: typeof paiCoin == "undefined" ? 0 : paiCoin, couponIds: typeof counpons == "undefined" ? 0 : counpons }) }); if ($('#objectType').val() == 1) { if (null == provinceCode || '' == provinceCode) { Feng.error("所在省不能为空"); return } if (null == cityCode || '' == cityCode) { Feng.error("所在市不能为空"); return } } if(null == storeId || '' == storeId){ Feng.error("所属门店不能为空"); return } if(null == coursePackageTypeId || '' == coursePackageTypeId){ Feng.error("课程类型不能为空"); return } if(null == name || '' == name){ Feng.error("课包名称不能为空"); return } if(null == siteId || '' == siteId){ Feng.error("上课场地不能为空"); return } if(null == coachId || '' == coachId){ Feng.error("授课教师不能为空"); return } // if(null == maxSubscribeNumber || '' == maxSubscribeNumber){ // Feng.error("最多预约人数不能为空"); // return // } // if(null == codeTime || '' == codeTime){ // Feng.error("扣除课时不能为空"); // return // } // if(null == classStartTime || '' == classStartTime){ // Feng.error("上课时间不能为空"); // return // } // if(null == classWeeks || '' == classWeeks){ // Feng.error("周不能为空"); // return // } if (type == 1 ) { var checkboxes1 = document.getElementsByName('payType'); var isChecked1 = false; for (var i = 0; i < checkboxes1.length; i++) { if (checkboxes1[i].checked) { isChecked1 = true; break; } } if (isChecked1) { console.log("At least one checkbox is selected."); } else { Feng.error("请选择支付方式") return; } var checkboxes = document.getElementsByName('payType'); var isChecked = false; var isChecked1 = false; for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked && checkboxes[i].value === '1') { isChecked = true; break; } } for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked && checkboxes[i].value === '2') { isChecked1 = true; break; } } if (isChecked1) { var elements3 = document.getElementsByClassName('paiCoin'); for (var i = 0; i < elements3.length; i++) { var value = elements3[i].value.trim(); if (value === '') { Feng.error("请输入玩湃币价格") return; // Value is empty // Perform your desired action } else { // Value is not empty // Perform other actions } } } if (isChecked) { var elements2 = document.getElementsByClassName('cash'); for (var i = 0; i < elements2.length; i++) { var value = elements2[i].value.trim(); if (value === '') { Feng.error("请输入现金价格") return; // Value is empty // Perform your desired action } else { // Value is not empty // Perform other actions } } } var elements1 = document.getElementsByClassName('classNumber'); for (var i = 0; i < elements1.length; i++) { var value = elements1[i].value.trim(); if (value === '') { Feng.error("请输入课时数") return; // Value is empty // Perform your desired action } else { // Value is not empty // Perform other actions } } var elements = document.querySelectorAll('[name="classStartTime"]'); var isEmpty = false; for (var i = 0; i < elements.length; i++) { if (elements[i].value.trim() === '') { isEmpty = true; break; } } if (isEmpty) { Feng.error("请输入上课时间") return; console.log("At least one element with the name 'yourName' is empty."); } else { console.log("All elements with the name 'yourName' are filled."); } if (null == maxSubscribeNumber || '' == maxSubscribeNumber) { Feng.error("最多预约人数不能为空"); return } if (null == codeTime || '' == codeTime) { Feng.error("扣除课时数不能为空"); return } if (null == classStartTime || '' == classStartTime) { Feng.error("上课时间不能为空"); return } if (null == classWeeks || '' == classWeeks) { Feng.error("上课时间不能为空"); return } if (null == validDays || '' == validDays) { Feng.error("课时有效期不能为空"); return } } classWeeks = classWeeks.substring(0, classWeeks.length - 1); if(null == coverDrawing || '' == coverDrawing){ Feng.error("课包封面不能为空"); return } // if(null == detailDrawing || '' == detailDrawing){ // Feng.error("详情页不能为空"); // return // } if(null == introduceDrawing || '' == introduceDrawing){ Feng.error("课包介绍不能为空"); return } // if(null == validDays || '' == validDays){ // Feng.error("课时有效期不能为空"); // return // } let holitime = $('#holitime').val(); let obj = { id: id, province: province, provinceCode: provinceCode, city: city, cityCode: cityCode, storeId: storeId, coursePackageTypeId: coursePackageTypeId, name: name, siteId: siteId, coachId: coachId, maxSubscribeNumber: maxSubscribeNumber, codeTime: codeTime, type:type, classStartTime: classStartTime, // classEndTime: classStartTime.split(" - ")[1], classWeeks: classWeeks, coverDrawing: coverDrawing, detailDrawing: imgOne, introduceDrawing: introduceDrawing, sort: sort, validDays: validDays, coursePackagePaymentConfig: JSON.stringify(price), holitime:$("#holitime").val() } console.log("看看") console.log("======="+holitime) console.log(holitime) console.log($("#holitime").val()) //提交信息 var ajax = new $ax(Feng.ctxPath + "/coursePackage/updateCoursePackage", function (data) { if(data.code == 200){ Feng.success("编辑成功!"); CoursePackageInfo.close(); window.parent.CoursePackage.table.refresh(); }else{ Feng.error(data.msg); } }, function (data) { Feng.error("编辑失败!" + data.responseJSON.message + "!"); }); ajax.set(obj); ajax.start(); }; function queryStore() { let ajax = new $ax(Feng.ctxPath + "/coursePackage/queryStore", function (data) { let htmlStr = ''; for (let i = 0; i < data.length; i++) { htmlStr += '' } $('#storeId').html(htmlStr); querySite(); }, function (data) { Feng.error("获取失败!" + data.responseJSON.message + "!"); }); ajax.set("cityCode", $('#cityCode').val()); ajax.start(); } function querySite(){ let ajax = new $ax(Feng.ctxPath + "/coursePackage/querySite", function (data) { let htmlStr = ''; for (let i = 0; i < data.length; i++) { htmlStr += '' } $('#siteId').html(htmlStr); }, function (data) { Feng.error("获取失败!" + data.responseJSON.message + "!"); }); ajax.set("storeId", $('#storeId').val()); ajax.start(); } function queryCoach(){ let ajax = new $ax(Feng.ctxPath + "/coursePackage/queryCoach", function (data) { let htmlStr = ''; for (let i = 0; i < data.length; i++) { htmlStr += '' } $('#coachId').html(htmlStr); }, function (data) { Feng.error("获取失败!" + data.responseJSON.message + "!"); }); ajax.set("cityCode", $('#cityCode').val()); ajax.start(); } function addPrice(y){ console.log("===="+y) let cash = false; let paiCoin = false; $('input[name="payType"]:checked').each(function (index, e) { let v = $(e).val(); if(v == 1){ cash = true; } if(v == 2){ paiCoin = true; } }) var i = $('#price > div').length+1 let htmlStr = '' if (y===1){ htmlStr += '
\n' + ' \n' + '
\n' + '      \n'; } if (y===2){ htmlStr += '
\n' + ' \n' + '
\n' + ' \n'; } '
\n' + ' \n' + '
\n' + '      \n'; if(cash){ htmlStr += '现金支付: ¥    \n'; } htmlStr += ' '; if(paiCoin){ htmlStr += '玩湃币支付: 币    \n'; } htmlStr += ''; htmlStr += ' \n' + '
\n' +''+i+ '
'; $('#price').append(htmlStr); } function removePrice(e){ $(e).parent('div').parent('div').remove(); } function removePrice1(e){ $(e).parent('div').remove(); } $(function () { $('#provinceCode').change(function () { let ajax = new $ax(Feng.ctxPath + "/coursePackage/queryCity", function (data) { let htmlStr = ''; for (let i = 0; i < data.length; i++) { htmlStr += '' } $('#cityCode').html(htmlStr); queryStore(); queryCoach(); }, function (data) { Feng.error("获取失败!" + data.responseJSON.message + "!"); }); ajax.set("code", $(this).val()); ajax.start(); }) $('#cityCode').change(function () { queryStore(); }) $('#storeId').change(function () { querySite(); }) $('input[name="payType"]').click(function () { $('input[name="payType"]').each(function (index, e) { let v = $(e).val(); if(v == 1) { if (e.checked) { $('span[class="cash_span"]').each(function (index, e) { $(e).html('现金支付: ¥    '); }) } else { $('span[class="cash_span"]').each(function (index, e) { $(e).html(''); }) } } if(v == 2){ if (e.checked) { $('span[class="paiCoin_span"]').each(function (index, e) { $(e).html('玩湃币支付: 币    ') }) } else { $('span[class="paiCoin_span"]').each(function (index, e) { $(e).html(''); }) } } }) }) });