$.ajaxSetup({cache: false}); var FinishSuperEntrance = { swfUpload: function (btn, addr) { ImageUpload.swfUpload(btn, addr); }, initConfig: function () { $.get("/finish/config/list", function (data) { if (data && "0" == data.code && data.json) { FinishSuperEntrance.configData = data.json; initDiv(data.json.config); } }); function initDiv(data) { if (data) { for (var key in data) { var $div = $("#" + key + "Div"); $div.html(""); if ($div.length && key) { var values = data[key]; if (values) { var html = ""; html += '<span class="label-list-item-all label-list-item selected">'; html += '全部'; html += '<i class="q-icon selected"></i>'; html += '</span>'; for (var k in values) { html += '<span class="label-list-item" val="' + k + '">'; html += values[k]; html += '<i class="q-icon"></i>'; html += '</span>'; } $div.append(html); } } } } } }, bindSelectUlEvent: function () { //$.dropSelector(); $(".click-drop-body ul li").each(function () { var $wrapper = $(this).parents(".click-drop-wrapper"); var $headerLabel = $wrapper.find(".select-drop-header label"); var $headerInput = $wrapper.find(".select-drop-header input"); var $body = $wrapper.find(".select-drop-body"); $(this).click(function () { var $itemLabel = $(this).find("label").html(); var $itemVal = $(this).find("label").attr("val"); $headerLabel.text($itemLabel); $headerInput.val($itemVal); $body.hide(); $wrapper.removeClass("open"); }); }); }, submit: function () { $("#addForm").ajaxForm({ success: function (result) { callback(result); } }); function callback(result) { if (!result) { alert("system error"); return; } if ('success' == result.code) { FinishSuperEntrance.success(); } else { alert(result.msg); } } if ($("#categoryInput").val().indexOf(",") != -1) { alert("品类类型格式若有多个需以英文逗号隔开"); return; } if ($("#categoryInputNext").val().indexOf(",") != -1) { alert("品类类型格式若有多个需以英文逗号隔开"); return; } if($("#supportOrderType").val().indexOf(",") != -1){ alert("订单类型若有多个需以英文逗号隔开"); return; } if($("#unsupportOrderType").val().indexOf(",") != -1){ alert("订单类型若有多个需以英文逗号隔开"); return; } //处理appIds if(!$("#appIdsInput").val()){ var chooseAppIds=""; var boxes = document.getElementsByName("appIds"); for (i = 0; i < boxes.length; i++) { if(boxes[i].checked){ chooseAppIds = chooseAppIds + boxes[i].value + ","; } } if(chooseAppIds.length>1) { chooseAppIds = chooseAppIds.substr(0,chooseAppIds.length-1); } $("#appIdsInput").val(chooseAppIds); } //处理sendPay的index校验,如果写的话必须是数字 var sendPayFirstIndex=$("#sendPayFirstIndex").val(); var sendPaySecondIndex=$("#sendPaySecondIndex").val(); if(sendPayFirstIndex!=""&&isNaN(parseInt(sendPayFirstIndex))){ alert("sendpay的位置条件必须是数字"); return; } if(sendPaySecondIndex!=""&&isNaN(parseInt(sendPaySecondIndex))){ alert("sendpay条件维度的位置必须是数字"); return; } var sendPayFirstValue=$("#sendPayFirstValue").val(); var sendPaySecondValue=$("#sendPaySecondValue").val(); if(sendPayFirstIndex!=""&&(sendPayFirstValue==""||sendPayFirstValue.length>1)){ alert("sendpay条件维度的第一组的值未正确填写"); return; } if(sendPaySecondIndex!=""&&(sendPaySecondValue==""||sendPaySecondValue.length>1)){ alert("sendpay条件维度的第二组的值未正确填写"); return; } // var iconNameFlag = true; // $("input[name='iconName']").each(function () { // if (!$(this).val()) { // iconNameFlag = false; // return false; // } // }); // var iconUrlFlag = true; // $("input[name='iconUrl']").each(function () { // if (!$(this).val()) { // iconUrlFlag = false; // return false; // } // }); // if (!iconNameFlag || !iconUrlFlag) { // alert("icon名称和URL不能为空"); // return; // } // // var bannerNameFlag = true; // $("input[name='bannerName']").each(function () { // if (!$(this).val()) { // bannerNameFlag = false; // return false; // } // }); // var bannerUrlFlag = true; // $("input[name='bannerUrl']").each(function () { // if (!$(this).val()) { // bannerUrlFlag = false; // return false; // } // }); // if (!bannerNameFlag || !bannerUrlFlag) { // alert("banner名称和URL不能为空"); // return; // } var projectNameFlag = true; var platformFlag = true; var crowdFlag = true; var buttonTextFlag = true; var buttonUrlFlag= true; var entranceFlag = true; $("input[name='projectName']").each(function () { if (!$(this).val()) { projectNameFlag = false; return false; } }); // 平台 $("#platformInput").each(function () { if ($(this).val() =="0-0-0-0") { platformFlag = false; return false; } }); // 定投人群 $("#crowdInput").each(function () { if ($(this).val() =="0-0-0") { crowdFlag = false; return false; } }); $("#buttonText").each(function () { if (!$(this).val()) { buttonTextFlag = false; return false; } }); $("#buttonUrl").each(function () { if (!$(this).val()) { buttonUrlFlag = false; return false; } }); $("#entrance").each(function () { if (!$(this).val()) { entranceFlag = false; return false; } }); if (!projectNameFlag || !platformFlag || !crowdFlag || !buttonTextFlag || !buttonUrlFlag || !entranceFlag) { alert("带*的不能为空"); return; } $("#addForm").submit(); }, success: function () { $('.close').click(); $("#resetBtn").click(); // 点击按钮显示操作成功结果提示层 $.qPopup.tip({ id: "opreationResultTipPopup", progressValue: 90 }); //重新加载数据 setTimeout(function () { $("#dataListTable").bootstrapTable('refresh'); }, 500); }, confirm: function (fn) { $.qPopup.confirm({ id: 'deleteTableItemConfirmPopup', onSure: function (close) { fn(); //关闭弹框 close(); }, onCancel: function (close) { //关闭弹框 close(); } }); }, onlineConfirm: function (fn) { $.qPopup.confirm({ id: 'onlineTableItemConfirmPopup', onSure: function (close) { fn(); //关闭弹框 close(); }, onCancel: function (close) { //关闭弹框 close(); } }); }, invalidConfirm: function (fn) { $.qPopup.confirm({ id: 'invalidTableItemConfirmPopup', onSure: function (close) { fn(); //关闭弹框 close(); }, onCancel: function (close) { //关闭弹框 close(); } }); } } // Table var TableInit = function () { var oTableInit = new Object(); //初始化Table oTableInit.Init = function () { $('#dataListTable').bootstrapTable({ classes: 'table table-hover', url: '/finish/superEntrance/query', //请求后台的URL(*) method: 'post', //请求方式(*) toolbar: '#toolbar', //工具按钮用哪个容器 striped: false, //是否显示行间隔色 cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*) pagination: true, //是否显示分页(*) sortable: false, //是否启用排序 sortOrder: "desc", //排序方式 queryParams: oTableInit.queryParams,//传递参数(*) sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*) pageNumber: 1, //初始化加载第一页,默认第一页 pageSize: 5, //每页的记录行数(*) pageList: [10, 25, 50, 100], //可供选择的每页的行数(*) paginationPreText: '上一页', paginationNextText: '下一页', paginationHAlign: 'left', paginationDetailHAlign: 'left', sidePagination: 'server', // client or server search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大 strictSearch: false, showColumns: false, //是否显示所有的列 showRefresh: false, //是否显示刷新按钮 minimumCountColumns: 2, //最少允许的列数 clickToSelect: false, //是否启用点击选中行 height: 500, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度 uniqueId: "id", //每一行的唯一标识,一般为主键列 showToggle: false, //是否显示详细视图和列表视图的切换按钮 cardView: false, //是否显示详细视图 detailView: false, //是否显示父子表 onLoadError: function (data) { window.location.href = "/noauth.html"; }, columns: [{ checkbox: true // formatter: checkboxFormatter },{ field: 'id', title: 'ID' },{ field: 'projectName', title: '名称', formatter: viewFormatter, events: viewEvents },{ field: 'group', title: '定投人群' },{ field: 'create', title: '创建人' }, { field: 'editor', title: '最后编辑人' },{ field: 'createTime', title: '创建时间', formatter: function (value) { if (value) { return new Date(value).format("yyyy-MM-dd hh:mm:ss"); } } },{ field: 'beginTime', title: '开始日期', formatter: function (value) { if (value) { return new Date(value).format("yyyy-MM-dd hh:mm:ss"); } } },{ field: 'endTime', title: '失效日期', formatter: function (value) { if (value) { return new Date(value).format("yyyy-MM-dd hh:mm:ss"); } } },{ field: 'sort', title: '优先级', formatter: function (value) { if (value) { if ('0' == value) { return '最低'; } return "T" + value; } } },{ field: 'valid', title: '生效状态', formatter: validFormatter, events: validEvents },{ field: 'white', title: '白名单', formatter: whiteFormatter, events: whiteEvents }, { field: 'online', title: '上线状态', formatter: onlineFormatter, events: onlineEvents }, { field: '', title: '操作', formatter: operateFormatter, events: operateEvents }] }); }; oTableInit.queryParams = function (params) { //var conditon = $("#searchForm").serializeArray(); var temp = { //这里的键的名字和控制器的变量名必须一直,这边改动,控制器也需要改成一样的 pageSize: params.limit, //页面大小 rowStart: params.offset //页码 // name: $.trim($("#txt_search_name").val()), // appName: $.trim($("#txt_search_appName").val()) }; //if (conditon && conditon.length) { /*for (var i = 0; i < conditon.length; i++) { var o = conditon[i]; temp[o.name] = o.value; }*/ //} return temp; }; return oTableInit; }; var ButtonInit = function () { var oInit = new Object(); var postdata = {}; oInit.Init = function () { //初始化页面上面的按钮事件 }; return oInit; }; function checkboxFormatter(value, row, index) { return '<div class="child-item"> <div class="input-wrapper"> <i class="q-icon checkbox"></i> <input type="checkbox"> </div> </div>'; } function viewFormatter(value, row, index){ return '<span class="q-btn" id="viewItem"> <a class="view-item">' + value + '</a></span>'; } function operateFormatter(value, row, index) { return [ '<span class="q-btn" id="editBtn"> <i class="q-icon edit-item"></i> </span>', '<span class="q-btn" id="copy" style="top:-15px; display:none;"><a class="copy-item" title="复制">复制</a></span>', '<span class="q-btn" id="delBtn" style="display:none;"><i class="q-icon delete-item"></i> </span>' ].join(''); } // 查看 window.viewEvents = { 'click #viewItem': function (e, value, row, index) { jQuery.ajax({ type: "get", url: "/finish/superEntrance/edit/before?id=" + row.id, dataType: "json", success: function (result) { if (result && "0" == result.code && result.json) { var tpl = doT.template($("#viewtmpl").text()); var rs = tpl(result.json); $("#interpolation").empty(); $("#interpolation").html(rs); $.initAllControls($(document)); FinishSuperEntrance .bindSelectUlEvent(); $(".upload-btn-img").each(function (i, e) { var input = $(e).parents(".popup-item").prev().find("input").eq(1); FinishSuperEntrance.swfUpload(e, input); }); $("#viewSourcePopup").modal({ keyboard: true }) getPlatform(); getCrowd(); } } }); } } // 编辑 window.operateEvents = { 'click #editBtn': function (e, value, row, index) { if("0" == row.online){ alert("上线状态不可编辑"); return; } jQuery.ajax({ type: "get", url: "/finish/superEntrance/edit/before?id=" + row.id, dataType: "json", success: function (result) { if (result && "0" == result.code && result.json) { var tpl = doT.template($("#interpolationtmpl").text()); var rs = tpl(result.json); $("#interpolation").empty(); $("#interpolation").html(rs); $.initAllControls($(document)); FinishSuperEntrance.bindSelectUlEvent(); $(".upload-btn-img").each(function (i, e) { var input = $(e).parents(".item-block").find("input").eq(0); FinishSuperEntrance.swfUpload(e, input); }); // 唤起弹窗 $("#addSourcePopup").modal({ keyboard: true }) getPlatform(); getCrowd(); } } }); } }; function validFormatter(value, row, index) { console.log(value) return switchStatus('validSwitch', value, row, index); } function whiteFormatter(value, row, index) { return switchStatus('whiteSwitch', value, row, index); } function onlineFormatter(value, row, index) { return switchStatus('onlineSwitch', value, row, index); } window.validEvents = { 'click .switch-btn': function (e, value, row, index) { var valid = Math.abs(value - 1); console.log(value) modifyStatus(row.id, "valid", valid, index); } }; window.whiteEvents = { 'click .switch-btn': function (e, value, row, index) { var white = Math.abs(value - 1); modifyStatus(row.id, "white", white, index); } }; window.onlineEvents = { 'click .switch-btn': function (e, value, row, index) { var online = Math.abs(value - 1); modifyStatus(row.id, "online", online, index); } }; function modifyStatus(id, type, status, index) { if('0' == status){ FinishSuperEntrance.onlineConfirm(function () { var data = { "id": id, "type": type, "status": status }; jQuery.ajax({ type: "get", url: "/finish/superEntrance/modify/status", data: data, dataType: "json", type: "POST", success: function (result) { if ('0' == result.code) { $.qPopup.tip({ id: "opreationResultTipPopup", progressValue: 30 }) var $btn = $("#" + id + type + "Switch i"); if ($btn.hasClass("selected")) { $btn.removeClass("selected") if ("valid" == type && 1 == status) { //$("#" + id + "white" + "Switch i").removeClass("selected"); //$("#" + id + "online" + "Switch i").removeClass("selected"); $('#dataListTable').bootstrapTable('updateCell', { index: index, field: "white", value: 1 }); $('#dataListTable').bootstrapTable('updateCell', { index: index, field: "online", value: 1 }); } } else { $btn.addClass("selected") if (("white" == type || "online" == type) && 0 == status) { $('#dataListTable').bootstrapTable('updateCell', { index: index, field: "valid", value: 0 }); } } $('#dataListTable').bootstrapTable('updateCell', {index: index, field: type, value: status}); } } }); }); }else if('1' == status){ FinishSuperEntrance.invalidConfirm(function () { var data = { "id": id, "type": type, "status": status }; jQuery.ajax({ type: "get", url: "/finish/superEntrance/modify/status", data: data, dataType: "json", type: "POST", success: function (result) { if ('0' == result.code) { $.qPopup.tip({ id: "opreationResultTipPopup", progressValue: 30 }) var $btn = $("#" + id + type + "Switch i"); if ($btn.hasClass("selected")) { $btn.removeClass("selected") if ("valid" == type && 1 == status) { //$("#" + id + "white" + "Switch i").removeClass("selected"); //$("#" + id + "online" + "Switch i").removeClass("selected"); $('#dataListTable').bootstrapTable('updateCell', { index: index, field: "white", value: 1 }); $('#dataListTable').bootstrapTable('updateCell', { index: index, field: "online", value: 1 }); } } else { $btn.addClass("selected") if (("white" == type || "online" == type) && 0 == status) { $('#dataListTable').bootstrapTable('updateCell', { index: index, field: "valid", value: 0 }); } } $('#dataListTable').bootstrapTable('updateCell', {index: index, field: type, value: status}); } } }); }); } } function getByteLen(val) { var len = 0; for (var i = 0; i < val.length; i++) { var a = val.charAt(i); if (a.match(/[^x00-xff]/ig) != null) { len += 2; } else { len += 1; } } return len; } function appendError(obj,text) { clearError(obj); var errorHtml = '<div class="right-tip-error" style="font-size: 12px;color: red;"><span>' + text + '</span></div>'; $(obj).parent().children().last().after(errorHtml); } function clearError(obj) { $(obj).parent().children(".right-tip-error").remove(); } function checkLength(obj) { var maxChars = 20;//最多字符数 var curr = getByteLen(obj.value) - maxChars; if (curr > 0) { $(obj).focus(); var errorText = '名称最多支持10个汉字'; appendError(obj,errorText); return false; } else { clearError(obj); return true; } } function checkOrderType(obj) { if (obj.value.indexOf(",") != -1) { $(obj).focus(); var errorText = '订单类型输入格式为数字且以英文逗号隔开'; appendError(obj,errorText); return false; } else { clearError(obj); return true; } } function checkCategory(obj) { if (obj.value.indexOf(",") != -1) { $(obj).focus(); var errorText = '格式为数字-数字-数字,若输入多个需以英文逗号隔开'; appendError(obj,errorText); return false; } else { clearError(obj); return true; } } function IsURL(obj){ var strRegex = "^((https)?://)"; var re=new RegExp(strRegex); if (!re.test(obj.value)){ $(obj).focus(); var errorText = '输入的URL头部必须以https开头,请检查'; appendError(obj,errorText); return false; }else{ clearError(obj); return true; } } function switchStatus(id, value, row, index) { var html = '<div id="' + row.id + id + '" class="input-wrapper switch switch-btn">'; html += '<i class="q-icon switch '; if (0 == value) { html += 'selected'; } html += '"></i>'; html += '<input type="checkbox"'; if (0 == value) { html += ' checked="checked">'; } html += '</div>'; return html; } // 返回数组:选中行id function getIds() { // 获取选中行的数据 var selectionArray = $('#dataListTable').bootstrapTable('getSelections'); var ids = new Array(); $.map(selectionArray, function (row) { ids.push(row.id); }); return ids.join(",") } function getPlatform(){ //获取已经选中的平台 var platformInputVal = $("#platformInput").val() if(platformInputVal){ var arr = platformInputVal.split("-"); for(var i = 0;i<arr.length;i++){ if(arr[i] == 1){ $(".q-btn-platform").eq(i).addClass("selected") }else{ $(".q-btn-platform").eq(i).removeClass("selected") } } } } function getCrowd(){ //获取已经选中的定投人群 var crowdInputVal = $("#crowdInput").val() if(crowdInputVal){ var arr = crowdInputVal.split("-"); for(var i = 0;i<arr.length;i++){ if(arr[i] == 1){ $(".q-btn-crowd").eq(i).addClass("selected") }else{ $(".q-btn-crowd").eq(i).removeClass("selected") } } } } $(function () { FinishSuperEntrance.initConfig(); //1.初始化Table var oTable = new TableInit(); oTable.Init(); //2.初始化Button的点击事件 var oButtonInit = new ButtonInit(); oButtonInit.Init(); $.initAllControls($(document)); // 新增 $("#addBtn").click(function () { jQuery.ajax({ type: "get", url: '/finish/config/list?needCategoryFlag=1', dataType: "json", success: function (result) { if (result && "0" == result.code && result.json) { var tpl = doT.template($("#interpolationtmpl").text()); result.json.data = { "page": "all", "platform": "1-1-1-1", "sort": "" }; var rs = tpl(result.json); $("#interpolation").empty(); $("#interpolation").html(rs); $.initAllControls($(document)); FinishSuperEntrance.bindSelectUlEvent(); $(".upload-btn-img").each(function (i, e) { var input = $(e).parents(".item-block").find("input").eq(0); FinishSuperEntrance.swfUpload(e, input); }); $("#addSourcePopup").modal({ keyboard: true }) } } }); }); // 批量删除 $("#deleteTrsBtn").click(function () { var ids = getIds(); // "button0000000084,button0000000080" ids = $.trim(ids); if (!ids) { alert("请选择数据"); return; } // 弹窗 FinishSuperEntrance.confirm(function () { jQuery.ajax({ type: "get", url: "/finish/superEntrance/delete?ids=" + ids, dataType: "json", success: function (result) { if ('success' == result.code) { FinishSuperEntrance.success(); } } }); }); }); $(document).on("click", ".query-item .label-list .label-list-item", function () { $(this).siblings().removeClass("selected"); $(this).addClass("selected"); $(this).find("i").addClass("selected"); $(this).parents(".query-item").find("input").val($(this).attr("val")); }); /*$("#refreshBtn").click(function () { $("#dataListTable").bootstrapTable('refresh'); });*/ var secondList; $(document).on("click", "#firstCategoryUL li", function () { jQuery.ajax({ type: "get", url: "/product/category/get?id=" + $(this).find("label").attr("val"), dataType: "json", success: function (result) { if ('0' == result.code && result.object) { var map = secondList = result.object; var html = "<li><label>二级分类</label></li>"; for (var key in map) { var k = eval("(" + key + ")"); html += '<li><label val="' + k.id + '">' + k.name + '</label></li>'; } $("#threeCategoryUL").empty(); $("#secondCategoryUL").empty(); $("#secondCategoryUL").html(html); FinishSuperEntrance.bindSelectUlEvent(); //$("#secondCategoryUL li:eq(0)").click(); $("#threeCategoryLabel").text("三级分类"); $("#threeCategoryInput").val(""); } } }); }); var secondListNext; $(document).on("click", "#firstCategoryULNext li", function () { jQuery.ajax({ type: "get", url: "/product/category/get?id=" + $(this).find("label").attr("val"), dataType: "json", success: function (result) { if ('0' == result.code && result.object) { var map = secondList = result.object; var html = ""; for (var key in map) { var k = eval("(" + key + ")"); html += '<li><label val="' + k.id + '">' + k.name + '</label></li>'; } $("#threeCategoryULNext").empty(); $("#secondCategoryULNext").empty(); $("#secondCategoryULNext").html(html); FinishSuperEntrance.bindSelectUlEvent(); //$("#secondCategoryULNext li:eq(0)").click(); $("#threeCategoryLabelNext").text("三级分类"); $("#threeCategoryInputNext").val(""); } } }); }); $(document).on("click", "#secondCategoryUL li", function () { if (secondList) { var threeList = secondList['{"id":' + $(this).find("label").attr("val") + ',"name":"' + $(this).find("label").text() + '"}']; if (threeList) { var html = ""; for (var i = 0; i < threeList.length; i++) { html += '<li><label val="' + threeList[i].id + '">' + threeList[i].name + '</label></li>'; } $("#threeCategoryUL").empty(); $("#threeCategoryUL").html(html); FinishSuperEntrance.bindSelectUlEvent(); //$("#threeCategoryUL li:eq(0)").click(); } } }); $(document).on("click", "#secondCategoryULNext li", function () { if (secondList) { var threeList = secondList['{"id":' + $(this).find("label").attr("val") + ',"name":"' + $(this).find("label").text() + '"}']; if (threeList) { var html = ""; for (var i = 0; i < threeList.length; i++) { html += '<li><label val="' + threeList[i].id + '">' + threeList[i].name + '</label></li>'; } $("#threeCategoryULNext").empty(); $("#threeCategoryULNext").html(html); FinishSuperEntrance.bindSelectUlEvent(); //$("#threeCategoryULNext li:eq(0)").click(); } } }); $(document).on("click", "#addCategoryBtn", function () { var first = $("#firstCategoryInput").val(); var second = $("#secondCategoryInput").val(); var three = $("#threeCategoryInput").val(); if (!first) { alert("请先选择品类"); return; } if(second){ if(three){ var value = "--"+three; }else{ var value = "-"+second+"-"; } }else{ var value = first+"--" } if ($("#categoryInput").val()) { $("#categoryInput").val($("#categoryInput").val() + "," + value); } else { $("#categoryInput").val(value); } }); $(document).on("click", "#addCategoryBtnNext", function () { var first = $("#firstCategoryInputNext").val(); var second = $("#secondCategoryInputNext").val(); var three = $("#threeCategoryInputNext").val(); if (!first) { alert("请先选择品类"); return; } if(second){ if(three){ var value = "--"+three; }else{ var value = "-"+second+"-"; } }else{ var value = first+"--" } if ($("#categoryInputNext").val()) { $("#categoryInputNext").val($("#categoryInputNext").val() + "," + value); } else { $("#categoryInputNext").val(value); } }); /*$("#resetBtn").click(function () { $("#searchDiv input").val(""); $("#searchDiv .label-list-item-all").click(); });*/ $(document).on("click", ".clear-btn", function () { $(this).parents(".popup-item").parent().find("input").val(""); $(this).parents(".popup-item").parent().find("img").removeAttr("src"); }); $(document).on("click", "#checkAll", function () { var appIds = ""; var boxes = document.getElementsByName("appIds"); if(document.getElementById("checkAll").checked){ for(i=0;i<boxes.length;i++){ boxes[i].checked = true; appIds = appIds+boxes[i].value+","; } if(appIds.length>1) { appIds = appIds.substr(0,appIds.length-1); } $("#appIdsInput").val(appIds); }else{ for(i=0;i<boxes.length;i++){ boxes[i].checked = false; } $("#appIdsInput").val(""); } }); $(document).on("click", ".q-btn-platform",function(){ //点击选择平台交互 var platformInput = $("#platformInput").val().split("-"); if($(this).hasClass("selected")){ $(this).removeClass("selected"); platformInput[$(this).index()] = "0"; var string = platformInput.join("-"); $("#platformInput").val(string) }else{ $(this).addClass("selected"); platformInput[$(this).index()] = "1"; var string = platformInput.join("-"); $("#platformInput").val(string) } }); $(document).on("click", ".q-btn-crowd",function(){ //点击选择定投人群 var crowdInput = $("#crowdInput").val().split("-"); if($(this).hasClass("selected")){ $(this).removeClass("selected"); crowdInput[$(this).index()] = "0"; var string = crowdInput.join("-"); $("#crowdInput").val(string) }else{ $(this).addClass("selected"); crowdInput[$(this).index()] = "1"; var string = crowdInput.join("-"); $("#crowdInput").val(string) } }); $(document).on("blur",".item-block-value .input1",function(){ var inputVal1 = $(".item-block-value .input1").val(); //小于 50 var inputVal0 = $(".item-block-value .input0").val(); //大于 100 if(inputVal1&&inputVal0){ if(parseInt(inputVal1)<parseInt(inputVal0)){ $(this).val("金额过小"); setTimeout(function(){ $(".item-block-value .input1").val(""); $(".item-block-value .input1").focus(); },1000) } } }) $(document).on("blur",".item-block-value .input0",function(){ var inputVal1 = $(".item-block-value .input1").val(); //小于 50 var inputVal0 = $(".item-block-value .input0").val(); //大于 100 if(inputVal1&&inputVal0){ if(parseInt(inputVal1)<parseInt(inputVal0)){ $(this).val("金额过大"); setTimeout(function(){ $(".item-block-value .input0").val(""); $(".item-block-value .input0").focus(); },1000) } } }) });