/**
|
* 初始化详情对话框
|
*/
|
var THomeModuleDlg = {
|
tHomeModuleData : {}
|
};
|
var language=$("#language").val();
|
/**
|
* 清除数据
|
*/
|
THomeModuleDlg.clearData = function() {
|
this.tHomeModuleData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
THomeModuleDlg.set = function(key, val) {
|
this.tHomeModuleData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
THomeModuleDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
THomeModuleDlg.close = function() {
|
parent.layer.close(window.parent.THomeModule.layerIndex);
|
}
|
|
THomeModuleDlg.provinceChange = function () {
|
var provinceId = $("#cityId").val();
|
var ajax = new $ax(Feng.ctxPath + "/THomeModule/change", function(data){
|
if(data!=null){
|
if(language==1){
|
var content='<option value="">选择市</option>';
|
}else if(language==2){
|
var content='<option value="">Please select a city</option>';
|
}else {
|
var content='<option value="">Pilih Kota</option>';
|
}
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.id+"'>"+v.chineseName+"</option>";
|
});
|
$("#cityId1").empty().append(content);
|
}
|
});
|
ajax.set("id",provinceId);
|
ajax.start();
|
}
|
/**
|
* 收集数据
|
*/
|
THomeModuleDlg.collectData = function() {
|
this
|
.set('id')
|
.set('isOpen')
|
.set('title')
|
.set('isTop')
|
.set('sort')
|
.set('backgroundImage')
|
.set('buttonImage')
|
.set('model')
|
.set('page')
|
.set('jumpPage')
|
.set('type')
|
.set('typeId')
|
.set('turnId')
|
.set('content');
|
}
|
|
THomeModuleDlg.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();
|
data1.backgroundImage = $("#backgroundImage").val();
|
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 ( $("#roleType").val()==1){
|
if($("#content").val()==''){
|
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();
|
THomeModuleDlg.close();
|
Feng.success("编辑成功!");
|
},
|
error: function(xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "下架失败!";
|
Feng.error("您的网络异常!");
|
}
|
});
|
};
|
|
$(function() {
|
THomeModuleDlg.editor = UE.getEditor('editor');
|
var backgroundImage = new $WebUpload("backgroundImage");
|
backgroundImage.setUploadBarId("progressBar");
|
backgroundImage.init();
|
var buttonImage = new $WebUpload("buttonImage");
|
buttonImage.setUploadBarId("progressBar");
|
buttonImage.init();
|
});
|