/** * 跨城站点管理管理初始化 */ var THomeModule = { id: "THomeModule", //表格id seItem: null, //选中的条目 table: null, layerIndex: -1, picture:"", fileUrl:"", backgroundImage:"", buttonImage:"", plan:"", goodsPicArray:[], validateFields: { } }; var objectType =$("#objectType").val() // /** // * 初始化表格的列 // */ // THomeModule.initColumn = function () { // return [ // {field: 'selectItem', checkbox: true}, // {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'}, // {title: '广告类型', field: 'position', visible: true, align: 'center', valign: 'middle',width:'20%', // formatter:function (data) { // return {1:"首页banner",2:"线上课得积分",3:"看视频得奖励",4:"常见问题"}[data] // } // }, // {title: '广告名称', field: 'name', visible: true, align: 'center', valign: 'middle'}, // {title: '广告图片', field: 'img', visible: true, align: 'center', valign: 'middle', // formatter: function (value, row, index) { // value = typeof value == "undefined" || value == '' ? '/static/img/NoPIC.png' : value; // return '' // } // }, // {title: '跳转模块', field: 'model', visible: true, align: 'center', valign: 'middle', // }, // {title: '跳转页面', field: 'page', visible: true, align: 'center', valign: 'middle', // }, // {title: '排序', field: 'sort', visible: true, align: 'center', valign: 'middle', // }, // {title: '状态', field: 'state', visible: true, align: 'center', valign: 'middle', // formatter:function (data) { // return {1:"上架中",2:"下架中"}[data] // } // } // ]; // }; /** * 检查是否选中 */ THomeModule.check = function () { var selected = $('#' + this.id).bootstrapTable('getSelections'); if(selected.length == 0){ Feng.info("请先选中表格中的某一记录!"); return false; }else{ THomeModule.seItem = selected[0]; return true; } }; /** * 打开查看详情页面 */ THomeModule.openInfo = function () { var selected = $('#' + this.id).bootstrapTable('getSelections'); if(selected.length >1 ){ Feng.info("只能选择一个广告进行查看!"); }else { if (this.check()) { var index = layer.open({ type: 2, title: "查看详情", area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/advertisement/update/' + THomeModule.seItem.id+'/1' }); this.layerIndex = index; } } }; /** * 跳转编辑页面 */ THomeModule.openEditTHomeModule = function () { var selected = $('#' + this.id).bootstrapTable('getSelections'); if(selected.length >1 ){ Feng.info("只能选择一个广告进行编辑!"); }else { if (this.check()) { var index = layer.open({ type: 2, title: "编辑广告", area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/advertisement/update/' + THomeModule.seItem.id+'/2' }); this.layerIndex = index; } } }; /** * 关闭此对话框 */ THomeModule.close = function() { parent.layer.close(parent.layer.getFrameIndex(window.name)); }; THomeModule.oneChange = function () { var modelId = $('#model option:selected').val(); var pageSelect = document.getElementById("page"); var typeSelect = document.getElementById("type"); var ajax = new $ax(Feng.ctxPath + "/THomeModule/getCity", function(data){ if(data!=null){ var content=''; $.each(data, function(k,v) { content += ""; }); $("#cCode").empty().append(content); } }); if (modelId === ""){ pageSelect.innerHTML = ''; typeSelect.innerHTML = ''; } ajax.set("province",province); ajax.start(); }; THomeModule.addConfig = function(){ $("#cover1").val(); $("#cover2").val(); $("#cover7").val(); var ajax = new $ax(Feng.ctxPath + "/advertisement/updateConfig", function (data) { Feng.success("基础页面设置成功") }); ajax.set("p1",$("#cover1").val()) ajax.set("p2",$("#cover2").val()) ajax.set("p7",$("#cover7").val()) ajax.start(); } THomeModule.addBenefits = function(){ $("#cover3").val(); $("#cover4").val(); $("#cover5").val(); $("#cover6").val(); var ajax = new $ax(Feng.ctxPath + "/advertisement/updateBenefits", function (data) { Feng.success("基础页面设置成功") }); ajax.set("p3",$("#cover3").val()) ajax.set("p4",$("#cover4").val()) ajax.set("p5",$("#cover5").val()) ajax.set("p6",$("#cover6").val()) ajax.start(); } THomeModule.updateSubmit = function(){ console.log("kankan") console.log($("#backgroundImage").val()) var data1 = { id:null, isOpen:null, title:"", isTop:null, sort:null, backgroundImage:"", buttonImage:"", model:null, page:"", jumpPage:null, type:"", typeId:null, turnId:null, content:"", }; let name = $("#model").val(); data1.id = $("#id").val(); if(document.querySelector('input[name="isOpen"]').checked){ data1.isOpen = 1; }else { data1.isOpen = 0; } if(document.querySelector('input[name="isTop"]').checked){ data1.isTop = 1; }else { data1.isTop = 0; } data1.title = $("#title").val(); data1.sort = $("#sort").val(); if($("#backgroundImage").val() == null || $("#backgroundImage").val() == ""){ data1.backgroundImage = $("#backgroundImage1").val(); }else { data1.backgroundImage = $("#backgroundImage").val(); } if($("#buttonImage").val() == null || $("#buttonImage").val() == ""){ data1.buttonImage = $("#buttonImage1").val(); }else { data1.buttonImage = $("#buttonImage").val(); } data1.model = $('#model option:selected').text(); data1.page = $('#page option:selected').text(); data1.jumpPage = $("#page").val(); data1.type = $('#type option:selected').text(); data1.typeId = $("#type").val(); data1.turnId = $("#pageId").val(); data1.content = jQuery.trim(THomeModuleDlg.editor.getContent()); if ( $("#roleType").val()==1){ if($("#title").val()==''){ data1.title = $("#title").val(); Feng.info("请填写标题") return; } } if ( $("#roleType").val()==1) { if ($("#model").val() == '') { Feng.info("请选择跳转模块") return; } } if(name !='0'){ if($("#page").val()=='' ){ Feng.info("请选择跳转页面") return; } } if(name !='0') { if ($("#roleType").val() == 1) { if ($("#type").val() == ''&&$("#page").val()!=2&&$("#page").val()!=25&&$("#page").val()!=27&&$("#page").val()!=37&&$("#page").val()!=28) { Feng.info("请选择跳转类型") return; } } } if(name !='0') { if ($("#roleType").val() == 1) { if ($('#type option:selected').text() == "详情"||$('#type option:selected').text() == "指定商品"||$('#type option:selected').text() == "指定折扣") { if ($("#pageId").val() == '') { Feng.info("请输入跳转ID") return; } } } } if(data1.content ==''){ data1.content = $("#content").val(); Feng.info("请填写内容设置") return; } $.ajax({ url: Feng.ctxPath + "/tHomeModule/updateHomeModule", type: "POST", contentType: "application/json", // 设置请求头的 Content-Type data: JSON.stringify(data1), // 将数据转换为 JSON 字符串 success: function(response) { // window.parent.THomeModule.table.refresh(); THomeModule.close(); Feng.success("编辑成功!"); }, error: function(xhr, status, error) { var errorMessage = xhr.responseText ? xhr.responseText : "下架失败!"; Feng.error("您的网络异常!"); } }); }; THomeModule.resetSearch = function () { $("#advertisementName").val(""); $("#cCode").val(""); $("#page").val(""); $("#state").val(""); THomeModule.search(); }; function UploadFileFn(){ $('#upFile').click(); } $(function () { });