puzhibing
2024-03-06 a2ca8c0889a39ebd83195d5d2ebe8e2ed20b16d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/**
 * 跨城站点管理管理初始化
 */
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 '<img src="' + value + '" style="height: 100px;"/>'
//             }
//         },
//         {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='<option value="">选择跳转页面</option>';
            $.each(data, function(k,v) {
                content += "<option value='"+v.id+"'>"+v.name+"</option>";
            });
            $("#cCode").empty().append(content);
        }
    });
    if (modelId === ""){
        pageSelect.innerHTML = '<option value="">请先选择跳转模块</option>';
        typeSelect.innerHTML = '<option value="">请先选择跳转模块</option>';
    }
    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 ( $("#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();
            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 () {
 
});